FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional...

33
FlexLogger Plugin Development Kit Manual Version 1.2 Contents Getting Started .......................................................................................................................... 2 Installation ........................................................................................................................ 2 Using the Wizard .............................................................................................................. 2 Building a Plugin .............................................................................................................. 4 Why Is There an XML File?............................................................................................. 4 Importing into FlexLogger ............................................................................................... 5 Loading Plugins from Additional Locations ........................................................... 5 Using Plugins in FlexLogger ............................................................................................ 5 Channels—Data Produced by a Plugin .................................................................... 7 Channels—Setpoint Data Sent to a Plugin ............................................................... 8 Send FlexLogger Channel Data to a Plugin ............................................................. 9 Versioning ........................................................................................................................ 9 Examples .......................................................................................................................... 10 Getting Started with Plugin Development ........................................................................ 11 FlexLogger Palette in LabVIEW...................................................................................... 13 FlexLogger Plugin LabVIEW Classes (PluginSDK.lvlibp) ..................................................... 13 Processing Element (Processing Element.lvclass) ........................................................... 14 Timing the Process State .......................................................................................... 15 Plugin (Plugin.lvclass) ...................................................................................................... 17 Commands ................................................................................................................ 17 Channel (Channel.lvclass) ................................................................................................ 19 Writing Channel Data from a Plugin to FlexLogger ................................................ 19 Reading and Writing Waveform Channels ............................................................... 20 Reading Setpoint Channels from FlexLogger .......................................................... 21 Retrieving Data from Individual Channels ............................................................... 22 Create Channel VI .................................................................................................... 22 Channel-Specific Parameters.................................................................................... 23 Channel Data Types.................................................................................................. 24 Dynamic Channels.................................................................................................... 24 System Interface (System Interface.lvclass) ..................................................................... 25 Additional Classes ............................................................................................................ 25 Plugin Debugging ..................................................................................................................... 25 Loading Plugins into FlexLogger ..................................................................................... 25 Viewing Errors in FlexLogger .......................................................................................... 26 Interactively Testing Plugins ............................................................................................ 26 Interactive Debugging Session Example .................................................................. 32

Transcript of FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional...

Page 1: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit ManualVersion 1.2

ContentsGetting Started.......................................................................................................................... 2

Installation ........................................................................................................................ 2Using the Wizard .............................................................................................................. 2Building a Plugin .............................................................................................................. 4Why Is There an XML File?............................................................................................. 4Importing into FlexLogger ............................................................................................... 5

Loading Plugins from Additional Locations ........................................................... 5Using Plugins in FlexLogger ............................................................................................ 5

Channels—Data Produced by a Plugin .................................................................... 7Channels—Setpoint Data Sent to a Plugin ............................................................... 8Send FlexLogger Channel Data to a Plugin ............................................................. 9

Versioning ........................................................................................................................ 9Examples .......................................................................................................................... 10Getting Started with Plugin Development........................................................................ 11FlexLogger Palette in LabVIEW...................................................................................... 13

FlexLogger Plugin LabVIEW Classes (PluginSDK.lvlibp) ..................................................... 13Processing Element (Processing Element.lvclass) ........................................................... 14

Timing the Process State .......................................................................................... 15Plugin (Plugin.lvclass)...................................................................................................... 17

Commands ................................................................................................................ 17Channel (Channel.lvclass) ................................................................................................ 19

Writing Channel Data from a Plugin to FlexLogger ................................................ 19Reading and Writing Waveform Channels............................................................... 20Reading Setpoint Channels from FlexLogger .......................................................... 21Retrieving Data from Individual Channels............................................................... 22Create Channel VI .................................................................................................... 22Channel-Specific Parameters.................................................................................... 23Channel Data Types.................................................................................................. 24Dynamic Channels.................................................................................................... 24

System Interface (System Interface.lvclass)..................................................................... 25Additional Classes ............................................................................................................ 25

Plugin Debugging ..................................................................................................................... 25Loading Plugins into FlexLogger ..................................................................................... 25Viewing Errors in FlexLogger.......................................................................................... 26Interactively Testing Plugins ............................................................................................ 26

Interactive Debugging Session Example.................................................................. 32

Page 2: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

2 | ni.com | FlexLogger Plugin Development Kit Manual

Getting Started

Installation1. Install LabVIEW 2019 64-bit.

2. (Optional) Install FlexLogger 2020 R2 or higher.

Note The FlexLogger Plugin Development Kit (version 1.2) is compatible with FlexLogger 2020 R2. Refer to the version of the manual that aligns with your FlexLogger Plugin Development Kit version to ensure content compatibility.

3. Open NI Package Manager and search for FlexLogger Plugin Development Kit.

4. Select FlexLogger Plugin Development Kit and click Install.

5. Follow the instructions on the following screens to complete installation.

Using the Wizard1. Launch LabVIEW.

2. In LabVIEW, select File»Create Project.

3. From the Create Project window, select FlexLogger IO Plugin.

4. In the Create FlexLogger IO Plugin window, update the IO Plugin Name and select a Plugin Template from one the following options:

• Consume setpoint data from FlexLogger—This template is appropriate for instruments that need to be controlled while FlexLogger acquires data, such as a programmable power supply. The template plugin defines two channels that receive setpoint data from FlexLogger to control a third-party instrument.

A setpoint is defined as a channel in FlexLogger that allows the user to change the value using a screen control, from the Channel Specification in the project, or from a SystemLink tag. Setpoints can have a single value at a time.

• Perform Calculation—This template is appropriate for creating plugins that consume data from other FlexLogger channels and produces a result such as a mathematical calculation on multiple channels. To demonstrate this the template plugin calculates the minimum or maximum value of multiple input channels and produces a result waveform channel.

• Produce data for FlexLogger—This template is appropriate for third-party instruments that continuously acquire data. To demonstrate data acquisition, the template plugin generates two channels of data with a constant value of zero.

Page 3: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 3

5. Update the Description and Destination Directory (Source) for the plugin, if desired. By default, the wizard saves new plugins into the My Documents\LabVIEW Projects\FlexLogger IO Plugins\ directory.

The wizard creates a new LabVIEW project with the necessary dependencies, new LabVIEW class, corresponding XML file, and Packed Library build specification.

Page 4: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

4 | ni.com | FlexLogger Plugin Development Kit Manual

Building a PluginIn the LabVIEW project created by the wizard, the build specification is ready to build. Without any developer modification, plugins created using the templates can be built and run in FlexLogger.

After building, the resulting build destination contains a folder with the plugin’s packed library and XML file. For example, the MyFirstPlugin build specification creates a MyFirstPlugin folder containing MyFirstPlugin.lvlibp and MyFirstPlugin.xml. By default, the build specification will build the plugin into the directory FlexLogger uses to load plugins. Refer to the Importing into FlexLogger section for more information.

Why Is There an XML File?FlexLogger uses the XML file to register and load the plugin for use at run-time. The project wizard scripts the XML file and adds it to the plugin’s LabVIEW project. It contains the plugin name and description. The XML file’s name must match the plugin’s packed library name. If there are no naming or version changes after the plugin is created, no manual changes to the XML file are necessary.

Page 5: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 5

Importing into FlexLoggerWhen it launches, FlexLogger loads plugins from %public%\Documents\National Instruments\FlexLogger\Plugins\IOPlugins.

For example, a plugin named PowerSupply would have the following path: %public%\Documents\National Instruments\FlexLogger\Plugins\IOPlugins\PowerSupply. The PowerSupply folder contains the corresponding PowerSupply.lvlibp and PowerSupply.xml files. The folder name must exactly match the contained plugin file names.

FlexLogger projects must be closed and re-opened to consume new or modified plugins.

Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file that specifies additional absolute paths to load plugins from. The file should end in a .config extension and be placed in the root directory of %public%\Documents\National Instruments\FlexLogger\Plugins\IOPlugins. The configuration file must use the following JSON format:

{"AdditionalPluginPaths":["C:\\Users\\<username>\\Documents\\FlexLoggerProjects\\ ","<another absolute path>"]}

Using Plugins in FlexLoggerTo add plugins in FlexLogger, select Add channel»Plugin in the Channel Specification document. If FlexLogger did not load any plugins on launch, the Plugin option will not appear. For troubleshooting plugin appearance issues, refer to the Importing into FlexLogger and the Plugin Debugging sections.

All plugins imported into FlexLogger appear as selectable options:

If your plugin is not appearing in the drop-down menu, refer to the Plugin Debugging section for more information.

Page 6: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

6 | ni.com | FlexLogger Plugin Development Kit Manual

To configure plugin-level parameters, click the Configure gear icon that corresponds to the plugin:

FlexLogger automatically generates dialogs for parameters as defined by plugins:

Parameters cannot be modified while a FlexLogger test is running (the Start Test button has been clicked).

Use the Delete button to remove plugins from your project.

Page 7: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 7

Channels—Data Produced by a PluginFor plugins like the Produce data for FlexLogger template, the plugin generates channel data and sends it to FlexLogger. For these channels, the channel configuration dialog allows users to rename channels and configure channel-specific parameters. The dialog also provides a live value graph to visualize the channel’s waveforms:

The channel name can also be renamed by double-clicking the channel name in the Channel Specification table. The Live value column displays the latest data point, so the data can be previewed with the channel dialog closed.

Page 8: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

8 | ni.com | FlexLogger Plugin Development Kit Manual

Channels—Setpoint Data Sent to a PluginFor plugins using the Consume setpoint data from FlexLogger template, the FlexLogger application sends setpoint values to the plugin’s channel. Those channel values can then be used to control a third-party output device. The channel value can be changed using the Value field in the channel configuration dialog:

Alternatively, the channel value can be modified directly in the Live value column:

Page 9: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 9

Send FlexLogger Channel Data to a PluginFor plugins using the Perform calculation template, users can send data from FlexLogger’s analog input channels to their plugin for analysis or processing. Users can select one or more channels in the plugin configuration dialog.

VersioningWhen a plugin is created it is given a version number as defined by the <Version> tag in the plugin’s XML file and an oldest compatible version number as defined by the <OldestCompatibleVersion> tag. Developers can change these numbers to reflect any updates that are made to the plugin behavior after the plugin has been used in a FlexLogger project.

FlexLogger does not support plugins with identical names. If a developer makes a breaking change to their plugin, they should update both the version and the oldest compatible version. Those updates tell FlexLogger to not load any plugins that were saved with a lower version. However, if a developer makes a non-breaking change, they may want to update the version to communicate that changes were made.

Page 10: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

10 | ni.com | FlexLogger Plugin Development Kit Manual

ExamplesFlexLogger Plugin Development Kit examples can be found in <Program Files>\National Instruments\LabVIEW 2019\examples\FlexLogger. Table 1 describes the available examples:

To load either of the IVI examples, the IVI Compliance Package must first be installed from NI Package Manger. Additionally, an IVI compliant instrument driver is necessary for the IVI Meter example in order to read voltage values from an instrument. Likewise, an IVI DC Power compliant instrument driver is needed for the IVI DC Power Supply example in order to control a power supply.

Table 1. Plugin Examples

Name Type Description

IVI DC Power Supply

Consume setpoint data from FlexLogger

Uses the IVI DC Power class driver to control a power supply instrument

IVI Meter – DC Voltage

Produce data for FlexLogger Read DC voltage values from an IVI DMM class driver compliant instrument

Mouse Input Produce data for FlexLogger Reads data from the mouse connected to the computer

Rosette Calculation Calculates a rosette measurement from multiple strain input channels.

Digital Port Calculator

Calculation Combines eight individual digital channels into a single analog value representing the port value.

Page 11: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 11

The examples include a LabVIEW-only VI that demonstrates how to map functionality from a standalone VI to a FlexLogger plugin class. For example, the Mouse Input LabVIEW project contains Mouse Input - LabVIEW Only Example VI that describes how different parts of the block diagram correspond to the VIs in Mouse Input.lvclass:

Getting Started with Plugin DevelopmentAs described in the Using the Wizard section, new FlexLogger plugins are created through LabVIEW’s Create Project menu. If a developer names their plugin MyFirstPlugin, the wizard creates the following file hierarchy:

Table 2. LabVIEW Project Files

File Name File Type

MyFirstPlugin.lvproj LabVIEW Project

MyFirstPlugin.lvlib LabVIEW Library

MyFirstPlugin.lvclass LabVIEW Class

Page 12: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

12 | ni.com | FlexLogger Plugin Development Kit Manual

The VIs inside MyFirstPlugin.lvclass are the starting point for code changes. These VIs perform different roles, such as defining parameters and reading data from/writing data to FlexLogger. This functionality is described in detail in the Processing Element (Processing Element.lvclass) section. State information—like a hardware reference—can be passed between the MyFirstPlugin VIs using the class private data defined in MyFirstPlugin.ctl.

When planning a FlexLogger plugin, it is helpful to have an existing LabVIEW VI that communicates with the third-party instrument. This LabVIEW-only functionality allows for hardware and driver testing before beginning plugin development. As mentioned in the Examples section, the example plugin projects include a LabVIEW-only VI that demonstrates how to map functionality from a standalone VI to a FlexLogger plugin class.

After reviewing the examples, use the following questions to guide the design of a plugin:

• How many channels are needed?

• Refer to the Channel (Channel.lvclass) section for details on how plugin channels communicate with FlexLogger.

• How many plugin-level parameters are needed?

• These are parameter values that affect the entire plugin—for example, a hardware resource name.

• Refer to the Plugin (Plugin.lvclass) section.

• How many channel-specific parameters are needed?

• These parameter values are unique to every channel and are defined when creating new plugin channels.

• Refer to the Channel (Channel.lvclass) section.

• What data needs to be passed between plugin VIs?

• For example, if an instrument session is initialized in Configure Session VI, it needs to be passed to Process VI for use and then to Cleanup Session VI for disposal.

• Important plugin information can be stored in the plugin’s private class data (for example, MyFirstPlugin.ctl).

When developing a plugin, there are two approaches to evaluate a plugin’s functionality. Both options execute the plugin’s logic and allow developers to investigate the effect of code changes.

• Loading the plugin into FlexLogger. Refer to the Importing into FlexLogger section for more information.

• Running the plugin with the Plugin Environment Simulator. Refer to the Interactively Testing Plugins section for more information.

Page 13: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 13

FlexLogger Palette in LabVIEWTo facilitate plugin creation, installing the Plugin Development Kit adds the FlexLogger palette to the LabVIEW Functions palette.

The palette provides the plugin and channel methods needed to interact with the FlexLogger application. For more information on the methods contained in the palette, refer to the FlexLogger Plugin LabVIEW Classes (PluginSDK.lvlibp) section.

Figure 1. FlexLogger Palette in LabVIEW

FlexLogger Plugin LabVIEW Classes (PluginSDK.lvlibp)In the FlexLogger Plugin Development Kit, PluginSDK.lvlibp contains the classes and VIs used for plugin development. Plugin developers will mostly interact with the Plugin and Channel classes.

If you are unfamiliar with LabVIEW object-oriented programming, refer to the LabVIEW Object-Oriented Programming topic in the LabVIEW Help for conceptual and how-to documentation. To access this topic, visit ni.com/r/lvobjectprog.

Page 14: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

14 | ni.com | FlexLogger Plugin Development Kit Manual

Processing Element (Processing Element.lvclass)The Processing Element class defines the plugin execution states. FlexLogger’s data engine manages the transitions between these states. Refer to Figure 2 and Table 3 for more information on how FlexLogger plugins manage state.

Figure 2. FlexLogger Plugin Execution State Management Flow

Start Initialize

Cleanup Session

Finalize

Remove

Configure Session

Configuration Change

Process

Page 15: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 15

Timing the Process StateIn the Initialize state, Plugins which produce data or consume only setpoint data set the Timing Parameters that control how the Process state executes. If a plugin reads waveform data from other FlexLogger channels, you should instead set the Resampling Parameters, which determine how input data will be resampled. Plugins should typically only use either the Set

Table 3. FlexLogger Plugin Methods

Method Description

Initialize Runs only once—When plugin added in the FlexLogger Channel Specification.

Defines the timing method used by the Process state.

Declare the plugin-level parameters users interact with in FlexLogger.

Declare the channels (and corresponding channel parameters) the plugin will read data from or send data with.

Configure Session Initialize and configure hardware/instrument sessions.

Runs after Initialize

Runs when a configuration change is detected and FlexLogger is not running a test.

Read the latest channel parameters set in FlexLogger.

Read the latest plugin-level parameters set in FlexLogger.

Set the timing information (dt, T0) for data written to FlexLogger in the Process state.

Read what channels FlexLogger reports as valid (channels defined by the plugin may be modified in FlexLogger).

Process Read from and write to third-party hardware.

Read channel data from FlexLogger.

Write channel data to FlexLogger.

Cleanup Session Clean up the hardware sessions and resources initialized by the Configure Session state.

Runs when a configuration change is detected.

Finalize Runs when the plugin is being shut down, during either FlexLogger project close or when the plugin is removed

Clean up any resources initialized during the Initialize state.

Commonly empty.

Page 16: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

16 | ni.com | FlexLogger Plugin Development Kit Manual

Plugin Timing VI or the Set Plugin Resampling VI in Initialize VI, but not both. In situations where the plugin timing is not driven by the timing of the input data, you may want to use Set Plugin Timing in addition to Set Plugin Resampling.

Table 4. FlexLogger Plugin Process State Timing Parameters

Timing MethodTiming Period (ms)

required? Description

Periodic Yes With a timing period of n, periodic timing ensures at least n milliseconds between runs of the Process state.

Immediate No Run Process without delay. This method is typically used when a blocking call inside the Process state controls timing.

On Data Ready No For use by plugins that read channel data from FlexLogger—such as the Consume setpoint data from FlexLogger template. On Data Ready blocks execution of Process until FlexLogger sends new channel data to the plugin.

Triggered No Not applicable for IO Plugin development

Table 5. FlexLogger Plugin Process State Resampling Parameters

Resampling Method Description

Resampling Mode Determines how resampling of input waveforms will be done. In Minimum and Maximum mode the resampling rate is determined by the input channels. In Maximum mode any slower channels will be resampled to the rate of the fastest channel. In Custom mode resampling is done at a fixed rate specified by the Resampling Rate parameter. In Original Rate mode no resampling will be done. This mode should only be used if there is a single input channel.

Resampling Rate (Hz) The rate to resample the data at if using Custom mode

Drift Tolerance (seconds)

The amount of history to store in the plugin waiting for time aligned data from different sources. A high number here increases the memory usage of the plugin, a low number potentially causes issues with plugins which are not synchronized.

Block Size (seconds) The minimum amount of overlapping data that should be present before Process is called.

Page 17: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 17

Plugin (Plugin.lvclass)The Plugin class is the parent class for plugins created with the FlexLogger Plugin Development Kit. It provides the plugin’s state management functionality by inheriting from Processing Element.lvclass. The Plugin class also provides methods to define and interact with plugin channels and parameters. After the channels are initialized, the Plugin class maintains channel information that correctly reflects the state of the plugin channels in the FlexLogger application.

The Plugin class supports double-precision floating point numbers, strings, enums, booleans, and integers as plugin-level parameters. Plugin-level parameters can be created by using the Plugin class’s Write Parameter VI, as shown in the following example:

CommandsPlugins have a special parameter type called Command. Using this parameter will cause FlexLogger to create a button in the application that can be pressed. When pressed, the plugin will be notified. One example of how this could be used is a scale plugin which exposed a Tare command.

When the Tare button is pressed by the user, the plugin could take the appropriate action and tare the scale.

Page 18: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

18 | ni.com | FlexLogger Plugin Development Kit Manual

In order to use a command in the plugin, Handle Notification VI must be overridden. This VI is not overridden by the default templates. You can create an overriding VI by right-clicking your .lvclass in the project and selecting New»VI for Override. This VI has two input parameters: a Notification Type and a Payload string. The Notification Type string matches the name given to your plugin command parameter. The Payload string is only used by two built-in commands: Test Stop and Test Start.

These events fill in the payload with the current time (in seconds). You can add code to Handle Message VI, which causes different actions to be taken, or changes the state of the class data in some way that the rest of the states respond to.

Note that Handle Notification VI is run in a separate loop, so if you want to share data with your other VIs in your class, it should be done through a Data Value Reference instead of directly changing the class private member variables, since LabVIEW classes are copied by value.

Channel (Channel.lvclass)The Channel class allows plugins to send data to the FlexLogger application and read setpoint data from the FlexLogger application. The Plugin class uses the Channel class to organize channels and ensure the plugin and the FlexLogger application agree on what channels should exist.

Page 19: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 19

Writing Channel Data from a Plugin to FlexLoggerAs demonstrated by plugins created from the Produce data for FlexLogger template, plugins can publish data from their data source to FlexLogger:

Figure 3. IO Plugin Data Flow for Production of Data for FlexLogger

To create a channel that can send data to FlexLogger, use the Produced by Plugin option in Create Channel VI:

When sending data to FlexLogger, writing waveforms that overlap in time can disrupt FlexLogger’s visualization and logging capabilities. Using the Plugin class’s Set Stream Timing VI and Write Data VI to send data to FlexLogger protects plugin developers from waveform overlap errors. For example, Set Stream Timing VI defines the waveform dt and Start Time timing parameters in the Configure Session state:

Since Configure Session always executes before the Process state, the output channels timing information updates after every configuration change. Write Data VI allows the Process state to write channel data to FlexLogger in either a one or two-dimensional array of doubles:

3rd PartyData Acquisition

Device

Produce Datafor FlexLogger

Plugin

FlexLoggerApplication

Data Data

Page 20: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

20 | ni.com | FlexLogger Plugin Development Kit Manual

Reading and Writing Waveform ChannelsPlugins created from the Consume-produce waveform data template both read waveform data from FlexLogger and publish waveform data back to FlexLogger. It is also possible to create a plugin which only reads waveform data and does not publish any waveform data back to FlexLogger.

Figure 4. IO Plugin Data Flow for Consumption of Data from FlexLogger

To allow a user to map other FlexLogger channels to a plugin use the Write Parameter VI Single Channel or Multiple Channel options.

The single channel option maps one named parameter to one channel while the multiple channel option lets any number of FlexLogger channels be selected.

When using the minimum or maximum resampling mode of a plugin, it is common that the rate of the waveform channels produced by the plugin will match the rate of the input. Since the rate can change dynamically based on the user’s channel selection in these modes, a new type of channel is provided (the Produced by Plugin—Resampler Timing) which automatically adapts to these changes in sample rate. NI recommends creating your producer channels with this option whenever the resampling mode is set to Minimum or Maximum.

Reading Setpoint Channels from FlexLoggerPlugins created from the Consume setpoint data from FlexLogger template read channel values from FlexLogger and use those values to control third-party output devices:

Figure 5. IO Plugin Data Flow for Consumption of Data from FlexLogger

FlexLoggerApplication

Consumer-ProducerPlugin

FlexLoggerApplication

Data Data

FlexLoggerApplication

Basic OutputPlugin

3rd PartyOutput Device

Data Setpoint

Page 21: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 21

To create a channel that can consume setpoint channel information from the FlexLogger application, use the Setpoint consumed by Plugin option in Create Channel VI:

As demonstrated in the Consume setpoint data from FlexLogger template’s Process VI, the Plugin class’s Read Latest Setpoints VI extracts the most recent scalar value and provides a one-dimensional array of setpoints (one per channel):

In the IVI DC Power Supply example, the setpoint value read from FlexLogger is used as the level input to set the Power Supply’s DC voltage level:

Retrieving Data from Individual ChannelsIf you are using multiple waveform or setpoint channels in a plugin, you can use the Get Stream Data VI on the Advanced palette to retrieve the data for any specific individual channel in the Process method. Setpoint and waveform read VIs return an array of channel values and stream names, where the stream name is the name of the channel the user mapped into the plugin. The different polymorphic options in Get Stream Data VI will translate the plugin unique channel name to the stream name and select the appropriate data from the values array.

Page 22: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

22 | ni.com | FlexLogger Plugin Development Kit Manual

Create Channel VIAs described in the previous sections, Create Channel VI allows users to create three types of channels, Produced by Plugin, Produced by Plugin (Resampler timing), and Setpoint consumed by Plugin. Creating channels involves the following information:

Table 6. Plugin Channel Components

NameLabVIEW Data Type Description

Unique Channel Identifier

string Channel identifier that is unique in the plugin context. Displayed in the far-left Channel Specification column (for example, ai0 for a DAQ channel). Strings with five or fewer characters display best in FlexLogger.

Default Channel Name string Channel name in FlexLogger.

Display Group string Name used in Channel Specification header and channel selector.

Unit string Channel units (for example, Hz).

Can Disable? Boolean Allow users to disable this channel. False by default.

Default Value Double Setpoint consumed by Plugin channels allow plugin developers to set the default value that appears in FlexLogger when the plugin is added.

dt(sec) Double If Produced by Plugin channels use the 1D Wfm (DBL) or 1D Wfm (Digital) option provided by Write VI, this parameter tells the FlexLogger application what dt to expect.

Page 23: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 23

FlexLogger allows users to change a channel’s Default Channel Name from both the channel configuration dialog and directly in the Channel Specification table. Additionally, FlexLogger requires all channels in the Channel Specification to have unique names—and will automatically change a plugin channel name if that rule is violated (for example, myChannel becomes myChannel_1). Regardless of the change to Default Channel Name, the Unique Channel Identifier parameter remains unchanged.

Channel-Specific ParametersThe Channel class supports double-precision floating point numbers, strings, enums, booleans, and integers as channel-level parameters. Channel-specific parameters can be created by using the Channel class’s Write Parameter VI, as shown in the following example:

Channel Data TypesThe Channel class supports both analog (Wfm (DBL)) and digital (Wfm (Digital)) data types for all channels. Analog waveform (Wfm (DBL)) is the default data type. Set the data type using Write Data Type VI, as shown in the following example:

The following example shows using Write Data Type VI to change a channel’s data type.

Dynamic Channels

To help developers work with dynamic channels—such as when names change or channels are disabled—plugins maintain an array of valid channels. Wiring a property node to a plugin class

Page 24: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

24 | ni.com | FlexLogger Plugin Development Kit Manual

wire provides direct access to the ValidProducerChannels, and ValidConsumerChannels arrays:

Knowing what channels are valid allows developers to configure their plugins correctly and produce the right data for the available channels.

When channels assigned to a plugin need to be changed, developers can use Replace Producer Channels VI and Replace Channel Group VI to replace multiple channels at once rather than individually. Replace Producer Channels VI replaces all existing producer channels with a specified list of channels, which can be useful in situation where the user configuration changes in a way that requires a completely new set of producer channels. Replace Channel Group VI replaces all channels in a particular group with a with a specified list of channels, which can be useful in situations where only a subset of the channels need to be replaced.

System Interface (System Interface.lvclass)The System Interface class defines the execution environment interacting with a FlexLogger plugin. When FlexLogger loads and runs a built plugin, the plugin will communicate with FlexLogger’s underlying data engine. When debugging a plugin in the Plugin Environment Simulator, the plugin will communicate with a simplified, test-specific environment.

Additional ClassesThe following classes belong to PluginSDK.lvlibp and are outside the scope of FlexLogger plugin development. These classes should not be used in your plugins.

Table 7. Additional Classes Not Used in Plugin Development

Class Name Summary

Addon Interface.lvclass Defines the communication between plugins and FlexLogger

Message Completion Handler.lvclass

Messaging functionality for classes that do not inherit from Plugin.lvclass

Parameters.lvclass Provides the parameter functionality for the Channel and Plugin classes.

Page 25: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 25

Plugin Debugging

Loading Plugins into FlexLoggerIf FlexLogger fails to parse a plugin’s XML file, the plugin will not be available for users to add in the Channel Specification. In case of parsing failure, an Error.txt file will be created in the plugin’s folder with details about the problem.

Viewing Errors in FlexLoggerBecause the Plugin class provides built-in error handling, it is important that developers wire their error wires to the provided error out terminals. For example, IVI class driver VIs publish errors on their error wires when they are initialized incorrectly. Wiring the error terminals from those driver VIs to the error out terminal ensures errors appear to users in FlexLogger:

Users receive three distinct error notifications

• Detailed errors in the Errors and Warnings pane

• An error icon on the plugin’s header

• The Error indicator by the Stop Test button

Interactively Testing PluginsWhen plugins load and run in FlexLogger, the application’s compiled data engine and the compiled plugins prevent interactive debugging with LabVIEW. The Plugin Environment Simulator provides a simplified, test-specific environment that allows developers to run and debug plugins from the source G code.

Page 26: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

26 | ni.com | FlexLogger Plugin Development Kit Manual

The Plugin Environment Simulator installs to %ProgramFiles%\National Instruments\LabVIEW 2019\resource\FlexLogger\SDK\Plugin Environment Simulator.

Note The Plugin Environment Simulator does not support digital channels.

To enable interactive debugging of Plugin source code, the Simulator is provided as a VI:

To debug a plugin, open and run Plugin Environment Simulator VI. When the Simulator starts running, it prompts the user for the Plugin class to debug. The following is the Simulator running an unmodified Produce data for FlexLogger plugin:

Page 27: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 27

The Configure Plugin Parameters button allows users to update plugin-level parameters:

Similarly, the Configure Channel Parameters allows developer to update channel-specific parameters:

Page 28: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

28 | ni.com | FlexLogger Plugin Development Kit Manual

Plugins following the Consume setpoint data from FlexLogger template do not write any data to FlexLogger, so the Channel Data chart shows the current setpoint values. The Update Setpoint Channels button provides the input information needed to write the correct values to an external system. The following shows setting the setpoint for an unmodified setpoint consumer plugin example:

Page 29: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 29

When using waveform channel inputs with the Plugin Simulator, it is first necessary to pick channel(s) that are mapped to the parameters. This mimics the behavior when interacting with the application. In the Simulator, any designated name will receive a constant value waveform. Mapped channels are configured through the Configure Device Parameters dialog:

Page 30: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

30 | ni.com | FlexLogger Plugin Development Kit Manual

The constant value can be changed using the Change Setpoint option:

Page 31: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

FlexLogger Plugin Development Kit Manual | © National Instruments | 31

Interactive Debugging Session ExampleThe following scenario illustrates how the Simulator could be used to investigate an issue with a plugin under development.

1. After loading and configuring the DMM plugin, the plugin’s channel does not produce any data. In FlexLogger’s Error and Warning pane, the error message references a problem in the Configure Session VI.

2. To investigate further, open the LabVIEW project for the DMM plugin %ProgramFiles%\National Instruments\LabVIEW 2019\examples\FlexLogger\IO Plugins\IVI Meter – DC Voltage\IVI Meter – DC Voltage.lvproj.

3. Open and run Plugin Environment Simulator VI and then select the DMM plugin’s LabVIEW class (IVI Meter – DC Voltage.lvclass).

4. After updating the plugin-level parameter that defines the IVI Logical Name to test channel, the simulator stops running and the Runtime Information error terminal displays and error:

Page 32: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

32 | ni.com | FlexLogger Plugin Development Kit Manual

5. To investigate further, navigate to the plugin’s LabVIEW project and open Configure Session VI.

6. With Configure Session VI open, add a breakpoint to see what part of the logic is generating the error:

7. With the breakpoint in place, run the simulator again and load the DMM plugin. That action will hit the newly placed breakpoint. Using LabVIEW’s debugging tools, step through the block diagram to see exactly which VI is having problems:

8. After this debugging session, you will see that the plugin has been using the wrong IVI Logical Name parameter, resulting in an error from the IVI driver VIs. The plugin runs as expected when using the correct name.

Page 33: FlexLogger Plugin Development Kit Manual - National ... · Loading Plugins from Additional Locations To load a plugin from a different location, users can add a configuration file

© 2019-2020 National Instruments. All rights reserved.

378089C-01 Apr20

Information is subject to change without notice. Refer to the NI Trademarks and Logo Guidelines at ni.com/trademarks for more information on NI trademarks. Other product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering NI products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patents Notice at ni.com/patents. You can find information about end-user license agreements (EULAs) and third-party legal notices in the readme file for your NI product. Refer to the Export Compliance Information at ni.com/legal/export-compliance for the NI global trade compliance policy and how to obtain relevant HTS codes, ECCNs, and other import/export data. NI MAKES NO EXPRESS OR IMPLIED WARRANTIES AS TO THE ACCURACY OF THE INFORMATION CONTAINED HEREIN AND SHALL NOT BE LIABLE FOR ANY ERRORS. U.S. Government Customers: The data contained in this manual was developed at private expense and is subject to the applicable limited rights and restricted data rights as set forth in FAR 52.227-14, DFAR 252.227-7014, and DFAR 252.227-7015.