ソースを参照

Store glob when entering function

Yentl Van Tendeloo 7 年 前
コミット
ea557cda92
3 ファイル変更7 行追加7 行削除
  1. 3 3
      kernel/modelverse_kernel/main.py
  2. 3 3
      wrappers/modelverse.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 3 - 3
kernel/modelverse_kernel/main.py

@@ -292,7 +292,7 @@ class ModelverseKernel(object):
             str_value, = yield [("RV", [value])]
             if str_value:
                 # Is a global
-                prev = "  " * nested_indent + "_globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + \
+                prev = \
                        "  " * nested_indent + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value) + \
                        "  " * nested_indent + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value)
                 instruction = str_value
@@ -323,7 +323,6 @@ class ModelverseKernel(object):
                 # Got something to do before the variable is usable, so this is a global!
                 # Therefore we actually do the operation in the Modelverse as well!
                 instruction += \
-                       "  " * nested_indent + "_globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + \
                        "  " * nested_indent + "_var, = yield [('RD', [_globs, '%s'])]\n" % instruction_var + \
                        "  " * nested_indent + "if _var is None:\n" + \
                        "  " * (nested_indent + 1) + "_var, = yield [('CN', [])]\n" + \
@@ -405,12 +404,13 @@ class ModelverseKernel(object):
 
         print("Reading function: %s" % suggested_name)
         (prev, printed), = yield [("CALL_ARGS", [self.print_instruction, (inst, 1)])]
-        printed = prev + printed
+        printed = "  _globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + prev + printed
         print("Total printed function: ")
         if params:
             func = "def " + suggested_name + "(" + ", ".join([chr(ord('a') + i) for i in range(len(params))]) + ", **kwargs):\n" + "".join(["  var_%s = %s\n" % (param, chr(ord('a') + i)) for i, param in enumerate(params)]) + printed
         else:
             func = "def " + suggested_name + "(**kwargs):\n" + printed
+        
         print(func)
 
         # To write out all generated functions

+ 3 - 3
wrappers/modelverse.py

@@ -529,7 +529,7 @@ def service_get(port):
     """Get the values on the specified port."""
 
     data = urlencode({"op": "get_output", "taskname": port}).encode()
-    val = json.loads(urlopen(Request("http://%s" % controller.address, data)).read())
+    val = json.loads(urlopen(Request("http://%s" % controller.address, data), timeout=99999).read())
     return val
 
 def service_set(port, value):
@@ -537,11 +537,11 @@ def service_set(port, value):
     if isinstance(value, type([])):
         value = json.dumps(value)
         data = urlencode({"op": "set_input", "data": value, "taskname": port}).encode()
-        urlopen(Request("http://%s" % controller.address, data)).read()
+        urlopen(Request("http://%s" % controller.address, data), timeout=99999).read()
     else:
         value = json.dumps(value)
         data = urlencode({"op": "set_input", "value": value, "taskname": port}).encode()
-        urlopen(Request("http://%s" % controller.address, data)).read()
+        urlopen(Request("http://%s" % controller.address, data), timeout=99999).read()
 
 def service_poll(port):
     """Checks whether or not the Modelverse side has any input ready to be processed."""

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Mon Apr 23 14:15:21 2018
+Date:   Mon Apr 23 15:44:35 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server