Skip to content

NI DataPlugins extension for Visual Studio Code

License

Notifications You must be signed in to change notification settings

ni/vscode-ni-python-dataplugins

Repository files navigation

NI DataPlugins Extension for Visual Studio Code

A Visual Studio Code extension that provides development support for NI DataPlugins written in Python. For more information about writing Python DataPlugins, please refer to the SystemLink Operations Handbook.

CI

Quick Start

Step 1. Install this extension. Download from marketplace or download the latest vsix from Release.

  • Open Visual Studio Code and select View->Extensions from the menu to display the Extensions pane.
  • Click the ... in the top-right corner of the Extensions pane and select Install from VSIX.
  • Locate the .vsix file you download and click Open.
  • Click Restart to confirm.

Installing the extension

Step 2. Create a new DataPlugin. Launch VSCode Command Palette (Ctrl+Shift+P), paste the command below, and press Enter.

NI DataPlugins: Create new Python-DataPlugin

Creating a new DataPlugin

Step 3. Export the DataPlugin. Right-click the *.py file you want to export.

  • NI DataPlugins: Export DataPlugin: Your code will be embedded in a *.uri file that you can share with others.
  • NI DataPlugins: Register DataPlugin for Development (CTRL+ALT+F5): Use this option to register the DataPlugin exclusively on your development machine and test your code changes in DIAdem, LabVIEW, or SystemLink.

Snippets

This extension defines a few helpful Snippets that extend the auto-completion capabilities of VSCode. Start typing and press Ctrl+Space to display a list of suggestions.

Use the following Snippets to quickly select a supported data type:

  • DataTypeChnFloat32
  • DataTypeChnFloat64
  • DataTypeChnString
  • DataTypeChnDate
  • DataTypeChnUInt8
  • DataTypeChnInt16
  • DataTypeChnInt32
  • DataTypeChnInt64

Use the following Snippets to insert the most common stubs:

  • if __name__ == "__main__"
  • def read_channel_length
  • def read_channel_values
  • def read_store

Feel free to contribute additional Snippets to the project: snippets/snippets.json

Advanced Settings

Custom Template

Start writing your DataPlugin with your own custom template. Simply add your template to the examples directory. You find the examples folder at $HOME/.vscode/extensions/ni.vscode-ni-python-dataplugins-<version> under Mac and Linux or at %USERPROFILE%\.vscode\extensions\ni.vscode-ni-python-dataplugins-<version> folder under Windows.

.file-extensions

Create a file .file-extensions in the root directory of your project and list all file extensions that you want your DataPlugin to support. If no list is defined, you will be prompted to provide a list of file extensions when you export your DataPlugin.

Export Path

Set the export path for all your plugins in Preferences -> Settings -> Extensions -> Python DataPlugins -> Export Path. The path can be a folder or a *.uri file.

Example
{
    "Python-DataPlugins.exportPath": "C:\\Temp"
}
// OR
{
    "Python-DataPlugins.exportPath": "C:\\Temp\\MyPlugin.uri"
}

Contribute

Contribute to this project by finding issues, requesting features or creating Pull Requests. General documentation about developing extensions for Visual Studio Code can be found here and here.

Developer Setup

To compile this extension, run:

git clone https://github.com/ni/vscode-ni-python-dataplugins.git
cd vscode-ni-python-dataplugins
npm install

To test your changes, run:

npm run lint
npm run test
npm run test:e2e

Run the extension from VSCode by pressing F5.

License

See LICENSE for details about how this extension is licensed.