dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hdsd / scd / fsm / scd_stm_terminate.cpp
diff --git a/dol/src/dol/visitor/hdsd/scd/fsm/scd_stm_terminate.cpp b/dol/src/dol/visitor/hdsd/scd/fsm/scd_stm_terminate.cpp
new file mode 100644 (file)
index 0000000..3035321
--- /dev/null
@@ -0,0 +1,40 @@
+#include "fsm/scd_stm_terminate.h"
+
+#include "scd_logging.h"
+#include "scd_exception.h"
+#include "scd_cont_man_master.h"
+
+
+void scd_stm_terminate::set_busy()
+{
+    scd_error("received further events while terminating");
+    set_fail();
+}
+
+
+void scd_stm_terminate::set_idle(const sc_core::sc_time& time)
+{
+    scd_error("received future events while terminating");
+    set_fail();
+}
+
+
+void scd_stm_terminate::process()
+{
+    // check for failed slaves and react
+    if (!_check_slaves())
+        return;
+
+    if (_some_slaves_active())
+    {
+        // not all slaves have terminated yet
+        return;
+    }
+    else
+    {
+        // all slaves terminated
+        _sim.get_chan_man().close();
+        _close_slaves();
+        _fsm.set_state(_st_terminated);
+    }
+}