Measurement Plug-In Code Generator for Python
Project description
Measurement Plug-In SDK Generator for Python
Introduction
Measurement Plug-In SDK Generator for Python (ni-measurement-plugin-sdk-generator) is a Python package containing tools for generating reusable measurement plug-ins and clients.
ni-measurement-plugin-generatoris a command for generating measurement plug-ins using gRPC services.ni-measurement-plugin-client-generatoris a command for generating plug-in clients to interact with the measurement plug-ins.
Dependencies
Developing Measurements: Quick Start
For installation and usage, see Measurement Plug-In SDK Service for Python - Developing Measurements: Quick Start section.
Generating Measurement Clients: Quick Start
This section provides instructions to generate custom measurement clients in Python using Measurement Plug-In SDK for Python.
Installation
Make sure the system has the recommended Python version installed. Install Measurement Plug-In SDK for Python using pip.
REM Activate the required virtual environment if any.
pip install ni-measurement-plugin-sdk
Check if you have installed the expected version of Measurement Plug-In SDK for Python installed by running the below command:
pip show ni-measurement-plugin-sdk
Generating a Minimal Python Measurement Client
Run the ni-measurement-plugin-client-generator tool.
-
To create measurement clients for specific measurements, use this command with optional arguments:
ni-measurement-plugin-client-generator --measurement-service-class "ni.examples.SampleMeasurement_Python" [--module-name "sample_measurement_client"] [--class-name "SampleMeasurementClient"] [--directory-out <new_path_for_created_files>]-
--measurement-service-classspecifies the measurement service class for which the client is being generated. -
Optional arguments:
-
--module-nameand--class-namedefine the module and class names of the generated client. If not specified, they are derived from the measurement service class name. -
--directory-outspecifies the output directory for the generated files. If not specified, files are placed in the current directory.
-
Note: When generating multiple measurement clients,
--module-nameand--class-nameare ignored and derived from the service class of each measurement. So, ensure that the measurement service class name adheres to proper naming conventions. -
-
To create measurement clients for all registered measurements, use this command:
ni-measurement-plugin-client-generator --all [--directory-out <new_path_for_created_files>] -
To interactively create measurement clients for any registered measurements, use this command:
ni-measurement-plugin-client-generator --interactive
The generated client includes four APIs: measure, stream_measure, register_pin_map, and cancel. The usage of these APIs is discussed in the "Steps to Run/Debug the Measurement Client" section.
Note:
- The Measurement Plug-In Client is compatible with all datatypes supported by the Measurement Plug-In.
- The Double XY datatype is not supported for measurement configurations (inputs).
- For Enum datatypes, the generated enum class names will be the measurement parameter name suffixed with 'Enum'. For instance, if the measurement parameter name is 'Enum In', the generated enum in the client will be `EnumInEnum'.
- Ring control in LabVIEW measurements will be represented as numeric datatypes in the generated client.
Steps to Run/Debug the Measurement Client
-
Make sure the required measurement service is running before interacting with it via the client.
-
Use the client APIs from the "Generating a Minimal Python Measurement Client" section.
-
For non-streaming measurements, use the
measuremethod.from sample_measurement_client import SampleMeasurementClient client = SampleMeasurementClient() outputs = client.measure() print(outputs)
-
For streaming measurements, use the
stream_measuremethod.from sample_measurement_client import SampleMeasurementClient client = SampleMeasurementClient() outputs_itr = client.stream_measure() for index, outputs in enumerate(outputs_itr): print(f"outputs[{index}] = {outputs}")
-
If a measurement requires a pin map, it can be registered using the
register_pin_mapmethod. By default,sitesis set to [0].from sample_measurement_client import SampleMeasurementClient client = SampleMeasurementClient() client.register_pin_map(pin_map_path) outputs = client.measure() print(outputs)
- Alternatively, when calling a measurement service from another measurement, you can pass the first measurement's pin map context to the second measurement's pin map context through the
pin_map_contextproperty. Sites can also be provided through thesitesproperty.
from sample_measurement_client import SampleMeasurementClient client = SampleMeasurementClient() client.pin_map_context = available_pin_map_context client.sites = [0, 1] outputs = client.measure() print(outputs)
- Alternatively, when calling a measurement service from another measurement, you can pass the first measurement's pin map context to the second measurement's pin map context through the
-
Cancel an ongoing
measureorstream_measurecall using thecancelmethod.from concurrent.futures import ThreadPoolExecutor from sample_measurement_client import SampleMeasurementClient client = SampleMeasurementClient() with ThreadPoolExecutor() as executor: future = executor.submit(client.measure) client.cancel() outputs = future.result() # Raises grpc.RpcException with status code "CANCELLED"
-
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ni_measurement_plugin_sdk_generator-3.1.0.tar.gz.
File metadata
- Download URL: ni_measurement_plugin_sdk_generator-3.1.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10456fc82e4a90322dbee21cd06b28d13f90c84332338844b80c79530bd5c843
|
|
| MD5 |
e699d0e64308411d9d9ff05edb590f54
|
|
| BLAKE2b-256 |
61544c02e6eaed40eaea988f0b37f812f6754ae7766d505ae1dfcda641dd31ee
|
Provenance
The following attestation bundles were made for ni_measurement_plugin_sdk_generator-3.1.0.tar.gz:
Publisher:
publish.yml on ni/measurement-plugin-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ni_measurement_plugin_sdk_generator-3.1.0.tar.gz -
Subject digest:
10456fc82e4a90322dbee21cd06b28d13f90c84332338844b80c79530bd5c843 - Sigstore transparency entry: 767666268
- Sigstore integration time:
-
Permalink:
ni/measurement-plugin-python@c4a05f0e38ebf447205bad3a0b7b565d3e6cf2ce -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/ni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4a05f0e38ebf447205bad3a0b7b565d3e6cf2ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file ni_measurement_plugin_sdk_generator-3.1.0-py3-none-any.whl.
File metadata
- Download URL: ni_measurement_plugin_sdk_generator-3.1.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
676ed46ed8add60597e91386e5ad575f17f23edad1e47ad1750c6067a4a1aa8a
|
|
| MD5 |
631cd45748b72aec5e32304edb7f1176
|
|
| BLAKE2b-256 |
2ffe04322a3665a0a9e7fb34144f5ee5058a423bd3a4a759fb94be060dd9cba4
|
Provenance
The following attestation bundles were made for ni_measurement_plugin_sdk_generator-3.1.0-py3-none-any.whl:
Publisher:
publish.yml on ni/measurement-plugin-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ni_measurement_plugin_sdk_generator-3.1.0-py3-none-any.whl -
Subject digest:
676ed46ed8add60597e91386e5ad575f17f23edad1e47ad1750c6067a4a1aa8a - Sigstore transparency entry: 767666270
- Sigstore integration time:
-
Permalink:
ni/measurement-plugin-python@c4a05f0e38ebf447205bad3a0b7b565d3e6cf2ce -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/ni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4a05f0e38ebf447205bad3a0b7b565d3e6cf2ce -
Trigger Event:
release
-
Statement type: