22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 from weakref import ref |
25 from weakref import ref |
26 |
26 |
|
27 |
27 class POULibrary: |
28 class POULibrary: |
28 def __init__(self, CTR, LibName, TypeStack): |
29 def __init__(self, CTR, LibName, TypeStack): |
29 from PLCControler import PLCControler |
30 from PLCControler import PLCControler |
30 self.CTR = ref(CTR) |
31 self.CTR = ref(CTR) |
31 self.LibName = LibName |
32 self.LibName = LibName |
32 self.LibraryControler = PLCControler() |
33 self.LibraryControler = PLCControler() |
33 self.LibraryControler.OpenXMLFile(self.GetLibraryPath()) |
34 self.LibraryControler.OpenXMLFile(self.GetLibraryPath()) |
34 self.LibraryControler.ClearConfNodeTypes() |
35 self.LibraryControler.ClearConfNodeTypes() |
35 self.LibraryControler.AddConfNodeTypesList(TypeStack) |
36 self.LibraryControler.AddConfNodeTypesList(TypeStack) |
36 self.program = None; |
37 self.program = None |
37 |
38 |
38 def GetSTCode(self): |
39 def GetSTCode(self): |
39 if not self.program: |
40 if not self.program: |
40 self.program = self.LibraryControler.GenerateProgram()[0]+"\n" |
41 self.program = self.LibraryControler.GenerateProgram()[0]+"\n" |
41 return self.program |
42 return self.program |
42 |
43 |
43 def GetName(self): |
44 def GetName(self): |
44 return self.LibName |
45 return self.LibName |
45 |
46 |
46 def GetCTR(self): |
47 def GetCTR(self): |
47 return self.CTR() |
48 return self.CTR() |
48 |
49 |
49 def GetTypes(self): |
50 def GetTypes(self): |
50 return {"name" : self.GetName(), "types": self.LibraryControler.Project} |
51 return {"name": self.GetName(), "types": self.LibraryControler.Project} |
51 |
52 |
52 def GetLibraryPath(self): |
53 def GetLibraryPath(self): |
53 raise Exception("Not implemented") |
54 raise Exception("Not implemented") |
54 |
55 |
55 def Generate_C(self, buildpath, varlist, IECCFLAGS): |
56 def Generate_C(self, buildpath, varlist, IECCFLAGS): |