POULibrary.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 20 Apr 2016 17:15:35 +0300
changeset 1489 9c22ff9c8c06
parent 772 98786137232d
child 1511 91538d0c242c
permissions -rw-r--r--
fix splash loading with wx3.0

Previously only gray square was shown. Apparently to show splash screen several calls of wx.Yield() are necessary.
Unfortunately splash.IsShowOnScreen() returns always 1 regardless of whether splash is on the screen or not.
this fix is a dirty hack. It just process all events after splash is created during 0.3 seconds.
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), ""