Replies: 3 comments 1 reply
-
|
Actually, PyLECO already contains the infrastructure for that PUB SUB communication in its "data protocol" (vs. the "control protocol" which exchanges messages back and forth). I like the decoupling, which was the goal of LECO, as my own measurement software got hickups with concurrent read/writes, leading me to write LECO. |
Beta Was this translation helpful? Give feedback.
-
|
@BenediktBurger: To your experience, what's the overhead of going through leco compared to communicating directly as it is now? This proposal also reminds me of YAQ which I don't like because you always have your instruments hanging around and no direct control. It goes in the direction of other framework like tango, bluesky and we have to be carefull of what/who we target with pymodaq. Can we do a visio conf on the subject to exchange our views? @Ashwolaa do you want to chair it? |
Beta Was this translation helpful? Give feedback.
-
Indeed, this is already very well versed and I started using it to get the data.
I was not aware of these softwares, the tango looks neat ^^ https://evento.renater.fr/survey/leco-implementation-vmhcsw4v |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
LECO and ZMQ: decoupling hardware from DAQ modules
The LECO protocol makes managing communication between the different entities in an acquisition software very interesting. The Actor/Director/Coordinator model, once understood, is particularly powerful, and some extensions of these concepts could be very fruitful.
I have been thinking about improving the communication flow between the different components inside and outside PyMoDAQ. A powerful tool at the heart of PyLECO is ZMQ. I have started using it in my own software development and it allows easy asynchronous
data distribution over a network.
A promising direction is to entirely decouple the hardware layer from the DAQ modules and instead fully associate it with the Actor. The DAQs would be limited to the role of directors that query or change data. One could say that this is already the case — a DAQ has to implement specific methods to get information from the hardware. However, the coupling between the DAQ and the hardware is currently much tighter than it needs to be.
Let me first introduce the notion of Observable and Variable.
Observable vs Variable
Every quantity a hardware instrument exposes falls into one of two categories:
DAQ_Viewerdirector is built on observables.DAQ_Movedirector requires at least one variable. EveryVariableis also anObservable, as we usually need to read it back — for example, following a stage moving to verify it reached its target position.Unified hardware interface
At the hardware level, all instrument interaction can thus be reduced to two operations:
query_data→ get anObservablechange_to→ change aVariableThe point of this semantic distinction is that by exposing
read/writemethods targeting specific elements of the hardware, it becomes straightforward to derive a DAQ module from an instrument driver. A reading method translates to aDAQ_Viewerdirector asking the Actor to update a value, while a writing method gives rise to aDAQ_Movedirector.I believe this is also a bit closer to the original approach of PyLECO in which the Actor and the hardware are linked within one another.
Three key differences from the current approach
1. No master/slave conflicts
In the current architecture, the master/slave distinction can lead to read/write conflicts when multiple modules share access to hardware. In the proposed model there is exactly one Actor per hardware instrument, and it is the only entity that ever touches the
hardware directly. DAQ modules connect to the Actor through the LECO protocol and send RPC commands to make it act as they wish. Conflicts between concurrent hardware accesses disappear by construction.
2. Data channel via ZMQ Proxy
Instead of routing measurement data back and forth between the Actor and the Director through the Coordinator — which is designed for control flow, not bulk data — a dedicated Data Proxy (ZMQ XPUB/XSUB) dispatches published data from the Actor to any number of
subscribers over the network. This separates two fundamentally different communication patterns:
This separation also enables a new concept: the Spectator (see below).
3. Modularity: one Actor, many Directors simultaneously
Because the Actor is fully decoupled from any specific DAQ module, multiple directors can connect to the same Actor at the same time. A scan director, a live viewer, and a data logger can all subscribe to the same camera Actor simultaneously, each receiving every published frame independently. No special coordination between them is required —the ZMQ PUB/SUB pattern handles fan-out natively.
This also means that an Actor can be shared across different PyMoDAQ instances running on different machines, or even across different software frameworks that speak LECO similarly to what is currently implemented with the DAQ_move and DAQ_viewer
Conceptual model
The Spectator concept
A Spectator is a lightweight subscriber that connects only to the Data Proxy. Unlike a Director, it has no RPC channel to the Actor and cannot issue commands. It simply subscribes to one or more Actor topics and receives every published frame.
Spectators are useful for:
Because the ZMQ PUB/SUB pattern is purely additive — adding a new subscriber never affects the publisher or existing subscribers — Spectators are completely transparent to both the Actor and the Directors.
@seb5g @malik-irain @rgeneaux @quantumm @BenediktBurger
Beta Was this translation helpful? Give feedback.
All reactions