Developing a Measurement Plug-In Client with Python
- Updated2024-10-16
- 3 minute(s) read
Developing a Measurement Plug-In Client with Python
This section outlines the required steps for developing a measurement plug-in client in Python. Use the Python examples in github and the remaining topics in this manual to understand how to develop a working measurement plug-in client for your application.
Creating a Python Measurement Plug-In Client
using Batch Mode
The client can be created using a one-line command by configuring the necessary options in Batch Mode.
- Open a command prompt.
- Enter the following command, specifying the name of the measurement service class: ni_measurement_plugin_client_generator --measurement-service-class measurement_service_class_name
- Optional:
You can specify additional parameters when running this command. For more
details, refer to Python Measurement Plug-In Client Generator Batch Mode
Parameters. If no further parameters are required, run the
command.
A Python file containing the client class will be generated for the specified measurement service class. For details on using Python plug-in clients, refer to Python Measurement Plug-In Client Usage
Python Measurement Plug-In Client Generator
Batch Mode Parameters
The ni_measurement_plugin_client_generator tool requires the measurement plug-in service class as the first parameter. This parameter can be specified multiple times to create multiple plug-in clients.
Parameter Name | Default Value | Description |
---|---|---|
-s, --measurement-service-class | - | Creates a Python Measurement Plug-In Client for the given
measurement service. Note This parameter should not be used with
the --all parameter. |
-a, --all | False | Creates a Python Measurement Plug-In Client for all the registered measurement services. |
-m, --module-name | Constructed from service class | Name for the Python Measurement Plug-In Client module. This value is ignored if --all is chosen. |
-c, --class | Constructed from service class | Name for the Python Measurement Plug-In Client class in the generated module. This value is ignored if --all is chosen. |
-o, --directory-out | current_directory/module_name.py | Output directory for Measurement Plug-In Client files. |
Creating a Python Measurement Plug-In Client
using Interactive Mode
Measurement plug-in clients can be created individually by providing the necessary inputs via the command line in interactive mode.
- Open a command prompt.
-
Run the following command to list the registered and active measurements on the
machine: ni_measurement_plugin_client_generator
--interactive
This command displays a numbered list of all registered measurement services.
1. Measurement A 2. Measurement B 3. Measurement C
- Enter the number corresponding to the measurement you want to create a client module for. To create a client module for Measurement B from the example above, you would enter 2.
-
Enter the name of the measurement client module and class, ensuring that the
name follows Python's module naming conventions.
A Python file containing the client class will be generated for the specified measurement service class. For more details, refer to Python Measurement Plug-In Client Usage.
Python Measurement Plug-In Client
Usage
The generated Python file will contain a class and public methods for the specified measurement. Before you can interact with a measurement via the plug-in client, the Measurement Service must be running. Refer to the following section for descriptions of the public methods you can use to interact with a measurement service:
- register_pin_map— Registers the pin map with the pin map service.
- measure— Interacts with non-streaming data measurements by accepting the actual input configured in the measurement and returning the measurement output.
- stream_measure— Same as measure, but used specifically for interacting with streaming data measurements.
-
cancel— Aborts any ongoing measure or
stream_measure call. Note This API can only be used from a separate thread.