Viewer.py
changeset 477 fd9625f6e92a
parent 471 ea90da16a5e2
child 479 2fab0eefa66e
equal deleted inserted replaced
476:2e09d2e86a35 477:fd9625f6e92a
   725             iec_path = "%s.%s"%(self.InstancePath, element.GetName())
   725             iec_path = "%s.%s"%(self.InstancePath, element.GetName())
   726         elif isinstance(element, SFC_Step):
   726         elif isinstance(element, SFC_Step):
   727             iec_path = "%s.%s.X"%(self.InstancePath, element.GetName())
   727             iec_path = "%s.%s.X"%(self.InstancePath, element.GetName())
   728         elif isinstance(element, SFC_Transition):
   728         elif isinstance(element, SFC_Transition):
   729             connectors = element.GetConnectors()
   729             connectors = element.GetConnectors()
   730             previous_steps = self.GetPreviousSteps(connectors["input"])
   730             previous_steps = self.GetPreviousSteps(connectors["inputs"])
   731             next_steps = self.GetNextSteps(connectors["output"])
   731             next_steps = self.GetNextSteps(connectors["outputs"])
   732             iec_path = "%s.%s->%s"%(self.InstancePath, ",".join(previous_steps), ",".join(next_steps))
   732             iec_path = "%s.%s->%s"%(self.InstancePath, ",".join(previous_steps), ",".join(next_steps))
   733         return iec_path
   733         return iec_path
   734        
   734        
   735 #-------------------------------------------------------------------------------
   735 #-------------------------------------------------------------------------------
   736 #                              Reset functions
   736 #                              Reset functions
   874         self.Inhibit(False)
   874         self.Inhibit(False)
   875         self.RefreshVisibleElements()
   875         self.RefreshVisibleElements()
   876         self.ShowErrors()
   876         self.ShowErrors()
   877         self.Refresh(False)
   877         self.Refresh(False)
   878     
   878     
   879     def GetPreviousSteps(self, connector):
   879     def GetPreviousSteps(self, connectors):
   880         steps = []
   880         steps = []
   881         for wire, handle in connector.GetWires():
   881         for connector in connectors:
   882             previous = wire.GetOtherConnected(connector).GetParentBlock()
   882             for wire, handle in connector.GetWires():
   883             if isinstance(previous, SFC_Step):
   883                 previous = wire.GetOtherConnected(connector).GetParentBlock()
   884                 steps.append(previous.GetName())
   884                 if isinstance(previous, SFC_Step):
   885             elif isinstance(previous, SFC_Divergence) and previous.GetType() in [SIMULTANEOUS_CONVERGENCE, SELECTION_DIVERGENCE]:
   885                     steps.append(previous.GetName())
   886                 connectors = previous.GetConnectors()
   886                 elif isinstance(previous, SFC_Divergence) and previous.GetType() in [SIMULTANEOUS_CONVERGENCE, SELECTION_DIVERGENCE]:
   887                 for input in connectors["inputs"]:
   887                     connectors = previous.GetConnectors()
   888                     steps.extend(self.GetPreviousSteps(input))
   888                     steps.extend(self.GetPreviousSteps(connectors["inputs"]))
   889         return steps
   889         return steps
   890     
   890     
   891     def GetNextSteps(self, connector):
   891     def GetNextSteps(self, connectors):
   892         steps = []
   892         steps = []
   893         for wire, handle in connector.GetWires():
   893         for connector in connectors:
   894             next = wire.GetOtherConnected(connector).GetParentBlock()
   894             for wire, handle in connector.GetWires():
   895             if isinstance(next, SFC_Step):
   895                 next = wire.GetOtherConnected(connector).GetParentBlock()
   896                 steps.append(next.GetName())
   896                 if isinstance(next, SFC_Step):
   897             elif isinstance(next, SFC_Jump):
   897                     steps.append(next.GetName())
   898                 steps.append(next.GetTarget())
   898                 elif isinstance(next, SFC_Jump):
   899             elif isinstance(next, SFC_Divergence) and next.GetType() in [SIMULTANEOUS_DIVERGENCE, SELECTION_CONVERGENCE]:
   899                     steps.append(next.GetTarget())
   900                 connectors = next.GetConnectors()
   900                 elif isinstance(next, SFC_Divergence) and next.GetType() in [SIMULTANEOUS_DIVERGENCE, SELECTION_CONVERGENCE]:
   901                 for output in connectors["outputs"]:
   901                     connectors = next.GetConnectors()
   902                     steps.extend(self.GetNextSteps(output))
   902                     steps.extend(self.GetNextSteps(connectors["outputs"]))
   903         return steps
   903         return steps
   904     
   904     
   905     def GetMaxSize(self):
   905     def GetMaxSize(self):
   906         maxx = maxy = 0
   906         maxx = maxy = 0
   907         for element in self.GetElements():
   907         for element in self.GetElements():