plugins/canfestival/canfestival.py
changeset 15 7a473efc4530
parent 13 f1f0edbeb313
child 17 ee8cb104dbe0
equal deleted inserted replaced
14:eb9fdd316a40 15:7a473efc4530
    46         
    46         
    47     def PlugRequestSave(self):
    47     def PlugRequestSave(self):
    48         self.SaveProject()
    48         self.SaveProject()
    49         return True
    49         return True
    50 
    50 
    51     def Generate_C(self, dirpath, locations):
    51     def PlugGenerate_C(self, buildpath, current_location, locations):
    52         """
    52         """
    53         return C code for network dictionnary
    53         Generate C code
       
    54         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
       
    55         @param locations: List of complete variables locations \
       
    56             [(IEC_loc, IEC_Direction IEC_Type, Name)]\
       
    57             ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...]
    54         """
    58         """
    55         filepath = os.path.join(dirpath, "master.c")
    59         prefix = "_".join(map(lambda x:str(x), current_location))
    56         master = config_utils.GenerateConciseDCF(locations, self)
    60         Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" )
    57         res = gen_cfile.GenerateFile(filepath, master)
    61         master = config_utils.GenerateConciseDCF(locations, current_location, self)
    58         if not res:
    62         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    59              s = str(self.BaseParams.BusId)+"_IN(){}\n"
    63         if res :
    60              s += "CanOpen(\""+self.CanFestivalNode.CAN_Device+"\")"
    64             raise Exception, res
    61              f = file(filepath, 'a')
    65         
    62              f.write(s)
    66         return [(Gen_OD_path,CanFestival_OD_CFLAGS)],""
    63         else:
       
    64              pass # error
       
    65         return {"headers":["master.h"],"sources":["master.c"]}
       
    66     
    67     
    67 class RootClass:
    68 class RootClass:
    68     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    69     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    69     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    70     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    70       <xsd:element name="CanFestivalInstance">
    71       <xsd:element name="CanFestivalInstance">
    75     </xsd:schema>
    76     </xsd:schema>
    76     """
    77     """
    77 
    78 
    78     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
    79     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
    79 
    80 
    80     def Generate_C(self, filepath, locations):
    81     def PlugGenerate_C(self, buildpath, current_location, locations):
    81         """
    82         """
    82         return C code for network dictionnary
    83         Generate C code
       
    84         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
       
    85         @param locations: List of complete variables locations \
       
    86             [(IEC_loc, IEC_Direction IEC_Type, Name)]\
       
    87             ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...]
    83         """
    88         """
       
    89         prefix = "_".join(map(lambda x:str(x), current_location))
       
    90         Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" )
    84         master = config_utils.GenerateConciseDCF(locations, self)
    91         master = config_utils.GenerateConciseDCF(locations, self)
    85         res = gen_cfile.GenerateFile(filepath, master)
    92         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    86         if not res:
    93         if not res:
    87              s = str(self.BaseParams.BusId)+"_IN(){}\n"
    94              s = str(self.BaseParams.BusId)+"_IN(){}\n"
    88              s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device+"\")"
    95              s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device+"\")"
    89              f = file(filepath, 'a')
    96              f = file(filepath, 'a')
    90              f.write(s)
    97              f.write(s)
    91         else:
    98         else:
    92              pass # error
    99              pass # error
       
   100          
       
   101         return [],""
    93 
   102 
       
   103