Example Code

Adding to the TestStand Report Generation Plug-in - Setting all reports to be Read-Only

Code and Documents

Attachment

 

Overview

This example shows how you can expand the functionality to the TestStand report generation plugin which ships with TestStand. This particular example adds the ability to specify that report files should be marked as read-only after being generated. The plug-in has the following modifications:

 

  • An Additional callback is added to expose a new "Make Report Files Read-Only" option: Model Plugin - Configure Additional Options
  • A subsequence is added which sets the read-only flag on the specified report file.  This sequence is called after the report file is generated

 

Description

If you are not familiar with the TestStand process model plug-in architecture, refer to this overview before using this example:

 

TestStand Help: Process Model Plug-in Architecture

 

This example shows how you can add functionality to the existing report generation plug-in with minimal changes to the existing code.  This allows you to more easily migrate the changes to future versions of the plug-in.

 

 

 

Typically, new features you add to the report generation plug-in will require that you expose settings to the user to configure the additional functionality.  This example needs to expose an option so the user can set whether reports should be marked as read only.  You can use the Model Plugin - Configure Additional Options callback to expose a secondary options dialog for these additional settings.  Using this approach decouples the additional settings from the default report options.

 

To create the Model Plugin - Configure Additional Options callback:

 

  1. Before modifying the report generation plug-in sequence file, create a copy of the file in the TestStand public location:

    Source Location: 
    <TestStand>\Components\Models\ModelPlugins\NI_ReportGenerator.seq
    Destination Location: 
    <TestStand Public>\Components\Models\ModelPlugins\NI_ReportGenerator.seq
  2. Copy the Model Plugin - Configure Standard Options sequence, and rename it Model Plugin - Configure Additional Options.  
  3. In the Setup group, add code to create any new settings you are adding using the PropertyObject API.  New properties should be added to the following container:
    Parameters.ModelPlugin.PluginSpecific.AdditionalOptions
    . This example adds a new property "MakeReportReadOnly".:

    Parameters.ModelPlugin.PluginSpecific.AdditionalOptions.SetValBoolean("MakeReportReadOnly", PropOption_SetOnlyIfDoesNotExist, 0)
  4.  Create a user interface to allow the user to set the plug-in properties
  5. Now, in the result processing dialog, an additional settings button will be present, which calls the Model Plugin - Configure Additional Options sequence

Once you have provided a way for the user to configure the new options, you can access these settings in any plug-in sequence.  In this example, a new sequence "SetReadOnly" is added which sets a specified file to be read-only.  This sequence is called from the Model Plugin - UUT Done and Model Plugin - Batch Done callbacks after the report file is saved.

 

 

Hardware and Software Requirements

Adding to the NI Report Generator - TS2016.zip

TestStand 2016 or Compatible

Visual Studio 2015 or Compatible (Optional, for viewing source code of additional options dialog)

 

Steps to Implement or Execute Code

  1. extract the files in the attached zip to the following location.
    <TestStand Public>\Components\Models\ModelPlugins\
  2. Open the result processing dialog.  Observe that the report generation plug-in instance has an additional settings button.  Click the button to enable the "Make Reports Read Only" option

    reportGenPluginSettings.PNG
  3. Run any sequence file using Execute » Single Pass.  Observe that the generated report file is marked as read-only.

 

Additional Information or References

 TestStand Help: Process Model Plug-in Architecture

 

Rod T.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors