Launching and Configuring LabVIEW VIs from DIAdem

DIAdem 2018 Help


Edition Date: June 2018
Part Number: 370858P-01
View Product Info

DOWNLOAD (Windows Only)


DIAdem 2017 Help
DIAdem 2018 Help
DIAdem 2019 Help
DIAdem 2020 Help
DIAdem 2020 SP1 Help

Use the script interface LVRuntime to open LabVIEW VIs in DIAdem and to request information and values from input terminals and output terminals. In order to execute the procedure, LabVIEW Runtime must be installed on your computer.
To start and configure a VI using a script, complete the following steps:

  1. Start LabVIEW and create a VI called Test. Save the VI in any folder. Refer to the LabVIEW Help for information on creating a VI.

  2. Switch to DIAdem.

  3. Select DIAdem SCRIPT.

  4. Select File»New»VBS Script to create a new script.

  5. Enter or copy the following text into the script editor:

    ' -------------------------------------------
    ' Initialize the LVRuntime
    Dim sgRunTimeVersionT : sgRunTimeVersionT = ""
    LVRuntime.Init sgRunTimeVersionT
    
    ' -------------------------------------------
    ' Load "Test.VI"
    Dim objVI
    Set objVI = LVRuntime.LoadVI(AutoActPath & "Test") 
    
    ' -------------------------------------------
    ' Call the VI
    Call objVI.Run(true)
    ' -------------------------------------------
    ' Clean up
    Set objVI = Nothing
    LVRuntime.DeInit
  6. Select File»Save As to save the script. Select the folder that you saved the VI in, and select MyLVRuntime.vbs as the filename.

  7. Click Save.

  8. Select Script»Run VBS Script to start the script. The script connects LabVIEW, starts the VI, and displays the associated front panel. When the VI is finished, the script disconnects LabVIEW.

  9. Switch to LabVIEW.

  10. Add to the VI a String type control called Input and a String type indicator called Output.

  11. Connect the control to the indicator or connect the two elements in such a way that LabVIEW outputs values at the indicator when LabVIEW launches the VI.

  12. Connect both the control and the indicator to an external terminal.

  13. Save your VI.

  14. Switch to DIAdem.

  15. Select DIAdem SCRIPT.

  16. In the script editor, make the following additions to the script:

    Dim sgRunTimeVersionT : sgRunTimeVersionT = ""
    LVRuntime.Init sgRunTimeVersionT
    ' -------------------------------------------
    ' Load "Test.VI"
    Dim objVI
    Set objVI = LVRuntime.LoadVi(AutoActPath & "Test")
    Call objVI.SetControlValue("Input", "InputValue")
    Call objVI.Run(true)
    ' Clean up
    Call MsgBoxdisp (objVI.GetControlVariant("Output"))
    Set objVI = Nothing
    LVRuntime.DeInit
  17. Select Script»Run VBS Script to start the script. The script connects LabVIEW and sets the value of the Input. The script then starts the VI. When the VI is finished, the script requests the value of the Output terminal and displays the value.

Note  For more information about working with the LVRuntime and the associated objects, methods, and properties refer to the help page LVRuntime Objects: Overview.
Note  If you create VIs with LabVIEW and you want these VIs to run only with the LabVIEW Runtime Engine, you must create a source distribution of the VIs. Refer to the LabVIEW help under the search term Source Distribution for further information.

If LabVIEW cannot interpret relative path specifications in a normal installation, because, for example, you are using Express VIs, you must edit the DIAdem.ini file in the DIAdem program folder. If the file does not exist, you must create this file. Insert the following entry into the DIAdem.ini file:

[LVRT]
libdir="LabVIEW_ProgramPath"

The LabVIEW_ProgramPath specifies the LabVIEW program path, for example, C:\Program Files\National Instruments\LabVIEW 8.2.

After you make this modification, you must restart DIAdem.

Examples

Calculating the Bessel Function with a LabVIEW VI

WAS THIS ARTICLE HELPFUL?

Not Helpful