LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programmatically run a VI in a LabVIEW project?

I'd like to have a shortcut on a Desktop that will effectively do what takes me three steps to do manually:

 

1. Open a LabVIEW project.

2. Open a VI within that project.

3. Run that VI.

 

Is there a good way to automate those three, especially without setting that VI's "Run when opened" property?

0 Kudos
Message 1 of 16
(3,003 Views)

Do you need to open the project?

 

Launching a VI from the Command Line.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 16
(2,989 Views)

Have you consider building an executable for your application? If you have the Application Builder (included with a LabVIEW Professional or Developer Suite license or as an add-on) you can build your application into an executable. You can then create a shortcut on your desktop for that executable. I am not aware of an easy way to create a shortcut that would do what you ar easking.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 16
(2,985 Views)

I can build an executable and that works great, but my request is for development purposes. I must (1) first open the project before I open the VI or else my .NET assembly is not loaded correctly. Then I must then (2) open the VI and (3) run it.

 

0 Kudos
Message 4 of 16
(2,934 Views)

The VI server hierarchy should include all the necessary tools. There are methods for opening projects, VIs and FPs and a method for running a VI. You could write a VI which will do this. The main caveat is probably that the VI needs to be opened in the context of the project and for that you might need to enable VI Server on the project and call Open Application Reference to get the app refnum for the Open VI Reference function. You might also be able to use properties to get that reference, but I haven't checked.

 

I don't have LV open, so the names might be incorrect, but these are the relevant methods and properties. The first part is the class:

App: Project.Open.

Open VI Reference.

VI:FP.State.

VI:Run Instrument.


___________________
Try to take over the world!
0 Kudos
Message 5 of 16
(2,915 Views)

That sounds like it should work, thanks! I'll try it out....

0 Kudos
Message 6 of 16
(2,903 Views)

@bruce008 wrote:

I can build an executable and that works great, but my request is for development purposes. I must (1) first open the project before I open the VI or else my .NET assembly is not loaded correctly. Then I must then (2) open the VI and (3) run it.

 


Sorry, I misuderstood your reasons for wanting to do on why you wanted to run the VI.

 

It might be an interesting question for me to ponder, though.  What are your reasons for actually wanting to run it once you open the VI upon opening the project?  The main reason I would want to open a project would be to edit it.  Any runs would most likely be after edits and with the project already open.  The reason I am asking is because I'd like to learn why I might want to run a VI right after opening the project often enough that I would need some way to automate it.

 

Sorry, if I am hijacking the thread, but seems to be a prime opportunity for me to learn form someone else's experience.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 16
(2,896 Views)

@bruce008 wrote:

I can build an executable and that works great, but my request is for development purposes. I must (1) first open the project before I open the VI or else my .NET assembly is not loaded correctly. Then I must then (2) open the VI and (3) run it.

 


While this is not a complete solution I would like to point out that you include an unnessecary step (2)  The Right-click menu in the project explorer contains "Run".

Capture.PNG

Now lets get into some LabVIEW trivia:

Running a vi from the project explorer runs in the project context with the project application instance as seen here:

Capture1.PNG

Running the VI from a invoke node or an ACBR from a "Launch vi" on your desktop would run it in the LabVIEW context although all dependancies should load correctly.

 

Which brings us to the question of does the context matter to you for what you want to accomplish?


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 16
(2,883 Views)

billko,

 

The reason I want to run our VI right after I open it is that people are testing our source code as we're writing it at a rather rapid pace, and we don't want to have to build an executable each time. We have a really long build time and a really short development cycle time lately!

Message 9 of 16
(2,874 Views)

Jeff,

 

I'd like to be able to programmatically run or not, although your solution would work if I only wanted to run. I want the people who test my code to run it from the source (not the executable), in which case it would run, or I might want to edit that source, in which case it would not run.

0 Kudos
Message 10 of 16
(2,870 Views)