06-22-2021 01:11 AM
Hi,
I'm using QMH to manage an equipment (eg power supply) via serial port. The states are initialize, set voltage, set current, read voltage, read current, close. From other loops, I can enqueue to get this MHL to process the action. How do I read back the data from read voltage / read current? I want the caller to wait until the data is returned. There may also be situations where there is timeout. Is there a way to wrap this nicely?
Solved! Go to Solution.
06-22-2021 02:15 AM
Why do you want to have a separate loop to handle instrument operation? It seems you need a synchronous control of the instrument, maybe you can use a simple API that you can call whenever you need to communicate with the instrument. The caller will always wait until the method in the API is executed and if data is returned, the caller can easily get it. Unless the instrument is sending data continuously (and caller has to always listen for data) I don't think a separate loop (thread) is appropriate.
06-22-2021 03:45 AM
Hi Lucian,
In some cases, I can use idle state or one of the states to perform update query (eg update voltage / current to indicators). I can also perform self error recovery based on this. There could also be cases where the instrument needs to be 'ping' within an interval to keep it alive.
So far I have no issue getting it to work, by adding another queue to act as reply, just that I wonder if there's a better way to do this (especially when there are multiple cavities sharing the same power supply).
06-22-2021 06:18 AM
Include a queue reference in your messages to the QMH. Then QMH can then use that reference to pass data back. I tend to make API VIs that will create the return queue, send the message, wait for the response, and then destroy the return queue.
06-22-2021 06:34 AM
Hi Crossrulz,
Thanks for your suggestion.