|
@@ -60,29 +60,30 @@ class FakeLayer():
|
|
|
attribute = []
|
|
|
available_attrs = []
|
|
|
simulation = []
|
|
|
+#simulation = [(1, {"a": 1, "b": 2}), (2, {"a": 3}), (3, {"a": 4, "b": 6})]
|
|
|
|
|
|
def poll(address):
|
|
|
- working_attribute = []
|
|
|
working_available_attrs = []
|
|
|
- working_simulation = []
|
|
|
+ working_simulation = None
|
|
|
|
|
|
while 1:
|
|
|
returnvalue = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": "CBD_env"}))).read()
|
|
|
- if returnvalue.startswith("AVAILABLE:"):
|
|
|
- working_available_attrs.append(returnvalue.split(":", 1)[1])
|
|
|
- elif returnvalue.startswith("ATTRIBUTE:"):
|
|
|
- working_attribute.append(returnvalue.split(":", 1)[1])
|
|
|
- elif returnvalue.startswith("SIMULATION:"):
|
|
|
- working_simulation.append(returnvalue.split(":", 1)[1])
|
|
|
- elif returnvalue.startswith("FINISH_AVAILABLE"):
|
|
|
- available_attrs.append(working_available_attrs)
|
|
|
- working_available_attrs = []
|
|
|
- elif returnvalue.startswith("FINISH_ATTRIBUTE"):
|
|
|
- attributes.append(working_attributes)
|
|
|
- working_attributes = []
|
|
|
- elif returnvalue.startswith("FINISH_SIMULATION"):
|
|
|
+ print("Process " + str(returnvalue))
|
|
|
+ if (returnvalue.startswith("AVAILABLE_ATTR_VALUE")):
|
|
|
+ working_available_attrs.append(returnvalue.split(" ", 1)[1])
|
|
|
+ elif (returnvalue.startswith("AVAILABLE_ATTR_END")):
|
|
|
+ available_attrs.append(working_available)
|
|
|
+ working_available = []
|
|
|
+ elif (returnvalue.startswith("ATTR_VALUE")):
|
|
|
+ attribute.append(returnvalue.split(" ", 1)[1])
|
|
|
+ elif (returnvalue.startswith("SIM_TIME")):
|
|
|
+ working_simulation = (float(returnvalue.split(" ", 1)[1]), {})
|
|
|
+ elif (returnvalue.startswith("SIM_PROBE")):
|
|
|
+ blockname, blockvalue = returnvalue.split(" ", 1)[1].rsplit(" ", 1)
|
|
|
+ working_simulation[1][blockname] = blockvalue
|
|
|
+ elif (returnvalue.startswith("SIM_END")):
|
|
|
simulation.append(working_simulation)
|
|
|
- working_simulation = []
|
|
|
+ working_simulation = None
|
|
|
|
|
|
class MvLayer():
|
|
|
def __init__(self, address):
|
|
@@ -116,12 +117,12 @@ class MvLayer():
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % value, "username": "CBD_env"}))).read()
|
|
|
|
|
|
def instantiate_block(self, name, block_type):
|
|
|
- urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"instantiate"', "username": "CBD_env"}))).read()
|
|
|
+ urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"instantiate_node"', "username": "CBD_env"}))).read()
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (block_type), "username": "CBD_env"}))).read()
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (name), "username": "CBD_env"}))).read()
|
|
|
|
|
|
def instantiate_link(self, name, link_type, source, target):
|
|
|
- urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"instantiate"', "username": "CBD_env"}))).read()
|
|
|
+ urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"instantiate_association"', "username": "CBD_env"}))).read()
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (link_type), "username": "CBD_env"}))).read()
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (name), "username": "CBD_env"}))).read()
|
|
|
urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (source), "username": "CBD_env"}))).read()
|