3 Created on Fri Mar 18 16:23:44 2024
4 @author: Ocean Optics Inc.
6 from typing
import List
7 from 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
8 from oceandirect.sdk_properties
import oceandirect_dll
9 from oceandirect.LighthouseTypes
import OceanDirectError,SpectrumWithMetadata, SpectrumWithMetadata_C, LighthouseNetworkConfiguration, LighthouseNetworkConfiguration_C
16 self.
oceandirectoceandirect = cdll.LoadLibrary(oceandirect_dll)
21 Closes all open devices and the odapi singleton.
25 except Exception
as e:
26 error_msg =
"shutdown error"
31 Release any remaining used resources before shutting down the program.
39 Loads and initializes the OceanDirect dll and initializes internal variables.
41 if not LighthouseAPI.instance:
47 return getattr(self.
instanceinstance, name)
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.
55 @param caller: The caller which produces the error code. Use for debugging purposes only.
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()))
66 Return OceanDirect api version information.
67 @return An integer tuple of major, minor, and point value.
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) )
76 return (major.value, minor.value, point.value)
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.
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
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)
92 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_revision_firmware")
95 fw_string =
"{0}.{1}.{2}".format(int(fw_rev_cp[0]), int(fw_rev_cp[1]), int(fw_rev_cp[2]))
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.
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
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)
110 if err_cp.value != 0:
111 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_revision_fpga")
114 fpga_rev_cp =
"{0}.{1}.{2}".format(int(fpga_rev_cp[0]), int(fpga_rev_cp[1]), int(fpga_rev_cp[2]))
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.
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
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)
129 if err_cp.value != 0:
130 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_revision_system")
133 sys_rev_cp =
"{0}.{1}.{2}".format(int(sys_rev_cp[0]), int(sys_rev_cp[1]), int(sys_rev_cp[2]))
161 Closes the connection to OceanDirectAPI. This is the last to be called before the program terminates.
163 self.oceandirect.lh_shutdown()
167 Set the number of times to send multicast message for dynamic probing. This must be called before probing network devices.
169 @param retryCount The number of times to send messages.
171 self.oceandirect.lh_set_multicast_msg_send_retry.argtypes = [c_size_t]
172 self.oceandirect.lh_set_multicast_msg_send_retry(retryCount)
176 Set the delay between reading multicast response. This must be called before probing network devices.
178 @param delayMs The delay in milliseconds before next read.
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)
185 Set the number of times to read multicast message response. This must be called before probing network devices.
187 @param retryCount The number of times to try reading multicast response messages.
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)
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()
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_errordecode_error(-1,
"lh_probe_all_devices")
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()
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_errordecode_error(-1,
"lh_probe_usb_devices")
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()
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_errordecode_error(-1,
"lh_probe_network_devices")
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.
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
259 if not ipAddress
or not deviceType:
261 error_msg = self.
decode_errordecode_error(15,
"add_network_device")
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_errordecode_error(-1,
"lh_add_network_devices")
270 if err_cp.value != 0:
271 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_add_network_devices")
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.
281 self.oceandirect.lh_get_number_of_device_ids.restype = c_size_t
284 num_devices = self.oceandirect.lh_get_number_of_device_ids()
285 except Exception
as e:
286 error_msg = self.
decode_errordecode_error(-1,
"lh_get_number_of_device_ids")
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.
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
300 ids_cp = (c_uint32 * num_ids)(0)
301 n = self.oceandirect.lh_get_network_device_ids(ids_cp, num_ids)
305 networkIds = list(ids_cp)[0 : n]
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.
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
319 ids_cp = (c_uint32 * num_ids)(0)
320 n = self.oceandirect.lh_get_device_ids(ids_cp, num_ids)
324 all_device_ids = list()
326 all_device_ids = list(ids_cp)[0 : n]
328 return all_device_ids
333 Read the device serial number.
334 @param device_id The device id.
335 @return The serial number.
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
340 serial_cp = create_string_buffer(b
'\000'*32)
341 self.oceandirect.lh_get_serial_number(device_id, byref(err_cp), serial_cp, 32)
343 if err_cp.value != 0:
344 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_serial_number")
346 return serial_cp.value.decode()
350 Read the device type.
351 @return The device type.
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)
358 error_msg = self.
decode_errordecode_error(err_cp[0],
"lh_get_device_type")
360 return device_type.value.decode()
364 Read the correct spectrometer model name assigned.
365 @param device_id The device id.
366 @return The device model name.
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)
372 self.oceandirect.lh_get_device_model(device_id, byref(err_cp), model_cp, 32)
374 if err_cp.value != 0:
375 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_model")
377 return model_cp.value.decode()
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.
391 @see find_usb_devices()
392 @see add_network_device()
395 self.oceandirect.lh_open_device.argtypes = [c_uint32, POINTER(c_int32)]
397 self.oceandirect.lh_open_device(device_id, byref(err_cp))
403 if err_cp.value > 0
and err_cp.value < 10001:
405 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_open_device")
408 self.oceandirect.lh_get_spectrum_length.restype = c_size_t
409 self.oceandirect.lh_get_spectrum_length.argtypes = [c_uint32, POINTER(c_int32)]
411 spectrum_length = self.oceandirect.lh_get_spectrum_length(device_id, byref(err_cp))
413 if err_cp.value != 0:
414 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_spectrum_length")
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.
425 self.oceandirect.lh_close_device.argtypes = [c_uint32, POINTER(c_int32)]
427 self.oceandirect.lh_close_device(device_id, byref(err_cp))
429 if err_cp.value != 0:
430 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_close_device")
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.
442 self.oceandirect.lh_set_scans_to_average.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
444 self.oceandirect.lh_set_scans_to_average(device_id, byref(err_cp), newScanToAverage)
446 if err_cp.value != 0:
447 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_scans_to_average")
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.
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)]
460 scanToAverage = self.oceandirect.lh_get_scans_to_average(device_id, byref(err_cp))
462 if err_cp.value != 0:
463 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_scans_to_average")
469 Sets the boxcar width to average the spectral data.
471 @param device_id The device id.
472 @param newBoxcarWidth The boxcar width.
474 self.oceandirect.lh_set_boxcar_width.argtypes = [c_uint32, POINTER(c_int32), c_uint16]
476 self.oceandirect.lh_set_boxcar_width(device_id, byref(err_cp), c_uint16(newBoxcarWidth))
478 if err_cp.value != 0:
479 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_boxcar_width")
484 Read the current boxcar width setting.
485 @see set_boxcar_width()
486 @param device_id The device id.
487 @return The boxcar width.
489 self.oceandirect.lh_get_boxcar_width.restype = c_uint16
490 self.oceandirect.lh_get_boxcar_width.argtypes = [c_uint32, POINTER(c_int32)]
492 boxcarWidth = self.oceandirect.lh_get_boxcar_width(device_id, byref(err_cp))
494 if err_cp.value != 0:
495 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_boxcar_width")
501 Returns the maximum pixel value the detector can read.
502 @param device_id The device id.
503 @return The maximum intensity.
505 self.oceandirect.lh_get_maximum_intensity.restype = c_uint32
506 self.oceandirect.lh_get_maximum_intensity.argtypes = [c_uint32, POINTER(c_int32)]
508 max_intensity = self.oceandirect.lh_get_maximum_intensity(device_id, byref(err_cp))
510 if err_cp.value != 0:
511 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_maximum_intensity")
518 Return a formatted spectrum length.
519 @param device_id The device id.
520 @return The formatted spectrum.
522 self.oceandirect.lh_get_spectrum_length.restype = c_size_t
523 self.oceandirect.lh_get_spectrum_length.argtypes = [c_uint32, POINTER(c_int32)]
525 spectrumLength = self.oceandirect.lh_get_spectrum_length(device_id, byref(err_cp))
527 if err_cp.value != 0:
528 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_spectrum_length")
530 return spectrumLength
534 Return a formatted spectrum.
535 @param device_id The device id.
536 @return The formatted spectrum.
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]
542 copiedCount = self.oceandirect.lh_get_spectrum(device_id, byref(err_cp), spd_c, self.
spectrum_length_mapspectrum_length_map[device_id])
544 if err_cp.value != 0:
545 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_spectrum")
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.
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))
569 if err_cp.value != 0:
570 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_spectrum_with_metadata")
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.
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]
585 buffer_size = self.oceandirect.lh_get_wavelengths(device_id, byref(err_cp), wl_c, self.
spectrum_length_mapspectrum_length_map[device_id])
587 if err_cp.value != 0:
588 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_wavelengths")
594 Returns the minimum allowable integration time on the device.
595 @param device_id The device id.
596 @return The minimum integration time.
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)]
601 int_time = self.oceandirect.lh_get_minimum_integration_time(device_id, byref(err_cp))
603 if err_cp.value != 0:
604 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_minimum_integration_time")
610 Returns the maximum allowable integration time on the device.
611 @param device_id The device id.
612 @return The maximum integration time.
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)]
617 int_time = self.oceandirect.lh_get_maximum_integration_time(device_id, byref(err_cp))
619 if err_cp.value != 0:
620 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_maximum_integration_time")
626 return int_time & 0xFFFFFFFF
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.
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)]
642 int_time = self.oceandirect.lh_get_minimum_averaging_integration_time(device_id, byref(err_cp))
644 if err_cp.value != 0:
645 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_minimum_averaging_integration_time")
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.
658 self.oceandirect.lh_set_integration_time.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
660 error_msg = self.oceandirect.lh_set_integration_time(device_id, byref(err_cp), c_uint32(int_time))
662 if err_cp.value != 0:
663 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_integration_time")
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.
673 self.oceandirect.lh_get_integration_time.restype = c_uint32
674 self.oceandirect.lh_get_integration_time.argtypes = [c_uint32, POINTER(c_int32)]
676 int_time = self.oceandirect.lh_get_integration_time(device_id, byref(err_cp))
678 if err_cp.value != 0:
679 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_integration_time")
684 return int_time & 0xFFFFFFFF
688 Returns the integration time increment on the device.
689 @param device_id The device id.
690 @return The integration time increment in microsecond.
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)]
695 int_time = self.oceandirect.lh_get_integration_time_increment(device_id, byref(err_cp))
697 if err_cp.value != 0:
698 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_integration_time_increment")
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.
709 self.oceandirect.lh_set_trigger_mode.argtypes = [c_uint32, POINTER(c_int32), c_uint8]
711 self.oceandirect.lh_set_trigger_mode(device_id, byref(err_cp), c_uint8(mode))
713 if err_cp.value != 0:
714 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_trigger_mode")
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.
725 self.oceandirect.lh_get_trigger_mode.restype = c_uint8
726 self.oceandirect.lh_get_trigger_mode.argtypes = [c_uint32, POINTER(c_int32)]
728 trigger = self.oceandirect.lh_get_trigger_mode(device_id, byref(err_cp))
730 if err_cp.value != 0:
731 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_trigger_mode")
738 This returns the number of pixels that are active.
739 @param device_id The device id.
740 @return The number of active pixels.
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)]
745 active_pixels = self.oceandirect.lh_get_active_pixel_count(device_id, byref(err_cp))
747 if err_cp.value != 0:
748 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_active_pixel_count")
750 return int(active_pixels)
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.
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]
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)
767 if err_cp.value != 0:
768 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_active_pixel_indices")
770 return list(range)[0:elementCopied]
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.
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)]
783 num_electric_dark_pixels = self.oceandirect.lh_get_electric_dark_pixel_count(device_id, byref(err_cp))
785 if err_cp.value != 0:
786 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_electric_dark_pixel_count")
788 return num_electric_dark_pixels
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.
798 if electric_dark_pixel_count == 0:
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)
805 elementCopied = self.oceandirect.lh_get_electric_dark_pixel_indices(device_id, byref(err_cp), range, electric_dark_pixel_count)
807 if err_cp.value != 0:
808 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_electric_dark_pixel_indices")
810 return list(range)[0:elementCopied]
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.
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)]
821 bevel_pixels = self.oceandirect.lh_get_transition_pixel_count(device_id, byref(err_cp))
823 if err_cp.value != 0:
824 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_transition_pixel_count")
826 return int(bevel_pixels)
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.
836 if transition_pixel_count == 0:
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)
843 elementCopied = self.oceandirect.lh_get_transition_pixel_indices(device_id, byref(err_cp), range, transition_pixel_count)
845 if err_cp.value != 0:
846 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_transition_pixel_indices")
848 return list(range)[0:elementCopied]
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.
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]
860 range = (c_uint16 * 40)(0)
861 elementCopied = self.oceandirect.lh_get_bad_pixel_indices(device_id, byref(err_cp), range, 40)
863 if err_cp.value != 0:
864 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_bad_pixel_indices")
866 return list(range)[0:elementCopied]
870 Prints the defined set of details about the device.
871 @param device_id The device id.
873 print(
"Device ID : %d" % device_id)
875 print(
"Model : %s" % self.
get_modelget_model())
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.
889 self.oceandirect.lh_set_acquisition_delay.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
891 self.oceandirect.lh_set_acquisition_delay(device_id, byref(err_cp), c_uint32(delayMicrosecond))
893 if err_cp.value != 0:
894 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_acquisition_delay")
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
906 @see set_acquisition_delay()
907 @param device_id The device id.
908 @return The acquisition delay in microseconds.
910 self.oceandirect.lh_get_acquisition_delay.restype = c_uint32
911 self.oceandirect.lh_get_acquisition_delay.argtypes = [c_uint32, POINTER(c_int32)]
913 delay_microsecond = self.oceandirect.lh_get_acquisition_delay(device_id, byref(err_cp))
915 if err_cp.value != 0:
916 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_acquisition_delay")
918 return delay_microsecond
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.
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)]
929 delay_increment_us = self.oceandirect.lh_get_acquisition_delay_increment(device_id, byref(err_cp))
931 if err_cp.value != 0:
932 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_acquisition_delay_increment")
934 return delay_increment_us
938 Get the maximum allowed acquisition delay in microseconds.
939 @param device_id The device id.
940 @return The maximum acquisition delay in microseconds.
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)]
945 delay_maximum_us = self.oceandirect.lh_get_acquisition_delay_maximum(device_id, err_cp)
947 if err_cp.value != 0:
948 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_acquisition_delay_maximum")
950 return delay_maximum_us
954 Get the minimum allowed acquisition delay in microseconds.
955 @param device_id The device id.
956 @return The minimum acquisition delay in microseconds.
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)]
961 delay_minimum_us = self.oceandirect.lh_get_acquisition_delay_minimum(device_id, byref(err_cp))
963 if err_cp.value != 0:
964 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_acquisition_delay_minimum")
966 return delay_minimum_us
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.
976 if len(darkSpectrum) == 0:
978 error_msg = self.
decode_errordecode_error(10,
"set_stored_dark_spectrum")
981 self.oceandirect.lh_set_stored_dark_spectrum.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_float), c_size_t]
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]
988 self.oceandirect.lh_set_stored_dark_spectrum(device_id, byref(err_cp), float_array, float_array_count)
990 if err_cp.value != 0:
991 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_stored_dark_spectrum")
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.
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]
1006 self.oceandirect.lh_get_stored_dark_spectrum(device_id, byref(err_cp), float_array, self.
spectrum_length_mapspectrum_length_map[device_id])
1007 if err_cp.value != 0:
1008 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_stored_dark_spectrum")
1010 return list(float_array)
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.
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_mapspectrum_length_map[device_id])(0)
1024 self.oceandirect.lh_get_dark_corrected_spectrum1(device_id, byref(err_cp), corrected_spectrum_array, self.
spectrum_length_mapspectrum_length_map[device_id])
1025 if err_cp.value != 0:
1026 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_dark_corrected_spectrum1")
1028 return list(corrected_spectrum_array)
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.
1038 if len(illuminatedSpectrum) == 0:
1040 error_msg = self.
decode_errordecode_error(10,
"dark_correct_spectrum1")
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_mapspectrum_length_map[device_id])(0)
1046 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1047 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)()
1049 for x
in range(illuminated_spectrum_array_count):
1050 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1052 self.oceandirect.lh_dark_correct_spectrum1(device_id, byref(err_cp), illuminated_spectrum_array, illuminated_spectrum_array_count,
1054 if err_cp.value != 0:
1055 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_dark_correct_spectrum1")
1057 return list(corrected_spectrum_array)
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.
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_mapspectrum_length_map[device_id])(0)
1069 dark_spectrum_array_count = len(darkSpectrum)
1070 dark_spectrum_array = (c_float * dark_spectrum_array_count)()
1072 for x
in range(dark_spectrum_array_count):
1073 dark_spectrum_array[x] = darkSpectrum[x]
1075 self.oceandirect.lh_get_dark_corrected_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1077 if err_cp.value != 0:
1078 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_dark_corrected_spectrum2")
1080 return list(corrected_spectrum_array)
1082 def dark_correct_spectrum2(self, device_id: int, darkSpectrum: list[float], illuminatedSpectrum: list[float]) -> list[float]:
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.
1090 if len(darkSpectrum) == 0
or len(illuminatedSpectrum) == 0:
1092 error_msg = self.
decode_errordecode_error(10,
"dark_correct_spectrum2")
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_mapspectrum_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)()
1103 for x
in range(dark_spectrum_array_count):
1104 dark_spectrum_array[x] = darkSpectrum[x]
1106 for x
in range(illuminated_spectrum_array_count):
1107 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
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,
1112 if err_cp.value != 0:
1113 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_dark_correct_spectrum2")
1115 return list(corrected_spectrum_array)
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.
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_mapspectrum_length_map[device_id])()
1130 self.oceandirect.lh_get_nonlinearity_corrected_spectrum1(device_id, byref(err_cp), corrected_spectrum_array, self.
spectrum_length_mapspectrum_length_map[device_id])
1131 if err_cp.value != 0:
1132 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_nonlinearity_corrected_spectrum1")
1134 return list(corrected_spectrum_array)
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.
1145 if len(illuminatedSpectrum) == 0:
1147 error_msg = self.
decode_errordecode_error(10,
"nonlinearity_correct_spectrum1")
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_mapspectrum_length_map[device_id])(0)
1153 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1154 illuminated_spectrum_array = (c_float * illuminated_spectrum_array_count)(0)
1156 for x
in range(illuminated_spectrum_array_count):
1157 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1159 self.oceandirect.lh_nonlinearity_correct_spectrum1(device_id, byref(err_cp), illuminated_spectrum_array, illuminated_spectrum_array_count,
1161 if err_cp.value != 0:
1162 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_nonlinearity_correct_spectrum1")
1164 return list(corrected_spectrum_array)
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.
1174 if len(darkSpectrum) == 0:
1176 error_msg = self.
decode_errordecode_error(10,
"get_nonlinearity_corrected_spectrum2")
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_mapspectrum_length_map[device_id])(0)
1182 dark_spectrum_array_count = len(darkSpectrum)
1183 dark_spectrum_array = (c_float * dark_spectrum_array_count)(0)
1185 for x
in range(dark_spectrum_array_count):
1186 dark_spectrum_array[x] = darkSpectrum[x]
1188 self.oceandirect.lh_get_nonlinearity_corrected_spectrum2(device_id, byref(err_cp), dark_spectrum_array, dark_spectrum_array_count,
1190 if err_cp.value != 0:
1191 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_nonlinearity_corrected_spectrum2")
1193 return list(corrected_spectrum_array)
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.
1203 if len(darkSpectrum) == 0
or len(illuminatedSpectrum) == 0:
1205 error_msg = self.
decode_errordecode_error(10,
"nonlinearity_correct_spectrum2")
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_mapspectrum_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)()
1217 for x
in range(dark_spectrum_array_count):
1218 dark_spectrum_array[x] = darkSpectrum[x]
1220 for x
in range(illuminated_spectrum_array_count):
1221 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
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,
1226 if err_cp.value != 0:
1227 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_nonlinearity_correct_spectrum2")
1229 return list(corrected_spectrum_array)
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.
1239 if len(illuminatedSpectrum) == 0:
1241 error_msg = self.
decode_errordecode_error(10,
"boxcar_correct_spectrum")
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)
1250 for x
in range(illuminated_spectrum_array_count):
1251 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
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)
1257 if err_cp.value != 0:
1258 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_boxcar_correct_spectrum")
1260 return list(boxcar_corrected_spectrum_array)
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.
1269 self.oceandirect.lh_set_electric_dark_correction_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1271 self.oceandirect.lh_set_electric_dark_correction_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1273 if err_cp.value != 0:
1274 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_electric_dark_correction_state")
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.
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)]
1287 correctionState = self.oceandirect.lh_get_electric_dark_correction_state(device_id, byref(err_cp))
1289 if err_cp.value != 0:
1290 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_electric_dark_correction_state")
1292 return bool(c_ubyte(correctionState))
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.
1301 self.oceandirect.lh_set_nonlinearity_correction_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1303 self.oceandirect.lh_set_nonlinearity_correction_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1305 if err_cp.value != 0:
1306 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_nonlinearity_correction_state")
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.
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)]
1319 correctionState = self.oceandirect.lh_get_nonlinearity_correction_state(device_id, byref(err_cp))
1321 if err_cp.value != 0:
1322 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_nonlinearity_correction_state")
1324 return bool(c_ubyte(correctionState))
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.
1333 self.oceandirect.lh_set_lamp_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1335 self.oceandirect.lh_set_lamp_state(device_id, byref(err_cp), c_ubyte(enable))
1337 if err_cp.value != 0:
1338 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_lamp_state")
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.
1348 self.oceandirect.lh_get_lamp_state.restype = c_ubyte
1349 self.oceandirect.lh_get_lamp_state.argtypes = [c_uint32, POINTER(c_int32)]
1351 enabled = self.oceandirect.lh_get_lamp_state(device_id, byref(err_cp))
1353 if err_cp.value != 0:
1354 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_lamp_state")
1356 return bool(c_ubyte(enabled))
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.
1365 self.oceandirect.lh_set_shutter_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1367 enabled = self.oceandirect.lh_set_shutter_state(device_id, byref(err_cp), c_ubyte(shutterState))
1369 if err_cp.value != 0:
1370 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_shutter_state")
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.
1380 self.oceandirect.lh_get_shutter_state.restype = c_ubyte
1381 self.oceandirect.lh_get_shutter_state.argtypes = [c_uint32, POINTER(c_int32)]
1383 shutterState = self.oceandirect.lh_get_shutter_state(device_id, byref(err_cp))
1385 if err_cp.value != 0:
1386 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_shutter_state")
1388 return bool(c_ubyte(shutterState))
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.
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)
1401 buffer_size = self.oceandirect.lh_get_wavelength_coefficients(device_id, byref(err_cp), wl_c, 20)
1403 if err_cp.value != 0:
1404 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_wavelength_coefficients")
1406 return list(wl_c)[:buffer_size]
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.
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)
1419 buffer_size = self.oceandirect.lh_get_nonlinearity_coefficients(device_id, byref(err_cp), nl_coeff, 20)
1421 if err_cp.value != 0:
1422 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_nonlinearity_coefficients")
1424 return list(nl_coeff)[:buffer_size]
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.
1435 self.oceandirect.lh_set_tec_temperature_setpoint.argtypes = [c_uint32, POINTER(c_int32), c_float]
1437 temp = self.oceandirect.lh_set_tec_temperature_setpoint(device_id, byref(err_cp), c_float(temp_C))
1439 if err_cp.value != 0:
1440 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_tec_temperature_setpoint")
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.
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)]
1454 temp = self.oceandirect.lh_get_tec_temperature_setpoint(device_id, byref(err_cp))
1456 if err_cp.value != 0:
1457 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_tec_temperature_setpoint")
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.
1469 self.oceandirect.lh_get_tec_temperature.restype = c_float
1470 self.oceandirect.lh_get_tec_temperature.argtypes = [c_uint32, POINTER(c_int32)]
1472 temp = self.oceandirect.lh_get_tec_temperature(device_id, byref(err_cp))
1474 if err_cp.value != 0:
1475 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_tec_temperature")
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.
1486 self.oceandirect.lh_get_tec_stable.restype = c_bool
1487 self.oceandirect.lh_get_tec_stable.argtypes = [c_uint32, POINTER(c_int32)]
1489 enabled = self.oceandirect.lh_get_tec_stable(device_id, byref(err_cp))
1491 if err_cp.value != 0:
1492 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_tec_stable")
1494 return bool(enabled)
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.
1507 self.oceandirect.lh_set_single_strobe_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1509 self.oceandirect.lh_set_single_strobe_state(device_id, byref(err_cp), c_ubyte(enable))
1511 if err_cp.value != 0:
1512 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_single_strobe_state")
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.
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)]
1528 enable = self.oceandirect.lh_get_single_strobe_state(device_id, byref(err_cp))
1530 if err_cp.value != 0:
1531 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_state")
1533 return bool(c_ubyte(enable))
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
1544 self.oceandirect.lh_set_single_strobe_delay.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1546 self.oceandirect.lh_set_single_strobe_delay(device_id, byref(err_cp), c_uint32(delayMicrosecond))
1548 if err_cp.value != 0:
1549 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_single_strobe_delay")
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.
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)]
1563 delay_us = self.oceandirect.lh_get_single_strobe_delay(device_id, byref(err_cp))
1565 if err_cp.value != 0:
1566 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_delay")
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
1579 self.oceandirect.lh_set_single_strobe_width.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1581 self.oceandirect.lh_set_single_strobe_width(device_id, byref(err_cp), c_uint32(widthMicrosecond))
1583 if err_cp.value != 0:
1584 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_single_strobe_width")
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.
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)]
1598 width_us = self.oceandirect.lh_get_single_strobe_width(device_id, err_cp)
1600 if err_cp.value != 0:
1601 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_width")
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.
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)]
1615 minimum_us = self.oceandirect.lh_get_single_strobe_delay_minimum(device_id, byref(err_cp))
1617 if err_cp.value != 0:
1618 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_delay_minimum")
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.
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)]
1632 maximum_us = self.oceandirect.lh_get_single_strobe_delay_maximum(device_id, byref(err_cp))
1634 if err_cp.value != 0:
1635 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_delay_maximum")
1641 Gets the single strobe delay increment in microseconds.
1642 @param device_id The device id.
1643 @return The delay increment.
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)]
1648 delay_increment = self.oceandirect.lh_get_single_strobe_delay_increment(device_id, byref(err_cp))
1650 if err_cp.value != 0:
1651 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_delay_increment")
1653 return delay_increment
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.
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)]
1665 width_minimum = self.oceandirect.lh_get_single_strobe_width_minimum(device_id, byref(err_cp))
1667 if err_cp.value != 0:
1668 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_width_minimum")
1670 return width_minimum
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.
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)]
1682 width_maximum = self.oceandirect.lh_get_single_strobe_width_maximum(device_id, byref(err_cp))
1684 if err_cp.value != 0:
1685 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_width_maximum")
1687 return width_maximum
1691 Get the single strobe width increment.
1692 @param device_id The device id.
1693 @return The width increment.
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)]
1698 width_increment = self.oceandirect.lh_get_single_strobe_width_increment(device_id, byref(err_cp))
1700 if err_cp.value != 0:
1701 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_single_strobe_width_increment")
1703 return width_increment
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
1713 self.oceandirect.lh_set_continuous_strobe_period.argtypes = [c_uint32, POINTER(c_int32), c_uint32]
1715 self.oceandirect.lh_set_continuous_strobe_period(device_id, byref(err_cp), c_uint32(period))
1717 if err_cp.value != 0:
1718 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_continuous_strobe_period")
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.
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)]
1731 period_us = self.oceandirect.lh_get_continuous_strobe_period(device_id, byref(err_cp))
1733 if err_cp.value != 0:
1734 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_continuous_strobe_period")
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.
1750 self.oceandirect.lh_set_continuous_strobe_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1752 self.oceandirect.lh_set_continuous_strobe_state(device_id, byref(err_cp), c_ubyte(enable))
1754 if err_cp.value != 0:
1755 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_continuous_strobe_state")
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.
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)]
1768 enable = self.oceandirect.lh_get_continuous_strobe_state(device_id, byref(err_cp))
1770 if err_cp.value != 0:
1771 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_continuous_strobe_state")
1773 return bool(c_ubyte(enable))
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.
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)]
1784 minimum_us = self.oceandirect.lh_get_continuous_strobe_period_minimum(device_id, byref(err_cp))
1786 if err_cp.value != 0:
1787 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_continuous_strobe_period_minimum")
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.
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)]
1800 maximum_us = self.oceandirect.lh_get_continuous_strobe_period_maximum(device_id, byref(err_cp))
1802 if err_cp.value != 0:
1803 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_continuous_strobe_period_maximum")
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.
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)]
1819 increment_us = self.oceandirect.lh_get_continuous_strobe_period_increment(device_id, byref(err_cp))
1821 if err_cp.value != 0:
1822 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_continuous_strobe_period_increment")
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.
1835 self.oceandirect.lh_set_led_state.argtypes = [c_uint32, POINTER(c_int32), c_ubyte]
1837 self.oceandirect.lh_set_led_state(device_id, byref(err_cp), c_ubyte(isEnabled))
1839 if err_cp.value != 0:
1840 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_led_state")
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.
1850 self.oceandirect.lh_get_led_state.restype = c_ubyte
1851 self.oceandirect.lh_get_led_state.argtypes = [c_uint32, POINTER(c_int32)]
1853 ledState = self.oceandirect.lh_get_led_state(device_id, byref(err_cp))
1855 if err_cp.value != 0:
1856 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_led_state")
1858 return bool(c_ubyte(ledState))
1863 Get the original vendor id (VID) of the device.
1864 @param device_id The device id.
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)]
1870 orig_vid = self.oceandirect.lh_get_device_original_vid(device_id, byref(err_cp))
1872 if err_cp.value != 0:
1873 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_original_vid")
1879 Get the original product id (PID) of the device.
1880 @param device_id The device id.
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)]
1886 orig_pid = self.oceandirect.lh_get_device_original_pid(device_id, byref(err_cp))
1888 if err_cp.value != 0:
1889 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_original_pid")
1895 Get the current vendor id (VID) of the device.
1896 @param device_id The device id.
1899 self.oceandirect.lh_get_device_vid.restype = c_uint16
1900 self.oceandirect.lh_get_device_vid.argtypes = [c_uint32, POINTER(c_int32)]
1902 vid = self.oceandirect.lh_get_device_vid(device_id, byref(err_cp))
1904 if err_cp.value != 0:
1905 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_vid")
1911 Get the current product id (PID) of the device.
1912 @param device_id The device id.
1915 self.oceandirect.lh_get_device_pid.restype = c_uint16
1916 self.oceandirect.lh_get_device_pid.argtypes = [c_uint32, POINTER(c_int32)]
1918 pid = self.oceandirect.lh_get_device_pid(device_id, byref(err_cp))
1920 if err_cp.value != 0:
1921 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_pid")
1927 Get the original manufacturer string of the device.
1928 @param device_id The device id.
1929 @return The manufacturer string.
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]
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)
1937 if err_cp.value != 0:
1938 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_original_manufacturer_string")
1940 return orig_manufacturer.value.decode()
1944 Get the original model string of the device.
1945 @param device_id The device id.
1946 @return The model string.
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]
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)
1954 if err_cp.value != 0:
1955 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_original_model_string")
1957 return orig_model.value.decode()
1961 Get the current manufacturer string of the device.
1962 @param device_id The device id.
1963 @return The manufacturer string.
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]
1968 manufacturer = create_string_buffer(b
'\000'*50)
1969 self.oceandirect.lh_get_device_manufacturer_string(device_id, byref(err_cp), manufacturer, 50)
1971 if err_cp.value != 0:
1972 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_manufacturer_string")
1974 return manufacturer.value.decode()
1978 Get the current model string of the device.
1979 @param device_id The device id.
1980 @return The model string.
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]
1985 model = create_string_buffer(b
'\000'*50)
1986 self.oceandirect.lh_get_device_model_string(device_id, byref(err_cp), model, 50)
1988 if err_cp.value != 0:
1989 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_model_string")
1991 return model.value.decode()
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.
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]
2003 device_alias = create_string_buffer(b
'\000'*50)
2004 self.oceandirect.lh_get_device_alias(device_id, byref(err_cp), device_alias, 50)
2006 if err_cp.value != 0:
2007 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_device_alias")
2009 return device_alias.value.decode()
2013 Restarts the device.
2014 @param device_id The device id.
2016 self.oceandirect.lh_reset_device.argtypes = [c_uint32, POINTER(c_int32)]
2018 self.oceandirect.lh_reset_device(device_id, byref(err_cp))
2020 if err_cp.value != 0:
2021 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_reset_device")
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.
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]
2035 user_string = create_string_buffer(b
'\000'*50)
2036 self.oceandirect.lh_get_user_string(device_id, byref(err_cp), user_string, 50)
2038 if err_cp.value != 0:
2039 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_user_string")
2041 return user_string.value.decode()
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.
2052 error_msg = self.
decode_errordecode_error(15,
"set_user_string")
2055 self.oceandirect.lh_set_user_string.argtypes = [c_uint32, POINTER(c_int32), POINTER(c_char), c_size_t]
2057 self.oceandirect.lh_set_user_string(device_id, byref(err_cp), userString.encode(
'utf-8'), len(userString))
2059 if err_cp.value != 0:
2060 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_user_string")
2068 @param device_id The device id.
2069 @return The pin count.
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)]
2074 gpioPinCount = self.oceandirect.lh_get_gpio_pin_count(device_id, byref(err_cp))
2076 if err_cp.value != 0:
2077 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_gpio_pin_count")
2079 return int(gpioPinCount)
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.
2089 self.oceandirect.lh_set_gpio_output_state.argtypes = [c_uint32, POINTER(c_int32), c_uint32, c_uint32]
2091 self.oceandirect.lh_set_gpio_output_state(device_id, byref(err_cp), c_uint32(direction), c_uint32(bitmask))
2093 if err_cp.value != 0:
2094 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_gpio_output_state")
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)
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)]
2107 allBitDirection = self.oceandirect.lh_get_gpio_output_state(device_id, byref(err_cp))
2109 if err_cp.value != 0:
2110 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_gpio_output_state")
2112 return int(allBitDirection)
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.
2122 self.oceandirect.lh_set_gpio_value.argtypes = [c_uint32, POINTER(c_int32), c_uint32, c_uint32]
2124 self.oceandirect.lh_set_gpio_value(device_id, byref(err_cp), c_uint32(value), c_uint32(bitmask))
2126 if err_cp.value != 0:
2127 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_gpio_value")
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).
2137 self.oceandirect.lh_get_gpio_value.restype = c_uint32
2138 self.oceandirect.lh_get_gpio_value.argtypes = [c_uint32, POINTER(c_int32)]
2140 allBitValue = self.oceandirect.lh_get_gpio_value(device_id, byref(err_cp))
2142 if err_cp.value != 0:
2143 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_gpio_value")
2145 return int(allBitValue)
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.
2156 self.oceandirect.lh_get_baud_rate.restype = c_uint32
2157 self.oceandirect.lh_get_baud_rate.argtypes = [c_int32, POINTER(c_int32)]
2159 baud_rate = self.oceandirect.lh_get_baud_rate(device_id, byref(err_cp))
2161 if err_cp.value != 0:
2162 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_baud_rate")
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.
2173 self.oceandirect.lh_set_baud_rate.argtypes = [c_int32, POINTER(c_int32), c_uint32]
2175 self.oceandirect.lh_set_baud_rate(device_id, byref(err_cp), c_uint32(baudRate))
2177 if err_cp.value != 0:
2178 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_set_baud_rate")
2190 Read the maximum ADC counts.
2191 @param device_id The device id.
2192 @return The ADC counts.
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)]
2197 adcCount = self.oceandirect.lh_get_autonull_maximum_adc_count(device_id, byref(err_cp))
2199 if err_cp.value != 0:
2200 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_autonull_maximum_adc_count")
2206 Read the baseline level.
2207 @param device_id The device id.
2208 @return The baseline level.
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)]
2213 baseline = self.oceandirect.lh_get_autonull_baseline_level(device_id, byref(err_cp))
2215 if err_cp.value != 0:
2216 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_autonull_baseline_level")
2222 Read the saturation level. Most devices returns 65535.
2223 @param device_id The device id.
2224 @return The saturation level.
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)]
2229 saturation = self.oceandirect.lh_get_autonull_saturation_level(device_id, byref(err_cp))
2231 if err_cp.value != 0:
2232 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_autonull_saturation_level")
2238 Read the fpga digital gain.
2239 @param device_id The device id.
2240 @return The digital gain value.
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)]
2245 gain = self.oceandirect.lh_get_autonull_fpga_digital_gain(device_id, byref(err_cp))
2247 if err_cp.value != 0:
2248 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_autonull_fpga_digital_gain")
2254 Read the fpga digital offset.
2255 @param device_id The device id.
2256 @return The digital offset value.
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)]
2261 offset = self.oceandirect.lh_get_autonull_fpga_digital_offset(device_id, byref(err_cp))
2263 if err_cp.value != 0:
2264 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_autonull_fpga_digital_offset")
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.
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)]
2278 status = self.oceandirect.lh_get_ip_address_assigned_mode(device_id, byref(err_cp))
2280 if err_cp.value != 0:
2281 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_ip_address_assigned_mode")
2285 return bool(c_ubyte(status).value == 0x02)
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.
2295 c_assigned_mode = c_ubyte(0x02)
2296 if useDHCP
is False or useDHCP
is None:
2297 c_assigned_mode = c_ubyte(0x01)
2299 self.oceandirect.lh_set_ip_address_assigned_mode.argtypes = [c_int32, POINTER(c_int32), c_ubyte]
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_errordecode_error(err_cp.value,
"lh_set_ip_address_assigned_mode")
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.
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)]
2315 value = self.oceandirect.lh_get_ethernet_addon_available(device_id, byref(err_cp))
2317 if err_cp.value != 0:
2318 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_ethernet_addon_available")
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.
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]
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)
2335 if err_cp.value != 0:
2336 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_ethernet_mac_address")
2340 for i
in range(array_len):
2341 value.append(int(mac_address_cp[i]))
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.
2354 self.oceandirect.lh_get_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(c_bool), POINTER(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))
2360 if err_cp.value != 0:
2361 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_get_network_configuration")
2364 return (bool(assignmentMode_cp.value), networkConfig.getLighthouseNetworkConfiguration())
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.
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."
2378 self.oceandirect.lh_set_manual_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(LighthouseNetworkConfiguration_C)]
2380 networkConfig_C = networkConfig.getLighthouseNetworkConfiguration_C()
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_errordecode_error(err_cp.value,
"lh_set_manual_network_configuration")
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.
2396 self.oceandirect.lh_get_manual_network_configuration.argtypes = [c_int32, POINTER(c_int32), POINTER(LighthouseNetworkConfiguration_C)]
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_errordecode_error(err_cp.value,
"lh_get_manual_network_configuration")
2404 return networkConfig.getLighthouseNetworkConfiguration()
2409 Save settings to flash. Not all devices supported this command.
2410 @param device_id The device id.
2412 self.oceandirect.lh_save_settings_to_flash.argtypes = [c_int32, POINTER(c_int32)]
2414 self.oceandirect.lh_save_settings_to_flash(device_id, byref(err_cp))
2416 if err_cp.value != 0:
2417 error_msg = self.
decode_errordecode_error(err_cp.value,
"lh_save_settings_to_flash")
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...
def __getattr__(self, name)
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.