03-06-2019 12:38 PM
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
03-06-2019 01:02 PM
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.
03-06-2019 02:47 PM
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 🙂
03-06-2019 05:11 PM
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.
03-06-2019 06:56 PM
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.
03-06-2019 07:13 PM
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.
03-07-2019 02:39 AM
Check Windows Task Manager is the .exe process runs.
/Y
03-07-2019 04:51 PM
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.
03-07-2019 06:04 PM
I can get a pretty comprehensive list of windows in LabVIEW if I install AutoITX and then use its ActiveX function WinList: