229 "SIZE" : size "X", "B", "W", "D", "L" |
229 "SIZE" : size "X", "B", "W", "D", "L" |
230 "LOC" : tuple of interger for IEC location (0,1,2,...) |
230 "LOC" : tuple of interger for IEC location (0,1,2,...) |
231 }, ...] |
231 }, ...] |
232 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
232 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
233 """ |
233 """ |
234 self.logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n") |
234 self.GetPlugRoot().logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n") |
235 return [],"",False |
235 return [],"",False |
236 |
236 |
237 def _Generate_C(self, buildpath, locations): |
237 def _Generate_C(self, buildpath, locations): |
238 # Generate plugins [(Cfiles, CFLAGS)], LDFLAGS, DoCalls, extra_files |
238 # Generate plugins [(Cfiles, CFLAGS)], LDFLAGS, DoCalls, extra_files |
239 # extra_files = [(fname,fobject), ...] |
239 # extra_files = [(fname,fobject), ...] |
427 # Rename plugin dir if exist |
427 # Rename plugin dir if exist |
428 if not dontexist: |
428 if not dontexist: |
429 shutil.move(oldname, self.PlugPath()) |
429 shutil.move(oldname, self.PlugPath()) |
430 # warn user he has two left hands |
430 # warn user he has two left hands |
431 if DesiredName != res: |
431 if DesiredName != res: |
432 self.logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res)) |
432 self.GetPlugRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res)) |
433 return res |
433 return res |
434 |
434 |
435 def FindNewIEC_Channel(self, DesiredChannel): |
435 def FindNewIEC_Channel(self, DesiredChannel): |
436 """ |
436 """ |
437 Changes IEC Channel number to DesiredChannel if available, nearest available if not. |
437 Changes IEC Channel number to DesiredChannel if available, nearest available if not. |
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.logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel) |
457 self.GetPlugRoot().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 if DesiredChannel != res: |
463 if DesiredChannel != res: |
464 self.logger.write_warning(_("A child with IEC channel %d already exist -> %d\n")%(DesiredChannel,res)) |
464 self.GetPlugRoot().logger.write_warning(_("A child with IEC channel %d already exist -> %d\n")%(DesiredChannel,res)) |
465 return res |
465 return res |
466 |
466 |
467 def OnPlugClose(self): |
467 def OnPlugClose(self): |
468 return True |
468 return True |
469 |
469 |
519 before PlugClass.__init__, and to do the file related stuff. |
519 before PlugClass.__init__, and to do the file related stuff. |
520 """ |
520 """ |
521 def __init__(_self): |
521 def __init__(_self): |
522 # self is the parent |
522 # self is the parent |
523 _self.PlugParent = self |
523 _self.PlugParent = self |
524 # self is the parent |
|
525 _self.logger = self.logger |
|
526 # Keep track of the plugin type name |
524 # Keep track of the plugin type name |
527 _self.PlugType = PlugType |
525 _self.PlugType = PlugType |
528 # remind the help string, for more fancy display |
526 # remind the help string, for more fancy display |
529 _self.PlugHelp = PlugHelp |
527 _self.PlugHelp = PlugHelp |
530 # Call the base plugin template init - change XSD into class members |
528 # Call the base plugin template init - change XSD into class members |
597 basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r') |
595 basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r') |
598 basetree = minidom.parse(basexmlfile) |
596 basetree = minidom.parse(basexmlfile) |
599 self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0]) |
597 self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0]) |
600 basexmlfile.close() |
598 basexmlfile.close() |
601 except Exception, exc: |
599 except Exception, exc: |
602 self.logger.write_error(_("Couldn't load plugin base parameters %s :\n %s") % (PlugName, str(exc))) |
600 self.GetPlugRoot().logger.write_error(_("Couldn't load plugin base parameters %s :\n %s") % (PlugName, str(exc))) |
603 self.logger.write_error(traceback.format_exc()) |
601 self.GetPlugRoot().logger.write_error(traceback.format_exc()) |
604 |
602 |
605 # Get the xml tree |
603 # Get the xml tree |
606 if self.PlugParams: |
604 if self.PlugParams: |
607 try: |
605 try: |
608 xmlfile = open(self.PluginXmlFilePath(PlugName), 'r') |
606 xmlfile = open(self.PluginXmlFilePath(PlugName), 'r') |
609 tree = minidom.parse(xmlfile) |
607 tree = minidom.parse(xmlfile) |
610 self.PlugParams[1].loadXMLTree(tree.childNodes[0]) |
608 self.PlugParams[1].loadXMLTree(tree.childNodes[0]) |
611 xmlfile.close() |
609 xmlfile.close() |
612 except Exception, exc: |
610 except Exception, exc: |
613 self.logger.write_error(_("Couldn't load plugin parameters %s :\n %s") % (PlugName, str(exc))) |
611 self.GetPlugRoot().logger.write_error(_("Couldn't load plugin parameters %s :\n %s") % (PlugName, str(exc))) |
614 self.logger.write_error(traceback.format_exc()) |
612 self.GetPlugRoot().logger.write_error(traceback.format_exc()) |
615 |
613 |
616 def LoadChilds(self): |
614 def LoadChilds(self): |
617 # Iterate over all PlugName@PlugType in plugin directory, and try to open them |
615 # Iterate over all PlugName@PlugType in plugin directory, and try to open them |
618 for PlugDir in os.listdir(self.PlugPath()): |
616 for PlugDir in os.listdir(self.PlugPath()): |
619 if os.path.isdir(os.path.join(self.PlugPath(), PlugDir)) and \ |
617 if os.path.isdir(os.path.join(self.PlugPath(), PlugDir)) and \ |
620 PlugDir.count(NameTypeSeparator) == 1: |
618 PlugDir.count(NameTypeSeparator) == 1: |
621 pname, ptype = PlugDir.split(NameTypeSeparator) |
619 pname, ptype = PlugDir.split(NameTypeSeparator) |
622 try: |
620 try: |
623 self.PlugAddChild(pname, ptype) |
621 self.PlugAddChild(pname, ptype) |
624 except Exception, exc: |
622 except Exception, exc: |
625 self.logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc))) |
623 self.GetPlugRoot().logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc))) |
626 self.logger.write_error(traceback.format_exc()) |
624 self.GetPlugRoot().logger.write_error(traceback.format_exc()) |
627 |
625 |
628 def EnableMethod(self, method, value): |
626 def EnableMethod(self, method, value): |
629 for d in self.PluginMethods: |
627 for d in self.PluginMethods: |
630 if d["method"]==method: |
628 if d["method"]==method: |
631 d["enabled"]=value |
629 d["enabled"]=value |