diff --git a/CHANGELOG.md b/CHANGELOG.md index 60880316f..1674908e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ All notable changes to this project will be documented in this file. * [862: docs tox env fails on rdss-nidaqmxbot-win-10-py32](https://github.com/ni/nidaqmx-python/issues/862) * ### Major Changes - * (IN PROGRESS behind "WAVEFORM_SUPPORT" feature toggle) Added support for reading and writing Waveform data through gRPC using [NI gRPC Device Server](https://github.com/ni/grpc-device). + * Added support for reading and writing Waveform data, including through gRPC using [NI gRPC Device Server](https://github.com/ni/grpc-device). * Add support for calculated power channels * Add support for A and C-type Thermocouples diff --git a/examples/analog_in/voltage_acq_int_clk_plot_wfm.py b/examples/analog_in/voltage_acq_int_clk_plot_wfm.py index 913e40e5f..a87c6fc46 100644 --- a/examples/analog_in/voltage_acq_int_clk_plot_wfm.py +++ b/examples/analog_in/voltage_acq_int_clk_plot_wfm.py @@ -5,14 +5,10 @@ Run 'pip install matplotlib' to install the matplotlib module. """ -import os +import matplotlib.pyplot as plot -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" - -import matplotlib.pyplot as plot # noqa: E402 # Must import after setting environment variable - -import nidaqmx # noqa: E402 -from nidaqmx.constants import READ_ALL_AVAILABLE, AcquisitionType # noqa: E402 +import nidaqmx +from nidaqmx.constants import READ_ALL_AVAILABLE, AcquisitionType with nidaqmx.Task() as task: task.ai_channels.add_ai_voltage_chan("Dev1/ai0") diff --git a/examples/analog_in/voltage_acq_int_clk_wfm.py b/examples/analog_in/voltage_acq_int_clk_wfm.py index e57fde512..7607aff2e 100644 --- a/examples/analog_in/voltage_acq_int_clk_wfm.py +++ b/examples/analog_in/voltage_acq_int_clk_wfm.py @@ -4,12 +4,8 @@ of data using the DAQ device's internal clock. """ -import os - -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" - -import nidaqmx # noqa: E402 # Must import after setting environment variable -from nidaqmx.constants import AcquisitionType # noqa: E402 +import nidaqmx +from nidaqmx.constants import AcquisitionType with nidaqmx.Task() as task: task.ai_channels.add_ai_voltage_chan("Dev1/ai0") diff --git a/examples/analog_out/gen_voltage_wfm_int_clk.py b/examples/analog_out/gen_voltage_wfm_int_clk.py index 065deebb9..f55017b89 100644 --- a/examples/analog_out/gen_voltage_wfm_int_clk.py +++ b/examples/analog_out/gen_voltage_wfm_int_clk.py @@ -5,14 +5,10 @@ sample clock. """ -import os +from nitypes.waveform import AnalogWaveform -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" - -from nitypes.waveform import AnalogWaveform # noqa: E402 - -import nidaqmx # noqa: E402 # Must import after setting environment variable -from nidaqmx.constants import AcquisitionType # noqa: E402 +import nidaqmx +from nidaqmx.constants import AcquisitionType with nidaqmx.Task() as task: total_samples = 1000 diff --git a/examples/digital_in/acq_dig_port_int_clk_wfm.py b/examples/digital_in/acq_dig_port_int_clk_wfm.py index a598856ef..985629892 100644 --- a/examples/digital_in/acq_dig_port_int_clk_wfm.py +++ b/examples/digital_in/acq_dig_port_int_clk_wfm.py @@ -4,17 +4,17 @@ using the DAQ device's internal clock. """ -import os +import numpy as np -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" - -import nidaqmx # noqa: E402 # Must import after setting environment variable -from nidaqmx.constants import ( # noqa: E402 +import nidaqmx +from nidaqmx.constants import ( READ_ALL_AVAILABLE, AcquisitionType, LineGrouping, ) +np.set_printoptions(linewidth=120) # ensure signal.data prints on a single line + with nidaqmx.Task() as task: task.di_channels.add_di_chan( "cdaqTesterMod4/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES @@ -23,7 +23,8 @@ waveform = task.read_waveform(READ_ALL_AVAILABLE) print("Acquired data:") - print(waveform.data) + for signal in waveform.signals: + print(f"{signal.name}: {signal.data}") print(f"Channel name: {waveform.channel_name}") print(f"t0: {waveform.timing.start_time}") print(f"dt: {waveform.timing.sample_interval}") diff --git a/examples/digital_out/cont_gen_dig_port_int_clk.py b/examples/digital_out/cont_gen_dig_port_int_clk.py index e0af4e895..45c55225f 100644 --- a/examples/digital_out/cont_gen_dig_port_int_clk.py +++ b/examples/digital_out/cont_gen_dig_port_int_clk.py @@ -11,7 +11,7 @@ data = [1, 2, 4, 8, 16, 32, 64, 128] task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) - task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS) + task.timing.cfg_samp_clk_timing(10.0, sample_mode=AcquisitionType.CONTINUOUS) task.write(data) task.start() diff --git a/examples/digital_out/cont_gen_dig_port_int_clk_wfm.py b/examples/digital_out/cont_gen_dig_port_int_clk_wfm.py index f3ed016c4..7c18bc115 100644 --- a/examples/digital_out/cont_gen_dig_port_int_clk_wfm.py +++ b/examples/digital_out/cont_gen_dig_port_int_clk_wfm.py @@ -4,23 +4,30 @@ pattern using the DAQ device's clock. """ -import os +import numpy as np +from nitypes.waveform import DigitalWaveform -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" +import nidaqmx +from nidaqmx.constants import AcquisitionType, LineGrouping -from nitypes.waveform import DigitalWaveform # noqa: E402 - -import nidaqmx # noqa: E402 # Must import after setting environment variable -from nidaqmx.constants import AcquisitionType, LineGrouping # noqa: E402 +np.set_printoptions(linewidth=220) # ensure signal.data prints on a single line with nidaqmx.Task() as task: - waveform = DigitalWaveform(sample_count=100, signal_count=16) - for i in range(100): - for j in range(16): - waveform.data[i][j] = (i >> j) & 1 - task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) - task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS) + task.timing.cfg_samp_clk_timing(10.0, sample_mode=AcquisitionType.CONTINUOUS) + + sample_count = 50 + signal_count = task.do_channels[0].do_num_lines + waveform = DigitalWaveform(sample_count, signal_count) + for i in range(sample_count): + for j in range(signal_count): + waveform.signals[j].name = f"line {j:2}" + waveform.signals[j].data[i] = (i >> (j % 8)) & 1 + + print("Writing data:") + for signal in waveform.signals: + print(f"{signal.name}: {signal.data}") + task.write(waveform) task.start() diff --git a/examples/synchronization/multi_function/cont_ai_ci_tdms_sync.py b/examples/synchronization/multi_function/cont_ai_ci_tdms_sync.py index 71aca2b27..154e13ab7 100644 --- a/examples/synchronization/multi_function/cont_ai_ci_tdms_sync.py +++ b/examples/synchronization/multi_function/cont_ai_ci_tdms_sync.py @@ -27,8 +27,6 @@ ) from nidaqmx.stream_readers import AnalogMultiChannelReader, CounterReader -os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1" - # Configuration SAMPLE_RATE = 1000 SAMPLES_PER_CHANNEL = 1000 diff --git a/generated/nidaqmx/_feature_toggles.py b/generated/nidaqmx/_feature_toggles.py index beda1173f..db5e583cf 100644 --- a/generated/nidaqmx/_feature_toggles.py +++ b/generated/nidaqmx/_feature_toggles.py @@ -153,4 +153,4 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T: # Define feature toggle constants here: # -------------------------------------- -WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.INCOMPLETE) +WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.RELEASE) diff --git a/poetry.lock b/poetry.lock index 4518cc663..538f01476 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2465,14 +2465,14 @@ toml = ">=0.10.1" [[package]] name = "nitypes" -version = "1.1.0.dev1" +version = "1.0.1.dev0" description = "Data types for NI Python APIs" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "nitypes-1.1.0.dev1-py3-none-any.whl", hash = "sha256:d98ad6e3f8b92db76b5c1c584431fa27d3e74cce6e20464e43ee0117b02fe089"}, - {file = "nitypes-1.1.0.dev1.tar.gz", hash = "sha256:50b23e00cc6960996656c4c9ef0ca71dd267fc5c9ca481077b682c29190aa2d3"}, + {file = "nitypes-1.0.1.dev0-py3-none-any.whl", hash = "sha256:f2574a6f43f813b240f0be24f6bf52af4ee2be1486c5b40ac032a4e846c49571"}, + {file = "nitypes-1.0.1.dev0.tar.gz", hash = "sha256:f872847c720cdca7002d6c16073c8dfe62275676ded73e36ab285302a7fa1d7c"}, ] [package.dependencies] @@ -4121,4 +4121,4 @@ grpc = ["grpcio", "ni-grpcdevice-v1-proto", "ni-protobuf-types", "protobuf"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4.0" -content-hash = "80db624a7860c7c0497305f8f9d2c685b6745075dc55ae030381d12157129d22" +content-hash = "d4e74aca180b6366a9dc5597c089f17d2143ce78a6c2ab14de8d8f7a2fad40e2" diff --git a/pyproject.toml b/pyproject.toml index 79ba78bd9..afeeada75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ click = ">=8.0.0" distro = { version = ">=1.9.0", platform = "linux" } requests = ">=2.25.0" typing_extensions = { version = ">=4.0.0" } -nitypes = {version=">=1.1.0.dev1"} +nitypes = {version=">=1.0.1.dev0"} [tool.poetry.group.codegen.dependencies] Mako = "^1.2" diff --git a/src/handwritten/_feature_toggles.py b/src/handwritten/_feature_toggles.py index beda1173f..db5e583cf 100644 --- a/src/handwritten/_feature_toggles.py +++ b/src/handwritten/_feature_toggles.py @@ -153,4 +153,4 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T: # Define feature toggle constants here: # -------------------------------------- -WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.INCOMPLETE) +WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.RELEASE)