LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically building a vi

Hi,
 
Is it possible to build a VI programatically from another VI.
 
For example, I have a enum with items Add, subtract and multiply. I will have have individual sub vi's for each of these functions.
Once I choose the function and press generate, a new vi should be created with the coressponding sub vi in it.
 
I think this is similar to express vi's where when we say generate code, labview code is generated.
 
Can you please help me in this regard.
 
Thanking You
Gopal
0 Kudos
Message 1 of 12
(5,264 Views)
Gopal,

currently, LV does not provide you with this functionality.
You are correct that similar mechanism are used for automatic codegeneration, but this is only used (meaning: implemented and tested) for these special cases.
I hope to have such functionality (esp. for creation/destruction of controls!) myself one day, but for now, we have to go the hardway ourselfs 😞

Norbert B.
NI Germany
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 12
(5,251 Views)
 
this may help
- James

Using LV 2012 on Windows 7 64 bit
Message 3 of 12
(5,249 Views)
Are you looking for a macro expansion?  you can check the LAVA site for scripting.  This is not supported by NI and is very difficult to use.  It is a good tool for internal code generation but not for commercial products.  You have to remember that code generation (macros) in text-based languages is simply a string parser and compiler call.  The code in labview has many more elements (wires icon locations ...) so scripting gets complex.  I have not played with the express vi toolkit but that might be an option for auto code generation.
 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 12
(5,243 Views)

Another thought, not sure if it'll help or not.

One thing I've done is to define my own "scripting language" where there are specific keyword textstrings that I can associate with specific sub-vi's I've made.  If I were to do it for functions like add, subtract, multiply, I'd also provide support for named variables.

Then a user can create a text script which my program can interpret and execute.  Functionally, it's *kind of* like building code on the fly.  Truly, it sequences operations on the fly, which may be close enough.

For your type of case, a script might look like:


Variable  S1

Variable P1

S1 = SUBTRACT(14, 10)

P1 = MULTIPLY(S1, 7)

etc.


(Sorry, I still haven't figured out how to control single-spaced lines vs. double-spaced lines in this forum editor.  I usually get double-spaced, but have occasionally gotten single-spaced and have no idea why.)

Will take a lot of careful string parsing and stuff required, but I hope it gives you a glimmer of hope that there are other ways to skin that cat...

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 12
(5,235 Views)

Dropping nodes on the diagram is easy. Wiring them up is another story.

The Express VI's the Vision toolkits, the State Diagram Editor, and the VI Analyzer all use scripting.

Here is the link to the scripting forum on LAVA.

http://forums.lavag.org/LabVIEW-VI-Scripting-f29.html

I am always interested in the "use case" case for scripting.

Why do you want to do this?

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 12
(5,218 Views)


@Kevin Price wrote:

Sorry, I still haven't figured out how to control single-spaced lines vs. double-spaced lines in this forum editor.  I usually get double-spaced, but have occasionally gotten single-spaced and have no idea why.



I agree that it's weird that sometimes the editor uses double-spaced and sometimes single-spaced, but at least there is a way to reliably get single spaced lines - use shift+enter. This is also useful for paragraphs inside indented lists.

___________________
Try to take over the world!
0 Kudos
Message 7 of 12
(5,195 Views)

Hi,

Thanks for the answer. I wanted to build an application which would help in writing test cases. For example, I have sub vi's for Add, sub and muliply. Instead of an user writing a test case flow in labview, I wanted to give him a GUI in which would enable him to write testcases using the labview modules. This would be easier for an user to write his own test case even if he doesn't know much about labview programming.

Regards
Gopal

0 Kudos
Message 8 of 12
(5,155 Views)
In most cases when you want to script a VI, the easiest approach is to start up with a template VI that is as close to the final VI as possible and then create a new VI from this template. After that make the required modifications to this VI using scripting. This tool from dataact helps somewhat the task as well.

Tomi
--
Tomi Maila
0 Kudos
Message 9 of 12
(5,145 Views)

Neat goal.  Trying to implement it as a GUI is well beyond what I've ever attempted.  But the text-based invented script language I referred to earlier was designed to accomplish the same thing.  Just a text language interface rather than a GUI.  But I succeeded in largely extracting myself from the need to provide continuous long-term programming support for all the sequencing variations they wanted to try.

My most recent implementation was based on the idea of a "plugin architecture".  Language instructions were implemented by vi's with the same name placed under a plugin folder.  (Example: "Multiply.vi").  All vi's had to adhere to a common wiring terminal interface and some other specific conventions I documented with a generic template.  Using this approach made the scripting language highly extensible, even after building an executable out of the main program. 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 10 of 12
(5,143 Views)