Skip to content

Commit 35551a8

Browse files
committed
updated cal functions to property and docstrings
1 parent 70f9b1e commit 35551a8

File tree

3 files changed

+102
-53
lines changed

3 files changed

+102
-53
lines changed

generated/nidaqmx/system/device.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,52 @@ def do_ports(self):
132132

133133
# endregion
134134

135+
# region Calibration Info property
136+
137+
@property
138+
def ext_cal_last_date_and_time(self):
139+
"""
140+
Indicates the last date and time that the device underwent an
141+
external calibration.
142+
"""
143+
144+
last_date_and_time = self._interpreter.get_ext_cal_last_date_and_time(self._name)
145+
146+
return datetime(
147+
year=last_date_and_time[0],
148+
month=last_date_and_time[1],
149+
day=last_date_and_time[2],
150+
hour=last_date_and_time[3],
151+
minute=last_date_and_time[4]
152+
)
153+
154+
@property
155+
def self_cal_last_date_and_time(self):
156+
"""
157+
Indicates the last date and time that the device underwent a
158+
self-calibration.
159+
"""
160+
161+
last_date_and_time = self._interpreter.get_self_cal_last_date_and_time(self._name)
162+
163+
return datetime(
164+
year=last_date_and_time[0],
165+
month=last_date_and_time[1],
166+
day=last_date_and_time[2],
167+
hour=last_date_and_time[3],
168+
minute=last_date_and_time[4]
169+
)
170+
171+
@property
172+
def device_supports_cal(self):
173+
"""
174+
Indicates if the device supports calibration.
175+
"""
176+
177+
return self._interpreter.device_supports_cal(self._name)
178+
179+
# endregion
180+
135181
@property
136182
def accessory_product_nums(self):
137183
"""
@@ -1071,16 +1117,15 @@ def reset_device(self):
10711117
self._interpreter.reset_device(
10721118
self._name)
10731119

1074-
def restore_last_ext_cal_const(self, device_name):
1120+
def restore_last_ext_cal_const(self):
10751121
"""
1076-
1077-
1078-
Args:
1079-
device_name (str):
1122+
This function nullifies any self-calibration you perform on the
1123+
device. If you have never performed a self-calibration on the
1124+
device, this function has no effect.
10801125
"""
10811126

10821127
self._interpreter.restore_last_ext_cal_const(
1083-
self._name, device_name)
1128+
self._name)
10841129

10851130
def self_cal(self):
10861131
"""
@@ -1174,28 +1219,6 @@ def unreserve_network_device(self):
11741219

11751220
# endregion
11761221

1177-
def get_ext_cal_last_date_and_time(device_name):
1178-
last_date_and_time = self._interpreter.get_ext_cal_last_date_and_time(device_name)
1179-
1180-
return datetime(
1181-
year = last_date_and_time[0],
1182-
month = last_date_and_time[1],
1183-
day = last_date_and_time[2],
1184-
hour = last_date_and_time[3],
1185-
minute = last_date_and_time[4]
1186-
)
1187-
1188-
def get_self_cal_last_date_and_time(device_name):
1189-
last_date_and_time = self._interpreter.get_self_cal_last_date_and_time(device_name)
1190-
1191-
return datetime(
1192-
year = last_date_and_time[0],
1193-
month = last_date_and_time[1],
1194-
day = last_date_and_time[2],
1195-
hour = last_date_and_time[3],
1196-
minute = last_date_and_time[4]
1197-
)
1198-
11991222
class _DeviceAlternateConstructor(Device):
12001223
"""
12011224
Provide an alternate constructor for the Device object.
@@ -1217,4 +1240,4 @@ def __init__(self, name, interpreter):
12171240

12181241
# Use meta-programming to change the type of this object to Device,
12191242
# so the user isn't confused when doing introspection.
1220-
self.__class__ = Device
1243+
self.__class__ = Device

src/codegen/metadata/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20096,10 +20096,12 @@
2009620096
'python_data_type': 'str',
2009720097
'python_description': '',
2009820098
'python_type_annotation': 'str',
20099-
'type': 'const char[]'
20099+
'type': 'const char[]',
20100+
'use_in_python_api': False
2010020101
}
2010120102
],
2010220103
'python_class_name': 'Device',
20104+
'python_description': 'This function nullifies any self-calibration you perform on the device. If you have never performed a self-calibration on the device, this function has no effect.',
2010320105
'returns': 'int32'
2010420106
},
2010520107
'SaveGlobalChan': {

src/codegen/templates/system/device.py.mako

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,52 @@ class Device:
141141

142142
# endregion
143143

144+
# region Calibration Info property
145+
146+
@property
147+
def ext_cal_last_date_and_time(self):
148+
"""
149+
Indicates the last date and time that the device underwent an
150+
external calibration.
151+
"""
152+
153+
last_date_and_time = self._interpreter.get_ext_cal_last_date_and_time(self._name)
154+
155+
return datetime(
156+
year=last_date_and_time[0],
157+
month=last_date_and_time[1],
158+
day=last_date_and_time[2],
159+
hour=last_date_and_time[3],
160+
minute=last_date_and_time[4]
161+
)
162+
163+
@property
164+
def self_cal_last_date_and_time(self):
165+
"""
166+
Indicates the last date and time that the device underwent a
167+
self-calibration.
168+
"""
169+
170+
last_date_and_time = self._interpreter.get_self_cal_last_date_and_time(self._name)
171+
172+
return datetime(
173+
year=last_date_and_time[0],
174+
month=last_date_and_time[1],
175+
day=last_date_and_time[2],
176+
hour=last_date_and_time[3],
177+
minute=last_date_and_time[4]
178+
)
179+
180+
@property
181+
def device_supports_cal(self):
182+
"""
183+
Indicates if the device supports calibration.
184+
"""
185+
186+
return self._interpreter.device_supports_cal(self._name)
187+
188+
# endregion
189+
144190
<%namespace name="property_template" file="/property_template.py.mako"/>\
145191
%for attribute in attributes:
146192
${property_template.script_property(attribute)}\
@@ -224,28 +270,6 @@ ${function_template.script_function(function_object)}
224270

225271
# endregion
226272

227-
def get_ext_cal_last_date_and_time(device_name):
228-
last_date_and_time = self._interpreter.get_ext_cal_last_date_and_time(device_name)
229-
230-
return datetime(
231-
year = last_date_and_time[0],
232-
month = last_date_and_time[1],
233-
day = last_date_and_time[2],
234-
hour = last_date_and_time[3],
235-
minute = last_date_and_time[4]
236-
)
237-
238-
def get_self_cal_last_date_and_time(device_name):
239-
last_date_and_time = self._interpreter.get_self_cal_last_date_and_time(device_name)
240-
241-
return datetime(
242-
year = last_date_and_time[0],
243-
month = last_date_and_time[1],
244-
day = last_date_and_time[2],
245-
hour = last_date_and_time[3],
246-
minute = last_date_and_time[4]
247-
)
248-
249273
class _DeviceAlternateConstructor(Device):
250274
"""
251275
Provide an alternate constructor for the Device object.
@@ -267,4 +291,4 @@ class _DeviceAlternateConstructor(Device):
267291

268292
# Use meta-programming to change the type of this object to Device,
269293
# so the user isn't confused when doing introspection.
270-
self.__class__ = Device
294+
self.__class__ = Device

0 commit comments

Comments
 (0)