etherlab/EthercatCIA402Slave.py
changeset 2154 6bbe93799956
parent 2153 91c10856adaa
child 2155 d63541200d8e
equal deleted inserted replaced
2153:91c10856adaa 2154:6bbe93799956
   103         {"bitmap" : "CIA402AxisRef",
   103         {"bitmap" : "CIA402AxisRef",
   104          "name" : _("Axis Ref"),
   104          "name" : _("Axis Ref"),
   105          "tooltip" : _("Initiate Drag'n drop of Axis ref located variable"),
   105          "tooltip" : _("Initiate Drag'n drop of Axis ref located variable"),
   106          "method" : "_getCIA402AxisRef",
   106          "method" : "_getCIA402AxisRef",
   107          "push": True},
   107          "push": True},
       
   108         {"bitmap" : "CIA402NetPos",
       
   109          "name" : _("Axis Pos"),
       
   110          "tooltip" : _("Initiate Drag'n drop of Network position located variable"),
       
   111          "method" : "_getCIA402NetworkPosition",
       
   112          "push": True},
   108     ]
   113     ]
   109     
   114     
   110 #--------------------------------------------------
   115 #--------------------------------------------------
   111 #    class code
   116 #    class code
   112 #--------------------------------------------------    
   117 #--------------------------------------------------    
   126         return _EthercatSlaveCTN.SetParamsAttribute(self, path, value)
   131         return _EthercatSlaveCTN.SetParamsAttribute(self, path, value)
   127     
   132     
   128     def GetVariableLocationTree(self):
   133     def GetVariableLocationTree(self):
   129         axis_name = self.CTNName()
   134         axis_name = self.CTNName()
   130         current_location = self.GetCurrentLocation()
   135         current_location = self.GetCurrentLocation()
   131         children = [{"name": "%s Axis Ref" % (axis_name),
   136         children = [{"name": "%s Network Position" % (axis_name),
       
   137                      "type": LOCATION_VAR_INPUT,
       
   138                      "size": "W",
       
   139                      "IEC_type": "UINT",
       
   140                      "var_name": axis_name,
       
   141                      "location": "%%IW%s" % (".".join(map(str, current_location))),
       
   142                      "description": "",
       
   143                      "children": []},
       
   144                     {"name": "%s Axis Ref" % (axis_name),
   132                      "type": LOCATION_VAR_INPUT,
   145                      "type": LOCATION_VAR_INPUT,
   133                      "size": "W",
   146                      "size": "W",
   134                      "IEC_type": "AXIS_REF",
   147                      "IEC_type": "AXIS_REF",
   135                      "var_name": axis_name,
   148                      "var_name": axis_name,
   136                      "location": "%%IW%s.0" % (".".join(map(str, current_location))),
   149                      "location": "%%IW%s.402" % (".".join(map(str, current_location))),
   137                      "description": "",
   150                      "description": "",
   138                      "children": []}]
   151                      "children": []}]
   139         children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), current_location, axis_name))
   152         children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), current_location, axis_name))
   140         return  {"name": axis_name,
   153         return  {"name": axis_name,
   141                  "type": LOCATION_CONFNODE,
   154                  "type": LOCATION_CONFNODE,
   148         return [("%s_%s" % (block_infos["blocktype"], 
   161         return [("%s_%s" % (block_infos["blocktype"], 
   149                             "_".join(map(str, current_location))),
   162                             "_".join(map(str, current_location))),
   150                  "EtherLab%s" % block_infos["blocktype"], "") 
   163                  "EtherLab%s" % block_infos["blocktype"], "") 
   151                 for block_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES]
   164                 for block_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES]
   152     
   165     
       
   166     def StartDragNDrop(self, data):
       
   167         data_obj = wx.TextDataObject(str(data))
       
   168         dragSource = wx.DropSource(self.GetCTRoot().AppFrame)
       
   169         dragSource.SetData(data_obj)
       
   170         dragSource.DoDragDrop()
       
   171     
       
   172     def _getCIA402NetworkPosition(self):
       
   173         self.StartDragNDrop(
       
   174             ("%%IW%s" % ".".join(map(str, self.GetCurrentLocation())), 
       
   175              "location", "UINT", self.CTNName() + "_Pos", ""))
       
   176         
   153     def _getCIA402AxisRef(self):
   177     def _getCIA402AxisRef(self):
   154         data = wx.TextDataObject(str(
   178         self.StartDragNDrop(
   155             ("%%IW%s.0" % ".".join(map(str, self.GetCurrentLocation())), 
   179             ("%%IW%s.402" % ".".join(map(str, self.GetCurrentLocation())), 
   156              "location", "AXIS_REF", self.CTNName(), "")))
   180              "location", "AXIS_REF", self.CTNName(), ""))
   157         dragSource = wx.DropSource(self.GetCTRoot().AppFrame)
   181         
   158         dragSource.SetData(data)
       
   159         dragSource.DoDragDrop()
       
   160     
       
   161     def CTNGenerate_C(self, buildpath, locations):
   182     def CTNGenerate_C(self, buildpath, locations):
   162         current_location = self.GetCurrentLocation()
   183         current_location = self.GetCurrentLocation()
   163         
   184         
   164         location_str = "_".join(map(lambda x:str(x), current_location))
   185         location_str = "_".join(map(lambda x:str(x), current_location))
   165         slave_pos = self.GetSlavePos()
   186         slave_pos = self.GetSlavePos()