11-22-2012 04:31 AM
Hi all,
I am currently re-thinking the implementation of a larger labview project which controls
an instrument via RT on a CRIO system.
Since the instrument is constantly improved and new features added to make it more and more
automated I come to the limits of the current design.
A quick description:
The instrument should be capable of taking different kinds of measurements either at
constant conditions or at conditions that continuously change.
Before an measurement, the instruments needs to be conditioned, which is a rather complicated
sequence of valves opened/closed, pumps started/stopped, temperature settings and so on.
I currently use commands stored in a text file and read into an array of command clusters (enum'ed command + string for parameters)
to be processed during conditioning.
Then the user can run another sequence to make a certain kind of measurement.
This works nicely but is not flexible enough. The conditioning and measurement sequences should be easily
editable without making changes to LV code.
This is one reason I did not yet code this as a state machine, but it is a logical next step to do so.
States would be idle, conditioning, measurement, re-conditioning ....
But how do I do this in a most flexible way?
In the sequences, I sometimes need to check for instrument parameters, and it would be elegant to
call sub-sequences. I already implemented a looping feature to repeat some commands
between two positions in the command array several times. But without the possibility to jump
out of the loop.
In short, if I continue this way I am about to write an interpreter for a simple scripting language .....
I know that possibly VeriStand has a lot of this functionality but I am bit hesitant to make
a big change like this and I am not sure if I can re-use the existing LV code to access and control
hardware using VeriStand.
Is there a good/elegant solution to what I intend to do with just LV and without re-inventing the wheel (script interpreter)?
Olaf
11-22-2012 04:45 AM
I should add, that the current implementation has already a producer/consumer queue.
My main concern is that I want more functionality in my "scripts", functionality that
one normally has in script or programming languages.
e.g. calling other "sub"-sequences which return to the previous position, so I need to
have a flexible implementation of a stack to store positons....
I have not yet looked into mathscripts. Is this a way to go? Can I "load" code from a file
into a mathscript during runtime?
Olaf
11-26-2012 07:55 AM
The most flexible way to implement this would be to use a command pattern and LabVIEW classes. Using this approach, you core state machine would probably never change and you dynamically add or remove steps as needed. Take some time to learn how this works by writing a couple of simple examples, then dive in. It will be easier than you may think.