Added more clear error message in case of access to non declared PLC global from python code
--- a/runtime/PLCObject.py Thu May 16 14:47:57 2013 +0900
+++ b/runtime/PLCObject.py Thu May 16 17:40:22 2013 +0900
@@ -266,11 +266,18 @@
self.python_runtime_vars["PLCBinary"] = self.PLClibraryHandle
class PLCSafeGlobals:
def __getattr__(_self, name):
- v = self.python_runtime_vars["_"+name+"_ctype"]()
+ try :
+ t = self.python_runtime_vars["_"+name+"_ctype"]
+ except KeyError:
+ raise KeyError("Try to get unknown shared global variable : %s"%name)
+ v = t()
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"]
+ try :
+ t = self.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))
self.python_runtime_vars["PLCGlobals"] = PLCSafeGlobals()