DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

SUD-dialog should wait for Labview VI has finished

Diadem 10.1
Labview 7.1

A compiled Labview VI should start from a SUD-Dialog. Then, the Dialog should wait for VI has finished. I don't find a solution. There are 2 possible ways:

1. Run VI as parallel task:

Call ExtProgram(Deskdrv&"\Labview\TestVI.exe")
While (VI_is_running)
    pause(1)
Wend

How to write write function "VI_is_running"?

2. Run VI modal:
Example from help don' work.

Dim sgRunTimeVersionT : sgRunTimeVersionT = ""
LVRuntime.Init sgRunTimeVersionT
Dim objVI Set objVI = LVRuntime.LoadVI(AutoActPath & "TestVI.vi")
Call objVI.run(True)
'Clean up
Set objVI = Nothing
LVRuntime.DeInit

I get message "unspecified error occourred".
Who can help? I think, it's a very common problem.

0 Kudos
Message 1 of 7
(3,661 Views)
Hello Martin!
 
ExtProgram is not able to do it but you can use the Windows Shell Objetct to solve the task:
Option Explicit

Dim oWshShell
Dim oExec

Set oWshShell = CreateObject("WScript.Shell")
Set oExec = oWshShell.Exec( Deskdrv & "\Labview\TestVI.exe" )

Do While oExec.Status = 0
  Call Pause(1)
Loop

MsgBox "VI Finished!"
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 7
(3,650 Views)
Thank you for your answer.
Running program in Windows Schell works fine with a standalone exe like "notepad.exe". 
To start a compiled Labbview VI at this way don't work. The VI appear but it dos not start and hang up. Killing  task with taskmanager, the VI finished message appear. I think, the VI don't find the Labview runtime envirement when starting in this context.



0 Kudos
Message 3 of 7
(3,640 Views)
Hello Martin!
 
I had tested the script with one of our VI's and it worked fine in a LV 7.1 RT!
 
Perhaps there is a problem with the working directory for the VI. Please try the script with this line before the Exec call:
oWshShell.CurrentDirectory = Deskdrv & "\Labview\"
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 4 of 7
(3,635 Views)
Thank you, I 've solved the problem.
The point was't the call of the VI itself, but the usage of  pause() -function in wait loop. The executuon of pause seams to block correct executuon of VI.
Here is my solution:

Dim oWshShell
Dim oExec

Set oWshShell = CreateObject("WScript.Shell")
oWshShell.CurrentDirectory = Deskdrv & "Labview\"
Set oExec = oWshShell.Exec( "TestVI.exe" )
Do While oExec.Status = 0
    call MsgBoxDisp("VI is running",,,, 1)    'msgbox whith timeout of 1s
Loop
MsgBox "VI Finished!"

0 Kudos
Message 5 of 7
(3,630 Views)
Hello Martin!
 
Verry interesting and good that you found a solution! Why did it worked with our VI?
In older DIAdem versions Pause blocked the message loop, but this was changed some versions ago. To use MsgBoxDisp has also the advantage to workaround a 10.1 bug.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 6 of 7
(3,625 Views)
Hi bohm,
 
Note that if you have DIAdem 10.1 or later, there is a new object variable called "LVRuntime" with which you can efficiently and easily run LabVIEW code from anywhere in DIAdem.  DIAdem 10.1 also ships with an example ("Calculating the Bessel Function with a LabVIEW VI") which launches a SUDialog that calls a LabVIEW VI and waits for it to finish before proceeding with the rest of the VBScript code-- sounds very like what you're wanting to do.
 
Note also that DIAdem 10.1 installs the LabVIEW 8.20 runtime engine,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 7 of 7
(3,618 Views)