LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the Execution State of a VI within a .lvproj from another vi

Hi all,

 

I've been working on this project and I've been stuck here wondering what detail I missed. I hope I can coherently articulate my issue and garner some feedback on the matter. 

 

What I have is a Main VI which is in a project (.lvproj). I have another separate utility Vi (not included in the project, but it's its own standalone vi). What I'm trying to do is to determine from the standalone VI if the Main.VI from the project is running. From this I know I check the execution state property. I'm attaching my code snippet. 

 

The problem that I have is that when I run my standalone vi, it works fine. However, when I create an executable for this vi (make a build .exe), then when I run from the application it doesn't work. Anything I'm missing here? Somewhere on the build configuration perhaps?

 

thanks in advanced

0 Kudos
Message 1 of 9
(3,336 Views)

Each executable has its own memory and application space.  So your simple monitoring VI cannot just simply get the status from the VI.  Also, it is not in a project.

 

Why are you trying to get the state of a VI running in an executable?  Perhaps there is a better way to get what you are actually trying to accomplish.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,324 Views)

Hi and thanks for the reply. 

 

the main vi opens references to resources which are not ever released/closed because of the nature of the application (specifically it's a power supply -PXI-4110). The power supply's reference is not closed until we exit the application. However, the other vi (which made into executable) utilizes the same power supply. if I try to use this power supply while the Main.VI is running, then this would produce an error because the power supply has been initialized through the main application and thus produces an error if initialized again. 

 

I thought that if there was a way to just determine if the Main Vi was running, then on my executable utility, it would catch that and therefore don't have to initialize and configure the power supply and just capture measurements and then close utility. If the utility would see that Main Vi is not running, then it would initialize the power supply, do the task, and then close the reference. 

 

Previous efforts I've tried to see if I can get the reference, but I was unsuccessful. Figured this would be a more straightforward and simpler approach.

 

thank you again for the response and if you have a much better approach from your experience, I'd appreciate the knowledge share 🙂

 

0 Kudos
Message 3 of 9
(3,304 Views)

You could have the EXE you want to check the status of open a TCP port when it runs, which should then close when it finishes running.  Your other application then just checks to see if that TCP port can be connected to or not to see if it's up.

 

If the program you want to run opens a window while running and then closes itself after, you can also just use some standard Windows functions to see what windows are open on the screen.  There's some functions in User32.dll (legacy) plus some newer ones using .NET you could use to accomplish this.

0 Kudos
Message 4 of 9
(3,289 Views)

Multiple programs utilizing a single resource, such as your power supply, rarely works.  What I would do is make an application that controls access to the power supply.  Other applications communicate with this app through TCP connections.  A message could be to ask for the usage status and just request the measurements.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 9
(3,278 Views)

If you cannot find a way to save the shared state on the disk, memory or IO, then you could try a networked shared variable.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 6 of 9
(3,277 Views)

Check Windows Task Manager is the .exe process runs.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 9
(3,267 Views)

hi all 

thanks for all the responses. You guys provided some good ideas that I didn't thought of. I was hoping to gain control of the instrument via the application but I guess retrieving references from an executable from another Vi is not as simple as doing it the other way around where the executable obtains references from a Vi. 

 

I was meddling with the task manager but I got all the processes but not the actual window applications that are open. Unless Labview is completely closed it will keep in memory. I'm using the systemdiagnostic.GetProcess.MainWindowTitle. There's got to be a function that just lists what windows are open on screen. I'll keep looking. thanks for the suggestion. 

0 Kudos
Message 8 of 9
(3,244 Views)

I can get a pretty comprehensive list of windows in LabVIEW if I install AutoITX  and then use its ActiveX function WinList:

 

List all windows.PNG

0 Kudos
Message 9 of 9
(3,237 Views)