POULibrary.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 19 Apr 2016 12:15:51 +0300
changeset 1484 d5efbb20927e
parent 772 98786137232d
child 1511 91538d0c242c
permissions -rw-r--r--
Suppress WXDEBUG assertions, as happens by default with wx2.8. This is
necessary for wx3.0

Exception while connecting LOCAL://!
Traceback (most recent call last):
File "/home/beremiz/beremiz/ProjectController.py", line 1560, in _Connect
self._SetConnector(connectors.ConnectorFactory(uri, self))
File "/home/beremiz/beremiz/ProjectController.py", line 1508, in _SetConnector
self.StatusTimer.Start(milliseconds=500, oneShot=False)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_misc.py", line 1324, in Start
return _misc_.Timer_Start(*args, **kwargs)
PyAssertionError: C++ assertion "m_window" failed at ../src/gtk/dcclient.cpp(2043) in DoGetSize(): GetSize() doesn't work without window
732
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
     1
from weakref import ref
728
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
     2
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
     3
class POULibrary:
732
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
     4
    def __init__(self, CTR, LibName, TypeStack):
772
98786137232d Fixed import dependency order for POUlibrary and PLCControler
Edouard Tisserant
parents: 732
diff changeset
     5
        from PLCControler import PLCControler
732
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
     6
        self.CTR = ref(CTR)
731
4fc681ed0c61 refecored library extension machanism
Edouard Tisserant
parents: 728
diff changeset
     7
        self.LibName = LibName
728
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
     8
        self.LibraryControler = PLCControler()
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
     9
        self.LibraryControler.OpenXMLFile(self.GetLibraryPath())
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    10
        self.LibraryControler.ClearConfNodeTypes()
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    11
        self.LibraryControler.AddConfNodeTypesList(TypeStack)
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    12
        self.program = None;
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    13
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    14
    def GetSTCode(self):
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    15
        if not self.program:
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    16
            self.program = self.LibraryControler.GenerateProgram()[0]+"\n"
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    17
        return self.program 
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    18
731
4fc681ed0c61 refecored library extension machanism
Edouard Tisserant
parents: 728
diff changeset
    19
    def GetName(self):
4fc681ed0c61 refecored library extension machanism
Edouard Tisserant
parents: 728
diff changeset
    20
        return self.LibName
732
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
    21
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
    22
    def GetCTR(self):
c4b0f117e106 Added reference to CTR in libraries
Edouard Tisserant
parents: 731
diff changeset
    23
        return self.CTR()
728
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    24
        
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    25
    def GetTypes(self):
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    26
        return {"name" : self.GetName(), "types": self.LibraryControler.Project}
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    27
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    28
    def GetLibraryPath(self):
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    29
        raise Exception("Not implemented")
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    30
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    31
    def Generate_C(self, buildpath, varlist, IECCFLAGS):
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    32
        # Pure python or IEC libs doesn't produce C code
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
diff changeset
    33
        return ((""), [], False), ""