Просмотр исходного кода

Files for the other DEVStone modules

Roman Cardenas 6 лет назад
Родитель
Сommit
a87f6b031d

+ 1 - 1
devstone/adevs/CMakeLists.txt

@@ -9,4 +9,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
 set(CMAKE_CXX_STANDARD 17)
 
-add_executable(DEVStone src/DEVStone.cpp src/DummyAtomic.cpp src/DEVSWrapper.cpp src/li.cpp)
+add_executable(DEVStone src/DEVStone.cpp src/DummyAtomic.cpp src/DEVSWrapper.cpp src/li.cpp src/hoMod.cpp src/hi.cpp src/hi.hpp src/ho.cpp src/ho.hpp)

+ 5 - 0
devstone/adevs/src/hi.cpp

@@ -0,0 +1,5 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#include "hi.hpp"

+ 14 - 0
devstone/adevs/src/hi.hpp

@@ -0,0 +1,14 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#ifndef DEVSTONE_ADEVS_HI_HPP
+#define DEVSTONE_ADEVS_HI_HPP
+
+
+class HI {
+
+};
+
+
+#endif //DEVSTONE_ADEVS_HI_HPP

+ 5 - 0
devstone/adevs/src/ho.cpp

@@ -0,0 +1,5 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#include "ho.hpp"

+ 14 - 0
devstone/adevs/src/ho.hpp

@@ -0,0 +1,14 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#ifndef DEVSTONE_ADEVS_HO_HPP
+#define DEVSTONE_ADEVS_HO_HPP
+
+
+class HO {
+
+};
+
+
+#endif //DEVSTONE_ADEVS_HO_HPP

+ 45 - 0
devstone/adevs/src/hoMod.cpp

@@ -0,0 +1,45 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#include "hoMod.hpp"
+#include <map>
+#include <list>
+
+const int HOMod::in1 = 0;
+const int HOMod::in2 = 1;
+const int HOMod::out = 2;
+
+HOMod::HOMod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
+adevs::Digraph<int*>()
+{
+    depth = depthIn;
+    width = widthIn;
+    intDelay = intDelayIn;
+    extDelay = extDelayIn;
+    procTime = procTimeIn;
+
+    if (depth == 1) {
+        DummyAtomic *a = new DummyAtomic(intDelay, extDelay, procTime);
+        add(a);
+        couple(this, this->in1, a, a->in);
+        couple(a, a->out, this, this->out);
+    } else {
+        HOMod *c = new HOMod(depth - 1, width, intDelay, extDelay, procTime);
+        couple(this, this->in1, c, c->in1);
+        couple(c, c->out, this, this->out);
+        if (width > 1) {
+            std::map<int, std::list<DummyAtomic>> atomics;
+            for (int i = 0; i < width; i++) {
+                int minRowIdx = (i < 2)? 0 : (i - 1);
+                for (int j = minRowIdx; j < width - 1; j++) {
+                    DummyAtomic *a = new DummyAtomic(intDelay, extDelay, procTime);
+                    add(a);
+                    if(atomics.find("f") == atomics.end()
+                        atomics.put(i, new LinkedList<>());
+                    atomics.get(i).add(atomic);
+                }
+            }
+        }
+    }
+}

+ 28 - 0
devstone/adevs/src/hoMod.hpp

@@ -0,0 +1,28 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#ifndef DEVSTONE_ADEVS_HOMOD_HPP
+#define DEVSTONE_ADEVS_HOMOD_HPP
+
+#include <adevs.h>
+#include "DEVStone.hpp"
+#include "DummyAtomic.hpp"
+
+
+class HOMod: public adevs::Digraph<int*> {
+protected:
+    int depth, width;
+    int intDelay, extDelay;
+    double procTime;
+public:
+    /// Model input ports
+    static const int in1, in2;
+    /// Model output port
+    static const int out;
+    // Constructor
+    HOMod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
+};
+
+
+#endif //DEVSTONE_ADEVS_HOMOD_HPP

+ 0 - 2
devstone/adevs/src/li.cpp

@@ -12,7 +12,5 @@ DEVSWrapper(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn)
         add(c);
         couple(this, this->in, c, c->in);
         couple(c, c->out, this, this->out);
-
-
     }
 }