self.CurrentNode.SetNodeType(type)
self.CurrentNode.SetNodeDescription(description)
AddIndexList = self.GetMandatoryIndexes()
+ AddSubIndexList = []
if NMT == "NodeGuarding":
AddIndexList.extend([0x100C, 0x100D])
elif NMT == "Heartbeat":
AddIndexList.extend([0x1010, 0x1011, 0x1020])
elif option == "StoreEDS":
AddIndexList.extend([0x1021, 0x1022])
+ if type == "slave":
+ # add default SDO server
+ AddIndexList.append(0x1200)
+ # add default 4 receive and 4 transmit PDO
+ for comm, mapping in [(0x1400, 0x1600),(0x1800, 0x1A00)]:
+ firstparamindex = self.GetLineFromIndex(comm)
+ firstmappingindex = self.GetLineFromIndex(mapping)
+ AddIndexList.extend(range(firstparamindex, firstparamindex + 4))
+ for idx in range(firstmappingindex, firstmappingindex + 4):
+ AddIndexList.append(idx)
+ AddSubIndexList.append((idx, 8))
# Add a new buffer
index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
self.SetCurrentFilePath("")
# Add Mandatory indexes
self.ManageEntriesOfCurrent(AddIndexList, [])
+ for idx, num in AddSubIndexList:
+ self.AddSubentriesToCurrent(idx, num)
return index
else:
return result
"""
def CloseCurrent(self, ignore = False):
# Verify if it's not forced that the current node is saved before closing it
- if self.UndoBuffers[self.NodeIndex].IsCurrentSaved() or ignore:
+ if self.NodeIndex in self.UndoBuffers and (self.UndoBuffers[self.NodeIndex].IsCurrentSaved() or ignore):
self.RemoveNodeBuffer(self.NodeIndex)
if len(self.UndoBuffers) > 0:
previousindexes = [idx for idx in self.UndoBuffers.keys() if idx < self.NodeIndex]
Export to an eds file and store it in a new buffer if no node edited
"""
def ExportCurrentToEDSFile(self, filepath):
- return eds_utils.GenerateEDSFile(filepath, self)
+ return eds_utils.GenerateEDSFile(filepath, self.CurrentNode)
"""
Build the C definition of Object Dictionary for current node
if name == "value":
if editor == "map":
value = node.GetMapValue(value)
- if value:
+ if value is not None:
node.SetEntry(index, subIndex, value)
elif editor == "bool":
value = value == "True"
def GetBufferNumber(self):
return len(self.UndoBuffers)
+ def GetBufferIndexes(self):
+ return self.UndoBuffers.keys()
+
def LoadCurrentPrevious(self):
self.CurrentNode = self.UndoBuffers[self.NodeIndex].Previous().Copy()
editors = []
values = node.GetEntry(index, compute = False)
params = node.GetParamsEntry(index)
- if type(values) == ListType:
+ if isinstance(values, ListType):
for i, value in enumerate(values):
data.append({"value" : value})
data[-1].update(params[i])
dic["access"] = AccessType[infos["access"]]
dic["save"] = OptionType[dic["save"]]
editor = {"subindex" : None, "save" : "option", "callback" : "option", "comment" : "string"}
- if type(values) == ListType and i == 0:
+ if isinstance(values, ListType) and i == 0:
editor["name"] = None
editor["type"] = None
if 0x1600 <= index <= 0x17FF or 0x1A00 <= index <= 0x1C00: