# HG changeset patch # User etisserant # Date 1188306052 -7200 # Node ID 7a473efc45304bdfc5a7ed623b6e5a99323a301b # Parent eb9fdd316a405da3b3ab6add3a0b09e55603e639 More precise design for plugins.... to be continued... diff -r eb9fdd316a40 -r 7a473efc4530 plugger.py --- a/plugger.py Tue Aug 28 07:57:36 2007 +0200 +++ b/plugger.py Tue Aug 28 15:00:52 2007 +0200 @@ -238,12 +238,12 @@ if os.path.isdir(_self.PlugPath(PlugName)) and os.path.isfile(_self.PluginXmlFilePath(PlugName)): #Load the plugin.xml file into parameters members _self.LoadXMLParams() + # Check that IEC_Channel is not already in use. + self.FindNewIEC_Channel(self.BaseParams.getIEC_Channel()) # Call the plugin real __init__ PlugClass.__init__(_self) #Load and init all the childs _self.LoadChilds() - # Check that IEC_Channel is not already in use. - self.FindNewIEC_Channel(self.BaseParams.getIEC_Channel()) else: # If plugin do not have corresponding file/dirs - they will be created on Save # Set plugin name diff -r eb9fdd316a40 -r 7a473efc4530 plugins/canfestival/canfestival.py --- a/plugins/canfestival/canfestival.py Tue Aug 28 07:57:36 2007 +0200 +++ b/plugins/canfestival/canfestival.py Tue Aug 28 15:00:52 2007 +0200 @@ -48,21 +48,22 @@ self.SaveProject() return True - def Generate_C(self, dirpath, locations): + def PlugGenerate_C(self, buildpath, current_location, locations): """ - return C code for network dictionnary + Generate C code + @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) + @param locations: List of complete variables locations \ + [(IEC_loc, IEC_Direction IEC_Type, Name)]\ + ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...] """ - filepath = os.path.join(dirpath, "master.c") - master = config_utils.GenerateConciseDCF(locations, self) - res = gen_cfile.GenerateFile(filepath, master) - if not res: - s = str(self.BaseParams.BusId)+"_IN(){}\n" - s += "CanOpen(\""+self.CanFestivalNode.CAN_Device+"\")" - f = file(filepath, 'a') - f.write(s) - else: - pass # error - return {"headers":["master.h"],"sources":["master.c"]} + prefix = "_".join(map(lambda x:str(x), current_location)) + Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" ) + master = config_utils.GenerateConciseDCF(locations, current_location, self) + res = gen_cfile.GenerateFile(Gen_OD_path, master) + if res : + raise Exception, res + + return [(Gen_OD_path,CanFestival_OD_CFLAGS)],"" class RootClass: XSD = """ @@ -77,12 +78,18 @@ PlugChildsTypes = [("CanOpenNode",_NodeListPlug)] - def Generate_C(self, filepath, locations): + def PlugGenerate_C(self, buildpath, current_location, locations): """ - return C code for network dictionnary + Generate C code + @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) + @param locations: List of complete variables locations \ + [(IEC_loc, IEC_Direction IEC_Type, Name)]\ + ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...] """ + prefix = "_".join(map(lambda x:str(x), current_location)) + Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" ) master = config_utils.GenerateConciseDCF(locations, self) - res = gen_cfile.GenerateFile(filepath, master) + res = gen_cfile.GenerateFile(Gen_OD_path, master) if not res: s = str(self.BaseParams.BusId)+"_IN(){}\n" s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device+"\")" @@ -90,4 +97,7 @@ f.write(s) else: pass # error + + return [],"" +