09-15-2006 07:51 PM
09-15-2006 11:02 PM
09-17-2006 10:54 AM - edited 09-17-2006 10:54 AM
Message Edité par chilly charly le 09-17-2006 05:56 PM
09-17-2006 12:46 PM
Here and here are a couple of links you might want to check out. Haven't tried them myself, though.
Of course, that's execution and not conversion (something which you seemed to suggest as well). You can do conversion using VI scripting, but as mentioned, you will have to write it yourself and it's probably not worth it. Check out the LAVA forums for their scripting board.
09-18-2006 07:40 AM
09-18-2006 08:03 AM
09-18-2006 01:24 PM
A lot depends on the scope of what you're after. A full-up interpreter for a bona-fide programming language is not something I'd care to tackle. However, I've done a few different medium-sized projects that supported a very limited text-based scripting language which proved to be VERY useful in "handing off" the project for use by non-programmers.
First you pick the script-language instructions to support and define some syntax. Resist the temptation to get super clever with your syntax -- simpler is almost always better. I've found the "Find Token" string function to be very helpful to get the parsing started. I also will typically convert my text to all lowercase before any parsing is performed. Each individual script instruction can map to the LabVIEW vi capable of performing that instruction.
For example, suppose you're testing some digital camera imaging sensor. You have a controllable filter that can be set to allow purely Red, Green, or Blue light to pass through. Maybe also a White and Black position to allow or stop all light. You can also control your light intensity. Here are some possible script instructions to support:
"Filter <color>" - will cause filter to move into the specified position
"Intensity <0-100>" - sets an intensity level of the light source from 0 - 100% of capability
"Snap" - will cause a frame grabber to capture and store an image, with filename based on filter and intensity settings
"Wait <delay time>" - don't know how it fits here, but I always need to implement a pure delay in my tests ![]()
"User <text message>" - brings up a little dialog prompt requiring user intervention before proceeding to next step
Now you've given a user a little set of tinkertoy commands that they can build up however they wish. All this script parsing may seem like overkill on day 1 when they are merely cycling: Intenstity 10, Filter Red, Snap, Filter Green, Snap, Filter Blue, Snap, Intensity 20, ... But what about the day where the investigator says, "Hmmm, I wonder if the Green sensors are affected by overexposure to Red light, and how long does that effect last?" Well, they can go: Filter Red, Intensity 80, Wait 25, Filter Green, Snap, Filter Black, Intensity 0, Wait 25, Filter Red, Intensity 80, Wait 10, Filter Green, Snap, ...
Already, with a very few very simple script instructions, it's possible to poke and prod at some modestly complicated questions.
Nested Flow Control: this is more advanced, but not beyond reason. I modeled an interpreter after what I think I know about simple microcontrollers. Script execution used a "program counter" to indicate which instruction is to be executed next, and I used LabVIEW queues in stack mode (Last In - First Out) to store the program counter while handling flow-control instructions like subroutine call/return and loops. I also used a queue in stack mode to store my Loop iteration values. Stacks make it natural to support nested loops.
-Kevin P.
09-18-2006 05:29 PM
09-19-2006 03:40 AM
09-19-2006 05:18 AM - edited 09-19-2006 05:18 AM
Message Edited by Odd_Modem on 09-19-2006 06:25 AM