# HG changeset patch # User Laurent Bessard # Date 1365812077 -7200 # Node ID 1f2c3fdd70d0b3583cb07e2f19e7fea88c24cba8 # Parent 68beaf825a20bb790dc4f998243ef2978e6f9cb2 Fixed bugs in drag'n drop from variables panel in master and slaves editor panel diff -r 68beaf825a20 -r 1f2c3fdd70d0 etherlab/ConfigEditor.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))) diff -r 68beaf825a20 -r 1f2c3fdd70d0 etherlab/EthercatMaster.py --- 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():