runtime/PLCObject.py
changeset 2697 93333d206198
parent 2689 7f67a7f6bfcc
child 2698 e50d32c747b3
equal deleted inserted replaced
2696:9bd639e9124e 2697:93333d206198
   358                 except KeyError:
   358                 except KeyError:
   359                     raise KeyError("Try to set unknown shared global variable : %s" % name)
   359                     raise KeyError("Try to set unknown shared global variable : %s" % name)
   360                 v = parent.python_runtime_vars["_"+name+"_pack"](t, value)
   360                 v = parent.python_runtime_vars["_"+name+"_pack"](t, value)
   361                 parent.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
   361                 parent.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
   362 
   362 
       
   363         class OnChangeStateClass(object):
       
   364             def __getattr__(self, name):
       
   365                 res = object()
       
   366                 u = parent.python_runtime_vars["_"+name+"_unpack"]
       
   367                 res.count = parent.python_runtime_vars["_PyOnChangeCount_"+name].value
       
   368                 res.first = u(parent.python_runtime_vars["_PyOnChangeFirst_"+name])
       
   369                 res.last = u(parent.python_runtime_vars["_PyOnChangeLast_"+name])
       
   370                 return res
       
   371 
       
   372 
   363         self.python_runtime_vars.update({
   373         self.python_runtime_vars.update({
   364             "PLCGlobals":     PLCSafeGlobals(),
   374             "PLCGlobals":     PLCSafeGlobals(),
       
   375             "OnChange":       OnChangeStateClass(),
   365             "WorkingDir":     self.workingdir,
   376             "WorkingDir":     self.workingdir,
   366             "PLCObject":      self,
   377             "PLCObject":      self,
   367             "PLCBinary":      self.PLClibraryHandle,
   378             "PLCBinary":      self.PLClibraryHandle,
   368             "PLCGlobalsDesc": []})
   379             "PLCGlobalsDesc": []})
   369 
   380