POULibrary.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 22 Apr 2016 21:26:31 +0300
changeset 1503 3a238c0c5993
parent 772 98786137232d
child 1511 91538d0c242c
permissions -rw-r--r--
fix regression introduced by changeset: 1431:28e9d479aa65 [Use '-p' command line option when running matiec (iec2c)]

Variable matiec_flags in c_ext.py and PythonFileCTNMixin.py is not
used for flags for matiec (IEC to C compiler) actually, but it's used
to compile C-code generated for extensions using normal C-compiler,
like gcc.
from weakref import ref

class POULibrary:
    def __init__(self, CTR, LibName, TypeStack):
        from PLCControler import PLCControler
        self.CTR = ref(CTR)
        self.LibName = LibName
        self.LibraryControler = PLCControler()
        self.LibraryControler.OpenXMLFile(self.GetLibraryPath())
        self.LibraryControler.ClearConfNodeTypes()
        self.LibraryControler.AddConfNodeTypesList(TypeStack)
        self.program = None;

    def GetSTCode(self):
        if not self.program:
            self.program = self.LibraryControler.GenerateProgram()[0]+"\n"
        return self.program 

    def GetName(self):
        return self.LibName

    def GetCTR(self):
        return self.CTR()
        
    def GetTypes(self):
        return {"name" : self.GetName(), "types": self.LibraryControler.Project}

    def GetLibraryPath(self):
        raise Exception("Not implemented")

    def Generate_C(self, buildpath, varlist, IECCFLAGS):
        # Pure python or IEC libs doesn't produce C code
        return ((""), [], False), ""