10-05-2020 05:46 PM
Hello,
I am developing VIs for our electronics device. Which is basically measure the voltage and current from battery. Customer want to develop the vi for device.
I create TCP wrapper on top of our code and it is in separate application. it is running in background of Labview vi.
I create the TCP client in Labview, and which is read the frame from Socket and decode data, and place the data in "Readable Queue". I do have another "Transmit Queue" which is help me to send the data on TCP port. (Transmit Queue is dequeue the element, and create the transmit frame)
I would like to create few Sub vi which will help to customer create the application.
For example:
1) ConnectDeviceAt.vi
Input of ConnectDeviceAt.vi should be:
"Readable Queue"
"Transmit Queue"
Comport (type: String)
Output of ConnectDeviceAt.vi should be:
DeviceName:
NumberOf channel:
2) getCustomExperiment.vi
Input of getCustomExperiment.vi should be:
"Readable Queue"
"Transmit Queue"
Output of getCustomExperiment.vi should be:
List of custom experiment.(type: stringList )
I know how create the Subvi and decode the data in subVi.
Here my main Question.
While dequeue element from "Readable Queue". How can I know in which VI I need to dequeue queue elements.
I need to connect ConnectDeviceAt.vi and getCustomExperiment.vi in series, and Both vi has Dequeue element present.
I want to something like
getCustomExperiment.vi send command through TCP, and correspond response should dequeue in getCustomExperiment.vi Not in ConnectDeviceAt.vi
Any functionality present in LabVIEW which is help to solve this issue?
In general I am try to create vi Something like API in other programming language.
10-05-2020 07:43 PM
My main advice is to turn this into a class. The private data of the class should contain the queues you are using. This way, it is just 1 wire the user needs to use and you don't have to worry about the user messing around with the queues. You will want your Connect Device VI to create the queues and launch your separate thread.
Now as far as your question for when you need to dequeue: you dequeue when you expect data to come back. It is usually that simple.
10-06-2020 07:58 AM
It's tempting to call this an OO command pattern as you mention command in the title...
I think in your situation it's simply a functor. You provide a base class, customer provides an override for the execute method.
As you mention API, your customer might want to deliver his code as a PPL, that you can load... The details depend a lot on what you want, like if this should all come together during development, or in the executable.
Another option is VI Server. That is more pragmatic, but the flip side is it will become messy. It might seem easier at first, but could be harder in the long run.