runtime/PLCObject.py
changeset 1868 616c3f4bcbcb
parent 1850 614396cbffbf
child 1878 fb73a6b6622d
--- a/runtime/PLCObject.py	Wed Oct 11 11:54:55 2017 +0300
+++ b/runtime/PLCObject.py	Wed Oct 11 13:15:21 2017 +0300
@@ -277,24 +277,25 @@
         MethodNames = ["init", "start", "stop", "cleanup"]
         self.python_runtime_vars = globals().copy()
         self.python_runtime_vars.update(self.pyruntimevars)
+        parent = self
 
         class PLCSafeGlobals(object):
-            def __getattr__(_self, name):
+            def __getattr__(self, name):
                 try:
-                    t = self.python_runtime_vars["_"+name+"_ctype"]
+                    t = parent.python_runtime_vars["_"+name+"_ctype"]
                 except KeyError:
                     raise KeyError("Try to get unknown shared global variable : %s" % name)
                 v = t()
-                self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v))
-                return self.python_runtime_vars["_"+name+"_unpack"](v)
-
-            def __setattr__(_self, name, value):
+                parent.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v))
+                return parent.python_runtime_vars["_"+name+"_unpack"](v)
+
+            def __setattr__(self, name, value):
                 try:
-                    t = self.python_runtime_vars["_"+name+"_ctype"]
+                    t = parent.python_runtime_vars["_"+name+"_ctype"]
                 except KeyError:
                     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))
+                v = parent.python_runtime_vars["_"+name+"_pack"](t, value)
+                parent.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
 
         self.python_runtime_vars.update({
             "PLCGlobals":     PLCSafeGlobals(),