You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Ensure the title can be understood without the parent item's context, e.g. "csharp instrumentstudio plugin example" rather than just "plugin example" -->
8
+
<!-- Ensure the title can be understood without the parent item's context, e.g. "csharp instrumentstudio plug-in example" rather than just "plug-in example" -->
The instrumentstudio-plugins repository contains documentation and examples for writing InstrumentStudio plugins.
4
-
InstrumentStudio plugins can be written in C# and in LabVIEW.
3
+
The instrumentstudio-plugins repository contains documentation and examples for
4
+
writing plug-ins for NI [InstrumentStudio](https://www.ni.com/en/shop/electronic-test-instrumentation/application-software-for-electronic-test-and-instrumentation-category/instrumentstudio.html).
5
+
InstrumentStudio plug-ins can be written in C#
6
+
and in LabVIEW.
7
+
8
+
**NOTE** : InstrumentStudio plug-ins require the 'InstrumentStudio Professional'
Copy file name to clipboardexpand all lines: csharp/docs/Creating A CSharp Plugin.md
+27-27
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
-
# Creating a C# Plugin for InstrumentStudio
1
+
# Creating a C# Plug-In for InstrumentStudio
2
2
3
-
This tutorial walks you through creating a simple C# plugin for InstrumentStudio from scratch. This plugin
4
-
has minimal functionality and is intended just to get you to a point where your plugin shows up and can
5
-
be put into a panel in InstrumentStudio. The plugin has no real functionality - the intent is to get you to
6
-
the point where you have a plugin that is building and running correctly as quickly as possible.
3
+
This tutorial walks you through creating a simple C# plug-in for InstrumentStudio from scratch. This plug-in
4
+
has minimal functionality and is intended just to get you to a point where your plug-in shows up and can
5
+
be put into a panel in InstrumentStudio. The plug-in has no real functionality - the intent is to get you to
6
+
the point where you have a plug-in that is building and running correctly as quickly as possible.
7
7
8
8
## Overview of the steps
9
9
@@ -15,8 +15,8 @@ the point where you have a plugin that is building and running correctly as quic
15
15
-[Implement the `PanelPlugin` Class](#implement-the-panelplugin-class)
16
16
-[Implement the `IPanelPluginFactory` Class](#implement-the-ipanelpluginfactory-class)
17
17
-[Optional: Delete the Class1.cs file](#optional-delete-the-class1cs-file)
18
-
-[Install the plugin](#install-the-plugin-assembly-into-instrumentstudio)
19
-
-[Test the plugin](#test-the-plugin)
18
+
-[Install the plug-in](#install-the-plug-in-assembly-into-instrumentstudio)
19
+
-[Test the plug-in](#test-the-plug-in)
20
20
21
21
## Install InstrumentStudio
22
22
@@ -26,25 +26,25 @@ InstrumentStudio with at least version 22.3.0.383-0+d383.
26
26
## Get the .NET SDK
27
27
28
28
You will need the .NET SDK and its command-line features in order to create the C# project
29
-
for the plugin. Install the latest Microsoft .NET 6.0 SDK from [this location](https://dotnet.microsoft.com/en-us/download).
29
+
for the plug-in. Install the latest Microsoft .NET 6.0 SDK from [this location](https://dotnet.microsoft.com/en-us/download).
30
30
31
31
## Create a C# Solution and Project
32
32
33
-
### Create a folder and a solution to contain your plugin
33
+
### Create a Folder and a Solution to contain your Plug-In
34
34
35
35
For this tutorial, we'll use **c:\myplugin** for this folder. From the command-line in **c:\myplugin**, run this command to create a solution
36
36
37
37
`dotnet new sln`
38
38
39
-
### Create a WPF library for the plugin
39
+
### Create a WPF Library for the Plug-In
40
40
41
41
`dotnet new wpflib`
42
42
43
-
### Add the plugin library to the solution
43
+
### Add the Plug-In Library to the Solution
44
44
45
45
`dotnet sln add .\myplugin.csproj`
46
46
47
-
Run `dotnet build` to ensure the plugin project is buildable at this point.
47
+
Run `dotnet build` to ensure the plug-in project is buildable at this point.
48
48
49
49
## Add Project References
50
50
@@ -79,7 +79,7 @@ Your .csproj file should look something like this:
79
79
</Project>
80
80
```
81
81
82
-
Run `dotnet build` to ensure the plugin project is buildable at this point.
82
+
Run `dotnet build` to ensure the plug-in project is buildable at this point.
83
83
84
84
## Add the ParticipatesInComposition Attribute
85
85
@@ -94,14 +94,14 @@ using NationalInstruments.Composition;
94
94
[assembly: ParticipatesInComposition]
95
95
```
96
96
97
-
Run `dotnet build` to ensure the plugin project is buildable at this point.
97
+
Run `dotnet build` to ensure the plug-in project is buildable at this point.
98
98
99
99
## Implement the `PanelPlugin` Class
100
100
101
101
Create a new class in the project that inherits from `PanelPlugin`. This is the central class for
102
-
the plugin and an instance of it will be returned from the `IPanelPluginFactory` class in the next step.
103
-
The `PanelContent` property represents the main UI for your plugin. It can be any WPF [`FrameworkElement`](https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-6.0) - in this example,
104
-
we are simply returning a `TextBlock` as the minimal user interface element of our plugin.
102
+
the plug-in and an instance of it will be returned from the `IPanelPluginFactory` class in the next step.
103
+
The `PanelContent` property represents the main UI for your plug-in. It can be any WPF [`FrameworkElement`](https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-6.0) - in this example,
104
+
we are simply returning a `TextBlock` as the minimal user interface element of our plug-in.
Run `dotnet build` to ensure the plugin project is buildable at this point.
161
+
Run `dotnet build` to ensure the plug-in project is buildable at this point.
162
162
163
163
## Optional: Delete the Class1.cs file
164
164
165
165
When the library was created, .NET put an initial Class1.cs file into the project directory.
166
166
This file is unneeded and can be deleted if you wish.
167
167
168
-
## Install the plugin assembly into InstrumentStudio
168
+
## Install the Plug-In assembly into InstrumentStudio
169
169
170
170
Copy the myplugin.dll from the built assembly directory (bin\Debug\net6.0-windows) to the Addons folder of InstrumentStudio
171
171
(C:\Program Files\National Instruments\InstrumentStudio\Addons). It can be anywhere under this directory including a sub-folder.
172
172
173
-
## Test the Plugin
173
+
## Test the Plug-In
174
174
175
-
Run InstrumentStudio. NOTE: Relaunch InstrumentStudio if it is already running to detect new plugins. From the lobby screen in InstrumentStudio, click the 'Manual Layout' button. You will see the 'Edit Layout' dialog with your new plugin listed there:
175
+
Run InstrumentStudio. NOTE: Relaunch InstrumentStudio if it is already running to detect new plugins. From the lobby screen in InstrumentStudio, click the 'Manual Layout' button. You will see the 'Edit Layout' dialog with your new plug-in listed there:
In order to register a plugin, put a .gplugindata into the Addons directory under the InstrumentStudio installation directory. The .gplugindata file is an XML file that tells InstrumentStudio the properties of the plugin and how to find the code that implements it.
3
+
## Registering a Plug-In
4
+
In order to register a plug-in, put a .gplugindata into the Addons directory under the InstrumentStudio installation directory. The .gplugindata file is an XML file that tells InstrumentStudio the properties of the plug-in and how to find the code that implements it.
5
5
6
6
### .gplugindata format
7
7
The .gplugindata file is an XML file. The easiest way to understand it is to look at an example.
@@ -10,11 +10,11 @@ The .gplugindata file is an XML file. The easiest way to understand it is to loo
UniqueName="National Instruments|Example G Plugin"
13
+
UniqueName="National Instruments|Example G Plug-In"
14
14
DisplayName="Example InstrumentStudio 2021"
15
15
PanelType="Examples"
16
16
GroupName="NI Example Plugins"
17
-
VIPath="NI Example G Plugin.vi"
17
+
VIPath="NI Example G Plug-In.vi"
18
18
SupportedPanelSizes="LargeAndSmall"
19
19
ApplicationContext="Unique" />
20
20
</Plugins>
@@ -23,16 +23,14 @@ The .gplugindata file is an XML file. The easiest way to understand it is to loo
23
23
24
24
* The `GPluginMetadata` element is the root element containing all of the data to be registered with InstrumentStudio. You must specify the namespace for the schema as shown in the example above.
25
25
* The `Plugins` element contains the list of plugins
26
-
* Each `PluginData` element registers a single plugin and lists its properties. Attributes of the plugin are expressed as attributes of the `PluginData` element. The attributes recognized are:
27
-
* UniqueName (required) - a unique string identifying this plugin. It should be globally unique across all registered plugins. It is recommended that you use a Guid or some other globally unique identifier which may include the company name to make it unique
28
-
* DisplayName (required) - a name that will be displayed to the user for the plugin in all places in InstrumentStudio
29
-
* SupportedPanelSizes (required) - set this to "Large", "Small", or "LargeAndSmall" to indicate which size layouts this plugin supports.
26
+
* Each `PluginData` element registers a single plug-in and lists its properties. Attributes of the plug-in are expressed as attributes of the `PluginData` element. The attributes recognized are:
27
+
* UniqueName (required) - a unique string identifying this plug-in. It should be globally unique across all registered plugins. It is recommended that you use a Guid or some other globally unique identifier which may include the company name to make it unique
28
+
* DisplayName (required) - a name that will be displayed to the user for the plug-in in all places in InstrumentStudio
29
+
* SupportedPanelSizes (required) - set this to "Large", "Small", or "LargeAndSmall" to indicate which size layouts this plug-in supports.
30
30
* GroupName - The name of a group which will appear in the Edit Layout dialog. All plugins with this group name will be shown together in the dialog
31
-
* PanelType - A string to categorize this plugin. It can be used to filter plugins (show only plugins of this type) in
31
+
* PanelType - A string to categorize this plug-in. It can be used to filter plugins (show only plugins of this type) in
32
32
the Edit Layout dialog
33
-
* StepTypeName - The name of the step type that will be added to the sequence by the IO Configuration in TestStand. If you do not specify a step type name, the default step will be added by TestStand and the `StepTypeConfigurationPropertyPath` will be ignored.
34
-
* StepTypeConfigurationPropertyPath - The property path to a property where TestStand will store the variable property path of the variable that contains the plugin's configuration. This could be the property path to a parameter in the step type that is expecting the configuration.
35
-
* VIPath (required) - a path to the top-level VI to load for the plugin. A relative path can be
33
+
* VIPath (required) - a path to the top-level VI to load for the plug-in. A relative path can be
36
34
specified, in which case the path is considered to be relative to the gplugindata file's location. If culture
37
35
specific gplugindata files are installed underneath culture specific folders, the relative path is considered
38
36
to be relative to the folder above the culture specific folder.
@@ -42,28 +40,28 @@ The .gplugindata file is an XML file. The easiest way to understand it is to loo
42
40
specified, in which case the path is considered to be relative to the gplugindata file's location. If culture
43
41
specific gplugindata files are installed underneath culture specific folders, the relative path is considered
44
42
to be relative to the folder above the culture specific folder.
45
-
* DebuggingEnabled (defaults to false) - Set this to true to make the application context of the plugin visible to LabVIEW as a debuggable context.
43
+
* DebuggingEnabled (defaults to false) - Set this to true to make the application context of the plug-in visible to LabVIEW as a debuggable context.
46
44
* ReentrantExecutionEnabled (defaults to true) - Set this to false to better support debugging. Currently in LabVIEW 2020 and earlier there are some issues when debugging
47
45
a VI that is running reentrantly that might be addressed in a future version of LabVIEW that you can use this setting to workaround, as follows:
48
46
* The first issue is that there is no way to get at the reentrant VI from the debug session after it starts running. This generally means you have to save a breakpoint in the source VI before the clone is created and starts running.
49
47
* However, the saved breakpoint in the clone also isn't being honored and the clone never breaks.
50
48
* Similarly, if you set a breakpoint in a non-reentrant VI called by the clone and then try to step out/up into the reentrant VI, it just steps over and effectively does a resume running command.
51
49
* ApplicationContext (required) - This is an enum value that can be either "Project", "Global", or "Unique"
52
-
* Project - This allows you to share state between multiple plugins, or multiple instances of a plugin implemented within the same lvproj. If you use this option, you also need to specify the ProjectPath attribute.
50
+
* Project - This allows you to share state between multiple plug-ins, or multiple instances of a plug-in implemented within the same lvproj. If you use this option, you also need to specify the ProjectPath attribute.
53
51
* Global - This allows you to share state between plugins globally, but there is a greater risk of conflict with plugins from other developers.
54
-
* Unique - A unique context will be created for each instance of the plugin. This avoids the risk of the state of your VI conflicting with other plugins or instance of your plugin, but it also makes sharing data between plugins and plugin instances more difficult.
52
+
* Unique - A unique context will be created for each instance of the plug-in. This avoids the risk of the state of your VI conflicting with other plugins or instance of your plug-in, but it also makes sharing data between plugins and plug-in instances more difficult.
55
53
56
54
## Relative Versus Absolute Paths
57
55
While there might be some use cases for absolute paths, such as enabling debugging of loose VIs without having to build a source distribution or PPL for it to find all of its
58
56
dependencies by setting an absolute path to an installed LabVIEW's vilib folder under the AdditionalVISearchPaths setting, in general you should never ship
59
-
a gplugindata file with absolute paths because that makes it harder to make a plugin that can work at any possible install location for InstrumentStudio.
57
+
a gplugindata file with absolute paths because that makes it harder to make a plug-in that can work at any possible install location for InstrumentStudio.
60
58
61
-
## Adding <vilib>, <userlib>, and <instrlib>
59
+
## Adding <vilib>, <userlib>, and <instrlib>
62
60
Our recommendation is to create lvlibp files or source distributions when distributing your plugins to end users. However, in order to support
63
61
using loose, unpackaged VIs during development that can still reference VIs in the LabVIEW IDE's search paths, there is an option on the Preferences
64
62
dialog under the Plugins category to automatically include the search paths for these folders if you have the correct version of the LabVIEW IDE
65
63
installed. Note that G plugins always use the latest version of the backwards compatible LabVIEW runtime on the machine, so you will need to have
66
64
the corresponding version of LabVIEW on your machine to debug VIs and to support this option.
67
65
68
66
## Troubleshooting
69
-
If your plugin doesn't appear in the Edit Layout dialog, ensure the .gplugindata file is under the Addons directory of InstrumentStudio. If there is an error reading this file, InstrumentStudio will display a message box with details about the error.
67
+
If your plug-in doesn't appear in the Edit Layout dialog, ensure the .gplugindata file is under the Addons directory of InstrumentStudio. If there is an error reading this file, InstrumentStudio will display a message box with details about the error.
0 commit comments