05-29-2014 03:54 PM
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?
05-29-2014 04:11 PM
Do you need to open the project?
05-29-2014 04:13 PM
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.
05-30-2014 07:00 AM
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.
05-30-2014 08:34 AM - edited 05-30-2014 08:35 AM
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.
05-30-2014 09:24 AM
That sounds like it should work, thanks! I'll try it out....
05-30-2014 09:44 AM
@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. 🙂
05-30-2014 10:26 AM
@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".
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:
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?
05-30-2014 10:38 AM
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!
05-30-2014 10:41 AM
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.