plugins/canfestival/canfestival.py
changeset 24 585d5b387b6a
parent 23 e007d9d466d7
child 25 fa7503684c28
equal deleted inserted replaced
23:e007d9d466d7 24:585d5b387b6a
    53         
    53         
    54     def OnPlugSave(self):
    54     def OnPlugSave(self):
    55         self.SaveProject()
    55         self.SaveProject()
    56         return True
    56         return True
    57 
    57 
    58     def PlugGenerate_C(self, buildpath, current_location, locations, logger):
    58     def PlugGenerate_C(self, buildpath, locations, logger):
    59         """
    59         """
    60         Generate C code
    60         Generate C code
    61         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
    61         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
    62         @param locations: List of complete variables locations \
    62         @param locations: List of complete variables locations \
    63             [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
    63             [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
    66             "SIZE" : size "X", "B", "W", "D", "L"
    66             "SIZE" : size "X", "B", "W", "D", "L"
    67             "LOC" : tuple of interger for IEC location (0,1,2,...)
    67             "LOC" : tuple of interger for IEC location (0,1,2,...)
    68             }, ...]
    68             }, ...]
    69         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    69         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    70         """
    70         """
       
    71         current_location = self.GetCurrentLocation()
    71         # define a unique name for the generated C file
    72         # define a unique name for the generated C file
    72         prefix = "_".join(map(lambda x:str(x), current_location))
    73         prefix = "_".join(map(lambda x:str(x), current_location))
    73         Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" )
    74         Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" )
    74         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
    75         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
    75         master = config_utils.GenerateConciseDCF(locations, current_location, self)
    76         master = config_utils.GenerateConciseDCF(locations, current_location, self)
    76         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    77         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    77         if res :
    78         if res :
    78             raise Exception, res
    79             raise Exception, res
    79         
    80         
    80         return [(Gen_OD_path,CanFestival_OD_CFLAGS)],""
    81         return [(Gen_OD_path,"")],""
    81     
    82     
    82 class RootClass:
    83 class RootClass:
    83     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    84     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    84     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    85     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    85       <xsd:element name="CanFestivalInstance">
    86       <xsd:element name="CanFestivalInstance">
    90     </xsd:schema>
    91     </xsd:schema>
    91     """
    92     """
    92 
    93 
    93     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
    94     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
    94     
    95     
    95     def PlugGenerate_C(self, buildpath, current_location, locations, logger):
    96     def PlugGenerate_C(self, buildpath, locations, logger):
    96         return [],""
    97         return [],""
    97 
    98 
    98 
    99