--- a/PLCControler.py Fri Aug 03 18:02:54 2007 +0200
+++ b/PLCControler.py Tue Aug 07 17:37:38 2007 +0200
@@ -1300,7 +1300,6 @@
infos["type"] = "transition"
condition = instance.getConditionContent()
infos["condition_type"] = condition["type"]
- infos["condition"] = condition["value"]
infos["connectors"] = {"input":{},"output":{}}
infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
infos["connectors"]["input"]["links"] = []
@@ -1310,6 +1309,18 @@
dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
infos["connectors"]["input"]["links"].append(dic)
infos["connectors"]["output"]["position"] = instance.connectionPointOut.getRelPosition()
+ if infos["condition_type"] == "connection":
+ infos["connectors"]["connection"] = {}
+ infos["connectors"]["connection"]["links"] = []
+ connections = instance.getConnections()
+ print connections
+ if connections:
+ for link in connections:
+ dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
+ infos["connectors"]["connection"]["links"].append(dic)
+ infos["condition"] = None
+ else:
+ infos["condition"] = condition["value"]
elif isinstance(instance, (plcopen.selectionDivergence, plcopen.simultaneousDivergence)):
if isinstance(instance, plcopen.selectionDivergence):
infos["type"] = "selectionDivergence"
@@ -1743,7 +1754,7 @@
def SetCurrentElementEditingTransitionInfos(self, id, infos):
transition = self.GetCurrentElementEditing().getInstance(id)
for param, value in infos.items():
- if param == "type" and "condition" in infos:
+ if param == "type" and infos.get("condition", None):
transition.setConditionContent(value, infos["condition"])
elif param == "height":
transition.setHeight(value)
@@ -1763,6 +1774,9 @@
position = output_connector.GetRelPosition()
transition.addConnectionPointOut()
transition.connectionPointOut.setRelPosition(position.x, position.y)
+ if infos.get("type", None) == "connection":
+ connection_connector = value["connection"]
+ self.SetConnectionWires(transition, connection_connector)
def AddCurrentElementEditingDivergence(self, id, type):
if type == SELECTION_DIVERGENCE:
--- a/plcopen/plcopen.py Fri Aug 03 18:02:54 2007 +0200
+++ b/plcopen/plcopen.py Tue Aug 07 17:37:38 2007 +0200
@@ -808,6 +808,89 @@
content["value"].updateElementName(old_name, new_name)
setattr(cls, "updateElementName", updateElementName)
+ def addConnection(self):
+ print "addConnection"
+ if not self.condition:
+ self.addCondition()
+ content = self.condition.getContent()
+ if content["name"] != "connection":
+ self.condition.setContent("connection", [])
+ content = self.condition.getContent()
+ content["value"].append(PLCOpenClasses["connection"]())
+ setattr(cls, "addConnection", addConnection)
+
+ def removeConnection(self, idx):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ content["value"].pop(idx)
+ setattr(cls, "removeConnection", removeConnection)
+
+ def removeConnections(self):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ content["value"] = []
+ setattr(cls, "removeConnections", removeConnections)
+
+ def getConnections(self):
+ if self.condition:
+ content = self.condition.getContent()
+ print "getConnections", content
+ if content["name"] == "connection":
+ return content["value"]
+ setattr(cls, "getConnections", getConnections)
+
+ def setConnectionId(self, idx, id):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ content["value"][idx].setRefLocalId(id)
+ print "SetId", content
+ setattr(cls, "setConnectionId", setConnectionId)
+
+ def getConnectionId(self, idx):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ return content["value"][idx].getRefLocalId()
+ return None
+ setattr(cls, "getConnectionId", getConnectionId)
+
+ def setConnectionPoints(self, idx, points):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ content["value"][idx].setPoints(points)
+ print "SetPoints", content
+ setattr(cls, "setConnectionPoints", setConnectionPoints)
+
+ def getConnectionPoints(self, idx):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ return content["value"][idx].getPoints()
+ return None
+ setattr(cls, "getConnectionPoints", getConnectionPoints)
+
+ def setConnectionParameter(self, idx, parameter):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ content["value"][idx].setFormalParameter(parameter)
+ print "SetParameter", content
+ setattr(cls, "setConnectionParameter", setConnectionParameter)
+
+ def getConnectionParameter(self, idx):
+ if self.condition:
+ content = self.condition.getContent()
+ if content["name"] == "connection":
+ return content["value"][idx].getFormalParameter()
+ return None
+ setattr(cls, "getConnectionParameter", getConnectionParameter)
+
+ setattr(cls, "addConnection", addConnection)
+
if "selectionDivergence" in PLCOpenClasses:
cls = PLCOpenClasses["selectionDivergence"]
setattr(cls, "getX", getX)