LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Python control of multiple VIs

Solved!
Go to solution

I am trying to use python to control a Labview application that has been compiled into an executable. I can access the VI through the following code snippet

 

import win32com.client

import os

 

#start the exe

exe_path = r'D:\PyAE with FPGA\BEPyAE.exe'

os.startfile(exe_path)

 

#Dispatch application

labview = win32com.client.Dispatch("BEPyAE.Application")

 

#get VI reference

VI = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\BE_PyAE_01.vi')

 

This works fine. However, another labview program is also compiled within this same executable, and this is opened immediately once the first executable is run. The application is called PyScanner, and the VI name is FPGA_PyScanner_01.vi. I cannot seem to access that VI. I have tried various permutations and combinations for obtaining the labview VI reference, but nothing seems to work. I have attached a screen grab of the project so you can see how things are structured. Is there a way to access FPGA_PyScanner_01.vi ?

0 Kudos
Message 1 of 4
(785 Views)

Hi Rama,

 


@RamaV wrote:

I have attached a screen grab of the project so you can see how things are structured. Is there a way to access FPGA_PyScanner_01.vi ?


I don't think you can access that VI: as it seems from your image it runs within the FPGA…

 


@RamaV wrote:

However, another labview program is also compiled within this same executable, and this is opened immediately once the first executable is run.


Usually there is only one "program" compiled into the executable. And usually a Windows executable opens a UI upon start of execution.

So I expect this "usual behaviour"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(750 Views)

Thanks Greg. I guess I didn't get the verbiage right, there are two VIs that are within the exe, and one of them launches, and on launching, immediately launches the second VI. It is this second VI I would like to control with python, is there a way I can do it? 

 

0 Kudos
Message 3 of 4
(705 Views)
Solution
Accepted by topic author RamaV

Oh wait, I found the solution. It seems it works if we use the absolute paths, not the ones in the labview project view. 

 

labview = win32com.client.Dispatch("BEPyAE.Application")
VI = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\BE_PyAE_01.vi')
VI_s = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\FPGA PyScanner\FPGA_PyScanner_01.vi')

 

This gives me the control I need. 

0 Kudos
Message 4 of 4
(696 Views)