OceanDirectLighthouse 3.1.3
OceanDirect Lighthouse Python API
LighthouseAPI.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2"""
3Created on Fri Mar 18 16:23:44 2024
4@author: Ocean Optics Inc.
5"""
6from typing import List
7from ctypes import c_bool, c_uint32, c_size_t, c_char, c_int32, c_uint16, c_bool, c_uint8, cdll, c_int, c_ushort, c_uint, c_long, create_string_buffer, c_ulong, c_ubyte, c_double, c_float, c_longlong, POINTER, byref
8from oceandirect.sdk_properties import oceandirect_dll
9from oceandirect.LighthouseTypes import OceanDirectError,SpectrumWithMetadata, SpectrumWithMetadata_C, LighthouseNetworkConfiguration, LighthouseNetworkConfiguration_C
10
11
13
14 class __LighthouseSingleton:
15 def __init__(self):
16 self.oceandirect = cdll.LoadLibrary(oceandirect_dll)
17 self.oceandirect.lh_initialize()
18
19 def __del__(self):
20 """
21 Closes all open devices and the odapi singleton.
22 """
23 try:
24 self.shutdown()
25 except Exception as e:
26 error_msg = "shutdown error"
27 raise OceanDirectError(-1, error_msg)
28
29 def shutdown(self) -> None:
30 """
31 Release any remaining used resources before shutting down the program.
32 """
33 self.oceandirect.lh_shutdown()
34
35 instance = None
36
37 def __init__(self):
38 """
39 Loads and initializes the OceanDirect dll and initializes internal variables.
40 """
41 if not LighthouseAPI.instance:
42 LighthouseAPI.instance = LighthouseAPI.__LighthouseSingleton()
43 #Dictionary with mapping id to spectrum length.
45
46 def __getattr__(self, name):
47 return getattr(self.instance, name)
48
49 def decode_error(self, errno: int, caller: str) -> str:
50 """
51 OceanDirectAPI returns an error code if something goes wrong. This function will decode
52 that error to a readable string.
53 @param errno: The error code generated by OceanDirect api.
54 :type errno: int
55 @param caller: The caller which produces the error code. Use for debugging purposes only.
56 :type caller: str
57 """
58 error_str_len = self.oceandirect.lh_get_error_string_length(errno)
59 errstr_cp = create_string_buffer(b'\000'*error_str_len)
60 self.oceandirect.lh_get_error_string(errno, errstr_cp, error_str_len)
61 errstr = ("%s errcode(%d): %s" % (caller, errno, errstr_cp.value.decode()))
62 return errstr
63
64 def get_api_version_numbers(self) -> tuple[int, int, int]:
65 """!
66 Return OceanDirect api version information.
67 @return An integer tuple of major, minor, and point value.
68 """
69 major = c_uint(0)
70 minor = c_uint(0)
71 point = c_uint(0)
72
73 self.oceandirect.lh_get_api_version_numbers.argtypes = [POINTER(c_uint), POINTER(c_uint), POINTER(c_uint)]
74 self.oceandirect.lh_get_api_version_numbers(byref(major), byref(minor), byref(point) )
75
76 return (major.value, minor.value, point.value)
77
78 def get_revision_firmware(self, device_id: int) -> str:
79 """!
80 Reads out the firmware revision from the device's internal memory if that feature is supported.
81 @param device_id The device id.
82 @return The firmware revision.
83 """
84 self.oceandirect.lh_get_revision_firmware.argtypes = [c_int32, POINTER(c_int32), POINTER(c_ubyte), c_size_t]
85 self.oceandirect.lh_get_revision_firmware.restype = c_size_t
86
87 err_cp = c_int32(0)
88 fw_rev_cp = (c_ubyte * 3)(0)
89 bytesRead = self.oceandirect.lh_get_revision_firmware(device_id, byref(err_cp), fw_rev_cp, 3)
90
91 if err_cp.value != 0:
92 error_msg = self.decode_error(err_cp.value, "lh_get_revision_firmware")
93 raise OceanDirectError(err_cp.value, error_msg)
94
95 fw_string = "{0}.{1}.{2}".format(int(fw_rev_cp[0]), int(fw_rev_cp[1]), int(fw_rev_cp[2]))
96 return fw_string
97
98 def get_revision_fpga(self, device_id: int) -> str:
99 """!
100 Reads out the FPGA revision from the device's internal memory if that feature is supported.
101 @param device_id The device id.
102 @return The fpga revision.
103 """
104 self.oceandirect.lh_get_revision_fpga.argtypes = [c_int32, POINTER(c_int32), POINTER(c_ubyte), c_size_t]
105 self.oceandirect.lh_get_revision_fpga.restype = c_size_t
106 err_cp = c_int32(0)
107 fpga_rev_cp = (c_ubyte * 3)(0)
108 bytesRead = self.oceandirect.lh_get_revision_fpga(device_id, byref(err_cp), fpga_rev_cp, 3)
109
110 if err_cp.value != 0:
111 error_msg = self.decode_error(err_cp.value, "lh_get_revision_fpga")
112 raise OceanDirectError(err_cp.value, error_msg)
113
114 fpga_rev_cp = "{0}.{1}.{2}".format(int(fpga_rev_cp[0]), int(fpga_rev_cp[1]), int(fpga_rev_cp[2]))
115 return fpga_rev_cp
116
117 def get_revision_system(self, device_id: int) -> str:
118 """!
119 Reads out the System revision from the device's internal memory if that feature is supported.
120 @param device_id The device id.
121 @return The system revision.
122 """
123 self.oceandirect.lh_get_revision_system.argtypes = [c_int32, POINTER(c_int32), POINTER(c_ubyte), c_size_t]
124 self.oceandirect.lh_get_revision_system.restype = c_size_t
125 err_cp = c_int32(0)
126 sys_rev_cp = (c_ubyte * 3)(0)
127 bytesRead = self.oceandirect.lh_get_revision_system(device_id, byref(err_cp), sys_rev_cp, 3)
128
129 if err_cp.value != 0:
130 error_msg = self.decode_error(err_cp.value, "get_revision_system")
131 raise OceanDirectError(err_cp.value, error_msg)
132
133 sys_rev_cp = "{0}.{1}.{2}".format(int(sys_rev_cp[0]), int(sys_rev_cp[1]), int(sys_rev_cp[2]))
134 return sys_rev_cp
135
136 #def add_network_device(self, ipAddressStr: str, deviceTypeStr: str) -> int:
137 # """!
138 # Manually create an instance of the network attached device and then open it using
139 # the openDevice() function. It is the responsiblitiy of the user to ensure that
140 # the device exist and configured properly. Note that this should only be done by one thread
141 # at a time. For multithreaded application this function must be synchronized.
142 # @param ipAddressStr The ip address of the device to be opened.
143 # @param deviceTypeStr The device type could be OceanFX or OceanHDX. This is case sensitive.
144 # """
145 # if not ipAddressStr or not deviceTypeStr:
146 # error_msg = self.decode_error(15, "add_network_device")
147 # raise OceanDirectError(15, error_msg)
148
149 # self.oceandirect.lh_add_network_devices.argtypes = [POINTER(c_char), POINTER(c_char), c_int32]
150 # self.oceandirect.lh_add_network_devices.restype = c_uint32
151 # err_cp = c_int32(0)
152 # devId = self.oceandirect.lh_add_network_devices(ipAddressStr.encode('utf-8'), deviceTypeStr.encode('utf-8'), byref(err_cp))
153
154 # if err_cp.value != 0:
155 # error_msg = self.decode_error(err_cp.value, "lh_add_network_devices")
156 # raise OceanDirectError(err_cp.value, error_msg)
157 # return devId
158
159 def shutdown(self) -> None:
160 """!
161 Closes the connection to OceanDirectAPI. This is the last to be called before the program terminates.
162 """
163 self.oceandirect.lh_shutdown()
164
165 def setMulticastMsgSendRetry(self, retryCount: int) -> None:
166 """!
167 Set the number of times to send multicast message for dynamic probing. This must be called before probing network devices.
168 @see find_devices()
169 @param retryCount The number of times to send messages.
170 """
171 self.oceandirect.lh_set_multicast_msg_send_retry.argtypes = [c_size_t]
172 self.oceandirect.lh_set_multicast_msg_send_retry(retryCount)
173
174 def setMulticastMsgResponseReadDelay(self, delayMs: int) -> None:
175 """!
176 Set the delay between reading multicast response. This must be called before probing network devices.
177 @see find_devices()
178 @param delayMs The delay in milliseconds before next read.
179 """
180 self.oceandirect.lh_set_multicast_msg_response_read_delay.argtypes = [c_size_t]
181 self.oceandirect.lh_set_multicast_msg_response_read_delay(delayMs)
182
183 def setMulticastMsgResponseReadRetry(self, retryCount: int) -> None:
184 """!
185 Set the number of times to read multicast message response. This must be called before probing network devices.
186 @see find_devices()
187 @param retryCount The number of times to try reading multicast response messages.
188 """
189 self.oceandirect.lh_set_multicast_msg_response_read_retry.argtypes = [c_size_t]
190 self.oceandirect.lh_set_multicast_msg_response_read_retry(retryCount)
191
192 def probe_all_devices(self) -> int:
193 """!
194 Finds all available Ocean devices by scanning on USB for devices with Ocean drivers, finding
195 devices that respond to UDP multicast, and also returning IDs for any TCP-enabled
196 devices that have been manually specified using addTCPDeviceLocation(). Note that this should
197 only be done by one thread at a time. For multithreaded application this function must be synchronized.
198 @return Number of devices found.
199 @see probe_usb_devices()
200 @see probe_network_devices()
201 @see open_device()
202 """
203 try:
204 self.oceandirect.lh_probe_all_devices.restype = c_size_t
205 return self.oceandirect.lh_probe_all_devices()
206 except Exception as e:
207 error_msg = self.decode_error(-1, "lh_probe_all_devices")
208 raise OceanDirectError(-1, error_msg)
209
210 def probe_usb_devices(self) -> int:
211 """!
212 Finds all available Ocean devices by scanning on USB for devices with Ocean drivers. Note that
213 this should only be done by one thread at a time. For multithreaded application this function
214 must be synchronized.
215 @return Number of devices found.
216 @see probe_network_devices()
217 @see probe_all_devices()
218 @see open_device()
219 """
220 try:
221 self.oceandirect.lh_probe_usb_devices.restype = c_size_t
222 return self.oceandirect.lh_probe_usb_devices()
223 except Exception as e:
224 error_msg = self.decode_error(-1, "lh_probe_usb_devices")
225 raise OceanDirectError(-1, error_msg)
226
227 def probe_network_devices(self) -> int:
228 """!
229 Finds all available Ocean devices by scanning the network for devices with Ocean drivers. Note that
230 this should only be done by one thread at a time. For multithreaded application this function
231 must be synchronized.
232 @return Number of devices found.
233 @see probe_usb_devices()
234 @see probe_all_devices()
235 @see open_device()
236 """
237 try:
238 self.oceandirect.lh_probe_network_devices.restype = c_size_t
239 return self.oceandirect.lh_probe_network_devices()
240 except Exception as e:
241 error_msg = self.decode_error(-1, "lh_probe_network_devices")
242 raise OceanDirectError(-1, error_msg)
243
244 def add_network_device(self, ipAddress: str, deviceType: str) -> int:
245 """!
246 Manually create an instance of the network attached device and then open it using the openDevice() function. It
247 is the responsiblitiy of the user to ensure that the device exist and configured properly. Note that this
248 should only be done by one thread at a time.
249 @param ipAddress The ip address as string (ex: "10.20.30.100" ) of the device to be opened.
250 @param deviceType The device type could be OceanFX or OceanHDX. This is case sensitive.
251 @return The device id.
252 @see open_device()
253 """
254 self.oceandirect.lh_add_network_devices.argtypes = [POINTER(c_char), POINTER(c_char), POINTER(c_int32)]
255 self.oceandirect.lh_add_network_devices.restype = c_uint32
256 deviceId = -1
257 err_cp = c_int32(0)
258
259 if not ipAddress or not deviceType:
260 #15 is an error code defined in OceanDirectAPIConstants.c
261 error_msg = self.decode_error(15, "add_network_device")
262 raise OceanDirectError(15, error_msg)
263
264 try:
265 deviceId = self.oceandirect.lh_add_network_devices(ipAddress.encode('utf-8'), deviceType.encode('utf-8'), byref(err_cp))
266 except Exception as e:
267 error_msg = self.decode_error(-1, "lh_add_network_devices")
268 raise OceanDirectError(-1, error_msg)
269
270 if err_cp.value != 0:
271 error_msg = self.decode_error(err_cp.value,"lh_add_network_devices")
272 raise OceanDirectError(err_cp.value, error_msg)
273 return deviceId
274
275 def get_number_devices(self) -> int:
276 """!
277 Returns the number of devices available. Note that this should only be done by
278 one thread at a time.
279 @return The number of connected(discovered) devices.
280 """
281 self.oceandirect.lh_get_number_of_device_ids.restype = c_size_t
282 num_devices = 0
283 try:
284 num_devices = self.oceandirect.lh_get_number_of_device_ids()
285 except Exception as e:
286 error_msg = self.decode_error(-1,"lh_get_number_of_device_ids")
287 raise OceanDirectError(-1, error_msg)
288 return num_devices
289
290 def get_network_device_ids(self) -> list[int]:
291 """!
292 Return a list of network device ids from devices that were probe. Note that
293 this should only be done by one thread at a time. For multithreaded application
294 this function must be synchronized.
295 @return List of network device id's.
296 """
297 self.oceandirect.lh_get_network_device_ids.argtypes = [POINTER(c_uint32), c_size_t]
298 self.oceandirect.lh_get_network_device_ids.restype = c_size_t
299 num_ids = self.get_number_devices()
300 ids_cp = (c_uint32 * num_ids)(0)
301 n = self.oceandirect.lh_get_network_device_ids(ids_cp, num_ids)
302
303 networkIds = list()
304 if n > 0:
305 networkIds = list(ids_cp)[0 : n]
306
307 return networkIds
308
309 def get_device_ids(self) -> list[int]:
310 """!
311 Return a list of device ids from devices that were both probe or manually added. Note that
312 this should only be done by one thread at a time. For multithreaded application this
313 function must be synchronized.
314 @return List of device id's.
315 """
316 self.oceandirect.lh_get_device_ids.argtypes = [POINTER(c_uint32), c_size_t]
317 self.oceandirect.lh_get_device_ids.restype = c_size_t
318 num_ids = self.get_number_devices()
319 ids_cp = (c_uint32 * num_ids)(0)
320 n = self.oceandirect.lh_get_device_ids(ids_cp, num_ids)
321
322 #print("PYTHON.get_device_ids(): num_ids = %d" % (num_ids))
323 #print("PYTHON.get_device_ids(): n = %d" % (n))
324 all_device_ids = list()
325 if n > 0:
326 all_device_ids = list(ids_cp)[0 : n]
327
328 return all_device_ids
329
330
331 def get_serial_number(self, device_id: int) -> str:
332 """!
333 Read the device serial number.
334 @param device_id The device id.
335 @return The serial number.
336 """
337 self.oceandirect.lh_get_serial_number.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
338 self.oceandirect.lh_get_serial_number.restype = c_size_t
339 err_cp = c_int32(0)
340 serial_cp = create_string_buffer(b'\000'*32)
341 self.oceandirect.lh_get_serial_number(device_id, byref(err_cp), serial_cp, 32)
342
343 if err_cp.value != 0:
344 error_msg = self.decode_error(err_cp.value, "lh_get_serial_number")
345 raise OceanDirectError(err_cp.value, error_msg)
346 return serial_cp.value.decode()
347
348 def get_device_type(self, device_id: int) -> int:
349 """!
350 Read the device type.
351 @return The device type.
352 """
353 device_type = create_string_buffer(b'\000' * 32)
354 err_cp = (c_long * 1)(0)
355 self.oceandirect.lh_get_device_type(device_id, err_cp, device_type, 32)
356
357 if err_cp[0] != 0:
358 error_msg = self.decode_error(err_cp[0], "lh_get_device_type")
359 raise OceanDirectError(err_cp[0], error_msg)
360 return device_type.value.decode()
361
362 def get_model(self, device_id: int) -> str:
363 """!
364 Read the correct spectrometer model name assigned.
365 @param device_id The device id.
366 @return The device model name.
367 """
368 self.oceandirect.lh_get_device_model.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
369 self.oceandirect.lh_get_device_model.restype = c_size_t
370 model_cp = create_string_buffer(b'\000'*32)
371 err_cp = c_int32(0)
372 self.oceandirect.lh_get_device_model(device_id, byref(err_cp), model_cp, 32)
373
374 if err_cp.value != 0:
375 error_msg = self.decode_error(err_cp.value, "lh_get_device_model")
376 raise OceanDirectError(err_cp.value, error_msg)
377 return model_cp.value.decode()
378
379
380 def open_device(self, device_id: int) -> None:
381 """!
382 Attach to a device discovered by probe_devices or get_device_ids. After the device is closed the
383 device_id becomes invalid. You need to call either find_devices()/find_usb_devices()/add_network_device()
384 and get_device_ids() in order to have a valid id before reopening the device again. For a network connected device this function
385 may return an error code if the device is not yet ready to accept incoming connection or the device is
386 unreachable. Note that this should only be done by one thread at a time. For multithreaded
387 application this function must be synchronized.
388 @param device_id The device id.
389 @return The device object.
390 @see find_devices()
391 @see find_usb_devices()
392 @see add_network_device()
393 @see close_device()
394 """
395 self.oceandirect.lh_open_device.argtypes = [c_uint32, POINTER(c_int32)]
396 err_cp = c_int32(0)
397 self.oceandirect.lh_open_device(device_id, byref(err_cp))
398
399 #NOTE:
400 #Error code definitions:
401 # 0 = success
402 # 10001 = beginning of warning message codes.
403 if err_cp.value > 0 and err_cp.value < 10001:
404
405 error_msg = self.decode_error(err_cp.value,"lh_open_device")
406 raise OceanDirectError(err_cp.value, error_msg)
407 else:
408 self.oceandirect.lh_get_spectrum_length.restype = c_size_t
409 self.oceandirect.lh_get_spectrum_length.argtypes = [c_uint32, POINTER(c_int32)]
410 err_cp = c_int32(0)
411 spectrum_length = self.oceandirect.lh_get_spectrum_length(device_id, byref(err_cp))
412
413 if err_cp.value != 0:
414 error_msg = self.decode_error(err_cp.value, "lh_get_spectrum_length")
415 raise OceanDirectError(err_cp.value, error_msg)
416 self.spectrum_length_map[device_id] = spectrum_length
417
418 def close_device(self, device_id: int) -> None:
419 """!
420 Detaches the device to free it up for other users. The device_id becomes invalid after closing the device.
421 Note that this should only be done by one thread at a time. For multithreaded application this function must be synchronized.
422 @param device_id The id of the device to be closed.
423 @see open_device()
424 """
425 self.oceandirect.lh_close_device.argtypes = [c_uint32, POINTER(c_int32)]
426 err_cp = c_int32(0)
427 self.oceandirect.lh_close_device(device_id, byref(err_cp))
428
429 if err_cp.value != 0:
430 error_msg = self.decode_error(err_cp.value,"lh_close_device")
431 raise OceanDirectError(err_cp.value, error_msg)
432
433
434
435 def set_scans_to_average(self, device_id: int, newScanToAverage: int) -> None:
436 """!
437 Sets the number of spectra to average.
438 @see get_scans_to_average()
439 @param device_id The device id.
440 @param newScanToAverage The number of spectra to average.
441 """
442 self.oceandirect.lh_set_scans_to_average.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
443 err_cp = c_int32(0)
444 self.oceandirect.lh_set_scans_to_average(device_id, byref(err_cp), newScanToAverage)
445
446 if err_cp.value != 0:
447 error_msg = self.decode_error(err_cp.value, "lh_set_scans_to_average")
448 raise OceanDirectError(err_cp.value, error_msg)
449
450 def get_scans_to_average(self, device_id: int) -> int:
451 """!
452 Gets the number of spectra to average.
453 @see set_scans_to_average()
454 @param device_id The device id.
455 @return The number of spectra to average.
456 """
457 self.oceandirect.lh_get_scans_to_average.restype = c_uint32
458 self.oceandirect.lh_get_scans_to_average.argtypes = [c_uint32, POINTER(c_int32)]
459 err_cp = c_int32(0)
460 scanToAverage = self.oceandirect.lh_get_scans_to_average(device_id, byref(err_cp))
461
462 if err_cp.value != 0:
463 error_msg = self.decode_error(err_cp.value, "lh_get_scans_to_average")
464 raise OceanDirectError(err_cp.value, error_msg)
465 return scanToAverage
466
467 def set_boxcar_width(self, device_id: int, newBoxcarWidth: int) -> None:
468 """!
469 Sets the boxcar width to average the spectral data.
470 @get_boxcar_width()
471 @param device_id The device id.
472 @param newBoxcarWidth The boxcar width.
473 """
474 self.oceandirect.lh_set_boxcar_width.argtypes = [c_uint32, POINTER(c_int32), c_uint16]
475 err_cp = c_int32(0)
476 self.oceandirect.lh_set_boxcar_width(device_id, byref(err_cp), c_uint16(newBoxcarWidth))
477
478 if err_cp.value != 0:
479 error_msg = self.decode_error(err_cp.value, "lh_set_boxcar_width")
480 raise OceanDirectError(err_cp.value, error_msg)
481
482 def get_boxcar_width(self, device_id: int) -> int:
483 """!
484 Read the current boxcar width setting.
485 @see set_boxcar_width()
486 @param device_id The device id.
487 @return The boxcar width.
488 """
489 self.oceandirect.lh_get_boxcar_width.restype = c_uint16
490 self.oceandirect.lh_get_boxcar_width.argtypes = [c_uint32, POINTER(c_int32)]
491 err_cp = c_int32(0)
492 boxcarWidth = self.oceandirect.lh_get_boxcar_width(device_id, byref(err_cp))
493
494 if err_cp.value != 0:
495 error_msg = self.decode_error(err_cp.value, "lh_get_boxcar_width")
496 raise OceanDirectError(err_cp.value, error_msg)
497 return boxcarWidth
498
499 def get_maximum_intensity(self, device_id: int) -> int:
500 """!
501 Returns the maximum pixel value the detector can read.
502 @param device_id The device id.
503 @return The maximum intensity.
504 """
505 self.oceandirect.lh_get_maximum_intensity.restype = c_uint32
506 self.oceandirect.lh_get_maximum_intensity.argtypes = [c_uint32, POINTER(c_int32)]
507 err_cp = c_int32(0)
508 max_intensity = self.oceandirect.lh_get_maximum_intensity(device_id, byref(err_cp))
509
510 if err_cp.value != 0:
511 error_msg = self.decode_error(err_cp.value, "lh_get_maximum_intensity")
512 raise OceanDirectError(err_cp.value, error_msg)
513 return max_intensity
514
515
516 def get_spectrum_length(self, device_id: int) -> int:
517 """!
518 Return a formatted spectrum length.
519 @param device_id The device id.
520 @return The formatted spectrum.
521 """
522 self.oceandirect.lh_get_spectrum_length.restype = c_size_t
523 self.oceandirect.lh_get_spectrum_length.argtypes = [c_uint32, POINTER(c_int32)]
524 err_cp = c_int32(0)
525 spectrumLength = self.oceandirect.lh_get_spectrum_length(device_id, byref(err_cp))
526
527 if err_cp.value != 0:
528 error_msg = self.decode_error(err_cp.value,"lh_get_spectrum_length")
529 raise OceanDirectError(err_cp.value, error_msg)
530 return spectrumLength
531
532 def get_spectrum(self, device_id: int) -> list[float]:
533 """!
534 Return a formatted spectrum.
535 @param device_id The device id.
536 @return The formatted spectrum.
537 """
538 self.oceandirect.lh_get_spectrum.restype = c_size_t
539 self.oceandirect.lh_get_spectrum.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
540 spd_c = (c_float * self.spectrum_length_map[device_id])(0)
541 err_cp = c_int32(0)
542 copiedCount = self.oceandirect.lh_get_spectrum(device_id, byref(err_cp), spd_c, self.spectrum_length_map[device_id])
543
544 if err_cp.value != 0:
545 error_msg = self.decode_error(err_cp.value,"lh_get_spectrum")
546 raise OceanDirectError(err_cp.value, error_msg)
547
548 if copiedCount == 0:
549 return list()
550 else:
551 return list(spd_c)
552
553 def get_spectrum_with_metadata(self, device_id: int) -> SpectrumWithMetadata:
554 """!
555 Returns spectra with metadata information. For older devices such as FX/HDX, read a maximum of 15
556 spectra from the data buffer. This function requires that both back to back scans and data buffer
557 be enabled. See "set_data_buffer_enable()" and "set_number_of_backtoback_scans()". For newer devices
558 such as Ocean SR2, you can call this function right away. See device manual if this command is supported.
559 @param device_id The device id.
560 @return The spectra with metadata info.
561 """
562 spectrum_length = self.spectrum_length_map[device_id]
563 err_cp = c_int32(0)
564 buffer = SpectrumWithMetadata_C(spectrum_length)
565
566 self.oceandirect.lh_get_spectrum_with_metadata.argtypes = [c_uint32, POINTER(c_int32), POINTER(SpectrumWithMetadata_C)]
567 self.oceandirect.lh_get_spectrum_with_metadata(device_id, byref(err_cp), byref(buffer))
568
569 if err_cp.value != 0:
570 error_msg = self.decode_error(err_cp.value, "lh_get_spectrum_with_metadata")
571 raise OceanDirectError(err_cp.value, error_msg)
572 return SpectrumWithMetadata(list(buffer.getSpectra()), buffer.tickCount)
573
574 def get_wavelengths(self, device_id: int) -> list[float]:
575 """!
576 This computes the wavelengths for the spectrometer and fills in the
577 provided array (up to the given length) with those values.
578 @param device_id The device id.
579 @return The wavelength values for the device in a python list.
580 """
581 self.oceandirect.lh_get_wavelengths.restype = c_size_t
582 self.oceandirect.lh_get_wavelengths.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
583 wl_c = (c_float * self.spectrum_length_map[device_id])()
584 err_cp = c_int32(0)
585 buffer_size = self.oceandirect.lh_get_wavelengths(device_id, byref(err_cp), wl_c, self.spectrum_length_map[device_id])
586
587 if err_cp.value != 0:
588 error_msg = self.decode_error(err_cp.value,"lh_get_wavelengths")
589 raise OceanDirectError(err_cp.value, error_msg)
590 return list(wl_c)
591
592 def get_minimum_integration_time(self, device_id: int) -> int:
593 """!
594 Returns the minimum allowable integration time on the device.
595 @param device_id The device id.
596 @return The minimum integration time.
597 """
598 self.oceandirect.lh_get_minimum_integration_time.restype = c_uint32
599 self.oceandirect.lh_get_minimum_integration_time.argtypes = [c_uint32, POINTER(c_int32)]
600 err_cp = c_int32(0)
601 int_time = self.oceandirect.lh_get_minimum_integration_time(device_id, byref(err_cp))
602
603 if err_cp.value != 0:
604 error_msg = self.decode_error(err_cp.value,"lh_get_minimum_integration_time")
605 raise OceanDirectError(err_cp.value, error_msg)
606 return int_time
607
608 def get_maximum_integration_time(self, device_id: int) -> int:
609 """!
610 Returns the maximum allowable integration time on the device.
611 @param device_id The device id.
612 @return The maximum integration time.
613 """
614 self.oceandirect.lh_get_maximum_integration_time.restype = c_uint32
615 self.oceandirect.lh_get_maximum_integration_time.argtypes = [c_uint32, POINTER(c_int32)]
616 err_cp = c_int32(0)
617 int_time = self.oceandirect.lh_get_maximum_integration_time(device_id, byref(err_cp))
618
619 if err_cp.value != 0:
620 error_msg = self.decode_error(err_cp.value, "lh_get_maximum_integration_time")
621 raise OceanDirectError(err_cp.value, error_msg)
622
623 #NOTE:
624 #The mask is needed in order to chop off some bytes that are set to 1 (it should be 0) which resulted into
625 #a bad value. This bug was reproduced on device that has very high integration time. This is a python bug.
626 return int_time & 0xFFFFFFFF
627
628 def get_minimum_averaging_integration_time(self, device_id: int) -> int:
629 """!
630 This function returns the smallest integration time setting, in microseconds, that is valid for the spectrometer.
631 NOTE: some devices that make use of onboard functionality to perform averaging have
632 a different, larger, minimum integration time for acquisition when averaging is enabled.
633 Refer to the documentation for your spectrometer to see if this is the case.
634 The minimum integration time when averaging is enabled can be determined
635 using odapi_get_minimum_averaging_integration_time_micros.
636 @param device_id The device id.
637 @return The minimum averaging integration time.
638 """
639 self.oceandirect.lh_get_minimum_averaging_integration_time.restype = c_uint32
640 self.oceandirect.lh_get_minimum_averaging_integration_time.argtypes = [c_uint32, POINTER(c_int32)]
641 err_cp = c_int32(0)
642 int_time = self.oceandirect.lh_get_minimum_averaging_integration_time(device_id, byref(err_cp))
643
644 if err_cp.value != 0:
645 error_msg = self.decode_error(err_cp.value,"lh_get_minimum_averaging_integration_time")
646 raise OceanDirectError(err_cp.value, error_msg)
647 return int_time
648
649
650 def set_integration_time(self, device_id: int, int_time: int) -> None:
651 """!
652 Sets the integration time on the device. This should be verified to be within range prior
653 to calling this function.
654 @see get_integration_time()
655 @param device_id The device id.
656 @param int_time The new integration time in microseconds. See device manual for supported integration increment.
657 """
658 self.oceandirect.lh_set_integration_time.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
659 err_cp = c_int32(0)
660 error_msg = self.oceandirect.lh_set_integration_time(device_id, byref(err_cp), c_uint32(int_time))
661
662 if err_cp.value != 0:
663 error_msg = self.decode_error(err_cp.value,"lh_set_integration_time")
664 raise OceanDirectError(err_cp.value, error_msg)
665
666 def get_integration_time(self, device_id: int) -> int:
667 """!
668 Returns the current integration time on the device.
669 @see set_integration_time()
670 @param device_id The device id.
671 @return The integration time in microsecond.
672 """
673 self.oceandirect.lh_get_integration_time.restype = c_uint32
674 self.oceandirect.lh_get_integration_time.argtypes = [c_uint32, POINTER(c_int32)]
675 err_cp = c_int32(0)
676 int_time = self.oceandirect.lh_get_integration_time(device_id, byref(err_cp))
677
678 if err_cp.value != 0:
679 error_msg = self.decode_error(err_cp.value, "lh_get_integration_time")
680 raise OceanDirectError(err_cp.value, error_msg)
681 #NOTE:
682 #The mask is needed in order to chop off some bytes that are set to 1 (it should be 0) which resulted into
683 #a bad value. This bug was reproduced on device that has very high integration time. This is a python bug.
684 return int_time & 0xFFFFFFFF
685
686 def get_integration_time_increment(self, device_id: int) -> int:
687 """!
688 Returns the integration time increment on the device.
689 @param device_id The device id.
690 @return The integration time increment in microsecond.
691 """
692 self.oceandirect.lh_get_integration_time_increment.restype = c_uint32
693 self.oceandirect.lh_get_integration_time_increment.argtypes = [c_uint32, POINTER(c_int32)]
694 err_cp = c_int32(0)
695 int_time = self.oceandirect.lh_get_integration_time_increment(device_id, byref(err_cp))
696
697 if err_cp.value != 0:
698 error_msg = self.decode_error(err_cp.value, "lh_get_integration_time_increment")
699 raise OceanDirectError(err_cp.value, error_msg)
700 return int_time
701
702 def set_trigger_mode(self, device_id: int, mode: int) -> None:
703 """!
704 Set the device trigger mode.
705 @see get_trigger_mode()
706 @param device_id The device id.
707 @param mode Trigger mode. See device manual for the supported trigger mode.
708 """
709 self.oceandirect.lh_set_trigger_mode.argtypes = [c_uint32, POINTER(c_int32), c_uint8]
710 err_cp = c_int32(0)
711 self.oceandirect.lh_set_trigger_mode(device_id, byref(err_cp), c_uint8(mode))
712
713 if err_cp.value != 0:
714 error_msg = self.decode_error(err_cp.value, "lh_set_trigger_mode")
715 raise OceanDirectError(err_cp.value, error_msg)
716
717 def get_trigger_mode(self, device_id: int) -> None:
718 """!
719 Returns the current trigger mode from the device. If this function is not
720 supported by the device then an exception will be thrown.
721 @see set_trigger_mode()
722 @param device_id The device id.
723 @return The trigger mode.
724 """
725 self.oceandirect.lh_get_trigger_mode.restype = c_uint8
726 self.oceandirect.lh_get_trigger_mode.argtypes = [c_uint32, POINTER(c_int32)]
727 err_cp = c_int32(0)
728 trigger = self.oceandirect.lh_get_trigger_mode(device_id, byref(err_cp))
729
730 if err_cp.value != 0:
731 error_msg = self.decode_error(err_cp.value, "lh_get_trigger_mode")
732 raise OceanDirectError(err_cp.value, error_msg)
733 return trigger
734
735
736 def get_active_pixel_count(self, device_id: int) -> int:
737 """!
738 This returns the number of pixels that are active.
739 @param device_id The device id.
740 @return The number of active pixels.
741 """
742 self.oceandirect.lh_get_active_pixel_count.restype = c_size_t
743 self.oceandirect.lh_get_active_pixel_count.argtypes = [c_uint32, POINTER(c_int32)]
744 err_cp = c_int32(0)
745 active_pixels = self.oceandirect.lh_get_active_pixel_count(device_id, byref(err_cp))
746
747 if err_cp.value != 0:
748 error_msg = self.decode_error(err_cp.value,"lh_get_active_pixel_count")
749 raise OceanDirectError(err_cp.value, error_msg)
750 return int(active_pixels)
751
752 def get_active_pixel_indices(self, device_id: int) -> list[int]:
753 """!
754 Read the active pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
755 If the device don't support this command then a non-zero error code will be returned.
756 @param device_id The device id.
757 @return A list of active pixel range.
758 """
759 active_pixel_count = self.get_active_pixel_count(device_id)
760
761 self.oceandirect.lh_get_active_pixel_indices.restype = c_size_t
762 self.oceandirect.lh_get_active_pixel_indices.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_uint16), c_size_t]
763 err_cp = c_int32(0)
764 range = (c_uint16 * active_pixel_count)(0)
765 elementCopied = self.oceandirect.lh_get_active_pixel_indices(device_id, byref(err_cp), range, active_pixel_count)
766
767 if err_cp.value != 0:
768 error_msg = self.decode_error(err_cp.value,"lh_get_active_pixel_indices")
769 raise OceanDirectError(err_cp.value, error_msg)
770 return list(range)[0:elementCopied]
771
772 def get_electric_dark_pixel_count(self, device_id: int) -> int:
773 """!
774 This returns the number of pixels that are electrically active but optically
775 masked (a.k.a. electric dark pixels). Note that not all detectors have optically masked pixels;
776 in that case, this function will return zero.
777 @param device_id The device id.
778 @return The number of electric dark pixels on the spectrometer.
779 """
780 self.oceandirect.lh_get_electric_dark_pixel_count.restype = c_size_t
781 self.oceandirect.lh_get_electric_dark_pixel_count.argtypes = [c_uint32, POINTER(c_int32)]
782 err_cp = c_int32(0)
783 num_electric_dark_pixels = self.oceandirect.lh_get_electric_dark_pixel_count(device_id, byref(err_cp))
784
785 if err_cp.value != 0:
786 error_msg = self.decode_error(err_cp.value,"lh_get_electric_dark_pixel_count")
787 raise OceanDirectError(err_cp.value, error_msg)
788 return num_electric_dark_pixels
789
790 def get_electric_dark_pixel_indices(self, device_id: int) -> list[int]:
791 """!
792 Read the optical dark pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
793 If the device don't support this command then a non-zero error code will be returned.
794 @param device_id The device id.
795 @return A list of optical dark pixel range.
796 """
797 electric_dark_pixel_count = self.get_electric_dark_pixel_count(device_id)
798 if electric_dark_pixel_count == 0:
799 return []
800
801 self.oceandirect.lh_get_electric_dark_pixel_indices.restype = c_size_t
802 self.oceandirect.lh_get_electric_dark_pixel_indices.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_uint16), c_size_t]
803 range = (c_uint16 * electric_dark_pixel_count)(0)
804 err_cp = c_int32(0)
805 elementCopied = self.oceandirect.lh_get_electric_dark_pixel_indices(device_id, byref(err_cp), range, electric_dark_pixel_count)
806
807 if err_cp.value != 0:
808 error_msg = self.decode_error(err_cp.value,"lh_get_electric_dark_pixel_indices")
809 raise OceanDirectError(err_cp.value, error_msg)
810 return list(range)[0:elementCopied]
811
812 def get_transition_pixel_count(self, device_id: int) -> int:
813 """!
814 This returns the number of pixels that are transition or bevel.
815 @param device_id The device id.
816 @return The number of active pixels.
817 """
818 self.oceandirect.lh_get_transition_pixel_count.restype = c_size_t
819 self.oceandirect.lh_get_transition_pixel_count.argtypes = [c_uint32, POINTER(c_int32)]
820 err_cp = c_int32(0)
821 bevel_pixels = self.oceandirect.lh_get_transition_pixel_count(device_id, byref(err_cp))
822
823 if err_cp.value != 0:
824 error_msg = self.decode_error(err_cp.value,"lh_get_transition_pixel_count")
825 raise OceanDirectError(err_cp.value, error_msg)
826 return int(bevel_pixels)
827
828 def get_transition_pixel_indices(self, device_id: int) -> list[int]:
829 """!
830 Read the transition pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
831 If the device don't support this command then a non-zero error code will be returned.
832 @param device_id The device id.
833 @return A list of transition pixel range.
834 """
835 transition_pixel_count = self.get_transition_pixel_count(device_id)
836 if transition_pixel_count == 0:
837 return []
838
839 self.oceandirect.lh_get_transition_pixel_indices.restype = c_size_t
840 self.oceandirect.lh_get_transition_pixel_indices.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_uint16), c_size_t]
841 range = (c_uint16 * transition_pixel_count)(0)
842 err_cp = c_int32(0)
843 elementCopied = self.oceandirect.lh_get_transition_pixel_indices(device_id, byref(err_cp), range, transition_pixel_count)
844
845 if err_cp.value != 0:
846 error_msg = self.decode_error(err_cp.value,"lh_get_transition_pixel_indices")
847 raise OceanDirectError(err_cp.value, error_msg)
848 return list(range)[0:elementCopied]
849
850 def get_bad_pixel_indices(self, device_id: int) -> list[int]:
851 """!
852 Read bad pixel indices from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
853 If the device don't support this command then a non-zero error code will be returned.
854 @param device_id The device id.
855 @return A list of bad pixel indices.
856 """
857 self.oceandirect.lh_get_bad_pixel_indices.restype = c_size_t
858 self.oceandirect.lh_get_bad_pixel_indices.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_uint16), c_size_t]
859 err_cp = c_int32(0)
860 range = (c_uint16 * 40)(0)
861 elementCopied = self.oceandirect.lh_get_bad_pixel_indices(device_id, byref(err_cp), range, 40)
862
863 if err_cp.value != 0:
864 error_msg = self.decode_error(err_cp.value,"lh_get_bad_pixel_indices")
865 raise OceanDirectError(err_cp.value, error_msg)
866 return list(range)[0:elementCopied]
867
868 def details(self, device_id: int) -> None:
869 """!
870 Prints the defined set of details about the device.
871 @param device_id The device id.
872 """
873 print("Device ID : %d" % device_id)
874 print("Serial Number: %s" % self.get_serial_number())
875 print("Model : %s" % self.get_model())
876 print("Number pixels: %d" % self.spectrum_length_map[device_id])
877
878
879
880 def set_acquisition_delay(self, device_id: int, delayMicrosecond: int) -> None:
881 """!
882 Set the acquisition delay in microseconds. This may also be referred to as the
883 trigger delay. In any event, it is the time between some event (such as a request
884 for data, or an external trigger pulse) and when data acquisition begins.
885 @see get_acquisition_delay()
886 @param device_id The device id.
887 @param delayMicrosecond The new delay to use in microseconds.
888 """
889 self.oceandirect.lh_set_acquisition_delay.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
890 err_cp = c_int32(0)
891 self.oceandirect.lh_set_acquisition_delay(device_id, byref(err_cp), c_uint32(delayMicrosecond))
892
893 if err_cp.value != 0:
894 error_msg = self.decode_error(err_cp.value, "lh_set_acquisition_delay")
895 raise OceanDirectError(err_cp.value, error_msg)
896
897 def get_acquisition_delay(self, device_id: int) -> int:
898 """!
899 Get the acquisition delay in microseconds. This may also be referred to as the
900 trigger delay. In any event, it is the time between some event (such as a request
901 for data, or an external trigger pulse) and when data acquisition begins.
902 Note that not all devices support reading this value back. In these cases, the
903 returned value will be the last value sent to odapi_adv_set_acquisition_delay_microseconds().
904 If no value has been set and the value cannot be read back, this function will
905 indicate an error.
906 @see set_acquisition_delay()
907 @param device_id The device id.
908 @return The acquisition delay in microseconds.
909 """
910 self.oceandirect.lh_get_acquisition_delay.restype = c_uint32
911 self.oceandirect.lh_get_acquisition_delay.argtypes = [c_uint32, POINTER(c_int32)]
912 err_cp = c_int32(0)
913 delay_microsecond = self.oceandirect.lh_get_acquisition_delay(device_id, byref(err_cp))
914
915 if err_cp.value != 0:
916 error_msg = self.decode_error(err_cp.value, "lh_get_acquisition_delay")
917 raise OceanDirectError(err_cp.value, error_msg)
918 return delay_microsecond
919
920 def get_acquisition_delay_increment(self, device_id: int) -> int:
921 """!
922 Get the allowed step size for the acquisition delay in microseconds.
923 @param device_id The device id.
924 @return The acquisition delay step size in microseconds.
925 """
926 self.oceandirect.lh_get_acquisition_delay_increment.restype = c_uint32
927 self.oceandirect.lh_get_acquisition_delay_increment.argtypes = [c_uint32, POINTER(c_int32)]
928 err_cp = c_int32(0)
929 delay_increment_us = self.oceandirect.lh_get_acquisition_delay_increment(device_id, byref(err_cp))
930
931 if err_cp.value != 0:
932 error_msg = self.decode_error(err_cp.value, "lh_get_acquisition_delay_increment")
933 raise OceanDirectError(err_cp.value, error_msg)
934 return delay_increment_us
935
936 def get_acquisition_delay_maximum(self, device_id: int) -> int:
937 """!
938 Get the maximum allowed acquisition delay in microseconds.
939 @param device_id The device id.
940 @return The maximum acquisition delay in microseconds.
941 """
942 self.oceandirect.lh_get_acquisition_delay_maximum.restype = c_uint32
943 self.oceandirect.lh_get_acquisition_delay_maximum.argtypes = [c_uint32, POINTER(c_int32)]
944 err_cp = c_int32(0)
945 delay_maximum_us = self.oceandirect.lh_get_acquisition_delay_maximum(device_id, err_cp)
946
947 if err_cp.value != 0:
948 error_msg = self.decode_error(err_cp.value, "lh_get_acquisition_delay_maximum")
949 raise OceanDirectError(err_cp.value, error_msg)
950 return delay_maximum_us
951
952 def get_acquisition_delay_minimum(self, device_id: int) -> int:
953 """!
954 Get the minimum allowed acquisition delay in microseconds.
955 @param device_id The device id.
956 @return The minimum acquisition delay in microseconds.
957 """
958 self.oceandirect.lh_get_acquisition_delay_minimum.restype = c_uint32
959 self.oceandirect.lh_get_acquisition_delay_minimum.argtypes = [c_uint32, POINTER(c_int32)]
960 err_cp = c_int32(0)
961 delay_minimum_us = self.oceandirect.lh_get_acquisition_delay_minimum(device_id, byref(err_cp))
962
963 if err_cp.value != 0:
964 error_msg = self.decode_error(err_cp.value, "lh_get_acquisition_delay_minimum")
965 raise OceanDirectError(err_cp.value, error_msg)
966 return delay_minimum_us
967
968
969 def set_stored_dark_spectrum(self, device_id: int, darkSpectrum: list[float]) -> None:
970 """!
971 Store a dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
972 @see getStoredDarkSpectrum.
973 @param device_id The device id.
974 @param darkSpectrum The buffer that contains the dark spectrum to be stored.
975 """
976 if len(darkSpectrum) == 0:
977 #code 10 means missing value
978 error_msg = self.decode_error(10,"set_stored_dark_spectrum")
979 raise OceanDirectError(10, error_msg)
980
981 self.oceandirect.lh_set_stored_dark_spectrum.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
982 err_cp = c_int32(0)
983 float_array_count = len(darkSpectrum)
984 float_array = (c_float * float_array_count)(0)
985 for x in range(float_array_count):
986 float_array[x] = darkSpectrum[x]
987
988 self.oceandirect.lh_set_stored_dark_spectrum(device_id, byref(err_cp), float_array, float_array_count)
989
990 if err_cp.value != 0:
991 error_msg = self.decode_error(err_cp.value,"lh_set_stored_dark_spectrum")
992 raise OceanDirectError(err_cp.value, error_msg)
993
994 def get_stored_dark_spectrum(self, device_id: int) -> list[float]:
995 """!
996 Retrieve a previously stored dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
997 @see setStoredDarkSpectrum.
998 @param device_id The device id.
999 @return The dark spectrum.
1000 """
1001 self.oceandirect.lh_get_stored_dark_spectrum.restype = c_size_t
1002 self.oceandirect.lh_get_stored_dark_spectrum.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
1003 float_array = (c_float * self.spectrum_length_map[device_id])()
1004 err_cp = c_int32(0)
1005
1006 self.oceandirect.lh_get_stored_dark_spectrum(device_id, byref(err_cp), float_array, self.spectrum_length_map[device_id])
1007 if err_cp.value != 0:
1008 error_msg = self.decode_error(err_cp.value,"lh_get_stored_dark_spectrum")
1009 raise OceanDirectError(err_cp.value, error_msg)
1010 return list(float_array)
1011
1012 def get_dark_corrected_spectrum1(self, device_id: int) -> list[float]:
1013 """!
1014 Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction then return the dark corrected spectrum.
1015 @see setStoredDarkSpectrum.
1016 @param device_id The device id.
1017 @return The dark corrected spectrum.
1018 """
1019 self.oceandirect.lh_get_dark_corrected_spectrum1.restype = c_size_t
1020 self.oceandirect.lh_get_dark_corrected_spectrum1.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
1021 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1022 err_cp = c_int32(0)
1023
1024 self.oceandirect.lh_get_dark_corrected_spectrum1(device_id, byref(err_cp), corrected_spectrum_array, self.spectrum_length_map[device_id])
1025 if err_cp.value != 0:
1026 error_msg = self.decode_error(err_cp.value,"lh_get_dark_corrected_spectrum1")
1027 raise OceanDirectError(err_cp.value, error_msg)
1028 return list(corrected_spectrum_array)
1029
1030 def dark_correct_spectrum1(self, device_id: int, illuminatedSpectrum: list[float]) -> list[float]:
1031 """!
1032 Dark correct a previously acquired illuminated spectrum and using a stored dark spectrum.
1033 @see set_stored_dark_spectrum
1034 @param device_id The device id.
1035 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1036 @return The dark corrected spectrum.
1037 """
1038 if len(illuminatedSpectrum) == 0:
1039 #code 10 means missing value
1040 error_msg = self.decode_error(10,"dark_correct_spectrum1")
1041 raise OceanDirectError(10, error_msg)
1042
1043 self.oceandirect.lh_dark_correct_spectrum1.restype = c_size_t
1044 self.oceandirect.lh_dark_correct_spectrum1.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1045 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1046 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1047 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)()
1048 err_cp = c_int32(0)
1049 for x in range(illuminated_spectrum_array_count):
1050 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1051
1052 self.oceandirect.lh_dark_correct_spectrum1(device_id, byref(err_cp), illuminated_spectrum_array, illuminated_spectrum_array_count,
1053 corrected_spectrum_array, self.spectrum_length_map[device_id])
1054 if err_cp.value != 0:
1055 error_msg = self.decode_error(err_cp.value,"lh_dark_correct_spectrum1")
1056 raise OceanDirectError(err_cp.value, error_msg)
1057 return list(corrected_spectrum_array)
1058
1059 def get_dark_corrected_spectrum2(self, device_id: int, darkSpectrum: list[float]) -> list[float]:
1060 """!
1061 Acquire a spectrum and use the supplied dark spectrum to perform a dark correction then return the dark corrected spectrum.
1062 @see set_stored_dark_spectrum.
1063 @param device_id The device id.
1064 @return The dark corrected spectrum.
1065 """
1066 self.oceandirect.lh_get_dark_corrected_spectrum2.restype = c_size_t
1067 self.oceandirect.lh_get_dark_corrected_spectrum2.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1068 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1069 dark_spectrum_array_count = len(darkSpectrum)
1070 dark_spectrum_array = (c_float * dark_spectrum_array_count)()
1071 err_cp = c_int32(0)
1072 for x in range(dark_spectrum_array_count):
1073 dark_spectrum_array[x] = darkSpectrum[x]
1074
1075 self.oceandirect.lh_get_dark_corrected_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1076 corrected_spectrum_array, self.spectrum_length_map[device_id])
1077 if err_cp.value != 0:
1078 error_msg = self.decode_error(err_cp.value,"lh_get_dark_corrected_spectrum2")
1079 raise OceanDirectError(err_cp.value, error_msg)
1080 return list(corrected_spectrum_array)
1081
1082 def dark_correct_spectrum2(self, device_id: int, darkSpectrum: list[float], illuminatedSpectrum: list[float]) -> list[float]:
1083 """!
1084 Dark correct a previously acquired illuminated spectrum and using a previously acquired dark spectrum.
1085 @param device_id The device id.
1086 @param darkSpectrum The buffer that contains the dark spectrum to be used for the dark correction.
1087 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1088 @return The dark corrected spectrum.
1089 """
1090 if len(darkSpectrum) == 0 or len(illuminatedSpectrum) == 0:
1091 #code 10 means missing value
1092 error_msg = self.decode_error(10,"dark_correct_spectrum2")
1093 raise OceanDirectError(10, error_msg)
1094
1095 self.oceandirect.lh_dark_correct_spectrum2.restype = c_size_t
1096 self.oceandirect.lh_dark_correct_spectrum2.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1097 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])()
1098 dark_spectrum_array_count = len(darkSpectrum)
1099 dark_spectrum_array = (c_float * dark_spectrum_array_count)()
1100 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1101 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)()
1102 err_cp = c_int32(0)
1103 for x in range(dark_spectrum_array_count):
1104 dark_spectrum_array[x] = darkSpectrum[x]
1105
1106 for x in range(illuminated_spectrum_array_count):
1107 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1108
1109 self.oceandirect.lh_dark_correct_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1110 illuminated_spectrum_array, illuminated_spectrum_array_count,
1111 corrected_spectrum_array, self.spectrum_length_map[device_id])
1112 if err_cp.value != 0:
1113 error_msg = self.decode_error(err_cp.value,"lh_dark_correct_spectrum2")
1114 raise OceanDirectError(err_cp.value, error_msg)
1115 return list(corrected_spectrum_array)
1116
1117 def get_nonlinearity_corrected_spectrum1(self, device_id: int) -> list[float]:
1118 """!
1119 Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction
1120 followed by a nonlinearity correction then return the nonlinearity corrected spectrum.
1121 @see setStoredDarkSpectrum.
1122 @param device_id The device id.
1123 @return The nonlinearity corrected spectrum.
1124 """
1125 self.oceandirect.lh_get_nonlinearity_corrected_spectrum1.restype = c_size_t
1126 self.oceandirect.lh_get_nonlinearity_corrected_spectrum1.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
1127 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])()
1128 err_cp = c_int32(0)
1129
1130 self.oceandirect.lh_get_nonlinearity_corrected_spectrum1(device_id, byref(err_cp), corrected_spectrum_array, self.spectrum_length_map[device_id])
1131 if err_cp.value != 0:
1132 error_msg = self.decode_error(err_cp.value,"lh_get_nonlinearity_corrected_spectrum1")
1133 raise OceanDirectError(err_cp.value, error_msg)
1134 return list(corrected_spectrum_array)
1135
1136 def nonlinearity_correct_spectrum1(self, device_id: int, illuminatedSpectrum: list[float]) -> list[float]:
1137 """!
1138 Nonlinearity correct a previously acquired illuminated spectrum using a stored dark spectrum.
1139 This function performs a dark correction using a previously stored dark spectrum prior to performing the nonlinearity correction.
1140 @see set_stored_dark_spectrum
1141 @param device_id The device id.
1142 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1143 @return The nonlinearity corrected spectrum.
1144 """
1145 if len(illuminatedSpectrum) == 0:
1146 #code 10 means missing value
1147 error_msg = self.decode_error(10,"nonlinearity_correct_spectrum1")
1148 raise OceanDirectError(10, error_msg)
1149
1150 self.oceandirect.lh_nonlinearity_correct_spectrum1.restype = c_size_t
1151 self.oceandirect.lh_nonlinearity_correct_spectrum1.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1152 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1153 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1154 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)(0)
1155 err_cp = c_int32(0)
1156 for x in range(illuminated_spectrum_array_count):
1157 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1158
1159 self.oceandirect.lh_nonlinearity_correct_spectrum1(device_id, byref(err_cp), illuminated_spectrum_array, illuminated_spectrum_array_count,
1160 corrected_spectrum_array, self.spectrum_length_map[device_id])
1161 if err_cp.value != 0:
1162 error_msg = self.decode_error(err_cp.value,"lh_nonlinearity_correct_spectrum1")
1163 raise OceanDirectError(err_cp.value, error_msg)
1164 return list(corrected_spectrum_array)
1165
1166 def get_nonlinearity_corrected_spectrum2(self, device_id: int, darkSpectrum: list[float]) -> list[float]:
1167 """!
1168 Acquire a spectrum and use the supplied dark spectrum to perform a dark correction
1169 followed by the nonlinearity correction then return the nonlinearity corrected spectrum.
1170 @see set_stored_dark_spectrum.
1171 @param device_id The device id.
1172 @return The nonlinearity corrected spectrum.
1173 """
1174 if len(darkSpectrum) == 0:
1175 #code 10 means missing value
1176 error_msg = self.decode_error(10,"get_nonlinearity_corrected_spectrum2")
1177 raise OceanDirectError(10, error_msg)
1178
1179 self.oceandirect.lh_get_nonlinearity_corrected_spectrum2.restype = c_size_t
1180 self.oceandirect.lh_get_nonlinearity_corrected_spectrum2.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1181 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1182 dark_spectrum_array_count = len(darkSpectrum)
1183 dark_spectrum_array = (c_float * dark_spectrum_array_count)(0)
1184 err_cp = c_int32(0)
1185 for x in range(dark_spectrum_array_count):
1186 dark_spectrum_array[x] = darkSpectrum[x]
1187
1188 self.oceandirect.lh_get_nonlinearity_corrected_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1189 corrected_spectrum_array, self.spectrum_length_map[device_id])
1190 if err_cp.value != 0:
1191 error_msg = self.decode_error(err_cp.value,"lh_get_nonlinearity_corrected_spectrum2")
1192 raise OceanDirectError(err_cp.value, error_msg)
1193 return list(corrected_spectrum_array)
1194
1195 def nonlinearity_correct_spectrum2(self, device_id: int, darkSpectrum: list[float], illuminatedSpectrum: list[float]) -> list[float]:
1196 """!
1197 Nonlinearity correct a previously acquired illuminated spectrum after dark correction using a previously acquired dark spectrum.
1198 @param device_id The device id.
1199 @param darkSpectrum The buffer that contains the dark spectrum to be used prior to the nonlinearity correction.
1200 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1201 @return The nonlinearity corrected spectrum.
1202 """
1203 if len(darkSpectrum) == 0 or len(illuminatedSpectrum) == 0:
1204 #code 10 means missing value
1205 error_msg = self.decode_error(10,"nonlinearity_correct_spectrum2")
1206 raise OceanDirectError(10, error_msg)
1207
1208 self.oceandirect.lh_nonlinearity_correct_spectrum2.restype = c_size_t
1209 self.oceandirect.lh_nonlinearity_correct_spectrum2.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, POINTER(c_float), c_size_t, POINTER(c_float), c_size_t]
1210 corrected_spectrum_array = (c_float * self.spectrum_length_map[device_id])(0)
1211 dark_spectrum_array_count = len(darkSpectrum)
1212 dark_spectrum_array = (c_float * dark_spectrum_array_count)()
1213 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1214 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)()
1215 err_cp = c_int32(0)
1216
1217 for x in range(dark_spectrum_array_count):
1218 dark_spectrum_array[x] = darkSpectrum[x]
1219
1220 for x in range(illuminated_spectrum_array_count):
1221 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1222
1223 self.oceandirect.lh_nonlinearity_correct_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1224 illuminated_spectrum_array, illuminated_spectrum_array_count,
1225 corrected_spectrum_array, self.spectrum_length_map[device_id])
1226 if err_cp.value != 0:
1227 error_msg = self.decode_error(err_cp.value,"lh_nonlinearity_correct_spectrum2")
1228 raise OceanDirectError(err_cp.value, error_msg)
1229 return list(corrected_spectrum_array)
1230
1231 def boxcar_correct_spectrum(self, device_id: int, illuminatedSpectrum: list[float], boxcarWidth: int) -> list[float]:
1232 """!
1233 Apply a boxcar correction on the given illuminated spectrum.
1234 @param device_id The device id.
1235 @param illuminatedSpectrum The spectrum that will be boxcar corrected.
1236 @param boxcarWidth The boxcar width.
1237 @return The boxcar corrected spectrum.
1238 """
1239 if len(illuminatedSpectrum) == 0:
1240 #code 10 means missing value
1241 error_msg = self.decode_error(10,"boxcar_correct_spectrum")
1242 raise OceanDirectError(10, error_msg)
1243
1244 self.oceandirect.lh_boxcar_correct_spectrum.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t, c_size_t, POINTER(c_float), c_size_t]
1245 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1246 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)()
1247 boxcar_corrected_spectrum_array = (c_float * illuminated_spectrum_array_count)(0)
1248 err_cp = c_int32(0)
1249
1250 for x in range(illuminated_spectrum_array_count):
1251 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1252
1253 self.oceandirect.lh_boxcar_correct_spectrum(device_id, byref(err_cp),
1254 illuminated_spectrum_array, illuminated_spectrum_array_count,
1255 boxcarWidth, boxcar_corrected_spectrum_array, illuminated_spectrum_array_count)
1256
1257 if err_cp.value != 0:
1258 error_msg = self.decode_error(err_cp.value,"lh_boxcar_correct_spectrum")
1259 raise OceanDirectError(err_cp.value, error_msg)
1260 return list(boxcar_corrected_spectrum_array)
1261
1262 def set_electric_dark_correction_state(self, device_id: int, isEnabled: bool) -> None:
1263 """!
1264 Enable or disable an electric dark correction.
1265 @see get_electric_dark_correction_state()
1266 @param device_id The device id.
1267 @param isEnabled True to enable electric dark correction otherwise it's False.
1268 """
1269 self.oceandirect.lh_set_electric_dark_correction_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1270 err_cp = c_int32(0)
1271 self.oceandirect.lh_set_electric_dark_correction_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1272
1273 if err_cp.value != 0:
1274 error_msg = self.decode_error(err_cp.value,"lh_set_electric_dark_correction_state")
1275 raise OceanDirectError(err_cp.value, error_msg)
1276
1277 def get_electric_dark_correction_state(self, device_id: int) -> bool:
1278 """!
1279 Return electric dark correction usage.
1280 @see set_electric_dark_correction_state()
1281 @param device_id The device id.
1282 @return True if electric dark connection is applied otherwise it's False.
1283 """
1284 self.oceandirect.lh_get_electric_dark_correction_state.restype = c_ubyte
1285 self.oceandirect.lh_get_electric_dark_correction_state.argtypes = [c_uint32, POINTER(c_int32)]
1286 err_cp = c_int32(0)
1287 correctionState = self.oceandirect.lh_get_electric_dark_correction_state(device_id, byref(err_cp))
1288
1289 if err_cp.value != 0:
1290 error_msg = self.decode_error(err_cp.value,"lh_get_electric_dark_correction_state")
1291 raise OceanDirectError(err_cp.value, error_msg)
1292 return bool(c_ubyte(correctionState))
1293
1294 def set_nonlinearity_correction_state(self, device_id: int, isEnabled: bool) -> None:
1295 """!
1296 Enable or disable nonlinearity correction.
1297 @see get_nonlinearity_correction_state()
1298 @param device_id The device id.
1299 @param isEnabled True to enable nonlinearity correction otherwise it's False.
1300 """
1301 self.oceandirect.lh_set_nonlinearity_correction_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1302 err_cp = c_int32(0)
1303 self.oceandirect.lh_set_nonlinearity_correction_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1304
1305 if err_cp.value != 0:
1306 error_msg = self.decode_error(err_cp.value,"lh_set_nonlinearity_correction_state")
1307 raise OceanDirectError(err_cp.value, error_msg)
1308
1309 def get_nonlinearity_correction_state(self, device_id: int) -> bool:
1310 """!
1311 Return nonlinearity correction usage.
1312 @see set_nonlinearity_correction_state()
1313 @param device_id The device id.
1314 @return True if nonlinearity connection is applied otherwise it's False.
1315 """
1316 self.oceandirect.lh_get_nonlinearity_correction_state.restype = c_ubyte
1317 self.oceandirect.lh_get_nonlinearity_correction_state.argtypes = [c_uint32, POINTER(c_int32)]
1318 err_cp = c_int32(0)
1319 correctionState = self.oceandirect.lh_get_nonlinearity_correction_state(device_id, byref(err_cp))
1320
1321 if err_cp.value != 0:
1322 error_msg = self.decode_error(err_cp.value,"lh_get_nonlinearity_correction_state")
1323 raise OceanDirectError(err_cp.value, error_msg)
1324 return bool(c_ubyte(correctionState))
1325
1326 def set_lamp_state(self, device_id: int, enable: bool) -> None:
1327 """!
1328 Enable or disable the lamp.
1329 @see get_lamp_state()
1330 @param device_id The device id.
1331 @param enable True to enable lamp, False otherwise.
1332 """
1333 self.oceandirect.lh_set_lamp_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1334 err_cp = c_int32(0)
1335 self.oceandirect.lh_set_lamp_state(device_id, byref(err_cp), c_ubyte(enable))
1336
1337 if err_cp.value != 0:
1338 error_msg = self.decode_error(err_cp.value,"lh_set_lamp_state")
1339 raise OceanDirectError(err_cp.value, error_msg)
1340
1341 def get_lamp_state(self, device_id: int) -> bool:
1342 """!
1343 Return the lamp state.
1344 @see set_lamp_state()
1345 @param device_id The device id.
1346 @return True if lamp is ON otherwise False.
1347 """
1348 self.oceandirect.lh_get_lamp_state.restype = c_ubyte
1349 self.oceandirect.lh_get_lamp_state.argtypes = [c_uint32, POINTER(c_int32)]
1350 err_cp = c_int32(0)
1351 enabled = self.oceandirect.lh_get_lamp_state(device_id, byref(err_cp))
1352
1353 if err_cp.value != 0:
1354 error_msg = self.decode_error(err_cp.value,"lh_get_lamp_state")
1355 raise OceanDirectError(err_cp.value, error_msg)
1356 return bool(c_ubyte(enabled))
1357
1358 def set_shutter_state(self, device_id: int, shutterState: bool) -> None:
1359 """!
1360 This function will open or close the shutter on the spectrometer.
1361 @see get_shutter_state()
1362 @param device_id The device id.
1363 @param shutterState True will open the shutter. False will then close the shutter.
1364 """
1365 self.oceandirect.lh_set_shutter_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1366 err_cp = c_int32(0)
1367 enabled = self.oceandirect.lh_set_shutter_state(device_id, byref(err_cp), c_ubyte(shutterState))
1368
1369 if err_cp.value != 0:
1370 error_msg = self.decode_error(err_cp.value,"lh_set_shutter_state")
1371 raise OceanDirectError(err_cp.value, error_msg)
1372
1373 def get_shutter_state(self, device_id: int) -> None:
1374 """!
1375 This function returns the shutter state of the spectrometer.
1376 @see set_shutter_state()
1377 @param device_id The device id.
1378 @return True if the shutter is opened otherwise returns False.
1379 """
1380 self.oceandirect.lh_get_shutter_state.restype = c_ubyte
1381 self.oceandirect.lh_get_shutter_state.argtypes = [c_uint32, POINTER(c_int32)]
1382 err_cp = c_int32(0)
1383 shutterState = self.oceandirect.lh_get_shutter_state(device_id, byref(err_cp))
1384
1385 if err_cp.value != 0:
1386 error_msg = self.decode_error(err_cp.value,"lh_get_shutter_state")
1387 raise OceanDirectError(err_cp.value, error_msg)
1388 return bool(c_ubyte(shutterState))
1389
1390 def get_wavelength_coefficients(self, device_id: int) -> list[float]:
1391 """!
1392 Read the wavelength coefficients from the device. This command is being used in OBP-2.0 enabled devices.
1393 If the device don't support this command then a non-zero error code will be returned.
1394 @param device_id The device id.
1395 @return List of wavelength coefficient values.
1396 """
1397 self.oceandirect.lh_get_wavelength_coefficients.restype = c_size_t
1398 self.oceandirect.lh_get_wavelength_coefficients.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
1399 wl_c = (c_float * 20)(0)
1400 err_cp = c_int32(0)
1401 buffer_size = self.oceandirect.lh_get_wavelength_coefficients(device_id, byref(err_cp), wl_c, 20)
1402
1403 if err_cp.value != 0:
1404 error_msg = self.decode_error(err_cp.value,"lh_get_wavelength_coefficients")
1405 raise OceanDirectError(err_cp.value, error_msg)
1406 return list(wl_c)[:buffer_size]
1407
1408 def get_nonlinearity_coefficients(self, device_id: int) -> list[float]:
1409 """!
1410 Read the nonlinearity coefficients stored in the device. This command is being used in OBP-2.0 enabled devices.
1411 If the device don't support this command then a non-zero error code will be returned.
1412 @param device_id The device id.
1413 @return A list of nonlinearity coefficients.
1414 """
1415 self.oceandirect.lh_get_nonlinearity_coefficients.restype = c_size_t
1416 self.oceandirect.lh_get_nonlinearity_coefficients.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
1417 nl_coeff = (c_float * 20)(0)
1418 err_cp = c_int32(0)
1419 buffer_size = self.oceandirect.lh_get_nonlinearity_coefficients(device_id, byref(err_cp), nl_coeff, 20)
1420
1421 if err_cp.value != 0:
1422 error_msg = self.decode_error(err_cp.value,"lh_get_nonlinearity_coefficients")
1423 raise OceanDirectError(err_cp.value, error_msg)
1424 return list(nl_coeff)[:buffer_size]
1425
1426
1427 def set_tec_temperature_setpoint(self, device_id: int, temp_C: float) -> None:
1428 """!
1429 Apply the setpoint temperature (Celsius) in the thermo-electric cooler. If this function is not
1430 supported by the device then an exception will be thrown.
1431 @see get_tec_temperature_setpoint()
1432 @param device_id The device id.
1433 @param temp_C The setpoint temperature in celsius.
1434 """
1435 self.oceandirect.lh_set_tec_temperature_setpoint.argtypes = [c_uint32, POINTER(c_int32), c_float]
1436 err_cp = c_int32(0)
1437 temp = self.oceandirect.lh_set_tec_temperature_setpoint(device_id, byref(err_cp), c_float(temp_C))
1438
1439 if err_cp.value != 0:
1440 error_msg = self.decode_error(err_cp.value,"lh_set_tec_temperature_setpoint")
1441 raise OceanDirectError(err_cp.value, error_msg)
1442
1443 def get_tec_temperature_setpoint(self, device_id: int) -> float:
1444 """!
1445 Read the set point temperature of the thermo-electric cooler. If this function is not supported
1446 by the device then an exception will be thrown.
1447 @see set_tec_temperature_setpoint()
1448 @param device_id The device id.
1449 @return The temperature value in celsius.
1450 """
1451 self.oceandirect.lh_get_tec_temperature_setpoint.restype = c_float
1452 self.oceandirect.lh_get_tec_temperature_setpoint.argtypes = [c_uint32, POINTER(c_int32)]
1453 err_cp = c_int32(0)
1454 temp = self.oceandirect.lh_get_tec_temperature_setpoint(device_id, byref(err_cp))
1455
1456 if err_cp.value != 0:
1457 error_msg = self.decode_error(err_cp.value, "lh_get_tec_temperature_setpoint")
1458 raise OceanDirectError(err_cp.value, error_msg)
1459 return temp
1460
1461 def get_tec_temperature(self, device_id: int) -> float:
1462 """!
1463 Returns the temperature reading (celsius) of a detector thermistor. This is equivalent to calling
1464 get_temperature(index) where the "index" is a detector thermistor index. If this function is not
1465 supported by the device then an exception will be thrown.
1466 @param device_id The device id.
1467 @return The temperature in degrees celsius.
1468 """
1469 self.oceandirect.lh_get_tec_temperature.restype = c_float
1470 self.oceandirect.lh_get_tec_temperature.argtypes = [c_uint32, POINTER(c_int32)]
1471 err_cp = c_int32(0)
1472 temp = self.oceandirect.lh_get_tec_temperature(device_id, byref(err_cp))
1473
1474 if err_cp.value != 0:
1475 error_msg = self.decode_error(err_cp.value,"lh_get_tec_temperature")
1476 raise OceanDirectError(err_cp.value, error_msg)
1477 return temp
1478
1479 def get_tec_stable(self, device_id: int) -> bool:
1480 """!
1481 Returns the state of thermo-electric cooler temperature on whether it reached the stable
1482 temperature or not. If this function is not supported by the device then an exception will be thrown.
1483 @param device_id The device id.
1484 @return True if it's stable, False otherwise.
1485 """
1486 self.oceandirect.lh_get_tec_stable.restype = c_bool
1487 self.oceandirect.lh_get_tec_stable.argtypes = [c_uint32, POINTER(c_int32)]
1488 err_cp = c_int32(0)
1489 enabled = self.oceandirect.lh_get_tec_stable(device_id, byref(err_cp))
1490
1491 if err_cp.value != 0:
1492 error_msg = self.decode_error(err_cp.value, "lh_get_tec_stable")
1493 raise OceanDirectError(err_cp.value, error_msg)
1494 return bool(enabled)
1495
1496
1497 def set_single_strobe_state(self, device_id: int, enable: bool) -> None:
1498 """!
1499 Set the enable status of the single strobe signal. Note that on some
1500 devices the enable control is shared with other signals (e.g. lamp
1501 enable and continuous strobe) so this may have some side-effects and
1502 changing those features may affect the single strobe as well.
1503 @see get_single_strobe_state()
1504 @param device_id The device id.
1505 @param enable True to enable single strobe otherwise use False.
1506 """
1507 self.oceandirect.lh_set_single_strobe_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1508 err_cp = c_int32(0)
1509 self.oceandirect.lh_set_single_strobe_state(device_id, byref(err_cp), c_ubyte(enable))
1510
1511 if err_cp.value != 0:
1512 error_msg = self.decode_error(err_cp.value, "lh_set_single_strobe_state")
1513 raise OceanDirectError(err_cp.value, error_msg)
1514
1515 def get_single_strobe_state(self, device_id: int) -> bool:
1516 """!
1517 Get the enable status of the single strobe signal. Note that on some
1518 devices the enable control is shared with other signals (e.g. lamp
1519 enable and continuous strobe) so this may have some side-effects and
1520 changing those features may affect the single strobe as well.
1521 @see set_single_strobe_state()
1522 @param device_id The device id.
1523 @return True if single strobe is enabled otherwise it's False.
1524 """
1525 self.oceandirect.lh_get_single_strobe_state.restype = c_ubyte
1526 self.oceandirect.lh_get_single_strobe_state.argtypes = [c_uint32, POINTER(c_int32)]
1527 err_cp = c_int32(0)
1528 enable = self.oceandirect.lh_get_single_strobe_state(device_id, byref(err_cp))
1529
1530 if err_cp.value != 0:
1531 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_state")
1532 raise OceanDirectError(err_cp.value, error_msg)
1533 return bool(c_ubyte(enable))
1534
1535 def set_single_strobe_delay(self, device_id: int, delayMicrosecond: int) -> None:
1536 """!
1537 Set the amount of time, in microseconds, that should elapse after a starting event before
1538 the single strobe should have a rising edge.
1539 @see get_single_strobe_delay()
1540 @param device_id The device id.
1541 @param delayMicrosecond The delay, in microseconds, that the single strobe should wait before
1542 the pulse begins.
1543 """
1544 self.oceandirect.lh_set_single_strobe_delay.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1545 err_cp = c_int32(0)
1546 self.oceandirect.lh_set_single_strobe_delay(device_id, byref(err_cp), c_uint32(delayMicrosecond))
1547
1548 if err_cp.value != 0:
1549 error_msg = self.decode_error(err_cp.value, "lh_set_single_strobe_delay")
1550 raise OceanDirectError(err_cp.value, error_msg)
1551
1552 def get_single_strobe_delay(self, device_id: int) -> int:
1553 """!
1554 Get the amount of time, in microseconds, that should elapse after a starting event before
1555 the single strobe should have a rising edge
1556 @see set_single_strobe_delay()
1557 @param device_id The device id.
1558 @return The delay in microseconds.
1559 """
1560 self.oceandirect.lh_get_single_strobe_delay.restype = c_uint32
1561 self.oceandirect.lh_get_single_strobe_delay.argtypes = [c_uint32, POINTER(c_int32)]
1562 err_cp = c_int32(0)
1563 delay_us = self.oceandirect.lh_get_single_strobe_delay(device_id, byref(err_cp))
1564
1565 if err_cp.value != 0:
1566 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_delay")
1567 raise OceanDirectError(err_cp.value, error_msg)
1568 return delay_us
1569
1570 def set_single_strobe_width(self, device_id: int, widthMicrosecond: int) -> None:
1571 """!
1572 Set the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1573 @see get_single_strobe_width()
1574 @param device_id The device id.
1575 @param widthMicrosecond The duration, in microseconds, of the single strobe pulse after
1576 the rising edge occurs. Once this duration elapses, a falling edge
1577 will be generated.
1578 """
1579 self.oceandirect.lh_set_single_strobe_width.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1580 err_cp = c_int32(0)
1581 self.oceandirect.lh_set_single_strobe_width(device_id, byref(err_cp), c_uint32(widthMicrosecond))
1582
1583 if err_cp.value != 0:
1584 error_msg = self.decode_error(err_cp.value, "lh_set_single_strobe_width")
1585 raise OceanDirectError(err_cp.value, error_msg)
1586
1587 def get_single_strobe_width(self, device_id: int) -> int:
1588 """!
1589 Get the amount of time, in microseconds, that the single strobe pulse
1590 should remain high after it begins.
1591 @see set_single_strobe_width()
1592 @param device_id The device id.
1593 @return The pulse width in microseconds.
1594 """
1595 self.oceandirect.lh_get_single_strobe_width.restype = c_uint32
1596 self.oceandirect.lh_get_single_strobe_width.argtypes = [c_uint32, POINTER(c_int32)]
1597 err_cp = c_int32(0)
1598 width_us = self.oceandirect.lh_get_single_strobe_width(device_id, err_cp)
1599
1600 if err_cp.value != 0:
1601 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_width")
1602 raise OceanDirectError(err_cp.value, error_msg)
1603 return width_us
1604
1605 def get_single_strobe_delay_minimum(self, device_id: int) -> int:
1606 """!
1607 Get the minimum amount of time, in microseconds, that should elapse after
1608 a starting event before the single strobe should have a rising edge.
1609 @param device_id The device id.
1610 @return The minimum delay in microseconds.
1611 """
1612 self.oceandirect.lh_get_single_strobe_delay_minimum.restype = c_uint32
1613 self.oceandirect.lh_get_single_strobe_delay_minimum.argtypes = [c_uint32, POINTER(c_int32)]
1614 err_cp = c_int32(0)
1615 minimum_us = self.oceandirect.lh_get_single_strobe_delay_minimum(device_id, byref(err_cp))
1616
1617 if err_cp.value != 0:
1618 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_delay_minimum")
1619 raise OceanDirectError(err_cp.value, error_msg)
1620 return minimum_us
1621
1622 def get_single_strobe_delay_maximum(self, device_id: int) -> int:
1623 """!
1624 Get the maximum amount of time, in microseconds, that should elapse after
1625 a starting event before the single strobe should have a rising edge.
1626 @param device_id The device id.
1627 @return The maximum delay in microseconds.
1628 """
1629 self.oceandirect.lh_get_single_strobe_delay_maximum.restype = c_uint32
1630 self.oceandirect.lh_get_single_strobe_delay_maximum.argtypes = [c_uint32, POINTER(c_int32)]
1631 err_cp = c_int32(0)
1632 maximum_us = self.oceandirect.lh_get_single_strobe_delay_maximum(device_id, byref(err_cp))
1633
1634 if err_cp.value != 0:
1635 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_delay_maximum")
1636 raise OceanDirectError(err_cp.value, error_msg)
1637 return maximum_us
1638
1639 def get_single_strobe_delay_increment(self, device_id: int) -> int:
1640 """!
1641 Gets the single strobe delay increment in microseconds.
1642 @param device_id The device id.
1643 @return The delay increment.
1644 """
1645 self.oceandirect.lh_get_single_strobe_delay_increment.restype = c_uint32
1646 self.oceandirect.lh_get_single_strobe_delay_increment.argtypes = [c_uint32, POINTER(c_int32)]
1647 err_cp = c_int32(0)
1648 delay_increment = self.oceandirect.lh_get_single_strobe_delay_increment(device_id, byref(err_cp))
1649
1650 if err_cp.value != 0:
1651 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_delay_increment")
1652 raise OceanDirectError(err_cp.value, error_msg)
1653 return delay_increment
1654
1655 def get_single_strobe_width_minimum(self, device_id: int) -> int:
1656 """!
1657 Get the minimum amount of time, in microseconds, that the single strobe pulse
1658 should remain high after it begins.
1659 @param device_id The device id.
1660 @return The minimum width in microseconds.
1661 """
1662 self.oceandirect.lh_get_single_strobe_width_minimum.restype = c_uint32
1663 self.oceandirect.lh_get_single_strobe_width_minimum.argtypes = [c_uint32, POINTER(c_int32)]
1664 err_cp = c_int32(0)
1665 width_minimum = self.oceandirect.lh_get_single_strobe_width_minimum(device_id, byref(err_cp))
1666
1667 if err_cp.value != 0:
1668 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_width_minimum")
1669 raise OceanDirectError(err_cp.value, error_msg)
1670 return width_minimum
1671
1672 def get_single_strobe_width_maximum(self, device_id: int) -> int:
1673 """!
1674 Get the maximum amount of time, in microseconds, that the single strobe pulse
1675 should remain high after it begins.
1676 @param device_id The device id.
1677 @return The maximum width in microseconds.
1678 """
1679 self.oceandirect.lh_get_single_strobe_width_maximum.restype = c_uint32
1680 self.oceandirect.lh_get_single_strobe_width_maximum.argtypes = [c_uint32, POINTER(c_int32)]
1681 err_cp = c_int32(0)
1682 width_maximum = self.oceandirect.lh_get_single_strobe_width_maximum(device_id, byref(err_cp))
1683
1684 if err_cp.value != 0:
1685 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_width_maximum")
1686 raise OceanDirectError(err_cp.value, error_msg)
1687 return width_maximum
1688
1689 def get_single_strobe_width_increment(self, device_id: int) -> int:
1690 """!
1691 Get the single strobe width increment.
1692 @param device_id The device id.
1693 @return The width increment.
1694 """
1695 self.oceandirect.lh_get_single_strobe_width_increment.restype = c_uint32
1696 self.oceandirect.lh_get_single_strobe_width_increment.argtypes = [c_uint32, POINTER(c_int32)]
1697 err_cp = c_int32(0)
1698 width_increment = self.oceandirect.lh_get_single_strobe_width_increment(device_id, byref(err_cp))
1699
1700 if err_cp.value != 0:
1701 error_msg = self.decode_error(err_cp.value, "lh_get_single_strobe_width_increment")
1702 raise OceanDirectError(err_cp.value, error_msg)
1703 return width_increment
1704
1705
1706 def set_continuous_strobe_period(self, device_id: int, period: int) -> None:
1707 """!
1708 Sets the continuous strobe period in microseconds.
1709 @see get_continuous_strobe_period()
1710 @param device_id The device id.
1711 @param period The new period of the continuous strobe measured in microseconds
1712 """
1713 self.oceandirect.lh_set_continuous_strobe_period.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1714 err_cp = c_int32(0)
1715 self.oceandirect.lh_set_continuous_strobe_period(device_id, byref(err_cp), c_uint32(period))
1716
1717 if err_cp.value != 0:
1718 error_msg = self.decode_error(err_cp.value, "lh_set_continuous_strobe_period")
1719 raise OceanDirectError(err_cp.value, error_msg)
1720
1721 def get_continuous_strobe_period(self, device_id: int) -> int:
1722 """!
1723 Get the continuous strobe period in microseconds.
1724 @see set_continuous_strobe_period()
1725 @param device_id The device id.
1726 @return the period in microseconds.
1727 """
1728 self.oceandirect.lh_get_continuous_strobe_period.restype = c_uint32
1729 self.oceandirect.lh_get_continuous_strobe_period.argtypes = [c_uint32, POINTER(c_int32)]
1730 err_cp = c_int32(0)
1731 period_us = self.oceandirect.lh_get_continuous_strobe_period(device_id, byref(err_cp))
1732
1733 if err_cp.value != 0:
1734 error_msg = self.decode_error(err_cp.value, "lh_get_continuous_strobe_period")
1735 raise OceanDirectError(err_cp.value, error_msg)
1736 return period_us
1737
1738 def set_continuous_strobe_state(self, device_id: int, enable: bool) -> None:
1739 """!
1740 Sets the continuous strobe enable state on the device.
1741 @see get_continuous_strobe_state()
1742 @param device_id The device id.
1743 @param enable A boolean used for denoting the desired state (on/off) of the continuous
1744 strobe generator. If the value of enable is nonzero, then the continuous
1745 strobe will operate. If the value of enable is zero, then the continuous
1746 strobe will stop. Note that on some devices the continuous strobe enable
1747 is tied to other enables (such as lamp enable or single strobe enable)
1748 which may cause side effects.
1749 """
1750 self.oceandirect.lh_set_continuous_strobe_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1751 err_cp = c_int32(0)
1752 self.oceandirect.lh_set_continuous_strobe_state(device_id, byref(err_cp), c_ubyte(enable))
1753
1754 if err_cp.value != 0:
1755 error_msg = self.decode_error(err_cp.value, "lh_set_continuous_strobe_state")
1756 raise OceanDirectError(err_cp.value, error_msg)
1757
1758 def get_continuous_strobe_state(self, device_id: int) -> bool:
1759 """!
1760 Gets the continuous strobe state (enabled or disabled) of the device.
1761 @see set_continuous_strobe_state()
1762 @param device_id The device id.
1763 @return True if continuous strobe is enabled otherwise it's False.
1764 """
1765 self.oceandirect.lh_get_continuous_strobe_state.restype = c_ubyte
1766 self.oceandirect.lh_get_continuous_strobe_state.argtypes = [c_uint32, POINTER(c_int32)]
1767 err_cp = c_int32(0)
1768 enable = self.oceandirect.lh_get_continuous_strobe_state(device_id, byref(err_cp))
1769
1770 if err_cp.value != 0:
1771 error_msg = self.decode_error(err_cp.value, "lh_get_continuous_strobe_state")
1772 raise OceanDirectError(err_cp.value, error_msg)
1773 return bool(c_ubyte(enable))
1774
1775 def get_continuous_strobe_period_minimum(self, device_id: int) -> int:
1776 """!
1777 Gets the minimum continuous strobe period of the device in microseconds.
1778 @param device_id The device id.
1779 @return The minimum strobe period in microseconds.
1780 """
1781 self.oceandirect.lh_get_continuous_strobe_period_minimum.restype = c_uint32
1782 self.oceandirect.lh_get_continuous_strobe_period_minimum.argtypes = [c_uint32, POINTER(c_int32)]
1783 err_cp = c_int32(0)
1784 minimum_us = self.oceandirect.lh_get_continuous_strobe_period_minimum(device_id, byref(err_cp))
1785
1786 if err_cp.value != 0:
1787 error_msg = self.decode_error(err_cp.value, "lh_get_continuous_strobe_period_minimum")
1788 raise OceanDirectError(err_cp.value, error_msg)
1789 return minimum_us
1790
1791 def get_continuous_strobe_period_maximum(self, device_id: int) -> int:
1792 """!
1793 Gets the maximum continuous strobe period of the device in microseconds.
1794 @param device_id The device id.
1795 @return The maximum strobe period in microseconds.
1796 """
1797 self.oceandirect.lh_get_continuous_strobe_period_maximum.restype = c_uint32
1798 self.oceandirect.lh_get_continuous_strobe_period_maximum.argtypes = [c_uint32, POINTER(c_int32)]
1799 err_cp = c_int32(0)
1800 maximum_us = self.oceandirect.lh_get_continuous_strobe_period_maximum(device_id, byref(err_cp))
1801
1802 if err_cp.value != 0:
1803 error_msg = self.decode_error(err_cp.value, "lh_get_continuous_strobe_period_maximum")
1804 raise OceanDirectError(err_cp.value, error_msg)
1805 return maximum_us
1806
1807 def get_continuous_strobe_period_increment(self, device_id: int) -> int:
1808 """!
1809 This function gets the current size of the strobe period increment of the device in microseconds.
1810 The increment is dependent on the strobe period. Small strobe periods i.e. less than about 1ms
1811 will have a small increment, typically 1 microsecond. Larger strobe periods will have larger
1812 increments, typically 1ms.
1813 @param device_id The device id.
1814 @return The current strobe period increment in microseconds.
1815 """
1816 self.oceandirect.lh_get_continuous_strobe_period_increment.restype = c_uint32
1817 self.oceandirect.lh_get_continuous_strobe_period_increment.argtypes = [c_uint32, POINTER(c_int32)]
1818 err_cp = c_int32(0)
1819 increment_us = self.oceandirect.lh_get_continuous_strobe_period_increment(device_id, byref(err_cp))
1820
1821 if err_cp.value != 0:
1822 error_msg = self.decode_error(err_cp.value, "lh_get_continuous_strobe_period_increment")
1823 raise OceanDirectError(err_cp.value, error_msg)
1824 return increment_us
1825
1826
1827
1828 def set_led_state(self, device_id: int, isEnabled: bool) -> None:
1829 """!
1830 Enable or disable device LED. If the device don't have an LED then an exception will be thrown.
1831 @see get_led_state()
1832 @param device_id The device id.
1833 @param isEnabled True to enable LED blinking otherwise it's False.
1834 """
1835 self.oceandirect.lh_set_led_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1836 err_cp = c_int32(0)
1837 self.oceandirect.lh_set_led_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1838
1839 if err_cp.value != 0:
1840 error_msg = self.decode_error(err_cp.value, "lh_set_led_state")
1841 raise OceanDirectError(err_cp.value, error_msg)
1842
1843 def get_led_state(self, device_id: int) -> bool:
1844 """!
1845 Get device LED state. If the device don't have an LED then an exception will be thrown.
1846 @see set_led_state()
1847 @param device_id The device id.
1848 @return True if LED is enabled otherwise it's False.
1849 """
1850 self.oceandirect.lh_get_led_state.restype = c_ubyte
1851 self.oceandirect.lh_get_led_state.argtypes = [c_uint32, POINTER(c_int32)]
1852 err_cp = c_int32(0)
1853 ledState = self.oceandirect.lh_get_led_state(device_id, byref(err_cp))
1854
1855 if err_cp.value != 0:
1856 error_msg = self.decode_error(err_cp.value, "lh_get_led_state")
1857 raise OceanDirectError(err_cp.value, error_msg)
1858 return bool(c_ubyte(ledState))
1859
1860
1861 def get_device_original_vid(self, device_id: int) -> int:
1862 """!
1863 Get the original vendor id (VID) of the device.
1864 @param device_id The device id.
1865 @return The VID.
1866 """
1867 self.oceandirect.lh_get_device_original_vid.restype = c_uint16
1868 self.oceandirect.lh_get_device_original_vid.argtypes = [c_uint32, POINTER(c_int32)]
1869 err_cp = c_int32(0)
1870 orig_vid = self.oceandirect.lh_get_device_original_vid(device_id, byref(err_cp))
1871
1872 if err_cp.value != 0:
1873 error_msg = self.decode_error(err_cp.value, "lh_get_device_original_vid")
1874 raise OceanDirectError(err_cp.value, error_msg)
1875 return orig_vid
1876
1877 def get_device_original_pid(self, device_id: int) -> int:
1878 """!
1879 Get the original product id (PID) of the device.
1880 @param device_id The device id.
1881 @return The PID.
1882 """
1883 self.oceandirect.lh_get_device_original_pid.restype = c_uint16
1884 self.oceandirect.lh_get_device_original_pid.argtypes = [c_uint32, POINTER(c_int32)]
1885 err_cp = c_int32(0)
1886 orig_pid = self.oceandirect.lh_get_device_original_pid(device_id, byref(err_cp))
1887
1888 if err_cp.value != 0:
1889 error_msg = self.decode_error(err_cp.value, "lh_get_device_original_pid")
1890 raise OceanDirectError(err_cp.value, error_msg)
1891 return orig_pid
1892
1893 def get_device_vid(self, device_id: int) -> int:
1894 """!
1895 Get the current vendor id (VID) of the device.
1896 @param device_id The device id.
1897 @return The VID.
1898 """
1899 self.oceandirect.lh_get_device_vid.restype = c_uint16
1900 self.oceandirect.lh_get_device_vid.argtypes = [c_uint32, POINTER(c_int32)]
1901 err_cp = c_int32(0)
1902 vid = self.oceandirect.lh_get_device_vid(device_id, byref(err_cp))
1903
1904 if err_cp.value != 0:
1905 error_msg = self.decode_error(err_cp.value, "lh_get_device_vid")
1906 raise OceanDirectError(err_cp.value, error_msg)
1907 return vid
1908
1909 def get_device_pid(self, device_id: int) -> int:
1910 """!
1911 Get the current product id (PID) of the device.
1912 @param device_id The device id.
1913 @return The PID.
1914 """
1915 self.oceandirect.lh_get_device_pid.restype = c_uint16
1916 self.oceandirect.lh_get_device_pid.argtypes = [c_uint32, POINTER(c_int32)]
1917 err_cp = c_int32(0)
1918 pid = self.oceandirect.lh_get_device_pid(device_id, byref(err_cp))
1919
1920 if err_cp.value != 0:
1921 error_msg = self.decode_error(err_cp.value, "lh_get_device_pid")
1922 raise OceanDirectError(err_cp.value, error_msg)
1923 return pid
1924
1925 def get_device_original_manufacturer_string(self, device_id: int) -> str:
1926 """!
1927 Get the original manufacturer string of the device.
1928 @param device_id The device id.
1929 @return The manufacturer string.
1930 """
1931 self.oceandirect.lh_get_device_original_manufacturer_string.restype = c_size_t
1932 self.oceandirect.lh_get_device_original_manufacturer_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
1933 err_cp = c_int32(0)
1934 orig_manufacturer = create_string_buffer(b'\000'*50)
1935 self.oceandirect.lh_get_device_original_manufacturer_string(device_id, byref(err_cp), orig_manufacturer, 50)
1936
1937 if err_cp.value != 0:
1938 error_msg = self.decode_error(err_cp.value, "lh_get_device_original_manufacturer_string")
1939 raise OceanDirectError(err_cp.value, error_msg)
1940 return orig_manufacturer.value.decode()
1941
1942 def get_device_original_model_string(self, device_id: int) -> str:
1943 """!
1944 Get the original model string of the device.
1945 @param device_id The device id.
1946 @return The model string.
1947 """
1948 self.oceandirect.lh_get_device_original_model_string.restype = c_size_t
1949 self.oceandirect.lh_get_device_original_model_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
1950 err_cp = c_int32(0)
1951 orig_model = create_string_buffer(b'\000'*50)
1952 self.oceandirect.lh_get_device_original_model_string(device_id, byref(err_cp), orig_model, 50)
1953
1954 if err_cp.value != 0:
1955 error_msg = self.decode_error(err_cp.value, "lh_get_device_original_model_string")
1956 raise OceanDirectError(err_cp.value, error_msg)
1957 return orig_model.value.decode()
1958
1959 def get_device_manufacturer_string(self, device_id: int) -> str:
1960 """!
1961 Get the current manufacturer string of the device.
1962 @param device_id The device id.
1963 @return The manufacturer string.
1964 """
1965 self.oceandirect.lh_get_device_manufacturer_string.restype = c_size_t
1966 self.oceandirect.lh_get_device_manufacturer_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
1967 err_cp = c_int32(0)
1968 manufacturer = create_string_buffer(b'\000'*50)
1969 self.oceandirect.lh_get_device_manufacturer_string(device_id, byref(err_cp), manufacturer, 50)
1970
1971 if err_cp.value != 0:
1972 error_msg = self.decode_error(err_cp.value, "lh_get_device_manufacturer_string")
1973 raise OceanDirectError(err_cp.value, error_msg)
1974 return manufacturer.value.decode()
1975
1976 def get_device_model_string(self, device_id: int) -> str:
1977 """!
1978 Get the current model string of the device.
1979 @param device_id The device id.
1980 @return The model string.
1981 """
1982 self.oceandirect.lh_get_device_model_string.restype = c_size_t
1983 self.oceandirect.lh_get_device_model_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
1984 err_cp = c_int32(0)
1985 model = create_string_buffer(b'\000'*50)
1986 self.oceandirect.lh_get_device_model_string(device_id, byref(err_cp), model, 50)
1987
1988 if err_cp.value != 0:
1989 error_msg = self.decode_error(err_cp.value, "lh_get_device_model_string")
1990 raise OceanDirectError(err_cp.value, error_msg)
1991 return model.value.decode()
1992
1993
1994 def get_device_alias(self, device_id: int) -> str:
1995 """!
1996 Read the device alias from the device. If this field in the device is not yet populated then a non-zero(6) code will be returned.
1997 @param device_id The device id.
1998 @return The device alias.
1999 """
2000 self.oceandirect.lh_get_device_alias.restype = c_size_t
2001 self.oceandirect.lh_get_device_alias.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
2002 err_cp = c_int32(0)
2003 device_alias = create_string_buffer(b'\000'*50)
2004 self.oceandirect.lh_get_device_alias(device_id, byref(err_cp), device_alias, 50)
2005
2006 if err_cp.value != 0:
2007 error_msg = self.decode_error(err_cp.value, "lh_get_device_alias")
2008 raise OceanDirectError(err_cp.value, error_msg)
2009 return device_alias.value.decode()
2010
2011 def reset_device(self, device_id: int) -> None:
2012 """!
2013 Restarts the device.
2014 @param device_id The device id.
2015 """
2016 self.oceandirect.lh_reset_device.argtypes = [c_uint32, POINTER(c_int32)]
2017 err_cp = c_int32(0)
2018 self.oceandirect.lh_reset_device(device_id, byref(err_cp))
2019
2020 if err_cp.value != 0:
2021 error_msg = self.decode_error(err_cp.value, "lh_reset_device")
2022 raise OceanDirectError(err_cp.value, error_msg)
2023
2024 def get_user_string(self, device_id: int) -> str:
2025 """!
2026 Read the user string from the device. If this field in the device is not yet populated then a
2027 non-zero(6) code will be returned.
2028 @see set_user_string()
2029 @param device_id The device id.
2030 @return The user string.
2031 """
2032 self.oceandirect.lh_get_user_string.restype = c_size_t
2033 self.oceandirect.lh_get_user_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
2034 err_cp = c_int32(0)
2035 user_string = create_string_buffer(b'\000'*50)
2036 self.oceandirect.lh_get_user_string(device_id, byref(err_cp), user_string, 50)
2037
2038 if err_cp.value != 0:
2039 error_msg = self.decode_error(err_cp.value, "lh_get_user_string")
2040 raise OceanDirectError(err_cp.value, error_msg)
2041 return user_string.value.decode()
2042
2043 def set_user_string(self, device_id: int, userString: str) -> None:
2044 """!
2045 Set a new user string to the device. The maximum string length is 16.
2046 @see get_user_string()
2047 @param device_id The device id.
2048 @param userString The user string. If value is empty then an exception will be thrown.
2049 """
2050 if not userString:
2051 #15 is an error code defined in OceanDirectAPIConstants.c
2052 error_msg = self.decode_error(15, "set_user_string")
2053 raise OceanDirectError(15, error_msg)
2054
2055 self.oceandirect.lh_set_user_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
2056 err_cp = c_int32(0)
2057 self.oceandirect.lh_set_user_string(device_id, byref(err_cp), userString.encode('utf-8'), len(userString))
2058
2059 if err_cp.value != 0:
2060 error_msg = self.decode_error(err_cp.value, "lh_set_user_string")
2061 raise OceanDirectError(err_cp.value, error_msg)
2062
2063
2064
2065 def get_gpio_pin_count(self, device_id: int) -> int:
2066 """!
2067 Get GPIO pin count.
2068 @param device_id The device id.
2069 @return The pin count.
2070 """
2071 self.oceandirect.lh_get_gpio_pin_count.restype = c_uint8
2072 self.oceandirect.lh_get_gpio_pin_count.argtypes = [c_uint32, POINTER(c_int32)]
2073 err_cp = c_int32(0)
2074 gpioPinCount = self.oceandirect.lh_get_gpio_pin_count(device_id, byref(err_cp))
2075
2076 if err_cp.value != 0:
2077 error_msg = self.decode_error(err_cp.value, "lh_get_gpio_pin_count")
2078 raise OceanDirectError(err_cp.value, error_msg)
2079 return int(gpioPinCount)
2080
2081 def set_gpio_output_state(self, device_id: int, direction: int, bitmask: int) -> None:
2082 """!
2083 Sets the GPIO bit direction to either output or input.
2084 @see get_gpio_output_state()
2085 @param device_id The device id.
2086 @param direction The direction value for each bit which could be true(output) or false(input).
2087 @param bitmask The bit mask.
2088 """
2089 self.oceandirect.lh_set_gpio_output_state.argtypes = [c_uint32, POINTER(c_int32), c_uint32, c_uint32]
2090 err_cp = c_int32(0)
2091 self.oceandirect.lh_set_gpio_output_state(device_id, byref(err_cp), c_uint32(direction), c_uint32(bitmask))
2092
2093 if err_cp.value != 0:
2094 error_msg = self.decode_error(err_cp.value, "lh_set_gpio_output_state")
2095 raise OceanDirectError(err_cp.value, error_msg)
2096
2097 def get_gpio_output_state(self, device_id: int) -> int:
2098 """!
2099 Get all GPIO bit direction.
2100 @see set_gpio_output_state()
2101 @param device_id The device id.
2102 @return All bits direction which could be True(out) or False(in)
2103 """
2104 self.oceandirect.lh_get_gpio_output_state.restype = c_uint32
2105 self.oceandirect.lh_get_gpio_output_state.argtypes = [c_uint32, POINTER(c_int32)]
2106 err_cp = c_int32(0)
2107 allBitDirection = self.oceandirect.lh_get_gpio_output_state(device_id, byref(err_cp))
2108
2109 if err_cp.value != 0:
2110 error_msg = self.decode_error(err_cp.value, "lh_get_gpio_output_state")
2111 raise OceanDirectError(err_cp.value, error_msg)
2112 return int(allBitDirection)
2113
2114 def set_gpio_value(self, device_id: int, value: int, bitmask: int) -> None:
2115 """!
2116 Sets the GPIO bit value to either high or low.
2117 @see get_gpio_value()
2118 @param device_id The device id.
2119 @param value The direction value for each bit which could be true(high) or false(low).
2120 @param bitmask The bit mask.
2121 """
2122 self.oceandirect.lh_set_gpio_value.argtypes = [c_uint32, POINTER(c_int32), c_uint32, c_uint32]
2123 err_cp = c_int32(0)
2124 self.oceandirect.lh_set_gpio_value(device_id, byref(err_cp), c_uint32(value), c_uint32(bitmask))
2125
2126 if err_cp.value != 0:
2127 error_msg = self.decode_error(err_cp.value, "lh_set_gpio_value")
2128 raise OceanDirectError(err_cp.value, error_msg)
2129
2130 def get_gpio_value(self, device_id: int) -> int:
2131 """!
2132 Get all GPIO bit values.
2133 @see set_gpio_value()
2134 @param device_id The device id.
2135 @return All bit value (int) where each bit could be True(high) or False(low).
2136 """
2137 self.oceandirect.lh_get_gpio_value.restype = c_uint32
2138 self.oceandirect.lh_get_gpio_value.argtypes = [c_uint32, POINTER(c_int32)]
2139 err_cp = c_int32(0)
2140 allBitValue = self.oceandirect.lh_get_gpio_value(device_id, byref(err_cp))
2141
2142 if err_cp.value != 0:
2143 error_msg = self.decode_error(err_cp.value, "lh_get_gpio_value")
2144 raise OceanDirectError(err_cp.value, error_msg)
2145 return int(allBitValue)
2146
2147
2148
2149 def get_baud_rate(self, device_id: int) -> int:
2150 """!
2151 Read the device RS-232 baud rate.
2152 @see set_baud_rate()
2153 @param device_id The device id.
2154 @return The baud rate.
2155 """
2156 self.oceandirect.lh_get_baud_rate.restype = c_uint32
2157 self.oceandirect.lh_get_baud_rate.argtypes = [c_int32, POINTER(c_int32)]
2158 err_cp = c_int32(0)
2159 baud_rate = self.oceandirect.lh_get_baud_rate(device_id, byref(err_cp))
2160
2161 if err_cp.value != 0:
2162 error_msg = self.decode_error(err_cp.value, "lh_get_baud_rate")
2163 raise OceanDirectError(err_cp.value, error_msg)
2164 return baud_rate
2165
2166 def set_baud_rate(self, device_id: int, baudRate: int) -> None:
2167 """!
2168 Set a new baud rate for the RS-232 port.
2169 @see get_baud_rate()
2170 @param device_id The device id.
2171 @param baudRate The baud rate value.
2172 """
2173 self.oceandirect.lh_set_baud_rate.argtypes = [c_int32, POINTER(c_int32), c_uint32]
2174 err_cp = c_int32(0)
2175 self.oceandirect.lh_set_baud_rate(device_id, byref(err_cp), c_uint32(baudRate))
2176
2177 if err_cp.value != 0:
2178 error_msg = self.decode_error(err_cp.value, "lh_set_baud_rate")
2179 raise OceanDirectError(err_cp.value, error_msg)
2180
2181
2182 #MOVE THIS TO ADMIN
2183 #-lh_set_serial_comm_threshold_mode
2184 #-lh_get_serial_comm_threshold_mode
2185
2186
2187
2188 def get_autonull_maximum_adc_count(self, device_id: int) -> int:
2189 """!
2190 Read the maximum ADC counts.
2191 @param device_id The device id.
2192 @return The ADC counts.
2193 """
2194 self.oceandirect.lh_get_autonull_maximum_adc_count.restype = c_uint32
2195 self.oceandirect.lh_get_autonull_maximum_adc_count.argtypes = [c_int32, POINTER(c_int32)]
2196 err_cp = c_int32(0)
2197 adcCount = self.oceandirect.lh_get_autonull_maximum_adc_count(device_id, byref(err_cp))
2198
2199 if err_cp.value != 0:
2200 error_msg = self.decode_error(err_cp.value, "lh_get_autonull_maximum_adc_count")
2201 raise OceanDirectError(err_cp.value, error_msg)
2202 return adcCount
2203
2204 def get_autonull_baseline_level(self, device_id: int) -> int:
2205 """!
2206 Read the baseline level.
2207 @param device_id The device id.
2208 @return The baseline level.
2209 """
2210 self.oceandirect.lh_get_autonull_baseline_level.restype = c_uint32
2211 self.oceandirect.lh_get_autonull_baseline_level.argtypes = [c_int32, POINTER(c_int32)]
2212 err_cp = c_int32(0)
2213 baseline = self.oceandirect.lh_get_autonull_baseline_level(device_id, byref(err_cp))
2214
2215 if err_cp.value != 0:
2216 error_msg = self.decode_error(err_cp.value, "lh_get_autonull_baseline_level")
2217 raise OceanDirectError(err_cp.value, error_msg)
2218 return baseline
2219
2220 def get_autonull_saturation_level(self, device_id: int) -> int:
2221 """!
2222 Read the saturation level. Most devices returns 65535.
2223 @param device_id The device id.
2224 @return The saturation level.
2225 """
2226 self.oceandirect.lh_get_autonull_saturation_level.restype = c_uint32
2227 self.oceandirect.lh_get_autonull_saturation_level.argtypes = [c_int32, POINTER(c_int32)]
2228 err_cp = c_int32(0)
2229 saturation = self.oceandirect.lh_get_autonull_saturation_level(device_id, byref(err_cp))
2230
2231 if err_cp.value != 0:
2232 error_msg = self.decode_error(err_cp.value, "lh_get_autonull_saturation_level")
2233 raise OceanDirectError(err_cp.value, error_msg)
2234 return saturation
2235
2236 def get_autonull_fpga_digital_gain(self, device_id: int) -> int:
2237 """!
2238 Read the fpga digital gain.
2239 @param device_id The device id.
2240 @return The digital gain value.
2241 """
2242 self.oceandirect.lh_get_autonull_fpga_digital_gain.restype = c_uint32
2243 self.oceandirect.lh_get_autonull_fpga_digital_gain.argtypes = [c_int32, POINTER(c_int32)]
2244 err_cp = c_int32(0)
2245 gain = self.oceandirect.lh_get_autonull_fpga_digital_gain(device_id, byref(err_cp))
2246
2247 if err_cp.value != 0:
2248 error_msg = self.decode_error(err_cp.value, "get_autonull_fpga_digital_gain")
2249 raise OceanDirectError(err_cp.value, error_msg)
2250 return gain
2251
2252 def get_autonull_fpga_digital_offset(self, device_id: int) -> int:
2253 """!
2254 Read the fpga digital offset.
2255 @param device_id The device id.
2256 @return The digital offset value.
2257 """
2258 self.oceandirect.lh_get_autonull_fpga_digital_offset.restype = c_uint32
2259 self.oceandirect.lh_get_autonull_fpga_digital_offset.argtypes = [c_int32, POINTER(c_int32)]
2260 err_cp = c_int32(0)
2261 offset = self.oceandirect.lh_get_autonull_fpga_digital_offset(device_id, byref(err_cp))
2262
2263 if err_cp.value != 0:
2264 error_msg = self.decode_error(err_cp.value, "get_autonull_fpga_digital_offset")
2265 raise OceanDirectError(err_cp.value, error_msg)
2266 return offset
2267
2268 def get_ip_address_assigned_mode(self, device_id: int) -> bool:
2269 """!
2270 Read the IP address mode from the OBP2 device.
2271 @see set_ip_address_assigned_mode()
2272 @param device_id The device id.
2273 @return True if the ip address was generated via DHCP. False if the ip address was statically assigned.
2274 """
2275 self.oceandirect.lh_get_ip_address_assigned_mode.restype = c_ubyte
2276 self.oceandirect.lh_get_ip_address_assigned_mode.argtypes = [c_int32, POINTER(c_int32)]
2277 err_cp = c_int32(0)
2278 status = self.oceandirect.lh_get_ip_address_assigned_mode(device_id, byref(err_cp))
2279
2280 if err_cp.value != 0:
2281 error_msg = self.decode_error(err_cp.value, "lh_get_ip_address_assigned_mode")
2282 raise OceanDirectError(err_cp.value, error_msg)
2283
2284 #manual = 0x01, automatic = 0x02
2285 return bool(c_ubyte(status).value == 0x02)
2286
2287 def set_ip_address_assigned_mode(self, device_id: int, useDHCP: bool) -> None:
2288 """!
2289 Set the IP address mode to the OBP2 device.
2290 @see get_ip_address_assigned_mode()
2291 @param device_id The device id.
2292 @param useDHCP True will use DHCP generated ip address. False will use statically assigned IP address.
2293 """
2294 #manual = 0x01, automatic = 0x02
2295 c_assigned_mode = c_ubyte(0x02)
2296 if useDHCP is False or useDHCP is None:
2297 c_assigned_mode = c_ubyte(0x01)
2298
2299 self.oceandirect.lh_set_ip_address_assigned_mode.argtypes = [c_int32, POINTER(c_int32), c_ubyte]
2300 err_cp = c_int32(0)
2301 self.oceandirect.lh_set_ip_address_assigned_mode(device_id, byref(err_cp), c_assigned_mode)
2302 if err_cp.value != 0:
2303 error_msg = self.decode_error(err_cp.value, "lh_set_ip_address_assigned_mode")
2304 raise OceanDirectError(err_cp.value, error_msg)
2305
2306 def get_ethernet_addon_available(self, device_id: int) -> bool:
2307 """!
2308 Return True or False on whether an ethernet add-on package is available in the OBP2 enabled device.
2309 @param device_id The device id.
2310 @return True if the ethernet add-on is available otherwise False.
2311 """
2312 self.oceandirect.lh_get_ethernet_addon_available.restype = c_bool
2313 self.oceandirect.lh_get_ethernet_addon_available.argtypes = [c_int32, POINTER(c_int32)]
2314 err_cp = c_int32(0)
2315 value = self.oceandirect.lh_get_ethernet_addon_available(device_id, byref(err_cp))
2316
2317 if err_cp.value != 0:
2318 error_msg = self.decode_error(err_cp.value,"lh_get_ethernet_addon_available")
2319 raise OceanDirectError(err_cp.value, error_msg)
2320 return bool(value)
2321
2322 def get_ethernet_mac_address(self, device_id: int) -> list[int]:
2323 """!
2324 Read the ethernet 6-byte mac address from an OBP2 enabled device.
2325 @param device_id The device id.
2326 @return The mac address.
2327 """
2328 self.oceandirect.lh_get_ethernet_mac_address.restype = c_bool
2329 self.oceandirect.lh_get_ethernet_mac_address.argtypes = [c_int32, POINTER(c_int32), POINTER(c_uint8), c_size_t]
2330 err_cp = c_int32(0)
2331 array_len = 6
2332 mac_address_cp = (c_ubyte * array_len)(0)
2333 self.oceandirect.lh_get_ethernet_mac_address(device_id, byref(err_cp), mac_address_cp, array_len)
2334
2335 if err_cp.value != 0:
2336 error_msg = self.decode_error(err_cp.value,"lh_get_ethernet_mac_address")
2337 raise OceanDirectError(err_cp.value, error_msg)
2338
2339 value = []
2340 for i in range(array_len):
2341 value.append(int(mac_address_cp[i]))
2342 return value
2343
2344
2345 def get_network_configuration(self, device_id: int) -> tuple[bool, LighthouseNetworkConfiguration]:
2346 """!
2347 Read the network configuration parameters from an OBP2 enabled device. This function
2348 will return a tuple of 2 objects in this order:
2349 address mode - True if it's using DHCP IP address otherwise its False.
2350 network configuration - A LighthouseNetworkConfiguration object containing the ip address, subnet mask, default gateway, and dns server.
2351 @param device_id The device id.
2352 @return A tuple of 2 objects.
2353 """
2354 self.oceandirect.lh_get_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(c_bool), POINTER(LighthouseNetworkConfiguration_C)]
2355 err_cp = c_int32(0)
2356 networkConfig = LighthouseNetworkConfiguration_C()
2357 assignmentMode_cp = c_bool(0)
2358 self.oceandirect.lh_get_network_configuration(device_id, byref(err_cp), byref(assignmentMode_cp), byref(networkConfig))
2359
2360 if err_cp.value != 0:
2361 error_msg = self.decode_error(err_cp.value, "lh_get_network_configuration")
2362 raise OceanDirectError(err_cp.value, error_msg)
2363
2364 return (bool(assignmentMode_cp.value), networkConfig.getLighthouseNetworkConfiguration())
2365
2366 def set_manual_network_configuration(self, device_id: int, networkConfig: LighthouseNetworkConfiguration) -> None:
2367 """!
2368 Write the network configuration parameters (static ip address) on OBP2 enabled device.
2369 @see get_manual_network_configuration()
2370 @param device_id The device id.
2371 @param networkConfig The network configuration object containing ip address, subnet mask, default gateway, and dns server.
2372 """
2373 if len(networkConfig.ipv4Address) != 4 or len(networkConfig.subnetMask) != 4 or \
2374 len(networkConfig.defaultGateway) != 4 or len(networkConfig.dnsServer) != 4:
2375 error_msg = "set_manual_network_configuration() error: all address must of 4 bytes long."
2376 raise OceanDirectError(15, error_msg)
2377
2378 self.oceandirect.lh_set_manual_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(LighthouseNetworkConfiguration_C)]
2379 err_cp = c_int32(0)
2380 networkConfig_C = networkConfig.getLighthouseNetworkConfiguration_C()
2381
2382 self.oceandirect.lh_set_manual_network_configuration(device_id, byref(err_cp), byref(networkConfig_C))
2383 if err_cp.value != 0:
2384 error_msg = self.decode_error(err_cp.value, "lh_set_manual_network_configuration")
2385 raise OceanDirectError(err_cp.value, error_msg)
2386
2387 def get_manual_network_configuration(self, device_id: int) -> LighthouseNetworkConfiguration:
2388 """!
2389 Read the network configuration parameters (static ip address) from an OBP2 enabled device. This
2390 function will return a LighthouseNetworkConfiguration that contains the ip address, subnet mask,
2391 default gateway, and dns server address.
2392 @see set_manual_network_configuration()
2393 @param device_id The device id.
2394 @return A LighthouseNetworkConfiguration objects.
2395 """
2396 self.oceandirect.lh_get_manual_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(LighthouseNetworkConfiguration_C)]
2397 err_cp = c_int32(0)
2398 networkConfig = LighthouseNetworkConfiguration_C()
2399
2400 self.oceandirect.lh_get_manual_network_configuration(device_id, byref(err_cp), byref(networkConfig))
2401 if err_cp.value != 0:
2402 error_msg = self.decode_error(err_cp.value, "lh_get_manual_network_configuration")
2403 raise OceanDirectError(err_cp.value, error_msg)
2404 return networkConfig.getLighthouseNetworkConfiguration()
2405
2406
2407 def save_settings_to_flash(self, device_id: int) -> None:
2408 """!
2409 Save settings to flash. Not all devices supported this command.
2410 @param device_id The device id.
2411 """
2412 self.oceandirect.lh_save_settings_to_flash.argtypes = [c_int32, POINTER(c_int32)]
2413 err_cp = c_int32(0)
2414 self.oceandirect.lh_save_settings_to_flash(device_id, byref(err_cp))
2415
2416 if err_cp.value != 0:
2417 error_msg = self.decode_error(err_cp.value, "lh_save_settings_to_flash")
2418 raise OceanDirectError(err_cp.value, error_msg)
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434#-------------------------------------------------------------------------------------------------------------
2435
2438
2439
2440
2441
str get_device_model_string(self, int device_id)
Get the current model string of the device.
bool get_single_strobe_state(self, int device_id)
Get the enable status of the single strobe signal.
None shutdown(self)
Closes the connection to OceanDirectAPI.
tuple[int, int, int] get_api_version_numbers(self)
Return OceanDirect api version information.
None set_lamp_state(self, int device_id, bool enable)
Enable or disable the lamp.
int get_autonull_saturation_level(self, int device_id)
Read the saturation level.
str get_device_original_manufacturer_string(self, int device_id)
Get the original manufacturer string of the device.
None set_stored_dark_spectrum(self, int device_id, list[float] darkSpectrum)
Store a dark spectrum for use in subsequent corrections i.e.
None set_electric_dark_correction_state(self, int device_id, bool isEnabled)
Enable or disable an electric dark correction.
None set_single_strobe_delay(self, int device_id, int delayMicrosecond)
Set the amount of time, in microseconds, that should elapse after a starting event before the single ...
bool get_led_state(self, int device_id)
Get device LED state.
int get_continuous_strobe_period_maximum(self, int device_id)
Gets the maximum continuous strobe period of the device in microseconds.
int get_single_strobe_delay_increment(self, int device_id)
Gets the single strobe delay increment in microseconds.
int probe_usb_devices(self)
Finds all available Ocean devices by scanning on USB for devices with Ocean drivers.
None set_single_strobe_width(self, int device_id, int widthMicrosecond)
Set the amount of time, in microseconds, that the single strobe pulse should remain high after it beg...
int get_continuous_strobe_period_minimum(self, int device_id)
Gets the minimum continuous strobe period of the device in microseconds.
int get_transition_pixel_count(self, int device_id)
This returns the number of pixels that are transition or bevel.
str get_revision_system(self, int device_id)
Reads out the System revision from the device's internal memory if that feature is supported.
int get_autonull_fpga_digital_offset(self, int device_id)
Read the fpga digital offset.
list[int] get_active_pixel_indices(self, int device_id)
Read the active pixel range from the sensor pixel array.
int get_acquisition_delay(self, int device_id)
Get the acquisition delay in microseconds.
int get_continuous_strobe_period(self, int device_id)
Get the continuous strobe period in microseconds.
bool get_nonlinearity_correction_state(self, int device_id)
Return nonlinearity correction usage.
int get_gpio_output_state(self, int device_id)
Get all GPIO bit direction.
int get_scans_to_average(self, int device_id)
Gets the number of spectra to average.
None details(self, int device_id)
Prints the defined set of details about the device.
int get_single_strobe_delay_minimum(self, int device_id)
Get the minimum amount of time, in microseconds, that should elapse after a starting event before the...
None get_shutter_state(self, int device_id)
This function returns the shutter state of the spectrometer.
int get_gpio_pin_count(self, int device_id)
Get GPIO pin count.
None reset_device(self, int device_id)
Restarts the device.
None setMulticastMsgSendRetry(self, int retryCount)
Set the number of times to send multicast message for dynamic probing.
str get_device_manufacturer_string(self, int device_id)
Get the current manufacturer string of the device.
int get_maximum_intensity(self, int device_id)
Returns the maximum pixel value the detector can read.
int get_minimum_averaging_integration_time(self, int device_id)
This function returns the smallest integration time setting, in microseconds, that is valid for the s...
None set_continuous_strobe_state(self, int device_id, bool enable)
Sets the continuous strobe enable state on the device.
None set_trigger_mode(self, int device_id, int mode)
Set the device trigger mode.
list[int] get_device_ids(self)
Return a list of device ids from devices that were both probe or manually added.
int probe_network_devices(self)
Finds all available Ocean devices by scanning the network for devices with Ocean drivers.
int get_minimum_integration_time(self, int device_id)
Returns the minimum allowable integration time on the device.
None open_device(self, int device_id)
Attach to a device discovered by probe_devices or get_device_ids.
int get_single_strobe_delay_maximum(self, int device_id)
Get the maximum amount of time, in microseconds, that should elapse after a starting event before the...
int get_single_strobe_width_increment(self, int device_id)
Get the single strobe width increment.
float get_tec_temperature(self, int device_id)
Returns the temperature reading (celsius) of a detector thermistor.
None set_baud_rate(self, int device_id, int baudRate)
Set a new baud rate for the RS-232 port.
list[float] get_stored_dark_spectrum(self, int device_id)
Retrieve a previously stored dark spectrum for use in subsequent corrections i.e.
int get_autonull_fpga_digital_gain(self, int device_id)
Read the fpga digital gain.
list[float] get_wavelength_coefficients(self, int device_id)
Read the wavelength coefficients from the device.
list[int] get_network_device_ids(self)
Return a list of network device ids from devices that were probe.
int add_network_device(self, str ipAddress, str deviceType)
Manually create an instance of the network attached device and then open it using the openDevice() fu...
None setMulticastMsgResponseReadRetry(self, int retryCount)
Set the number of times to read multicast message response.
int get_maximum_integration_time(self, int device_id)
Returns the maximum allowable integration time on the device.
str get_serial_number(self, int device_id)
Read the device serial number.
None set_manual_network_configuration(self, int device_id, LighthouseNetworkConfiguration networkConfig)
Write the network configuration parameters (static ip address) on OBP2 enabled device.
int get_integration_time_increment(self, int device_id)
Returns the integration time increment on the device.
list[float] boxcar_correct_spectrum(self, int device_id, list[float] illuminatedSpectrum, int boxcarWidth)
Apply a boxcar correction on the given illuminated spectrum.
bool get_ip_address_assigned_mode(self, int device_id)
Read the IP address mode from the OBP2 device.
int get_boxcar_width(self, int device_id)
Read the current boxcar width setting.
None set_acquisition_delay(self, int device_id, int delayMicrosecond)
Set the acquisition delay in microseconds.
int get_acquisition_delay_minimum(self, int device_id)
Get the minimum allowed acquisition delay in microseconds.
bool get_continuous_strobe_state(self, int device_id)
Gets the continuous strobe state (enabled or disabled) of the device.
int get_acquisition_delay_maximum(self, int device_id)
Get the maximum allowed acquisition delay in microseconds.
list[float] nonlinearity_correct_spectrum2(self, int device_id, list[float] darkSpectrum, list[float] illuminatedSpectrum)
Nonlinearity correct a previously acquired illuminated spectrum after dark correction using a previou...
list[float] dark_correct_spectrum1(self, int device_id, list[float] illuminatedSpectrum)
Dark correct a previously acquired illuminated spectrum and using a stored dark spectrum.
int get_number_devices(self)
Returns the number of devices available.
int get_autonull_baseline_level(self, int device_id)
Read the baseline level.
list[int] get_electric_dark_pixel_indices(self, int device_id)
Read the optical dark pixel range from the sensor pixel array.
int get_device_original_pid(self, int device_id)
Get the original product id (PID) of the device.
None set_gpio_value(self, int device_id, int value, int bitmask)
Sets the GPIO bit value to either high or low.
float get_tec_temperature_setpoint(self, int device_id)
Read the set point temperature of the thermo-electric cooler.
None set_shutter_state(self, int device_id, bool shutterState)
This function will open or close the shutter on the spectrometer.
None set_ip_address_assigned_mode(self, int device_id, bool useDHCP)
Set the IP address mode to the OBP2 device.
tuple[bool, LighthouseNetworkConfiguration] get_network_configuration(self, int device_id)
Read the network configuration parameters from an OBP2 enabled device.
str decode_error(self, int errno, str caller)
str get_model(self, int device_id)
Read the correct spectrometer model name assigned.
int get_acquisition_delay_increment(self, int device_id)
Get the allowed step size for the acquisition delay in microseconds.
list[float] get_wavelengths(self, int device_id)
This computes the wavelengths for the spectrometer and fills in the provided array (up to the given l...
int get_device_pid(self, int device_id)
Get the current product id (PID) of the device.
bool get_tec_stable(self, int device_id)
Returns the state of thermo-electric cooler temperature on whether it reached the stable temperature ...
int get_device_vid(self, int device_id)
Get the current vendor id (VID) of the device.
int get_single_strobe_delay(self, int device_id)
Get the amount of time, in microseconds, that should elapse after a starting event before the single ...
int get_baud_rate(self, int device_id)
Read the device RS-232 baud rate.
list[int] get_transition_pixel_indices(self, int device_id)
Read the transition pixel range from the sensor pixel array.
str get_revision_fpga(self, int device_id)
Reads out the FPGA revision from the device's internal memory if that feature is supported.
None set_boxcar_width(self, int device_id, int newBoxcarWidth)
Sets the boxcar width to average the spectral data.
None set_tec_temperature_setpoint(self, int device_id, float temp_C)
Apply the setpoint temperature (Celsius) in the thermo-electric cooler.
list[float] get_dark_corrected_spectrum2(self, int device_id, list[float] darkSpectrum)
Acquire a spectrum and use the supplied dark spectrum to perform a dark correction then return the da...
int get_single_strobe_width_minimum(self, int device_id)
Get the minimum amount of time, in microseconds, that the single strobe pulse should remain high afte...
None set_led_state(self, int device_id, bool isEnabled)
Enable or disable device LED.
int get_spectrum_length(self, int device_id)
Return a formatted spectrum length.
LighthouseNetworkConfiguration get_manual_network_configuration(self, int device_id)
Read the network configuration parameters (static ip address) from an OBP2 enabled device.
str get_device_alias(self, int device_id)
Read the device alias from the device.
None setMulticastMsgResponseReadDelay(self, int delayMs)
Set the delay between reading multicast response.
list[float] dark_correct_spectrum2(self, int device_id, list[float] darkSpectrum, list[float] illuminatedSpectrum)
Dark correct a previously acquired illuminated spectrum and using a previously acquired dark spectrum...
bool get_ethernet_addon_available(self, int device_id)
Return True or False on whether an ethernet add-on package is available in the OBP2 enabled device.
list[int] get_bad_pixel_indices(self, int device_id)
Read bad pixel indices from the sensor pixel array.
int get_single_strobe_width_maximum(self, int device_id)
Get the maximum amount of time, in microseconds, that the single strobe pulse should remain high afte...
list[int] get_ethernet_mac_address(self, int device_id)
Read the ethernet 6-byte mac address from an OBP2 enabled device.
str get_user_string(self, int device_id)
Read the user string from the device.
list[float] get_nonlinearity_coefficients(self, int device_id)
Read the nonlinearity coefficients stored in the device.
None set_single_strobe_state(self, int device_id, bool enable)
Set the enable status of the single strobe signal.
int get_single_strobe_width(self, int device_id)
Get the amount of time, in microseconds, that the single strobe pulse should remain high after it beg...
None set_user_string(self, int device_id, str userString)
Set a new user string to the device.
None set_continuous_strobe_period(self, int device_id, int period)
Sets the continuous strobe period in microseconds.
None set_integration_time(self, int device_id, int int_time)
Sets the integration time on the device.
None set_nonlinearity_correction_state(self, int device_id, bool isEnabled)
Enable or disable nonlinearity correction.
None get_trigger_mode(self, int device_id)
Returns the current trigger mode from the device.
None close_device(self, int device_id)
Detaches the device to free it up for other users.
None set_gpio_output_state(self, int device_id, int direction, int bitmask)
Sets the GPIO bit direction to either output or input.
int get_device_original_vid(self, int device_id)
Get the original vendor id (VID) of the device.
int get_device_type(self, int device_id)
Read the device type.
list[float] get_nonlinearity_corrected_spectrum1(self, int device_id)
Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction followed ...
int get_gpio_value(self, int device_id)
Get all GPIO bit values.
int get_active_pixel_count(self, int device_id)
This returns the number of pixels that are active.
int get_continuous_strobe_period_increment(self, int device_id)
This function gets the current size of the strobe period increment of the device in microseconds.
bool get_lamp_state(self, int device_id)
Return the lamp state.
int get_electric_dark_pixel_count(self, int device_id)
This returns the number of pixels that are electrically active but optically masked (a....
str get_revision_firmware(self, int device_id)
Reads out the firmware revision from the device's internal memory if that feature is supported.
int get_integration_time(self, int device_id)
Returns the current integration time on the device.
int get_autonull_maximum_adc_count(self, int device_id)
Read the maximum ADC counts.
None save_settings_to_flash(self, int device_id)
Save settings to flash.
list[float] get_dark_corrected_spectrum1(self, int device_id)
Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction then retu...
bool get_electric_dark_correction_state(self, int device_id)
Return electric dark correction usage.
list[float] get_nonlinearity_corrected_spectrum2(self, int device_id, list[float] darkSpectrum)
Acquire a spectrum and use the supplied dark spectrum to perform a dark correction followed by the no...
None set_scans_to_average(self, int device_id, int newScanToAverage)
Sets the number of spectra to average.
list[float] nonlinearity_correct_spectrum1(self, int device_id, list[float] illuminatedSpectrum)
Nonlinearity correct a previously acquired illuminated spectrum using a stored dark spectrum.
str get_device_original_model_string(self, int device_id)
Get the original model string of the device.
list[float] get_spectrum(self, int device_id)
Return a formatted spectrum.
SpectrumWithMetadata get_spectrum_with_metadata(self, int device_id)
Returns spectra with metadata information.
int probe_all_devices(self)
Finds all available Ocean devices by scanning on USB for devices with Ocean drivers,...
Python wrapper for C-structure, LighthouseNetworkConfiguration.
An error code and error message object wrapper.
Python wrapper for C-structure, SpectrumWithMetadata.
Python class containing spectrum and metadata (tickcount).