POULibrary.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 28 Apr 2016 15:21:02 +0300
changeset 1508 4c645e6b8c98
parent 772 98786137232d
child 1511 91538d0c242c
permissions -rw-r--r--
fix error if non-latin character was entered in initial value in
data type element

Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 575, in OnStructureElementsGridCellChange
value = self.StructureElementsTable.GetValue(row, col)
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
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), ""