Viewer.py
changeset 694 b7c1914034f9
parent 687 629680fb0582
child 696 8865c406f616
equal deleted inserted replaced
693:4ecfbcc09bef 694:b7c1914034f9
    28 from threading import Lock
    28 from threading import Lock
    29 
    29 
    30 import wx
    30 import wx
    31 
    31 
    32 from plcopen.structures import *
    32 from plcopen.structures import *
    33 from PLCControler import ITEM_POU
    33 from PLCControler import ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK
    34 
    34 
    35 from dialogs import *
    35 from dialogs import *
    36 from graphics import *
    36 from graphics import *
    37 from controls import EditorPanel
    37 from controls import EditorPanel
    38 
    38 
   831                 connection = self.GetConnectorByName(block.GetName())
   831                 connection = self.GetConnectorByName(block.GetName())
   832                 if connection is not None:
   832                 if connection is not None:
   833                     connector = connection.GetConnector()
   833                     connector = connection.GetConnector()
   834                     if len(connector.Wires) == 1:
   834                     if len(connector.Wires) == 1:
   835                         iec_path = self.GetElementIECPath(connector.Wires[0][0])
   835                         iec_path = self.GetElementIECPath(connector.Wires[0][0])
   836         elif isinstance(element, LD_Contact):
   836         elif isinstance(element, (LD_Contact, FBD_Block)):
   837             iec_path = "%s.%s"%(self.InstancePath, element.GetName())
   837             iec_path = "%s.%s"%(self.InstancePath, element.GetName())
   838         elif isinstance(element, SFC_Step):
   838         elif isinstance(element, SFC_Step):
   839             iec_path = "%s.%s.X"%(self.InstancePath, element.GetName())
   839             iec_path = "%s.%s.X"%(self.InstancePath, element.GetName())
   840         elif isinstance(element, SFC_Transition):
   840         elif isinstance(element, SFC_Transition):
   841             connectors = element.GetConnectors()
   841             connectors = element.GetConnectors()
  1712         event.Skip()
  1712         event.Skip()
  1713     
  1713     
  1714     def OnViewerLeftDClick(self, event):
  1714     def OnViewerLeftDClick(self, event):
  1715         if self.Mode == MODE_SELECTION and self.SelectedElement is not None:
  1715         if self.Mode == MODE_SELECTION and self.SelectedElement is not None:
  1716             if self.Debug:
  1716             if self.Debug:
  1717                 iec_path = self.GetElementIECPath(self.SelectedElement)
  1717                 if self.IsBlock(self.SelectedElement):
  1718                 if iec_path is not None:
  1718                     instance_type = self.SelectedElement.GetType()
  1719                     if isinstance(self.SelectedElement, Wire):
  1719                     pou_type = {
  1720                         if self.SelectedElement.EndConnected is not None:
  1720                         "program": ITEM_PROGRAM,
  1721                             var_type = self.SelectedElement.EndConnected.GetType()
  1721                         "functionBlock": ITEM_FUNCTIONBLOCK,
  1722                             if self.Controler.IsOfType(var_type, "ANY_NUM", self.Debug) or\
  1722                     }.get(self.Controler.GetPouType(instance_type))
  1723                                self.Controler.IsOfType(var_type, "ANY_BIT", self.Debug):
  1723                     if pou_type is not None and instance_type in self.Controler.GetProjectPouNames(self.Debug):
  1724                                 self.ParentWindow.OpenGraphicViewer(iec_path)
  1724                         self.ParentWindow.OpenDebugViewer(pou_type, 
  1725                     else:
  1725                             self.GetElementIECPath(self.SelectedElement),
  1726                         self.ParentWindow.OpenGraphicViewer(iec_path)
  1726                             self.Controler.ComputePouName(instance_type))
       
  1727                 else:
       
  1728                     iec_path = self.GetElementIECPath(self.SelectedElement)
       
  1729                     if iec_path is not None:
       
  1730                         if isinstance(self.SelectedElement, Wire):
       
  1731                             if self.SelectedElement.EndConnected is not None:
       
  1732                                 var_type = self.SelectedElement.EndConnected.GetType()
       
  1733                                 if self.Controler.IsOfType(var_type, "ANY_NUM", self.Debug) or\
       
  1734                                    self.Controler.IsOfType(var_type, "ANY_BIT", self.Debug):
       
  1735                                     self.ParentWindow.OpenGraphicViewer(iec_path)
       
  1736                         else:
       
  1737                             self.ParentWindow.OpenGraphicViewer(iec_path)
  1727             elif event.ControlDown() and not event.ShiftDown():
  1738             elif event.ControlDown() and not event.ShiftDown():
  1728                 if self.IsBlock(self.SelectedElement) and self.SelectedElement.GetType() in self.Controler.GetProjectPouNames(self.Debug):
  1739                 instance_type = self.SelectedElement.GetType()
  1729                     self.ParentWindow.EditProjectElement(ITEM_POU, self.Controler.ComputePouName(self.SelectedElement.GetType()))
  1740                 if self.IsBlock(self.SelectedElement) and instance_type in self.Controler.GetProjectPouNames(self.Debug):
       
  1741                     self.ParentWindow.EditProjectElement(ITEM_POU, 
       
  1742                         self.Controler.ComputePouName(instance_type))
  1730                 else:
  1743                 else:
  1731                     self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
  1744                     self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
  1732             elif event.ControlDown() and event.ShiftDown():
  1745             elif event.ControlDown() and event.ShiftDown():
  1733                 movex, movey = self.SelectedElement.AdjustToScaling(self.Scaling)
  1746                 movex, movey = self.SelectedElement.AdjustToScaling(self.Scaling)
  1734                 self.SelectedElement.RefreshModel()
  1747                 self.SelectedElement.RefreshModel()