|
@@ -96,6 +96,10 @@ def poll(address):
|
|
|
elif (returnvalue.startswith("SIM_END")):
|
|
|
simulation.append(working_simulation)
|
|
|
working_simulation = None
|
|
|
+ elif (returnvalue.startswith("CONFORMANCE_OK")):
|
|
|
+ root.configure(background="grey")
|
|
|
+ elif (returnvalue.startswith("CONFORMANCE_FAIL")):
|
|
|
+ root.configure(background="red")
|
|
|
else:
|
|
|
print("Error: got unknown result: " + returnvalue)
|
|
|
|
|
@@ -174,43 +178,42 @@ class InterfaceCore():
|
|
|
self.mode = mode
|
|
|
|
|
|
def clicked(self, event):
|
|
|
- if self.mode not in ["AdditionBlock", "NegatorBlock", "ConstantBlock", "MultiplyBlock", "ConstantBlock", "InverseBlock", "DelayBlock"]:
|
|
|
+ if self.find((event.x, event.y)):
|
|
|
+ # Something already there, so don't add, but modify
|
|
|
+ lname = self.find((event.x, event.y))
|
|
|
+
|
|
|
+ attrs = self.mv.read_available_attributes(lname)
|
|
|
+ print("Managing " + str(attrs))
|
|
|
+
|
|
|
+ if not attrs:
|
|
|
+ print("No attrs to manage!")
|
|
|
+
|
|
|
+ for attr, t in attrs:
|
|
|
+ print("Reading data from " + str(attr))
|
|
|
+ old_value = self.mv.read_attribute(lname, attr)
|
|
|
+ if old_value == "None":
|
|
|
+ old_value = None
|
|
|
+
|
|
|
+ new_value = tkSimpleDialog.askstring("Attribute modification", attr, initialvalue=old_value)
|
|
|
+ if t == "Float":
|
|
|
+ new_value = float(new_value)
|
|
|
+ else:
|
|
|
+ print("Got unknown type: " + str(t))
|
|
|
+ self.mv.set_attribute(lname, attr, new_value)
|
|
|
+
|
|
|
+ elif self.mode not in ["AdditionBlock", "NegatorBlock", "ConstantBlock", "MultiplyBlock", "ConstantBlock", "InverseBlock", "DelayBlock"]:
|
|
|
print("Cannot create something not guaranteed to be block type!")
|
|
|
else:
|
|
|
- if self.find((event.x, event.y)):
|
|
|
- # Something already there, so don't add, but modify
|
|
|
- lname = self.find((event.x, event.y))
|
|
|
-
|
|
|
- attrs = self.mv.read_available_attributes(lname)
|
|
|
- print("Managing " + str(attrs))
|
|
|
-
|
|
|
- if not attrs:
|
|
|
- print("No attrs to manage!")
|
|
|
-
|
|
|
- for attr, t in attrs:
|
|
|
- print("Reading data from " + str(attr))
|
|
|
- old_value = self.mv.read_attribute(lname, attr)
|
|
|
- if old_value == "None":
|
|
|
- old_value = None
|
|
|
-
|
|
|
- new_value = tkSimpleDialog.askstring("Attribute modification", attr, initialvalue=old_value)
|
|
|
- if t == "Float":
|
|
|
- new_value = float(new_value)
|
|
|
- else:
|
|
|
- print("Got unknown type: " + str(t))
|
|
|
- self.mv.set_attribute(lname, attr, new_value)
|
|
|
-
|
|
|
- else:
|
|
|
- global name
|
|
|
- x = event.x
|
|
|
- y = event.y
|
|
|
- self.mv.instantiate_block(str(name), self.mode)
|
|
|
- r = canvas.create_rectangle(lower(x), lower(y), upper(x), upper(y), fill="white")
|
|
|
- t = canvas.create_text(avg(lower(x), upper(x)), avg(lower(y), upper(y)), text=self.mode, fill="black")
|
|
|
- b = (lower(x), lower(y), upper(x), upper(y), str(name))
|
|
|
- self.drawn.add(b)
|
|
|
- self.refs[str(name)] = [r, t]
|
|
|
- name += 1
|
|
|
+ global name
|
|
|
+ x = event.x
|
|
|
+ y = event.y
|
|
|
+ self.mv.instantiate_block(str(name), self.mode)
|
|
|
+ r = canvas.create_rectangle(lower(x), lower(y), upper(x), upper(y), fill="white")
|
|
|
+ t = canvas.create_text(avg(lower(x), upper(x)), avg(lower(y), upper(y)), text=self.mode, fill="black")
|
|
|
+ b = (lower(x), lower(y), upper(x), upper(y), str(name))
|
|
|
+ self.drawn.add(b)
|
|
|
+ self.refs[str(name)] = [r, t]
|
|
|
+ name += 1
|
|
|
|
|
|
def find(self, location):
|
|
|
x, y = location
|