plugins/canfestival/canfestival.py
changeset 15 7a473efc4530
parent 13 f1f0edbeb313
child 17 ee8cb104dbe0
--- 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 = """<?xml version="1.0" encoding="ISO-8859-1" ?>
@@ -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 [],""
 
+