def test_alarms(request, prefix, sevr_target, sevr_value, context): pv = f'{prefix}C' run_example_ioc('caproto.ioc_examples.mocking_records', request=request, args=['--prefix', prefix], pv_to_check=pv) PV = get_pv(pv, context=context) get_pv(f'{pv}.{sevr_target}', context=context).put(sevr_value, wait=True) def get_severity(postfix): return get_pv(f'{pv}.{postfix}', context=context).get(as_string=False) checks = ( ('lower_ctrl_limit', 'lower_alarm_limit', AlarmStatus.LOLO, get_severity('LLSV')), ('lower_alarm_limit', 'lower_warning_limit', AlarmStatus.LOW, get_severity('LSV')), ('lower_warning_limit', 'upper_warning_limit', AlarmStatus.NO_ALARM, AlarmSeverity.NO_ALARM), ('upper_warning_limit', 'upper_alarm_limit', AlarmStatus.HIGH, get_severity('HSV')), ('upper_alarm_limit', 'upper_ctrl_limit', AlarmStatus.HIHI, get_severity('HHSV')), ) for minv, maxv, a_status, a_sevr in checks: ctrl_vars = PV.get_ctrlvars() v = (ctrl_vars[minv] + ctrl_vars[maxv]) / 2 PV.put(v, wait=True) ctrl_vars = PV.get_ctrlvars() assert ctrl_vars['status'] == a_status assert ctrl_vars['severity'] == a_sevr
def __init__(self, prefix, *, filter_group, groups, abs_data, config_data, eV, pmps_run, pmps_tdes, **kwargs): super().__init__(prefix, **kwargs) self.prefix = prefix self.filter_group = filter_group self.groups = groups self.config_data = config_data self.startup() self.eV = epics.get_pv(eV, auto_monitor=True) self.pmps_run = epics.get_pv(pmps_run, auto_monitor=True) self.pmps_tdes = epics.get_pv(pmps_tdes, auto_monitor=True)
def test_limit_fields_and_description(request, prefix, context): pv = f'{prefix}C' run_example_ioc('caproto.ioc_examples.mocking_records', request=request, args=['--prefix', prefix], pv_to_check=pv) PV = get_pv(pv, context=context) def check_fields(): for k, v in PV.get_ctrlvars().items(): if k in field_map: fv, = read(f'{pv}.{field_map[k]}').data assert v == fv check_fields() for v in field_map.values(): work_pv = f'{pv}.{v}' write(work_pv, 2 * read(work_pv).data) check_fields() def string_read(pv): return b''.join(read(pv, data_type=ChannelType.STRING).data) assert string_read(f'{pv}.DESC') == b'The C pvproperty' write(f'{pv}.DESC', 'a new description', notify=True) assert string_read(f'{pv}.DESC') == b'a new description'
def test_put_empty_list(context, ioc): pv = get_pv(ioc.pvs['waveform'], context=context) pv.wait_for_connection(timeout=10) assert pv.connected pv.put([], wait=True) ret = pv.get() assert list(ret) == []
def test_event_read_collision(request, prefix, async_lib): # this is testing that monitors do not get pushed into # the socket while a ReadResponse is being pushed in parts. conftest.run_example_ioc( 'caproto.ioc_examples.big_image_noisy_neighbor', request=request, args=['--prefix', prefix, '--async-lib', async_lib], pv_to_check=f'{prefix}t1') from caproto.threading.pyepics_compat import Context, get_pv with Context() as cntx: image = get_pv(pvname=f'{prefix}image', context=cntx) t1 = get_pv(pvname=f'{prefix}t1', context=cntx) t1.add_callback(lambda value, **kwargs: None) for _ in range(4): image.get(timeout=45) image.disconnect() t1.disconnect()
def __init__(self, channel, pv, protocol=None, parent=None): super(Connection, self).__init__(channel, pv, protocol, parent) self.app = QApplication.instance() self._value = None self._severity = None self._precision = None self._enum_strs = None self._unit = None self._upper_ctrl_limit = None self._lower_ctrl_limit = None self.pv = epics.get_pv(pv, connection_callback=self.send_connection_state, form='ctrl', auto_monitor=SubscriptionType.DBE_VALUE|SubscriptionType.DBE_ALARM|SubscriptionType.DBE_PROPERTY, access_callback=self.send_access_state) self.pv.add_callback(self.send_new_value, with_ctrlvars=True) self.add_listener(channel)
def test_limit_fields(request, prefix, context): pv = f'{prefix}C' run_example_ioc('caproto.ioc_examples.mocking_records', request=request, args=['--prefix', prefix], pv_to_check=pv) PV = get_pv(pv, context=context) def check_fields(): for k, v in PV.get_ctrlvars().items(): if k in field_map: fv, = read(f'{pv}.{field_map[k]}').data assert v == fv check_fields() for v in field_map.values(): work_pv = f'{pv}.{v}' write(work_pv, 2 * read(work_pv).data) check_fields()
def __init__(self, channel, pv, protocol=None, parent=None): super(Connection, self).__init__(channel, pv, protocol, parent) self.app = QApplication.instance() self._value = None self._severity = None self._precision = None self._enum_strs = None self._unit = None self._upper_ctrl_limit = None self._lower_ctrl_limit = None self.pv = epics.get_pv(pv, connection_callback=self.send_connection_state, form='ctrl', auto_monitor=SubscriptionType.DBE_VALUE | SubscriptionType.DBE_ALARM | SubscriptionType.DBE_PROPERTY, access_callback=self.send_access_state) self.pv.add_callback(self.send_new_value, with_ctrlvars=True) self.add_listener(channel)
def get_severity(postfix): return get_pv(f'{pv}.{postfix}', context=context).get(as_string=False)