浏览代码

Added some preliminary code for process_execute

Yentl Van Tendeloo 8 年之前
父节点
当前提交
6e2dafc550
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. 22 1
      wrappers/modelverse.py

+ 22 - 1
wrappers/modelverse.py

@@ -328,7 +328,6 @@ def read_attrs(model_name, ID, context=None):
     return OUTPUT()
 
 def instantiate(model_name, typename, edge=None, ID="", context=None):
-    print("DOING INSTANTIATE")
     INPUT("instantiate", context, [model_name, typename, edge, ID])
     return OUTPUT()
 
@@ -376,6 +375,28 @@ def all_instances(model_name, type_name, context=None):
     INPUT("all_instances", context, [model_name, type_name])
     return OUTPUT()
 
+def process_execute(process_name, model_mappings, callbacks=None):
+    # for all callbacks to SCs, start up the output port already
+    sc_ports = {}
+
+    for k, v in callbacks.items():
+        if isinstance(v, (tuple, list)):
+            # Is a statechart, so register already
+            sc_ports[k] = v[0].addOutputListener(v[2])
+
+    INPUT("process_execute", context, [process_name, model_mappings])
+
+    #TODO this is all pseudo-code
+    while 1:
+        operation = OUTPUT()
+        if operation == "Finished":
+            # Finished execution of the process, so exit
+        
+        context = OUTPUT()
+
+        # TODO monitor the new function and execute the correct callback
+
+
 import threading
 thrd = threading.Thread(target=run_controller)
 thrd.daemon = True