03-20-2012 06:51 PM
Hello,
I am writing LV code for a Keithley 2400 instrument. The user interface includes 4 options that can then be queued up - including apply a current, apply a voltage, monitor open-circuit potential, and loop to another spot in the queue. The way I am handling the user input currently is with a table. Users can enter parameters for each of the 4 options, the use buttons to add steps to the table (ie: my command queue). The program then reads each line out of the table and decides what to do. Since the commands are different (including different termination options, such as wait time, max voltage, min. current, etc), the way I handle it is for the table to group them by control variable, etc, such that one column might have very different values. For instance, the control variable might be 4 V or 350 mA. This basically makes the table unreadable, and the code for interpreting the table isn't exactly the cleanest...
The outer control loop continuously executes, and on each pass it checks to see if any buttons have been pressed and updates the table (or not) accordingly. I have attached the part I use as a sub-vi, written in LV 2010.
There is surely a better way to do this, but I haven't found it. Any suggestions would be most welcome.
Scott
03-21-2012 06:27 PM
Hi Smullin,
It might be a good idea to look into Event Structures which are controlled by user inputs from the front panel.
https://decibel.ni.com/content/docs/DOC-2729
03-21-2012 06:53 PM
What you need is a Producer Consumer architecture. Do a search in LV help for more details, also there is a producer consumer with event template you can use. I don't remember the exact path but it is something like new, vi from template, ..design framework...(I don't have LV on this machine).
The Producer loop contain an event structure, use it to detect the GUI events. Usually you queue an enum with the value of the operation to perform. You can bundle this enum value with a variant (that will be your queue data type: a cluster contaning an enum and a variant) to also pass different data types to the consumer loop.
In the consumer loop you unbundle the enum to a case structure to manage cases for the different enum values (don't forget to make your enum a type def) and you unbundle the variant data to pass as a parameter.
Ben64