def array_get_callback(self, req_type, count, callback, *user_args): """Read a value or array of values from a channel and execute the user supplied callback after the get has completed. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. callback: function called when the get is completed. *user_args: user provided arguments that are passed to callback when it is invoked. >>> def getCB(epicsArgs, userArgs): ... for item in sorted(epicsArgs.keys()): ... if item.startswith('pv_'): ... print item,epicsArgs[item] >>> chan = CaChannel('catest') >>> chan.searchw() >>> chan.putw(145) >>> chan.array_get_callback(ca.DBR_CTRL_DOUBLE, 1, getCB) >>> status = chan.pend_event(1) pv_loalarmlim -20.0 pv_loctrllim 0.0 pv_lodislim 0.0 pv_lowarnlim -10.0 pv_precision 3 pv_seconds 0.0 pv_severity 2 pv_status 3 pv_units mm pv_upalarmlim 20.0 pv_upctrllim 0.0 pv_updislim 0.0 pv_upwarnlim 10.0 pv_value 145.0 >>> chan = CaChannel('cabo') >>> chan.searchw() >>> chan.putw(0) >>> chan.array_get_callback(ca.DBR_CTRL_ENUM, 1, getCB) >>> status = chan.pend_event(1) pv_nostrings 2 pv_seconds 0.0 pv_severity 0 pv_statestrings ('Done', 'Busy') pv_status 0 pv_value 0 """ if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 self._callbacks['getCB']=(callback, user_args) try: status=ca.get(self.__chid, self._get_callback, req_type, count) except ca.error,msg: raise CaChannelException,msg
def array_get_callback(self, req_type, count, callback, *user_args): """Read a value or array of values from a channel and execute the user supplied callback after the get has completed. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. callback: function called when the get is completed. *user_args: user provided arguments that are passed to callback when it is invoked. >>> def getCB(epicsArgs, userArgs): ... for item in sorted(epicsArgs.keys()): ... if item.startswith('pv_'): ... print item,epicsArgs[item] >>> chan = CaChannel('catest') >>> chan.searchw() >>> chan.putw(145) >>> chan.array_get_callback(ca.DBR_CTRL_DOUBLE, 1, getCB) >>> status = chan.pend_event(1) pv_loalarmlim -20.0 pv_loctrllim 0.0 pv_lodislim 0.0 pv_lowarnlim -10.0 pv_precision 3 pv_seconds 0.0 pv_severity 2 pv_status 3 pv_units mm pv_upalarmlim 20.0 pv_upctrllim 0.0 pv_updislim 0.0 pv_upwarnlim 10.0 pv_value 145.0 >>> chan = CaChannel('cabo') >>> chan.searchw() >>> chan.putw(0) >>> chan.array_get_callback(ca.DBR_CTRL_ENUM, 1, getCB) >>> status = chan.pend_event(1) pv_nostrings 2 pv_seconds 0.0 pv_severity 0 pv_statestrings ('Done', 'Busy') pv_status 0 pv_value 0 """ if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 self._callbacks['getCB'] = (callback, user_args) try: status = ca.get(self.__chid, self._get_callback, req_type, count) except ca.error, msg: raise CaChannelException, msg
def getw(self, req_type=None, count=None): """Return a value or array of values from a channel. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. """ updated = [False] value = [0] def update_value(valstat): if valstat is None: return try: value[0] = valstat[0] finally: updated[0] = True if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 try: ca.get(self.__chid, update_value, req_type, count) except ca.error,msg: raise CaChannelException,msg
def add_masked_array_event(self, req_type, count, mask, callback, *user_args): """Specify a callback function to be executed whenever changes occur to a PV. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. mask: logical or of ca.DBE_VALUE, ca.DBE_LOG, ca.DBE_ALARM. Defaults to be ca.DBE_VALUE|ca.DBE_ALARM. callback: function called when the get is completed. *user_args: user provided arguments that are passed to callback when it is invoked. >>> def eventCB(epicsArgs, userArgs): ... print 'pv_value', epicsArgs['pv_value'] ... print 'pv_status', epicsArgs['pv_status'], ca.alarmStatusString(epicsArgs['pv_status']) ... print 'pv_severity', epicsArgs['pv_severity'], ca.alarmSeverityString(epicsArgs['pv_severity']) >>> chan = CaChannel('cabo') >>> chan.searchw() >>> chan.putw(1) >>> chan.add_masked_array_event(ca.DBR_STS_ENUM, None, None, eventCB) >>> status = chan.pend_event(1) pv_value 1 pv_status 7 STATE pv_severity 1 MINOR >>> chan.clear_event() """ if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 if mask is None: mask = ca.DBE_VALUE | ca.DBE_ALARM if self.__evid is not None: self.clear_event() self.pend_io() self._callbacks['eventCB'] = (callback, user_args) try: self.__evid = ca.monitor(self.__chid, self._event_callback, count, mask) except ca.error, msg: raise CaChannelException, msg
def getw(self, req_type=None, count=None): """Return a value or array of values from a channel. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. """ updated = [False] value = [0] def update_value(valstat): if valstat is None: return try: value[0] = valstat[0] finally: updated[0] = True if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 try: ca.get(self.__chid, update_value, req_type, count) except ca.error, msg: raise CaChannelException, msg
def add_masked_array_event(self, req_type, count, mask, callback, *user_args): """Specify a callback function to be executed whenever changes occur to a PV. Parameters: req_type: database request type. Defaults to be the native data type. count: number of data values to read, Defaults to be the native count. mask: logical or of ca.DBE_VALUE, ca.DBE_LOG, ca.DBE_ALARM. Defaults to be ca.DBE_VALUE|ca.DBE_ALARM. callback: function called when the get is completed. *user_args: user provided arguments that are passed to callback when it is invoked. >>> def eventCB(epicsArgs, userArgs): ... print 'pv_value', epicsArgs['pv_value'] ... print 'pv_status', epicsArgs['pv_status'], ca.alarmStatusString(epicsArgs['pv_status']) ... print 'pv_severity', epicsArgs['pv_severity'], ca.alarmSeverityString(epicsArgs['pv_severity']) >>> chan = CaChannel('cabo') >>> chan.searchw() >>> chan.putw(1) >>> chan.add_masked_array_event(ca.DBR_STS_ENUM, None, None, eventCB) >>> status = chan.pend_event(1) pv_value 1 pv_status 7 STATE pv_severity 1 MINOR >>> chan.clear_event() """ if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type()) if count is None: count = 0 if mask is None: mask = ca.DBE_VALUE|ca.DBE_ALARM if self.__evid is not None: self.clear_event() self.pend_io() self._callbacks['eventCB']=(callback, user_args) try: self.__evid = ca.monitor(self.__chid, self._event_callback, count, mask) except ca.error,msg: raise CaChannelException,msg