Bladeren bron

LI model for aDEVS

Roman Cardenas 6 jaren geleden
bovenliggende
commit
927990fc28

+ 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)
+add_executable(DEVStone src/DEVStone.cpp src/DummyAtomic.cpp src/DEVSWrapper.cpp src/li.cpp)

+ 0 - 6
devstone/adevs/main.cpp

@@ -1,6 +0,0 @@
-#include <iostream>
-
-int main() {
-    std::cout << "Hello, World!" << std::endl;
-    return 0;
-}

+ 7 - 12
devstone/adevs/src/DEVSWrapper.cpp

@@ -8,7 +8,7 @@ const int DEVSWrapper::in = 0;
 const int DEVSWrapper::out = 1;
 
 DEVSWrapper::DEVSWrapper(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
-        adevs::Digraph<IO_Type>()
+        adevs::Digraph<int*>()
 {
     depth = depthIn;
     width = widthIn;
@@ -22,16 +22,11 @@ DEVSWrapper::DEVSWrapper(int depthIn, int widthIn, int intDelayIn, int extDelayI
         couple(this, this->in, a, a->in);
         couple(a, a->out, this, this->out);
     } else {
-        DEVSWrapper c = generateCoupled();
-        add(c);
-        couple(this, this->in, c, c->in);
-        couple(c, c->out, this, this->out);
-    }
-    for (int i = 0; i < width - 1; ++i) {
-        DummyAtomic a = DummyAtomic(intDelay, extDelay, procTime);
-        add(a);
+        for (int i = 0; i < width - 1; ++i) {
+            DummyAtomic *a = new DummyAtomic(intDelay, extDelay, procTime);
+            add(a);
+            couple(this, this->in, a, a->in);
+            couple(a, a->out, this, this->out);
+        }
     }
 }
-
-
-

+ 4 - 5
devstone/adevs/src/DEVSWrapper.hpp

@@ -10,10 +10,10 @@
 #include "DummyAtomic.hpp"
 
 
-class DEVSWrapper: public adevs::Digraph<IO_Type> {
-private:
-    int depth;
-    int width;
+class DEVSWrapper: public adevs::Digraph<int*>
+{
+protected:
+    int depth, width;
     int intDelay, extDelay;
     double procTime;
 public:
@@ -23,7 +23,6 @@ public:
     static const int out;
     /// Constructor
     DEVSWrapper(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
-    virtual DEVSWrapper generateCoupled();
 };
 
 #endif //DEVSTONE_ADEVS_DEVSWRAPPER_HPP

+ 2 - 3
devstone/adevs/src/DEVStone.cpp

@@ -4,10 +4,9 @@
 
 
 #include "DEVStone.hpp"
-//#include "DEVSWrapper.hpp"
-#include "DummyAtomic.hpp"
+#include "li.hpp"
 
 int main() {
- DummyAtomic a = DummyAtomic(0, 0, 0.0);
+    LI c = LI(2, 1, 0, 0, 0.0);
  return 0;
 }

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

@@ -0,0 +1,18 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#include "li.hpp"
+
+LI::LI(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
+DEVSWrapper(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn)
+{
+    if (depth > 1) {
+        LI *c =  new LI(depth - 1, width, intDelay, extDelay, procTime);
+        add(c);
+        couple(this, this->in, c, c->in);
+        couple(c, c->out, this, this->out);
+
+
+    }
+}

+ 18 - 0
devstone/adevs/src/li.hpp

@@ -0,0 +1,18 @@
+//
+// Created by rcardenas on 3/10/20.
+//
+
+#ifndef DEVSTONE_ADEVS_LI_HPP
+#define DEVSTONE_ADEVS_LI_HPP
+
+#include <adevs.h>
+#include "DEVStone.hpp"
+#include "DEVSWrapper.hpp"
+
+class LI: public DEVSWrapper
+{
+public:
+    LI(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
+};
+
+#endif //DEVSTONE_ADEVS_LI_HPP