objdictgen/nodemanager.py
changeset 580 2ae92a99ac10
parent 545 ff692766e5e9
child 582 e297491483ea
equal deleted inserted replaced
577:0bb82be64630 580:2ae92a99ac10
   213                         try:
   213                         try:
   214                             execfile(DS302Path)
   214                             execfile(DS302Path)
   215                             self.CurrentNode.SetDS302Profile(Mapping)
   215                             self.CurrentNode.SetDS302Profile(Mapping)
   216                             self.CurrentNode.ExtendSpecificMenu(AddMenuEntries)
   216                             self.CurrentNode.ExtendSpecificMenu(AddMenuEntries)
   217                         except:
   217                         except:
   218                             return "Problem with DS-302! Syntax Error."
   218                             return _("Problem with DS-302! Syntax Error.")
   219                     else:
   219                     else:
   220                         return "Couldn't find DS-302 in 'config' folder!"
   220                         return _("Couldn't find DS-302 in 'config' folder!")
   221                 elif option == "GenSYNC":
   221                 elif option == "GenSYNC":
   222                     AddIndexList.extend([0x1005, 0x1006])
   222                     AddIndexList.extend([0x1005, 0x1006])
   223                 elif option == "Emergency":
   223                 elif option == "Emergency":
   224                     AddIndexList.append(0x1014)
   224                     AddIndexList.append(0x1014)
   225                 elif option == "SaveConfig":
   225                 elif option == "SaveConfig":
   259                 node.SetProfileName(profile)
   259                 node.SetProfileName(profile)
   260                 node.SetProfile(Mapping)
   260                 node.SetProfile(Mapping)
   261                 node.SetSpecificMenu(AddMenuEntries)
   261                 node.SetSpecificMenu(AddMenuEntries)
   262                 return None
   262                 return None
   263             except:
   263             except:
   264                 return "Syntax Error\nBad OD Profile file!"
   264                 return _("Syntax Error\nBad OD Profile file!")
   265         else:
   265         else:
   266             # Default profile
   266             # Default profile
   267             node.SetProfileName("None")
   267             node.SetProfileName("None")
   268             node.SetProfile({})
   268             node.SetProfile({})
   269             node.SetSpecificMenu([])
   269             node.SetSpecificMenu([])
   283             # Add a new buffer and defining current state
   283             # Add a new buffer and defining current state
   284             index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
   284             index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
   285             self.SetCurrentFilePath(filepath)
   285             self.SetCurrentFilePath(filepath)
   286             return index
   286             return index
   287         except:
   287         except:
   288             return "Unable to load file \"%s\"!"%filepath
   288             return _("Unable to load file \"%s\"!")%filepath
   289 
   289 
   290     """
   290     """
   291     Save current node in  a file
   291     Save current node in  a file
   292     """
   292     """
   293     def SaveCurrentInFile(self, filepath = None):
   293     def SaveCurrentInFile(self, filepath = None):
   622                             node.AddEntry(index, i + 1, 0)
   622                             node.AddEntry(index, i + 1, 0)
   623                 if not disable_buffer:
   623                 if not disable_buffer:
   624                     self.BufferCurrentNode()
   624                     self.BufferCurrentNode()
   625                 return None
   625                 return None
   626             else:
   626             else:
   627                 return "Index 0x%04X already defined!"%index
   627                 return _("Index 0x%04X already defined!")%index
   628         else:
   628         else:
   629             return "Index 0x%04X isn't a valid index for Map Variable!"%index
   629             return _("Index 0x%04X isn't a valid index for Map Variable!")%index
   630 
   630 
   631     def AddUserTypeToCurrent(self, type, min, max, length):
   631     def AddUserTypeToCurrent(self, type, min, max, length):
   632         index = 0xA0
   632         index = 0xA0
   633         while index < 0x100 and self.CurrentNode.IsEntry(index):
   633         while index < 0x100 and self.CurrentNode.IsEntry(index):
   634             index += 1
   634             index += 1
   654                 self.CurrentNode.AddEntry(index, 1, type)
   654                 self.CurrentNode.AddEntry(index, 1, type)
   655                 self.CurrentNode.AddEntry(index, 2, length)
   655                 self.CurrentNode.AddEntry(index, 2, length)
   656             self.BufferCurrentNode()
   656             self.BufferCurrentNode()
   657             return None
   657             return None
   658         else:
   658         else:
   659             return "Too many User Types have already been defined!"
   659             return _("Too many User Types have already been defined!")
   660 
   660 
   661 #-------------------------------------------------------------------------------
   661 #-------------------------------------------------------------------------------
   662 #                      Modify Entry and Mapping Functions
   662 #                      Modify Entry and Mapping Functions
   663 #-------------------------------------------------------------------------------
   663 #-------------------------------------------------------------------------------
   664 
   664 
   848     
   848     
   849     def SetCurrentFilePath(self, filepath):
   849     def SetCurrentFilePath(self, filepath):
   850         self.FilePaths[self.NodeIndex] = filepath
   850         self.FilePaths[self.NodeIndex] = filepath
   851         if filepath == "":
   851         if filepath == "":
   852             self.LastNewIndex += 1
   852             self.LastNewIndex += 1
   853             self.FileNames[self.NodeIndex] = "Unnamed%d"%self.LastNewIndex
   853             self.FileNames[self.NodeIndex] = _("Unnamed%d")%self.LastNewIndex
   854         else:
   854         else:
   855             self.FileNames[self.NodeIndex] = os.path.splitext(os.path.basename(filepath))[0]
   855             self.FileNames[self.NodeIndex] = os.path.splitext(os.path.basename(filepath))[0]
   856                 
   856                 
   857     def GetCurrentFilePath(self):
   857     def GetCurrentFilePath(self):
   858         if len(self.FilePaths) > 0:
   858         if len(self.FilePaths) > 0: