448 # Build a list of used Channels out of parent's Children |
448 # Build a list of used Channels out of parent's Children |
449 AllChannels = self.GetAllChannels() |
449 AllChannels = self.GetAllChannels() |
450 |
450 |
451 # Now, try to guess the nearest available channel |
451 # Now, try to guess the nearest available channel |
452 res = DesiredChannel |
452 res = DesiredChannel |
453 while res in AllChannels: # While channel not free |
453 while res in AllChannels: # While channel not free |
454 if res < CurrentChannel: # Want to go down ? |
454 if res < CurrentChannel: # Want to go down ? |
455 res -= 1 # Test for n-1 |
455 res -= 1 # Test for n-1 |
456 if res < 0 : |
456 if res < 0 : |
457 self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n") % CurrentChannel) |
457 self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n") % CurrentChannel) |
458 return CurrentChannel # Can't go bellow 0, do nothing |
458 return CurrentChannel # Can't go bellow 0, do nothing |
459 else : # Want to go up ? |
459 else : # Want to go up ? |
460 res += 1 # Test for n-1 |
460 res += 1 # Test for n-1 |
461 # Finally set IEC Channel |
461 # Finally set IEC Channel |
462 self.BaseParams.setIEC_Channel(res) |
462 self.BaseParams.setIEC_Channel(res) |
463 return res |
463 return res |
464 |
464 |
465 def GetContextualMenuItems(self): |
465 def GetContextualMenuItems(self): |
559 # Call the base confnode template init - change XSD into class members |
559 # Call the base confnode template init - change XSD into class members |
560 ConfigTreeNode.__init__(_self) |
560 ConfigTreeNode.__init__(_self) |
561 # check name is unique |
561 # check name is unique |
562 NewCTNName = _self.FindNewName(CTNName) |
562 NewCTNName = _self.FindNewName(CTNName) |
563 # If dir have already be made, and file exist |
563 # If dir have already be made, and file exist |
564 if os.path.isdir(_self.CTNPath(NewCTNName)): #and os.path.isfile(_self.ConfNodeXmlFilePath(CTNName)): |
564 if os.path.isdir(_self.CTNPath(NewCTNName)): #and os.path.isfile(_self.ConfNodeXmlFilePath(CTNName)): |
565 # Load the confnode.xml file into parameters members |
565 # Load the confnode.xml file into parameters members |
566 _self.LoadXMLParams(NewCTNName) |
566 _self.LoadXMLParams(NewCTNName) |
567 # Basic check. Better to fail immediately. |
567 # Basic check. Better to fail immediately. |
568 if (_self.BaseParams.getName() != NewCTNName): |
568 if (_self.BaseParams.getName() != NewCTNName): |
569 msg = _("Project tree layout do not match confnode.xml {a1}!={a2} ").\ |
569 msg = _("Project tree layout do not match confnode.xml {a1}!={a2} ").\ |