Browse Source

Store glob when entering function

Yentl Van Tendeloo 7 years ago
parent
commit
ea557cda92
3 changed files with 7 additions and 7 deletions
  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])]
             str_value, = yield [("RV", [value])]
             if str_value:
             if str_value:
                 # Is a global
                 # 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', [_globs, '%s'])]\n" % (str_value, str_value) + \
                        "  " * nested_indent + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value)
                        "  " * nested_indent + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value)
                 instruction = 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!
                 # 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!
                 # Therefore we actually do the operation in the Modelverse as well!
                 instruction += \
                 instruction += \
-                       "  " * nested_indent + "_globs, = yield [('RD', [kwargs['task_root'], 'globals'])]\n" + \
                        "  " * nested_indent + "_var, = yield [('RD', [_globs, '%s'])]\n" % instruction_var + \
                        "  " * nested_indent + "_var, = yield [('RD', [_globs, '%s'])]\n" % instruction_var + \
                        "  " * nested_indent + "if _var is None:\n" + \
                        "  " * nested_indent + "if _var is None:\n" + \
                        "  " * (nested_indent + 1) + "_var, = yield [('CN', [])]\n" + \
                        "  " * (nested_indent + 1) + "_var, = yield [('CN', [])]\n" + \
@@ -405,12 +404,13 @@ class ModelverseKernel(object):
 
 
         print("Reading function: %s" % suggested_name)
         print("Reading function: %s" % suggested_name)
         (prev, printed), = yield [("CALL_ARGS", [self.print_instruction, (inst, 1)])]
         (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: ")
         print("Total printed function: ")
         if params:
         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
             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:
         else:
             func = "def " + suggested_name + "(**kwargs):\n" + printed
             func = "def " + suggested_name + "(**kwargs):\n" + printed
+        
         print(func)
         print(func)
 
 
         # To write out all generated functions
         # 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."""
     """Get the values on the specified port."""
 
 
     data = urlencode({"op": "get_output", "taskname": port}).encode()
     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
     return val
 
 
 def service_set(port, value):
 def service_set(port, value):
@@ -537,11 +537,11 @@ def service_set(port, value):
     if isinstance(value, type([])):
     if isinstance(value, type([])):
         value = json.dumps(value)
         value = json.dumps(value)
         data = urlencode({"op": "set_input", "data": value, "taskname": port}).encode()
         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:
     else:
         value = json.dumps(value)
         value = json.dumps(value)
         data = urlencode({"op": "set_input", "value": value, "taskname": port}).encode()
         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):
 def service_poll(port):
     """Checks whether or not the Modelverse side has any input ready to be processed."""
     """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)
 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 author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server