OxfordIonTrapGroup / wand

Wavemeter Analysis aNd Display
Apache License 2.0
13 stars 13 forks source link

Missing OSA trigger causes acquisition to stop #54

Open dnadlinger opened 1 month ago

dnadlinger commented 1 month ago

When the OSA trigger is momentarily disconnected (presumably, it was Jake having a look at the OSA in the lab) and hence the NI DAQ call fails, the acquisition task crashes, leading to the clients stopping to update.

This is not currently reported to the user in any way (except for the server log output), so can be confusing, especially as reconnecting the signal again doesn't fix it without restarting the server.

ERROR<35>:asyncio:Task exception was never retrieved
future: <Task finished name='Task-7' coro=<WandServer.measurement_task() done, defined at c:\scratch\wand\wand\frontend\wand_server.py:292> exception=TypeError("unhashable type: 'dict'")>
Traceback (most recent call last):
  File "c:\scratch\wand\wand\drivers\ni_osa.py", line 112, in get_trace
    PyDAQmx.DAQmxReadAnalogF64(
  File "<string>", line 2, in function
  File "C:\Users\LabUser\Miniconda3\envs\artiq-env\lib\site-packages\PyDAQmx\DAQmxFunctions.py", line 62, in mafunction
    raise exception_class(errBuff.value.decode("utf-8"), f.__name__)
PyDAQmx.DAQmxFunctions.SamplesNotYetAvailableError: Some or all of the samples requested have not yet been acquired.

To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger,  make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.
Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos
Property: DAQmx_Read_Offset
Corresponding Value: 0

Task Name: osa_blue

Status Code: -200284
 in function DAQmxReadAnalogF64

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\scratch\wand\wand\frontend\wand_server.py", line 352, in measurement_task
    wlm_data, osa = (await asyncio.gather(freq_measurement,
  File "C:\Users\LabUser\Miniconda3\envs\artiq-env\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "c:\scratch\wand\wand\frontend\wand_server.py", line 424, in take_osa_measurement
    osa = {"trace": self.osas.get_trace(osa).tolist(),
  File "c:\scratch\wand\wand\drivers\ni_osa.py", line 123, in get_trace
    self.clear()
  File "c:\scratch\wand\wand\drivers\ni_osa.py", line 76, in clear
    task_handle = self.handles.get(osa)
TypeError: unhashable type: 'dict'
dnadlinger commented 1 month ago

Only the follow-on exception was fixed.