Skip to content

Commit 41498b0

Browse files
mikeprosserniMike Prosser
andauthored
Enable Waveform Support By Default (#901)
* NIDAQMX_ENABLE_WAVEFORM_SUPPORT to RELEASE * update digital waveform examples to use signals * nitypes 1.0.1.dev0 * comments: # ensure signal.data prints on a single line * fix style issues * reduce continuous digital output examples timing from 1kHz to 10Hz --------- Co-authored-by: Mike Prosser <[email protected]>
1 parent 065ca88 commit 41498b0

File tree

12 files changed

+43
-49
lines changed

12 files changed

+43
-49
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ All notable changes to this project will be documented in this file.
3434
* [862: docs tox env fails on rdss-nidaqmxbot-win-10-py32](https://github.com/ni/nidaqmx-python/issues/862)
3535

3636
* ### Major Changes
37-
* (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).
37+
* Added support for reading and writing Waveform data, including through gRPC using [NI gRPC Device Server](https://github.com/ni/grpc-device).
3838
* Add support for calculated power channels
3939
* Add support for A and C-type Thermocouples
4040

examples/analog_in/voltage_acq_int_clk_plot_wfm.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
Run 'pip install matplotlib' to install the matplotlib module.
66
"""
77

8-
import os
8+
import matplotlib.pyplot as plot
99

10-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
11-
12-
import matplotlib.pyplot as plot # noqa: E402 # Must import after setting environment variable
13-
14-
import nidaqmx # noqa: E402
15-
from nidaqmx.constants import READ_ALL_AVAILABLE, AcquisitionType # noqa: E402
10+
import nidaqmx
11+
from nidaqmx.constants import READ_ALL_AVAILABLE, AcquisitionType
1612

1713
with nidaqmx.Task() as task:
1814
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")

examples/analog_in/voltage_acq_int_clk_wfm.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
of data using the DAQ device's internal clock.
55
"""
66

7-
import os
8-
9-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
10-
11-
import nidaqmx # noqa: E402 # Must import after setting environment variable
12-
from nidaqmx.constants import AcquisitionType # noqa: E402
7+
import nidaqmx
8+
from nidaqmx.constants import AcquisitionType
139

1410
with nidaqmx.Task() as task:
1511
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")

examples/analog_out/gen_voltage_wfm_int_clk.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
sample clock.
66
"""
77

8-
import os
8+
from nitypes.waveform import AnalogWaveform
99

10-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
11-
12-
from nitypes.waveform import AnalogWaveform # noqa: E402
13-
14-
import nidaqmx # noqa: E402 # Must import after setting environment variable
15-
from nidaqmx.constants import AcquisitionType # noqa: E402
10+
import nidaqmx
11+
from nidaqmx.constants import AcquisitionType
1612

1713
with nidaqmx.Task() as task:
1814
total_samples = 1000

examples/digital_in/acq_dig_port_int_clk_wfm.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
using the DAQ device's internal clock.
55
"""
66

7-
import os
7+
import numpy as np
88

9-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
10-
11-
import nidaqmx # noqa: E402 # Must import after setting environment variable
12-
from nidaqmx.constants import ( # noqa: E402
9+
import nidaqmx
10+
from nidaqmx.constants import (
1311
READ_ALL_AVAILABLE,
1412
AcquisitionType,
1513
LineGrouping,
1614
)
1715

16+
np.set_printoptions(linewidth=120) # ensure signal.data prints on a single line
17+
1818
with nidaqmx.Task() as task:
1919
task.di_channels.add_di_chan(
2020
"cdaqTesterMod4/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES
@@ -23,7 +23,8 @@
2323

2424
waveform = task.read_waveform(READ_ALL_AVAILABLE)
2525
print("Acquired data:")
26-
print(waveform.data)
26+
for signal in waveform.signals:
27+
print(f"{signal.name}: {signal.data}")
2728
print(f"Channel name: {waveform.channel_name}")
2829
print(f"t0: {waveform.timing.start_time}")
2930
print(f"dt: {waveform.timing.sample_interval}")

examples/digital_out/cont_gen_dig_port_int_clk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
data = [1, 2, 4, 8, 16, 32, 64, 128]
1212

1313
task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
14-
task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
14+
task.timing.cfg_samp_clk_timing(10.0, sample_mode=AcquisitionType.CONTINUOUS)
1515
task.write(data)
1616
task.start()
1717

examples/digital_out/cont_gen_dig_port_int_clk_wfm.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,30 @@
44
pattern using the DAQ device's clock.
55
"""
66

7-
import os
7+
import numpy as np
8+
from nitypes.waveform import DigitalWaveform
89

9-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
10+
import nidaqmx
11+
from nidaqmx.constants import AcquisitionType, LineGrouping
1012

11-
from nitypes.waveform import DigitalWaveform # noqa: E402
12-
13-
import nidaqmx # noqa: E402 # Must import after setting environment variable
14-
from nidaqmx.constants import AcquisitionType, LineGrouping # noqa: E402
13+
np.set_printoptions(linewidth=220) # ensure signal.data prints on a single line
1514

1615
with nidaqmx.Task() as task:
17-
waveform = DigitalWaveform(sample_count=100, signal_count=16)
18-
for i in range(100):
19-
for j in range(16):
20-
waveform.data[i][j] = (i >> j) & 1
21-
2216
task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
23-
task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
17+
task.timing.cfg_samp_clk_timing(10.0, sample_mode=AcquisitionType.CONTINUOUS)
18+
19+
sample_count = 50
20+
signal_count = task.do_channels[0].do_num_lines
21+
waveform = DigitalWaveform(sample_count, signal_count)
22+
for i in range(sample_count):
23+
for j in range(signal_count):
24+
waveform.signals[j].name = f"line {j:2}"
25+
waveform.signals[j].data[i] = (i >> (j % 8)) & 1
26+
27+
print("Writing data:")
28+
for signal in waveform.signals:
29+
print(f"{signal.name}: {signal.data}")
30+
2431
task.write(waveform)
2532
task.start()
2633

examples/synchronization/multi_function/cont_ai_ci_tdms_sync.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
)
2828
from nidaqmx.stream_readers import AnalogMultiChannelReader, CounterReader
2929

30-
os.environ["NIDAQMX_ENABLE_WAVEFORM_SUPPORT"] = "1"
31-
3230
# Configuration
3331
SAMPLE_RATE = 1000
3432
SAMPLES_PER_CHANNEL = 1000

generated/nidaqmx/_feature_toggles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,4 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T:
153153
# Define feature toggle constants here:
154154
# --------------------------------------
155155

156-
WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.INCOMPLETE)
156+
WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.RELEASE)

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)