LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Can I create the VIs, which work as command?

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.  















 

0 Kudos
Message 1 of 3
(917 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(873 Views)

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.

0 Kudos
Message 3 of 3
(817 Views)