diff --git a/src/pandablocks_ioc/ioc.py b/src/pandablocks_ioc/ioc.py index f65625a6..5bf47efb 100644 --- a/src/pandablocks_ioc/ioc.py +++ b/src/pandablocks_ioc/ioc.py @@ -309,6 +309,7 @@ class _RecordUpdater: Args: record_info: The RecordInfo structure for the record + record_prefix: The prefix of the record name client: The client used to send data to PandA all_values_dict: The dictionary containing the most recent value of all records as returned from GetChanges. This dict will be dynamically updated by other @@ -317,6 +318,7 @@ class _RecordUpdater: """ record_info: RecordInfo + record_prefix: str client: AsyncioClient all_values_dict: Dict[EpicsName, RecordValue] labels: Optional[List[str]] @@ -344,7 +346,8 @@ async def update(self, new_val: Any): # value is None - expected for action-write fields val = new_val - panda_field = device_and_record_to_panda_name(self.record_info.record.name) + record_name = self.record_info.record.name.removeprefix(self.record_prefix) + panda_field = device_and_record_to_panda_name(record_name) await self.client.send(Put(panda_field, val)) @@ -360,7 +363,9 @@ async def update(self, new_val: Any): ) try: if self.record_info.record: - record_name = self.record_info.record.name.split(":", maxsplit=1)[1] + record_name = self.record_info.record.name.removeprefix( + self.record_prefix + ":" + ) assert record_name in self.all_values_dict old_val = self.all_values_dict[record_name] @@ -408,7 +413,6 @@ class _TimeRecordUpdater(_RecordUpdater): of `time` do not have a `MIN` attribute.""" base_record: RecordWrapper - record_prefix: str is_type_time: bool async def update(self, new_val: Any): @@ -646,6 +650,7 @@ def _create_record_info( ): record_updater = _RecordUpdater( record_info, + self._record_prefix, self._client, self._all_values_dict, labels if labels else None, @@ -717,11 +722,11 @@ def _make_time( ) updater = _TimeRecordUpdater( record_dict[units_record_name], + self._record_prefix, self._client, self._all_values_dict, labels, time_record_info.record, - self._record_prefix, isinstance(field_info, TimeFieldInfo), ) @@ -1425,7 +1430,7 @@ def _make_action_write( ) updater = _WriteRecordUpdater( - record_info, self._client, self._all_values_dict, None + record_info, self._record_prefix, self._client, self._all_values_dict, None ) record_info.add_record(record_info.record) diff --git a/tests/fixtures/mocked_panda.py b/tests/fixtures/mocked_panda.py index 7c2b9c0c..990d08bd 100644 --- a/tests/fixtures/mocked_panda.py +++ b/tests/fixtures/mocked_panda.py @@ -88,11 +88,11 @@ def mocked_time_record_updater( yield ( _TimeRecordUpdater( mocked_record_info, + new_random_test_prefix, client, {}, ["TEST1", "TEST2", "TEST3"], base_record, - new_random_test_prefix, True, ), new_random_test_prefix, diff --git a/tests/test_ioc.py b/tests/test_ioc.py index e8a63230..977901d9 100644 --- a/tests/test_ioc.py +++ b/tests/test_ioc.py @@ -51,10 +51,11 @@ def record_updater() -> _RecordUpdater: client.send = AsyncMock() # type: ignore record_info = RecordInfo(float) mocked_record = MagicMock() - mocked_record.name = "PREFIX:ABC:DEF" + record_prefix = "PREFIX:ES" + mocked_record.name = record_prefix + ":ABC:DEF" record_info.add_record(mocked_record) - return _RecordUpdater(record_info, client, {}, None) + return _RecordUpdater(record_info, record_prefix, client, {}, None) @pytest.fixture