runtime/PLCObject.py
changeset 1145 203f4eff3313
parent 1144 21475ee0e688
child 1156 9708ed2a4ac2
--- a/runtime/PLCObject.py	Wed May 15 17:13:49 2013 +0900
+++ b/runtime/PLCObject.py	Wed May 15 18:21:20 2013 +0900
@@ -265,12 +265,14 @@
         self.python_runtime_vars["PLCObject"] = self
         self.python_runtime_vars["PLCBinary"] = self.PLClibraryHandle
         class PLCSafeGlobals:
-            def __getattr__(self, name):
-                r = globals()["_PySafeGetPLCGlob_"+name]()
-                return globals()["_"+name+"_unpack"](r)
-            def __setattr__(self, name, value):
-                v = globals()["_"+name+"_pack"](c_type,value)
-                globals()["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
+            def __getattr__(_self, name):
+                v = self.python_runtime_vars["_"+name+"_ctype"]()
+                r = self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v))
+                return self.python_runtime_vars["_"+name+"_unpack"](v)
+            def __setattr__(_self, name, value):
+                t = self.python_runtime_vars["_"+name+"_ctype"]
+                v = self.python_runtime_vars["_"+name+"_pack"](t,value)
+                self.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
         self.python_runtime_vars["PLCGlobals"] = PLCSafeGlobals()
         try:
             for filename in os.listdir(self.workingdir):