Explorar el Código

Removed all code that wrapped the R and V choices

Yentl Van Tendeloo hace 9 años
padre
commit
fa723c6a95

+ 5 - 14
hybrid_server/classes/mvkcontroller.xml

@@ -96,20 +96,11 @@
                             # No JSON encoding necessary, as it is not complex
                             try:
                                 if data["op"] == "set_input":
-                                    if "element_type" in data:
-                                        if data["element_type"] == "V":
-                                            value = json.loads(data["value"])
-                                        else:
-                                            value = data["value"]
-                                        args = [data["element_type"], value]
-                                        self.input_queue[data["username"]].append((source, [args]))
+                                    if "value" in data:
+                                        value = [json.loads(data["value"])]
                                     else:
-                                        d = []
-                                        for t, v in json.loads(data["data"]):
-                                            if t == "V":
-                                                v = json.loads(v)
-                                            d.append([t, v])
-                                        self.input_queue[data["username"]].append((source, d))
+                                        value = json.loads(data["data"])
+                                    self.input_queue[data["username"]].append((source, [value]))
                                 elif data["op"] == "get_output":
                                     self.output_queue[data["username"]].append(source)
                                 else:
@@ -138,7 +129,7 @@
                                         self.execute_modelverse(user, "set_input", args_entry)
 
                                     self.destination = source
-                                    self.value = {"id": 200, "value": "OK"}
+                                    self.value = "OK"
                                     self.all_failed = False
 
                                 # Now process for some steps, or until we are again blocked for input

+ 5 - 69
integration/utils.py

@@ -139,48 +139,10 @@ def run_file(files, parameters, expected, mode):
             if val != 0:
                 raise Exception("Linking error")
 
-        # Send in the actual request and wait for replies
-        var_list = {}
-        data = []
-        got_output = []
-        for p in parameters:
-            if isinstance(p, int):
-                if p not in var_list:
-                    data = flush_data(address, data)
-                    
-                    proc.poll()
-                    if proc.returncode is not None:
-                        # Modelverse has already terminated, which isn't a good sign!
-                        return False
-
-                    while 1:
-                        val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=120).read()
-                        l, r = val.split("&", 1)
-                        if l.startswith("id"):
-                            id_str = l
-                            val_str = r
-                        else:
-                            id_str = r
-                            val_str = l
-                        id_val = id_str.split("=", 1)[1]
-                        val_val = val_str.split("=", 1)[1]
-
-                        if val_val == "None":
-                            var_list[p] = id_val
-                            break
-                        else:
-                            got_output.append(val)
-                    continue
-                else:
-                    val = var_list[p]
-                    t = "R"
-            else:
-                val = p
-                t = "V"
-            data.append([t, val])
-        data = flush_data(address, data)
-        flush_data(address, data)
+        # Send the request ...
+        flush_data(address, parameters)
         
+        # ... and wait for replies
         for e in expected:
             c = len(e) if isinstance(e, set) else 1
             for _ in range(c):
@@ -193,7 +155,6 @@ def run_file(files, parameters, expected, mode):
                     # Modelverse has already terminated, which isn't a good sign!
                     raise Exception("Modelverse died!")
 
-                val = val.split("=", 2)[2]
                 print("Got %s, expect %s" % (val, e))
                 if isinstance(e, set):
                     assert str(val) in e
@@ -241,31 +202,8 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                 if time.time() - start > timeout_val:
                     raise
 
-        # Send in the actual request and wait for replies
-        var_list = {}
-        data = []
-        for p in parameters:
-            if isinstance(p, int):
-                if p not in var_list:
-                    data = flush_data(address, data)
-
-                    proc.poll()
-                    if proc.returncode is not None:
-                        # Modelverse has already terminated, which isn't a good sign!
-                        return False
-
-                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
-                    val = val.split("=", 2)[1].split("&", 1)[0]
-                    var_list[p] = val
-                    continue
-                else:
-                    val = var_list[p]
-                    t = "R"
-            else:
-                val = p
-                t = "V"
-            data.append([t, val])
-        data = flush_data(address, data)
+        # Send the request
+        flush_data(address, parameters)
 
         # Now do linking and loading
         if link is not None:
@@ -285,7 +223,6 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                     # Modelverse has already terminated, which isn't a good sign!
                     return False
 
-
         for inp in inputs:
             urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": inp, "username": username})), timeout=1).read()
             proc.poll()
@@ -310,7 +247,6 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                         return True
                     else:
                         raise
-                val = val.split("=", 2)[2]
 
                 print("Got %s, expect %s" % (val, e))
                 if isinstance(e, set):

+ 4 - 7
kernel/modelverse_kernel/main.py

@@ -153,15 +153,15 @@ class ModelverseKernel(object):
                                   ]
         if rv is None:
             self.success = False
-            self.returnvalue = {"id": None, "value": ""}
+            self.returnvalue = None
         else:
             rv_value, =     yield [("RV", [rv])]
             _, _ =          yield [("CD", [user_root, "output", next_output]),
                                    ("DN", [first_output]),
                                   ]
-            self.returnvalue = {"id": rv, "value": rv_value}
+            self.returnvalue = rv_value
 
-    def set_input(self, username, element_type, value):
+    def set_input(self, username, value):
         user_root, =        yield [("RD", [self.root, username])]
         old_input, link =   yield [("RD", [user_root, "last_input"]),
                                    ("RDE", [user_root, "last_input"]),
@@ -171,10 +171,7 @@ class ModelverseKernel(object):
                                    ("CD", [old_input, "next", new_input]),
                                   ]
 
-        if element_type == "R":
-            new_value = int(value)
-        elif element_type == "V":
-            new_value, =    yield [("CNV", [value])]
+        new_value, =        yield [("CNV", [value])]
         _, _ =              yield [("CD", [old_input, "value", new_value]),
                                    ("DE", [link])
                                   ]

+ 1 - 10
model/model.py

@@ -310,16 +310,7 @@ class ModelverseInterface(AtomicDEVS):
         return self.state
 
     def outputFnc(self):
-        send = []
-        for i in self.state.operations:
-            if isinstance(i, int) and i not in self.memory:
-                break
-            elif isinstance(i, int) and i in self.memory:
-                # Pass a reference!
-                send.append(("R", self.memory[i]))
-            elif not isinstance(i, int):
-                send.append(("V", i))
-        return {self.to_mvk: [(self.username, send)]}
+        return {self.to_mvk: [(self.username, self.state.operations)]}
 
     def timeAdvance(self):
         if self.state.init:

+ 1 - 7
scripts/prompt.py

@@ -73,12 +73,6 @@ local_print("To quit: execute command 'quit'")
 def print_output():
     while 1:
         output = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username}))).read()
-        l, r = output.split("&", 1)
-        if "value" in l:
-            output = l
-        else:
-            output = r
-        _, output = output.split("=", 1)
         remote_print("%s" % str(output))
 
 thrd = threading.Thread(target=print_output)
@@ -131,4 +125,4 @@ while 1:
         else:
             command = '"%s"' % command
 
-        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": command, "username": username}))).read()
+        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": command, "username": username}))).read()