Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
authorLaurent Bessard
Sat, 13 Apr 2013 02:14:37 +0200
changeset 2124 1f2c3fdd70d0
parent 2123 68beaf825a20
child 2125 f62eb0b2e57c
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
etherlab/ConfigEditor.py
etherlab/EthercatMaster.py
--- a/etherlab/ConfigEditor.py	Sat Apr 13 01:40:31 2013 +0200
+++ b/etherlab/ConfigEditor.py	Sat Apr 13 02:14:37 2013 +0200
@@ -174,20 +174,22 @@
                 access = entry.get("Access", "")
                 entry_index = self.Controler.ExtractHexDecValue(entry.get("Index", "0"))
                 entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0"))
+                location = self.Controler.GetCurrentLocation()
                 if self.PositionColumn:
                     slave_pos = self.Controler.ExtractHexDecValue(entry.get("Position", "0"))
+                    location += (slave_pos,)
+                    node_name = self.Controler.GetSlaveName(slave_pos)
                 else:
-                    slave_pos = self.Controler.GetSlavePos()
+                    node_name = self.Controler.CTNName()
                 
                 if pdo_mapping != "":
-                    var_name = "%s_%4.4x_%2.2x" % (self.Controler.CTNName(), entry_index, entry_subindex)
-                    if pdo_mapping == "R":
+                    var_name = "%s_%4.4x_%2.2x" % (node_name, entry_index, entry_subindex)
+                    if pdo_mapping == "T":
                         dir = "%I"
                     else:
                         dir = "%Q"
                     location = "%s%s" % (dir, data_size) + \
-                               ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + 
-                                                             (slave_pos, entry_index, entry_subindex)))
+                               ".".join(map(lambda x:str(x), location + (entry_index, entry_subindex)))
                     
                     data = wx.TextDataObject(str((location, "location", data_type, var_name, "", access)))
                     dragSource = wx.DropSource(self.VariablesGrid)
@@ -195,7 +197,7 @@
                     dragSource.DoDragDrop()
                     return
                 
-                elif self.ColumnPosition:
+                elif self.PositionColumn:
                     location = self.Controler.GetCurrentLocation() +\
                                (slave_pos, entry_index, entry_subindex)
                     data = wx.TextDataObject(str((location, "variable", access)))
--- a/etherlab/EthercatMaster.py	Sat Apr 13 01:40:31 2013 +0200
+++ b/etherlab/EthercatMaster.py	Sat Apr 13 02:14:37 2013 +0200
@@ -292,6 +292,12 @@
             return False
         return True
 
+    def GetSlaveName(self, slave_pos):
+        CTNChild = self.GetChildByIECLocation((slave_pos,))
+        if CTNChild is not None:
+            return CTNChild.CTNName()
+        return self.CTNName()
+
     def GetSlaves(self, vendor=None, slave_pos=None, slave_profile=None):
         slaves = []
         for slave in self.Config.getConfig().getSlave():