def _create_monitor(self, chan, name): """Creates a monitor for the PV's value. Args: chan (CaChannel): The channel object. name (string): The PV name. """ def _block_updated_callback(epics_args, user_args): # Update the current value... self.curr_lock.acquire() try: self.curr_values[user_args[0]] = (epics_args['pv_value'], epics_args['type']) except: # Don't care, it is all about releasing the lock print "Could not update value" pass finally: # Must release lock self.curr_lock.release() pass ftype = chan.field_type() if ca.dbr_type_is_ENUM(ftype) or ca.dbr_type_is_STRING(ftype): req_type = ca.DBR_STRING else: req_type = ca.dbf_type_to_DBR_STS(ftype) chan.add_masked_array_event( req_type, None, ca.DBE_VALUE | ca.DBE_ALARM, _block_updated_callback, name) chan.pend_event(PEND_EVENT_TIMEOUT)
def _get_type_as_string(self, ftype): if ftype is not None: if ca.dbr_type_is_ENUM(ftype) or ca.dbr_type_is_STRING(ftype): return "STRING" elif ca.dbr_type_is_CHAR(ftype): return "CHAR" else: return "NUMERIC" return "UNKNOWN"