Adding the ability for a user to Enable and Disable a Custom Device in the System Definition Editor allows the user to save time when troubleshooting large and complex system definition files. It can be extremely inefficient and painful to continually add and remove various Custom Devices.
How to "Enable/Disable" Custom Device Functionality
1. Updating the Custom Device Main Page GUIDs
2. Adding the “EnableDisable Main Page.vi” to the System Explorer library.
3. Updating the Custom Device XML Run Time Menu (RTM) to allow the user to enable and disable the Custom Device.
Updating Custom Device Main Page GUID
By default, the Template Custom Device generates a Main Page with a single GUID. To fully enable this functionality, two GUIDs are actually needed for the Main Page.
Within the “Custom Device Shared.lvlib:Constants.vi”:
1. Rename the “Custom Device” GUID to “Custom Device Enabled”.
a. You may have to update the rest of the code that references this GUID by the original name.
2. Create a new constant named “Custom Device Disabled."
3. Generate a new GUID for the “Custom Device Disabled” using the method of your choice.
a. I typically use an online GUID generator.
4. Save the new GUID value as the default value for the new constant.
Updating the System Explorer Library
LabVIEW VIs can be called from the System Definition Editor. This is done by adding action VIs which can contain all sorts of functionality such as adding new channel groups. These action VIs are then linked to an RTM item for the Custom Device. In this case we are going to create a VI to enable or disable the custom device.
Create a new VI called “EnableDisable Main Page.vi” in the Actions directory of the Custom Device System Explorer. This VI is responsible for switching between the Enabled and Disabled GUID for the selected Custom Device.
Add the following logic:
1. Custom Device API.lvlib:NI VeriStand - Get Item GUID.vi
2. Custom Device API.lvlib:NI VeriStand - Set Item GUID.vi
3. Custom Device API.lvlib:NI VeriStand - Update Custom Device Flag.vi
4. Simple Error Handler.vi
NOTE: Ensure that the Item Reference in is named “Node Ptr."
Updating Custom Device XML
Each Custom Device has an associated Run Time Menu (RTM). In this case, the Export Configuration was included by default. The following instructions will show how to create a new RTM item.
Updating Main Page RTM
Each RTM “Menu Item” has the following important properties:
1. GUID: This must be a unique GUID associated with this RTM Menu Item.
2. Type: Action in this case means that a VI will be called when this RTM Menu Item is selected.
3. Name: The text that appears for this RTM Menu Item.
4. Item2Launch: Information to select which VI to launch.
a. Type: “To Common Doc Dir” refers to the Public Documents folder where Custom Device code is stored (“C:\Users\Public\Documents\National Instruments\NI VeriStand 2020”).
b. Path: The path to the desired VI from the common directory specified in the Type property.
An example for Export Configuration is shown below:
We now need to add a new RTM Menu Item for the “EnableDisable Main Page.vi” that we just created.
1. Add new <MenuItem>
2. Add new <GUID>
a. For this menu item we will need to create a new GUID since there is nothing associated with it in our system explorer constants VI – the shared GUIDS are only for the top level pages
3. Add new <Type>
4. Add new <Name>
5. Add new <Item2Launch>
Optionally, we can also add a Separator RTM Menu Item to help organize the RTM.
Duplicate Custom Device Main Page Definition
As a part of setting up the Enable/Disable functionality, there must be two separate page definitions in the Custom Device XML to match the different GUIDs that were created earlier. The first step is to create a copy of the Main Page definition, then make the following changes:
- Update Page GUID to match “Custom Device Disable”.
- Update Glyph. (C:\ProgramData\National Instruments\NI VeriStand 2020\System Explorer\Glyphs)
- Change the action name from “Disable” to “Enable”.
NOTE: You may want to ensure any other RTM changes for the Custom Device are implemented first. After setting up this functionality, all other changes will now need to be made in both page definitions.
After the Custom Device System Explorer has been rebuilt, the RTM should have the ability to enable and disable individual instances of the custom device.
Check out these related blog posts:
How to Configure VeriStand Custom Device Upgrades By Version
How to Install the “NI VeriStand Custom Device Wizard”
Learn more about DMC's partnership with National Instruments.