Skip to content

Commit 01ed3af

Browse files
authored
Replacing DriverError with Error. Adding additional error code for timeout exceeded error. (#216)
* Replacing DriverError with Error. Adding additional error code for timeout exceeded error. Signed-off-by: Chris Delpire <chris.delpire@ni.com> * Replacing.Error with .errors.DriverError. Fixing fgen example as well. Signed-off-by: Chris Delpire <chris.delpire@ni.com> Signed-off-by: Chris Delpire <chris.delpire@ni.com>
1 parent 2a19c75 commit 01ed3af

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

examples/nidcpower_source_dc_voltage/measurement.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
NIDCPOWER_WAIT_FOR_EVENT_TIMEOUT_ERROR_CODE = -1074116059
20+
NIDCPOWER_TIMEOUT_EXCEEDED_ERROR_CODE = -1074097933
2021

2122
measurement_info = nims.MeasurementInfo(
2223
display_name="NI-DCPower Source DC Voltage (Py)",
@@ -129,15 +130,18 @@ def cancel_callback():
129130
try:
130131
channels.wait_for_event(nidcpower.enums.Event.SOURCE_COMPLETE, timeout=0.1)
131132
break
132-
except nidcpower.DriverError as e:
133+
except nidcpower.errors.DriverError as e:
133134
"""
134135
There is no native way to support cancellation when taking a DCPower
135136
measurement. To support cancellation, we will be calling WaitForEvent
136137
until it succeeds or we have gone past the specified timeout. WaitForEvent
137138
will throw an exception if it times out, which is why we are catching
138139
and doing nothing.
139140
"""
140-
if e.code == NIDCPOWER_WAIT_FOR_EVENT_TIMEOUT_ERROR_CODE:
141+
if (
142+
e.code == NIDCPOWER_WAIT_FOR_EVENT_TIMEOUT_ERROR_CODE
143+
or e.code == NIDCPOWER_TIMEOUT_EXCEEDED_ERROR_CODE
144+
):
141145
pass
142146
else:
143147
raise

examples/nifgen_standard_function/measurement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def cancel_callback():
138138
else:
139139
try:
140140
sessions[0].wait_until_done(hightime.timedelta(seconds=sleep_time))
141-
except nifgen.Error as e:
141+
except nifgen.errors.DriverError as e:
142142
"""
143143
There is no native way to support cancellation when generating a waveform.
144144
To support cancellation, we will be calling wait_until_done

0 commit comments

Comments
 (0)