InstrumentStudio

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Hosted Application Example

Background
You can use InstrumentStudio to host applications written in LabVIEW or C#. These applications run alongside the InstrumentStudio panels used to configure PXI instruments. Support for hosted applications is experimental in InstrumentStudio 2019.


This attached example is provided as-is. It is not a fully-vetted template. It demonstrates the core functionality currently available in InstrumentStudio 2019 for hosted LabVIEW applications.

 

Requirements

  • InstrumentStudio 19.0.2
  • LabVIEW 2016 or newer, 64-bit versions only (example is saved in LabVIEW 2016)

How it works
InstrumentStudio will look for LV DLLs in the National Instruments\InstrumentStudio 2019\Addons\LabVIEW Plugins in the location of the public documents (e.g., C:\Public\Documents). Using the template provided, you can create your own VI that can be hosted in InstrumentStudio.

 

The DLL must contain certain entry points. The build specification in this template is already set up to map the required VIs in the "Reserved" folder to the correct entry points (including Close.vi, GetConfiguration.vi, GetInformation.vi, and Launch.vi). Do not attempt to edit these VIs or remove them from the build spec.

 

You must edit Get Hostable VIs.vi to list the VI(s) you want to expose. On the block diagram, change the cluster array constant to match the name(s) of the top-level VI(s) that will be hostable in InstrumentStudio as well as what presentation types each supports. The project has one hostable VIs listed: Basic SMU.vi. Hostable VIs should be added to your build spec as well under the Always Included list. In order for your VIs to run properly, we recommend going through the checklist below.

 

Hostable VI examples

  • template.vi - This VI can be used as starting point for you to create a hostable VI. The main requirement is that you must have front panel control for two typedefs: InstrumentStudio initialization parameters.ctl  and StopAllOutputsEventInfo.ctl (provided in the Reserved folder) and that their labels must be "InstrumentStudio initialization parameters" and "StopAllOutputs Event Info" respectively.
    The cluster contains the InstrumentStudio event, the presentation type (large or small), and a data value reference for your configuration. You can use the presentation type to determine how your UI should render, either in a small panel or a large panel.
    The data value reference is for a cluster of two strings. The two strings represent your VI's edit-time configuration and run-time configuration respectively. Use the in-place data structure to query or set the values in the DVR. InstrumentStudio will periodically query this to determine if your VI's state has changed. The strings are saved with the .sfp file in InstrumentStudio. Upon opening the .sfp file, InstrumentStudio will pass the saved configurations in the DVR so your VI can deserialize and set your VI's initial state. 
  • Basic SMU.vi - A simple example using the available plugin features using a simulation of a third-party SMU. It demonstrates how to save and restore the plugin configuration and how to respond to events from InstrumentStudio, such as Close and Stop all outputs.

Hosted VI Requirements and Details

 

  1. Make the VI reentrant. This allows the VI to be run in multiple tabs.
  2. Do not show any modal dialog upon launch/shutdown of your VI. It is OK to display modal dialogs as a response to user action (like a button being clicked) but not upon startup/shutdown.
  3. Set your VI's window title in VI Properties. This is what will be used in InstrumentStudio when you select the VI.
  4. Upon closing a document containing a hosted LV plugin, InstrumentStudio will send an event to your VI (see the examples in the project). A "shutdown" string will be sent to your VI's event structure that you can handle. Whatever code that executes should complete before a 3 second timeout, otherwise InstrumentStudio will abort and close your VI.
  5. For saving state in the configuration DVR, we recommend using LabVIEW's Flatten to Json or Flatten to XML. Flatten to String will not work because the string can contain null characters which will not persist properly.

Using your plugin in InstrumentStudio
After building your DLL and copying it to the <Public Documents>\National Instruments\InstrumentStudio 2019\Addons\LabVIEW Plugins directory, launch InstrumentStudio. Enable the Hosted Applications experimental feature from File>>Preferences>>Hosted applications. On the Home tab, click the Manual Layout button. In the Edit Layout dialog, scroll down the listbox on the left until you see Other devices. There should be a LabVIEW plug-in option for each of your hostable VIs. Choose to create one of your LabVIEW plug-in in a large or small panel. Click OK to close the Edit Layout dialog and create a new document that includes your LabVIEW plugin.

 

Limitations
InstrumentStudio and LabVIEW use different UI frameworks, which leads to some "airspace" issues when hosting the LabVIEW front panel UI within InstrumentStudio. The incompatibility of UI frameworks is a known issue documented by Microsoft.​ Airspace issues include unexpected visual behavior when resizing the window, using scrollbars, and for some pop-overs like the InstrumentStudio Welcome Mat and Project Files pane. Additionally, when LabVIEW panels have command focus, InstrumentStudio won’t receive or process keyboard commands like Ctrl+S.

Message 1 of 4
(3,791 Views)

Known issue: If you're using a computer with a touch screen, when you try to create an InstrumentStudio document with the hosted application you may get a crash with DAbort 0xB78CFE1B in window.cpp. This is the result of a known LabVIEW issue that has been fixed in LabVIEW 2019 SP1.

Message 2 of 4
(3,734 Views)

Hello, thank you for sharing the excellent content. I'm curious to know if the latest version of InstrumentStudio still supports plugins in the same manner as described in your article. Currently, both my customer and I are facing challenges in replacing our existing test systems with a combination of RFmx, TestStand, and LabVIEW. The DUT (Device Under Test) we're working with requires TCP/VISA controls, and we've developed an application to address that requirement.

Our next goal is to efficiently control both RF measurements and the DUT. If we can seamlessly operate both RFmx and the DUT within the user-friendly environment of InstrumentStudio, it would be a significant achievement. This ambitious endeavor aligns with my customer's objective to further standardize the NI eco-system within his company.

0 Kudos
Message 3 of 4
(829 Views)

Hello UMASO,

 

I am the current product manager for InstrumentStudio and can address this for you. In the simplest terms, InstrumentStudio plugins still exist and NI has produced a number of solutions built on top of the technology. You'll notice that outside of NI, information regarding plugins is pretty sparse and that has also been intentional. Access to the latest and greatest source and documentation has been funnelled into a request-type, need-to-know basis. I would love to work with you (and anyone else reading) to better understand what you're wanting to accomplish and how we can help support your goals.

 

Can you send me a direct message so that we can start working together on your success?

 

Thanks,

RyanF

0 Kudos
Message 4 of 4
(506 Views)