Commit b003a754 authored by Grant Costa's avatar Grant Costa
Browse files

Use set_dataset_sys where applicable

parent e58ad6fa
Pipeline #568303198 passed with stage
in 13 minutes and 6 seconds
......@@ -274,7 +274,8 @@ class TrapDcModule(DaxModule):
raise ValueError(f"Line Delay must be greater than {self._min_line_delay_mu}")
key = self.get_system_key(name)
if not self._dma_recorded(key, solution, line_delay):
if not self._dma_recorded(name, solution, line_delay):
with self.core_dma.record(key):
for t in solution:
self.set_line(t)
......@@ -303,25 +304,26 @@ class TrapDcModule(DaxModule):
@rpc
def _dma_recorded(self,
key: TStr,
name: TStr,
solution: TList(TTuple([TList(TInt32), TList(TInt32)])), # type: ignore[valid-type]
line_delay: TInt64) -> TBool:
shuttle_dict = self._process_shuttling_data(solution, line_delay)
try:
self.get_dma_handle(key)
self.get_dma_handle(self.get_system_key(name))
except KeyError:
# If handle does not exist then no recording in DMA, possible restart occurred
for k, v in shuttle_dict.items():
self.set_dataset(key + self._KEY_CONNECTOR + k, v, broadcast=True)
self.set_dataset_sys(name + self._KEY_CONNECTOR + k, v)
return False
try:
for k, v in shuttle_dict.items():
if not np.array_equal(v, self.get_dataset(key + self._KEY_CONNECTOR + k)): # type: ignore[attr-defined]
if not np.array_equal(v, # type: ignore[attr-defined]
self.get_dataset_sys(name + self._KEY_CONNECTOR + k)):
raise ValueError("Data has been changed")
return True
except (KeyError, ValueError):
for k, v in shuttle_dict.items():
self.set_dataset(key + self._KEY_CONNECTOR + k, v, broadcast=True)
self.set_dataset_sys(name + self._KEY_CONNECTOR + k, v)
return False
@host_only
......@@ -339,7 +341,7 @@ class TrapDcModule(DaxModule):
def erase_dma_recording(self, key: TStr) -> None:
self.core_dma.erase(key)
for k in [self._DATASET_VOLTAGES_KEY, self._DATASET_CHANNELS_KEY, self._DATASET_LINE_DELAY_KEY]:
self.set_dataset(key + self._KEY_CONNECTOR + k, np.array([]))
self.set_dataset(key + self._KEY_CONNECTOR + k, np.array([]), broadcast=True, persist=True)
@kernel
def get_dma_handle(self, key: TStr) -> TTuple([TInt32, TInt64, TInt32]): # type: ignore[valid-type]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment