ConfigTreeNode.py
changeset 1734 750eeb7230a1
parent 1733 dea107dce0c4
child 1736 7e61baa047f0
equal deleted inserted replaced
1733:dea107dce0c4 1734:750eeb7230a1
   213                 XMLFile.close()
   213                 XMLFile.close()
   214 
   214 
   215             # Call the confnode specific OnCTNSave method
   215             # Call the confnode specific OnCTNSave method
   216             result = self.OnCTNSave(from_project_path)
   216             result = self.OnCTNSave(from_project_path)
   217             if not result:
   217             if not result:
   218                 return _("Error while saving \"%s\"\n")%self.CTNPath()
   218                 return _("Error while saving \"%s\"\n") % self.CTNPath()
   219 
   219 
   220             # mark confnode as saved
   220             # mark confnode as saved
   221             self.ChangesToSave = False
   221             self.ChangesToSave = False
   222             # go through all children and do the same
   222             # go through all children and do the same
   223             for CTNChild in self.IterChildren():
   223             for CTNChild in self.IterChildren():
   407             BaseDesiredName = DesiredName[:-2]
   407             BaseDesiredName = DesiredName[:-2]
   408         else:
   408         else:
   409             BaseDesiredName = DesiredName
   409             BaseDesiredName = DesiredName
   410         suffix = 1
   410         suffix = 1
   411         while res in AllNames:
   411         while res in AllNames:
   412             res = "%s_%d"%(BaseDesiredName, suffix)
   412             res = "%s_%d" % (BaseDesiredName, suffix)
   413             suffix += 1
   413             suffix += 1
   414 
   414 
   415         # Get old path
   415         # Get old path
   416         oldname = self.CTNPath()
   416         oldname = self.CTNPath()
   417         # Check previous confnode existance
   417         # Check previous confnode existance
   451         res = DesiredChannel
   451         res = DesiredChannel
   452         while res in AllChannels: # While channel not free
   452         while res in AllChannels: # While channel not free
   453             if res < CurrentChannel: # Want to go down ?
   453             if res < CurrentChannel: # Want to go down ?
   454                 res -=  1 # Test for n-1
   454                 res -=  1 # Test for n-1
   455                 if res < 0 :
   455                 if res < 0 :
   456                     self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel)
   456                     self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n") % CurrentChannel)
   457                     return CurrentChannel # Can't go bellow 0, do nothing
   457                     return CurrentChannel # Can't go bellow 0, do nothing
   458             else : # Want to go up ?
   458             else : # Want to go up ?
   459                 res +=  1 # Test for n-1
   459                 res +=  1 # Test for n-1
   460         # Finally set IEC Channel
   460         # Finally set IEC Channel
   461         self.BaseParams.setIEC_Channel(res)
   461         self.BaseParams.setIEC_Channel(res)