plugins/canfestival/canfestival.py
changeset 49 45dc6a944ab6
parent 47 fd45c291fed0
child 52 eaffcd0a2f03
equal deleted inserted replaced
48:6b30cfee163e 49:45dc6a944ab6
     1 import os, sys
     1 import os, sys
     2 base_folder = os.path.split(sys.path[0])[0]
     2 base_folder = os.path.split(sys.path[0])[0]
     3 sys.path.append(os.path.join(base_folder, "CanFestival-3", "objdictgen"))
     3 CanFestivalPath = os.path.join(base_folder, "CanFestival-3")
     4 CanfestivalIncludePath = os.path.join(base_folder, "CanFestival-3", "include")
     4 sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))
     5 CanfestivalLibPath = os.path.join(base_folder, "CanFestival-3", "src")
       
     6 
     5 
     7 from nodelist import NodeList
     6 from nodelist import NodeList
     8 from nodemanager import NodeManager
     7 from nodemanager import NodeManager
     9 import config_utils, gen_cfile
     8 import config_utils, gen_cfile
    10 from networkedit import networkedit
     9 from networkedit import networkedit
       
    10 import canfestival_config
    11 
    11 
    12 class _NetworkEdit(networkedit):
    12 class _NetworkEdit(networkedit):
    13     " Overload some of CanFestival Network Editor methods "
    13     " Overload some of CanFestival Network Editor methods "
    14     def OnCloseFrame(self, event):
    14     def OnCloseFrame(self, event):
    15         " Do reset _NodeListPlug.View when closed"
    15         " Do reset _NodeListPlug.View when closed"
    76         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    76         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    77         """
    77         """
    78         current_location = self.GetCurrentLocation()
    78         current_location = self.GetCurrentLocation()
    79         # define a unique name for the generated C file
    79         # define a unique name for the generated C file
    80         prefix = "_".join(map(lambda x:str(x), current_location))
    80         prefix = "_".join(map(lambda x:str(x), current_location))
    81         Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" )
    81         Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
    82         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
    82         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
    83         master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs())
    83         master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs())
    84         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    84         res = gen_cfile.GenerateFile(Gen_OD_path, master)
    85         if res :
    85         if res :
    86             raise Exception, res
    86             raise Exception, res
    87         
    87         
    88         return [(Gen_OD_path,"-I"+CanfestivalIncludePath)],""
    88         return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],""
    89     
    89     
    90 class RootClass:
    90 class RootClass:
    91     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    91     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
    92     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    92     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    93       <xsd:element name="CanFestivalInstance">
    93       <xsd:element name="CanFestivalInstance">
    99     """
    99     """
   100 
   100 
   101     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
   101     PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
   102     
   102     
   103     def PlugGenerate_C(self, buildpath, locations, logger):
   103     def PlugGenerate_C(self, buildpath, locations, logger):
   104         return [],"-L"+CanfestivalLibPath+" -lcanfestival"
   104         return [],canfestival_config.getLDFLAGS(CanFestivalPath)
   105 
   105 
   106 
   106