--- a/Beremiz_service.py Mon Feb 16 16:23:51 2015 +0100
+++ b/Beremiz_service.py Tue Feb 17 10:23:57 2015 +0100
@@ -401,8 +401,10 @@
self.servicepublisher = ServicePublisher.ServicePublisher()
self.servicepublisher.RegisterService(self.servicename, self.ip_addr, self.port)
- if self.autostart and self.plcobj.GetPLCstatus()[0] != "Empty":
+ if self.plcobj.GetPLCstatus()[0] != "Empty": --- a/py_ext/PythonFileCTNMixin.py Mon Feb 16 16:23:51 2015 +0100
+++ b/py_ext/PythonFileCTNMixin.py Tue Feb 17 10:23:57 2015 +0100
@@ -72,6 +72,7 @@
self.GetCurrentLocation()))
configname = self.GetCTRoot().GetProjectConfigNames()[0]
+ pyextname = self.CTNName() # python side PLC global variables access stub
globalstubs = "\n".join(["""\
@@ -83,11 +84,12 @@
_PySafeSetPLCGlob_%(name)s = PLCBinary.__SafeSetPLCGlob_%(name)s
_PySafeSetPLCGlob_%(name)s.restype = None
_PySafeSetPLCGlob_%(name)s.argtypes = [ctypes.POINTER(_%(name)s_ctype)]
-_PySafePLCGlobals.append(("%(name)s","%(IECtype)s"))
+_%(pyextname)sGlobalsDesc.append(("%(name)s","%(IECtype)s")) """ % { "name": variable.getname(),
"configname": configname.upper(),
"uppername": variable.getname().upper(),
- "IECtype": variable.gettype()}
+ "IECtype": variable.gettype(), for variable in self.CodeFile.variables.variable])
# Runtime calls (start, stop, init, and cleanup)
@@ -104,8 +106,6 @@
globalsection = self.GetSection("globals")
- pyextname = self.CTNName()
@@ -115,8 +115,8 @@
## Code for PLC global variable access
from targets.typemapping import TypeTranslator
-_PyExtName = "%(pyextname)s"
+_%(pyextname)sGlobalsDesc = [] +PLCGlobalsDesc.append(( "_%(pyextname)s" , _%(pyextname)sGlobalsDesc )) ## User code in "global" scope
--- a/runtime/PLCObject.py Mon Feb 16 16:23:51 2015 +0100
+++ b/runtime/PLCObject.py Tue Feb 17 10:23:57 2015 +0100
@@ -56,7 +56,7 @@
self.evaluator = evaluator
self.argv = [workingdir] + argv # force argv[0] to be "path" to exec...
self.workingdir = workingdir
- self.PLCStatus = "Stopped"
+ self.PLCStatus = "Empty" self.PLClibraryHandle = None
self.PLClibraryLock = Lock()
self.DummyIteratorLock = None
@@ -73,6 +73,7 @@
self.TraceWakeup = Event()
# Get the last transfered PLC if connector must be restart
self.CurrentPLCFilename=open(
@@ -264,11 +265,6 @@
self.python_runtime_vars = globals().copy()
self.python_runtime_vars.update(self.pyruntimevars)
- self.python_runtime_vars["WorkingDir"] = self.workingdir
- for methodname in MethodNames :
- self.python_runtime_vars["_runtime_%s"%methodname] = []
- self.python_runtime_vars["PLCObject"] = self
- self.python_runtime_vars["PLCBinary"] = self.PLClibraryHandle
def __getattr__(_self, name):
@@ -285,9 +281,21 @@
raise KeyError("Try to set unknown shared global variable : %s"%name)
v = self.python_runtime_vars["_"+name+"_pack"](t,value)
self.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
- self.python_runtime_vars["PLCGlobals"] = PLCSafeGlobals()
+ self.python_runtime_vars.update({ + "PLCGlobals" : PLCSafeGlobals(), + "WorkingDir" : self.workingdir, + "PLCBinary" : self.PLClibraryHandle, + "PLCGlobalsDesc" : []}) + for methodname in MethodNames : + self.python_runtime_vars["_runtime_%s"%methodname] = [] - for filename in os.listdir(self.workingdir):
+ filenames = os.listdir(self.workingdir) + for filename in filenames: name, ext = os.path.splitext(filename)
if name.upper().startswith("RUNTIME") and ext.upper() == ".PY":
execfile(os.path.join(self.workingdir, filename), self.python_runtime_vars)