microscope-cockpit / cockpit

Cockpit is a microscope graphical user interface. It is a flexible and easy to extend platform aimed at life scientists using bespoke microscopes.
https://microscope-cockpit.org
GNU General Public License v3.0
35 stars 26 forks source link

Remote push of input digital line updates. #846

Closed iandobbie closed 1 year ago

iandobbie commented 1 year ago

I have changed the microscope digitalIO device to be a DataDevice to allow it to push changes in input lines to cockpit without requiring network polling. I have also updated the cockpit end to have the required functions and a simulated DIO device now has some functionality.

There are a few outstanding issues:

1) The cockpit listener module requires a call to listener.connect() to initiate the Pryo connection back to the cockpit server.

2) The microscope code requires and enable() call to start the fetch_loop which polls the hardware and then sends data back when needed.

Not sure if we should just put both the connect and the enable call in the initialize function or provide something in the GUI to do the connect and enable dance.

iandobbie commented 1 year ago

Other possible additions include logging the state changes and the timestamps that are pushed with them. We could also record them in the logviewer.

iandobbie commented 1 year ago

Getting there but still problems with the interrupt triggered callback.

1) Need to decide how to trigger the device.listener.connect() and device._proxy.enable() calls to start the remote fetch loop

2) Julio made some good points about things that need to be fixed. We will discus tomorrow and add proper issue(s) after descissions are mad.

3) The interrupt setup works fine at home on my home wifi but has a number of weird issues on the PC at work over a private wired local network.

4) Some circumstances give me the following error

Error in subscribed callable cockpit.devices.microscopeDevice.outputChanged(). Traceback (most recent call last): File “/Users/ID/src/cockpit/cockpit/events.py”, line 218, in publish func(*args, **kwargs) File “/Users/ID/src/cockpit/cockpit/devices/microscopeDevice.py”, line 776, in outputChanged self.lineToButton[line][1].SetValue(state) TypeError: ‘int’ object is not callable

I don't know quite what triggers this but it is something to do with changing digital line between input and output.

iandobbie commented 1 year ago

A few more issues: 1) Proper documentation 2) One code path gives us 0 and 1 for inputs but another gives True and False 3)Need a method to trigger the required connect and enable calls. I plan to copy the technique used for the cameras which would add an enable button with an indicator area to say if the connection is active or not.

iandobbie commented 1 year ago

I have a fully working implementation with the receive client getting pushed input line updates from the simulation and from the Raspberry Pi. The section in the main panel has a button which enables and triggers the connect() call to receive pushed input changes. It has the same symantics as the camera grey when not connected and green when connected.

Outstanding issues: 1) I am still working on updating the documentation. 2) Not sure about the error above, I need to do more testing 3) Still getting input as True and False or 1 and 0 depending on code path 4) Still not sure what to call the paths config parameter, but Julio is correct it isnt the best name. 5) not made any effort to add logging or log viewer support

iandobbie commented 1 year ago

Ok made some more progress:

1) Updated the documentation some more 3) Fixed the code so inputs are always 1/0 and never True/False

iandobbie commented 1 year ago

Added logging to log state changes at .debug level. Added valueLogViewer support with code to push an update before and after every state change to get sharp digital transitions. Uses local rather than remote time stamps. Not sure what is best for this.

Another remaining issue is properly supporting path selection and output line state under channel load and save.

iandobbie commented 1 year ago

Path selection is now saved and restored in channels. The one weirdness is that the button labels are not updated, so I need to fix that.

iandobbie commented 1 year ago

Button labels work as they are meant to from commit d9566e5f3aba07081151e4f1fd5e220f285dd602