3 Created on Wed Jan 9 16:23:44 2019
4 @author: Ocean Insight Inc.
8 from typing
import List
9 from ctypes
import c_char, cdll, c_int, c_int32, c_ushort, c_uint, c_long, create_string_buffer, c_ulong, c_ubyte, c_double, c_float, c_longlong, POINTER, byref
10 from enum
import Enum,auto
11 from oceandirect.sdk_properties
import oceandirect_dll
12 from oceandirect.od_logger
import od_logger
18 An error code and error message object wrapper.
21 def __init__(self, errorCode: int, errorMsg: str):
22 super(OceanDirectError, self).
__init__(errorMsg)
33 self.
oceandirectoceandirect = cdll.LoadLibrary(oceandirect_dll)
41 Closes all open devices and the odapi singleton.
46 except Exception
as e:
47 exe_msg = traceback.format_exc()
48 sdk_data_json = json.dumps(exe_msg)
49 logger.error(sdk_data_json)
53 Closes all opened devices.
60 Release any remaining used resources before shutting down the program.
68 Loads and initializes the OceanDirect dll and initializes internal variables.
71 if not OceanDirectAPI.instance:
75 return getattr(self.
instanceinstance, name)
79 OceanDirectAPI returns an error code if something goes wrong. This function will decode
80 that error to a readable string.
81 @param errno: The error code generated by OceanDirect api.
83 @param caller: The caller which produces the error code. Use for debugging purposes only.
86 error_str_len = self.oceandirect.odapi_get_error_string_length(errno)
87 errstr_cp = create_string_buffer(b
'\000'*error_str_len)
88 self.oceandirect.odapi_get_error_string(errno, errstr_cp, error_str_len)
89 errstr = (
"%s errcode(%d): %s" % (caller, errno, errstr_cp.value.decode()))
97 Return OceanDirect api version information.
98 @return An integer tuple of major, minor, and point value.
104 self.oceandirect.odapi_get_api_version_numbers.argtypes = [POINTER(c_uint), POINTER(c_uint), POINTER(c_uint)]
105 self.oceandirect.odapi_get_api_version_numbers(byref(major), byref(minor), byref(point) )
106 return (major.value, minor.value, point.value)
110 Set the number of times to send multicast message for dynamic probing. This must be called before probing network devices.
112 @param retryCount The number of times to send messages.
114 self.oceandirect.odapi_set_multicast_msg_send_retry.argtypes = [c_uint]
115 self.oceandirect.odapi_set_multicast_msg_send_retry(retryCount)
119 Set the delay between reading multicast response. This must be called before probing network devices.
121 @param delayMs The delay in milliseconds before next read.
123 self.oceandirect.odapi_set_multicast_msg_response_read_delay.argtypes = [c_uint]
124 self.oceandirect.odapi_set_multicast_msg_response_read_delay(delayMs)
128 Set the number of times to read multicast message response. This must be called before probing network devices.
130 @param retryCount The number of times to try reading multicast response messages.
132 self.oceandirect.odapi_set_multicast_msg_response_read_retry.argtypes = [c_uint]
133 self.oceandirect.odapi_set_multicast_msg_response_read_retry(retryCount)
137 Attach to a device discovered by probe_devices or get_device_ids. It also saves it to a map
138 keyed off of the device id. After the device is closed the device_id becomes invalid. You need to
139 call either find_devices()/find_usb_devices()/add_network_device() and get_device_ids() in order
140 to have a valid id before reopening the device again. For a network connected device this function
141 may return an error code if the device is not yet ready to accept incoming connection or the device is
142 unreachable. Note that this should only be done by one thread at a time. For multithreaded
143 application this function must be synchronized.
144 @param device_id The device id.
145 @return The device object.
147 @see find_usb_devices()
148 @see add_network_device()
150 if device_id
in self.open_devices:
151 device = self.open_devices[device_id]
155 self.open_devices[device_id] = device
159 if device_id
in self.open_devices:
160 return self.open_devices[device_id]
166 Manually create an instance of the network attached device and then open it using
167 the openDevice() function. It is the responsiblitiy of the user to ensure that
168 the device exist and configured properly. Note that this should only be done by one thread
169 at a time. For multithreaded application this function must be synchronized.
170 @param ipAddressStr The ip address of the device to be opened.
171 @param deviceTypeStr The device type could be OceanFX or OceanHDX. This is case sensitive.
173 if not ipAddressStr
or not deviceTypeStr:
174 error_msg = self.
decode_errordecode_error(15,
"add_network_device")
177 err_cp = (c_long * 1)(0)
178 self.oceandirect.odapi_add_network_devices(ipAddressStr.encode(
'utf-8'), deviceTypeStr.encode(
'utf-8'), err_cp)
181 error_msg = self.
decode_errordecode_error(err_cp[0],
"add_network_device")
186 Detach from the device indicated by device_id. This persists the device for later use. The device_id becomes
187 invalid after closing the device. Note that this should only be done by one thread at a time.
188 For multithreaded application this function must be synchronized.
189 @param device_id The id of the device to be closed.
192 if device_id
in self.open_devices:
193 device = self.open_devices[device_id]
194 device.close_device()
198 Lists defined details of all active devices.
200 for dev
in self.open_devices:
201 self.open_devices[dev].details()
205 Closes the connection to OceanDirectAPI. This is the last to be called before the program terminates.
207 self.oceandirect.odapi_shutdown()
211 Finds all available Ocean devices by scanning on USB for devices with Ocean drivers, finding
212 devices that respond to UDP multicast (FX and HDX), and also returning IDs for any TCP-enabled
213 devices that have been manually specified using addTCPDeviceLocation(). Note that this should
214 only be done by one thread at a time. For multithreaded application this function must be synchronized.
215 @see find_usb_devices()
217 @return Number of devices found.
220 self.
tcpip_devicestcpip_devices = self.oceandirect.odapi_detect_network_devices()
221 except Exception
as e:
222 exe_msg = traceback.format_exc()
223 sdk_data_json = json.dumps(exe_msg)
224 logger.error(sdk_data_json)
227 self.
usb_devicesusb_devices = self.oceandirect.odapi_probe_devices()
228 except Exception
as e:
229 exe_msg = traceback.format_exc()
230 sdk_data_json = json.dumps(exe_msg)
231 logger.error(sdk_data_json)
233 totalDevicesFound = 0
235 totalDevicesFound = self.oceandirect.odapi_get_number_of_device_ids()
236 except OceanDirectError
as err:
237 exe_msg = traceback.format_exc()
238 sdk_data_json = json.dumps(exe_msg)
239 logger.error(sdk_data_json)
241 return totalDevicesFound
245 Finds all available Ocean devices by scanning on USB for devices with Ocean drivers. Note that
246 this should only be done by one thread at a time. For multithreaded application this function
247 must be synchronized.
250 @return Number of devices found.
253 self.
usb_devicesusb_devices = self.oceandirect.odapi_probe_devices()
254 except Exception
as e:
255 exe_msg = traceback.format_exc()
256 sdk_data_json = json.dumps(exe_msg)
257 logger.error(sdk_data_json)
262 Manually create an instance of the network attached device and then open it using the openDevice() function. It
263 is the responsiblitiy of the user to ensure that the device exist and configured properly. Note that this
264 should only be done by one thread at a time.
265 @param ipAddress The ip address as string (ex: "10.20.30.100" ) of the device to be opened.
266 @param deviceType The device type could be OceanFX or OceanHDX. This is case sensitive.
267 @return The device id.
271 err_cp = (c_long * 1)(0)
273 if not ipAddress
or not deviceType:
275 error_msg = self.
decode_errordecode_error(15,
"add_network_device")
279 deviceId = self.oceandirect.odapi_add_network_devices(ipAddress.encode(
'utf-8'), deviceType.encode(
'utf-8'), err_cp)
280 except Exception
as e:
281 exe_msg = traceback.format_exc()
282 sdk_data_json = json.dumps(exe_msg)
283 logger.error(sdk_data_json)
286 error_msg = self.
decode_errordecode_error(err_cp[0],
"add_network_device")
293 Returns the number of devices available. Note that this should only be done by
294 one thread at a time.
295 @return The number of connected(discovered) devices.
298 self.
num_devicesnum_devices = self.oceandirect.odapi_get_number_of_device_ids()
299 except Exception
as e:
300 exe_msg = traceback.format_exc()
301 sdk_data_json = json.dumps(exe_msg)
302 logger.error(sdk_data_json)
307 Return a list of device ids from devices that were both probe or manually added. Note that
308 this should only be done by one thread at a time. For multithreaded application this
309 function must be synchronized.
310 @return List of device id's.
314 ids_cp = (c_long * num_ids)()
315 err_cp = (c_long * 1)()
316 n = self.oceandirect.odapi_get_device_ids(ids_cp, num_ids)
323 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_device_ids")
329 Return a list of network device ids from devices that were probe. Note that
330 this should only be done by one thread at a time. For multithreaded application
331 this function must be synchronized.
332 @return List of network device id's.
334 self.oceandirect.odapi_get_network_device_ids.argtypes = [POINTER(c_long), c_uint]
335 self.oceandirect.odapi_get_network_device_ids.restype = c_int
337 ids_cp = (c_long * num_ids)()
338 n = self.oceandirect.odapi_get_network_device_ids(ids_cp, c_uint(num_ids))
341 networkIds = list(ids_cp)[0 : n]
348 Return a spectrometer object associated with device id. User should not call this function. This function is
349 used internally in OceanDirect.
350 @param serial_num The device serial number.
351 @return The spectrometer object if found, None otherwise.
357 for dev_id
in devids:
359 od_status = dev.status
363 if (od_status ==
'closed'):
369 Adds a device connected via RS 232 to the device list. Untested.
370 @param device_type The name of a type of device. This can be one of the following: QE-PRO, STS.
371 @param bus_path The location of the device on the RS232 bus. This will be a platform-specific
372 location. Under Windows, this may be COM1, COM2, etc. Under Linux, this might
373 be /dev/ttyS0, /dev/ttyS1,
374 @param baud The baud rate. See device manual for supported baud rate.
376 dev_type_cp = create_string_buffer(str.encode(device_type), len(device_type))
377 bus_path_cp = create_string_buffer(str.encode(bus_path), len(bus_path))
378 added = self.oceandirect.odapi_add_RS232_device_location(dev_type_cp, bus_path_cp, baud)
381 error_msg = self.
decode_errordecode_error(added,
"add_rs232_device")
383 logger.info(
"Add for %s at bus path %s result %d" % (device_type, bus_path, added))
387 Gets the serial number of a specified device. This is used internally to find the desired device.
388 @param dev_id The id of a device.
389 @return The device serial number if found, None otherwise.
392 if dev_id
in self.open_devices:
393 serial_number = self.open_devices[dev_id].serial_number
394 if serial_number
is None:
395 serial_cp = create_string_buffer(b
'\000'*32)
396 err_cp = (c_long * 1)()
397 self.oceandirect.odapi_get_serial_number(dev_id, err_cp, serial_cp, 32)
399 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_serial_number")
401 serial_number = serial_cp.value
407 An enumerated class for feature id. Use the method "is_feature_id()" and the id's below to check
408 if a feature is supported by the device or not.
410 Do not change the values and order below without synchronizing the changes from the C files.
413 SPECTROMETER = auto()
414 THERMOELECTRIC = auto()
415 IRRADIANCE_CAL = auto()
418 WAVELENGTH_CAL = auto()
419 NONLINEARITY_CAL = auto()
420 STRAYLIGHT_CAL = auto()
421 RAW_BUS_ACCESS = auto()
422 CONTINUOUS_STROBE = auto()
423 LIGHT_SOURCE = auto()
425 OPTICAL_BENCH = auto()
429 ACQUISITION_DELAY = auto()
430 PIXEL_BINNING = auto()
432 SINGLE_STROBE = auto()
433 QUERY_STATUS = auto()
434 BACK_TO_BACK = auto()
435 LED_ACTIVITY = auto()
439 IPV4_ADDRESS = auto()
441 AUTO_NULLING = auto()
443 DEVICE_INFORMATION = auto()
444 DEVICE_ALIAS = auto()
446 SPECTRUM_ACQUISITION_CONTROL = auto()
447 NETWORK_CONFIGURATION = auto()
450 HIGH_GAIN_MODE = auto()
454 if not isinstance(obj, FeatureID):
455 raise TypeError(
'not a FeatureID enumeration')
456 return c_int32(obj.value)
461 Class that models the individual spectrometer. Should be created by OceanDirectAPI instance. This
462 has an inner class called "Advanced" that contains functions to access other features of the device.
487 Read the device serial number.
488 @return The serial number.
490 serial_cp = create_string_buffer(b
'\000'*32)
491 err_cp = (c_long * 1)(0)
492 self.
oceandirectoceandirect.odapi_get_serial_number(self.
device_iddevice_id, err_cp, serial_cp, 32)
495 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_serial_number")
503 Read the device type.
504 @return The device type.
506 device_type = create_string_buffer(b
'\000' * 32)
507 err_cp = (c_long * 1)(0)
508 self.
oceandirectoceandirect.odapi_get_device_type(self.
device_iddevice_id, err_cp, device_type, 32)
511 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_device_type")
513 return device_type.value.decode()
517 Read the correct spectrometer model name assigned.
518 @return The device model name.
520 model_cp = create_string_buffer(b
'\000'*32)
521 err_cp = (c_long * 1)(0)
522 self.
oceandirectoceandirect.odapi_get_device_name(self.
device_iddevice_id, err_cp, model_cp, 32)
525 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_model")
528 self.
model_namemodel_name = model_cp.value.decode()
533 Decodes the error string returned from device calls.
534 @param errno The error code.
535 @param caller The method name that calls this function.
536 @return The string description of the error code.
538 error_str_len = self.
oceandirectoceandirect.odapi_get_error_string_length(errno)
539 errstr_cp = create_string_buffer(b
'\000'*error_str_len)
540 self.
oceandirectoceandirect.odapi_get_error_string(errno, errstr_cp, error_str_len)
542 return errstr_cp.value.decode()
546 Open the current device associated with this spectrometer object.
549 err_cp = (c_long * 1)(0)
553 if err_cp[0] != 0
and err_cp[0] != 10001:
555 error_msg = self.
decode_errordecode_error(err_cp[0],
"open_device")
558 self.
statusstatus =
'open'
559 err_cp = (c_long * 1)(0)
563 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_formatted_spectrum_length")
568 except OceanDirectError
as err:
569 [errorCode, errorMsg] = err.get_error_details()
575 except OceanDirectError
as err:
576 [errorCode, errorMsg] = err.get_error_details()
577 print(
"open_device(): get_wavelengths() %d = %s" % (errorCode, errorMsg))
581 Detaches the device to free it up for other users. This function must be called when you're done using the device.
584 err_cp = (c_long * 1)(0)
585 if self.
statusstatus ==
'open':
588 error_msg = self.
decode_errordecode_error(err_cp[0],
"close_device")
590 self.
statusstatus =
'closed'
594 Determine if nonlinearity correction should be used in calculations. Typically should be set to true.
595 @param nonlinearity_flag True to enable nonlinearity correction otherwise it's False.
598 if nonlinearity_flag:
605 Sets the number of spectra to average.
606 @see get_scans_to_average()
607 @param newScanToAverage The number of spectra to average.
609 err_cp = (c_long * 1)(0)
610 self.
oceandirectoceandirect.odapi_set_scans_to_average(self.
device_iddevice_id, err_cp, newScanToAverage)
613 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_scans_to_average")
618 Gets the number of spectra to average.
619 @see set_scans_to_average()
620 @return The number of spectra to average.
622 err_cp = (c_long * 1)(0)
623 scanToAverage = self.
oceandirectoceandirect.odapi_get_scans_to_average(self.
device_iddevice_id, err_cp)
626 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_scans_to_average")
632 Sets the boxcar width to average the spectral data.
633 @see get_boxcar_width()
634 @param newBoxcarWidth The boxcar width.
636 err_cp = (c_long * 1)(0)
637 self.
oceandirectoceandirect.odapi_set_boxcar_width(self.
device_iddevice_id, err_cp, newBoxcarWidth)
640 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_boxcar_width")
645 Read the current boxcar width setting.
646 @see set_boxcar_width()
647 @return The boxcar width.
649 err_cp = (c_long * 1)(0)
650 boxcarWidth = self.
oceandirectoceandirect.odapi_get_boxcar_width(self.
device_iddevice_id, err_cp)
653 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_boxcar_width")
659 Returns the maximum pixel value the detector can read.
660 @return The maximum intensity.
662 self.
oceandirectoceandirect.odapi_get_maximum_intensity.restype = c_double
663 err_cp = (c_long * 1)(0)
664 max_intensity = self.
oceandirectoceandirect.odapi_get_maximum_intensity(self.
device_iddevice_id, err_cp)
667 error_msg = self.
decode_errordecode_error(err_cp[0],
"max_intensity")
673 Return a formatted spectrum.
674 @return The formatted spectrum.
677 err_cp = (c_long * 1)(0)
680 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_formatted_spectrum")
690 Return the formatted spectra length.
691 @return The spectra length.
697 This computes the wavelengths for the spectrometer and fills in the
698 provided array (up to the given length) with those values.
699 @return The wavelength values for the device in a python list.
703 err_cp = (c_long * 1)(0)
707 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_wavelengths")
715 Returns the minimum allowable integration time on the device.
716 @return The minimum integration time.
718 err_cp = (c_long * 1)(0)
719 int_time_min = self.
oceandirectoceandirect.odapi_get_minimum_integration_time_micros(self.
device_iddevice_id, err_cp)
722 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_minimum_integration_time")
729 Returns the maximum allowable integration time on the device.
730 @return The maximum integration time.
732 self.
oceandirectoceandirect.odapi_get_maximum_integration_time_micros.restype = c_ulong
733 self.
oceandirectoceandirect.odapi_get_maximum_integration_time_micros.argtypes = [c_long, POINTER(c_int32)]
735 int_time_max = self.
oceandirectoceandirect.odapi_get_maximum_integration_time_micros(self.
device_iddevice_id, byref(err_cp))
737 if err_cp.value != 0:
738 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_maximum_integration_time")
749 This function returns the smallest integration time setting, in microseconds, that is valid for the spectrometer.
750 NOTE: some devices that make use of onboard functionality to perform averaging have
751 a different, larger, minimum integration time for acquisition when averaging is enabled.
752 Refer to the documentation for your spectrometer to see if this is the case.
753 The minimum integration time when averaging is enabled can be determined
754 using odapi_get_minimum_averaging_integration_time_micros.
755 @return The minimum averaging integration time.
757 self.
oceandirectoceandirect.odapi_get_minimum_averaging_integration_time_micros.restype = c_ulong
758 self.
oceandirectoceandirect.odapi_get_minimum_averaging_integration_time_micros.argtypes = [c_long, POINTER(c_int32)]
760 int_time_min = self.
oceandirectoceandirect.odapi_get_minimum_averaging_integration_time_micros(self.
device_iddevice_id, byref(err_cp))
762 if err_cp.value != 0:
763 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_minimum_averaging_integration_time")
769 Sets the integration time on the device. This should be verified to be within range prior
770 to calling this function.
771 @see get_integration_time()
772 @param int_time The new integration time in microseconds. See device manual for supported integration increment.
776 error_msg = self.
oceandirectoceandirect.odapi_set_integration_time_micros(self.
device_iddevice_id, byref(err_cp), c_ulong(int_time))
778 if err_cp.value != 0:
779 error_msg = self.
decode_errordecode_error(err_cp.value,
"set_integration_time")
784 Returns the current integration time on the device.
785 @see set_integration_time()
786 @return The integration time in microsecond.
788 self.
oceandirectoceandirect.odapi_get_integration_time_micros.restype = c_ulong
789 self.
oceandirectoceandirect.odapi_get_integration_time_micros.argtypes = [c_long, POINTER(c_int32)]
791 int_time = self.
oceandirectoceandirect.odapi_get_integration_time_micros(self.
device_iddevice_id, byref(err_cp))
793 if err_cp.value != 0:
794 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_integration_time")
800 return int_time & 0xFFFFFFFF
804 Returns the integration time increment on the device.
805 @return The integration time increment in microsecond.
807 self.
oceandirectoceandirect.odapi_get_integration_time_increment_micros.restype = c_ulong
808 self.
oceandirectoceandirect.odapi_get_integration_time_increment_micros.argtypes = [c_long, POINTER(c_int32)]
810 int_time = self.
oceandirectoceandirect.odapi_get_integration_time_increment_micros(self.
device_iddevice_id, byref(err_cp))
812 if err_cp.value != 0:
813 error_msg = self.
decode_errordecode_error(err_cp.value,
"get_integration_time_increment")
819 Set the device trigger mode.
820 @see get_trigger_mode()
821 @param mode Trigger mode. See device manual for the supported trigger mode.
823 err_cp = (c_long * 1)(0)
827 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_trigger_mode")
832 Returns the current trigger mode from the device. If this function is not
833 supported by the device then an exception will be thrown.
834 @see set_trigger_mode()
835 @return The trigger mode.
837 err_cp = (c_long * 1)(0)
838 trigger = self.
oceandirectoceandirect.odapi_adv_get_trigger_mode(self.
device_iddevice_id, err_cp)
841 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_trigger_mode")
847 Given an approximate wavelength, finds the closest wavelength and returns the index (pixel number) of that
848 wavelength, and the exact wavelength as an ordered pair
849 @param wavelength A double value containing a best guess or approximate (this should be within bounds
850 of the entire wavelength array or an error is generated).
851 @return A pair value (tuple) of index (pixel) and wavelength value.
853 new_wl = (c_double * 1)(0)
854 err_cp = (c_long * 1)(0)
855 index = self.
oceandirectoceandirect.odapi_get_index_at_wavelength(self.
device_iddevice_id, err_cp, new_wl, c_double(wavelength))
858 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_index_at_wavelength")
860 return index, new_wl[0]
864 Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices (pixel numbers) of those
865 wavelengths, and the exact wavelength as an ordered pair of lists
866 @param wavelengths List of approximate wavelengths.
867 @return A pair value (tuple) of list(indices) and list(actual_wavelengths).
870 length = len(wavelengths)
871 c_indices = (c_int * wavelengthCount)()
872 c_wavelength = (c_double * wavelengthCount)(*wavelengths)
874 err_cp = (c_long * 1)(0)
875 indexCount = self.
oceandirectoceandirect.odapi_get_indices_at_wavelengths(self.
device_iddevice_id, err_cp, c_indices, length, c_wavelength, length)
878 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_indices_at_wavelengths")
882 return list(c_indices[:indexCount]), list(c_wavelength[:indexCount])
886 Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices
887 (pixel numbers) of those wavelengths, and the exact wavelength as an ordered pair of lists.
888 @param lo Wavelength lower limit.
889 @param hi Wavelength upper limit.
890 @param length The number of wavelengths to return.
891 @return A pair value (tuple) of list(indices) and list(actual_wavelengths)
894 c_indices = (c_int * wavelengthCount)()
895 c_wavelength = (c_double * wavelengthCount)()
896 err_cp = (c_long * 1)(0)
897 wavelengthFoundCount = self.
oceandirectoceandirect.odapi_get_indices_at_wavelength_range(self.
device_iddevice_id, err_cp, c_indices, wavelengthCount,
898 c_wavelength, wavelengthCount, c_double(lo), c_double(hi))
901 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_indices_at_wavelength_range")
904 if wavelengthFoundCount == 0:
905 return list(), list()
906 elif wavelengthFoundCount < length:
907 return list(c_indices[:wavelengthFoundCount]), list(c_wavelength[:wavelengthFoundCount])
909 return list(c_indices[:length]), list(c_wavelength[:length])
913 This returns the number of pixels that are electrically active but optically
914 masked (a.k.a. electric dark pixels). Note that not all detectors have optically masked pixels;
915 in that case, this function will return zero.
916 @return The number of electric dark pixels on the spectrometer.
918 err_cp = (c_long * 1)(0)
922 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_number_electric_dark_pixels")
928 This returns array (up to the given length) with the indices of the pixels that are electrically active
929 but optically masked (a.k.a. electric dark pixels). Note that not all detectors have optically
930 masked pixels; in that case, this function will return zero.
931 @return A list of pixels that are electric dark on that spectrometer.
936 err_cp = (c_long * 1)(0)
940 error_msg = self.
decode_errordecode_error(err_cp[0],
"electric_dark_pixel_count")
947 Prints the defined set of details about the device.
949 logger.info(
"Device ID : %d status %s" % (self.
device_iddevice_id, self.
statusstatus))
951 logger.info(
"Model : %s" % self.
get_modelget_model())
956 Check if the given feature ID is supported by the device or not.
957 @param featureID An id from FeatureID enum.
958 @return True if the feature is supported otherwise it's false.
960 err_cp = (c_long * 1)(0)
961 feature_supported =self.
oceandirectoceandirect.odapi_is_feature_enabled(self.
device_iddevice_id, err_cp, featureID.value)
964 error_msg = self.
decode_errordecode_error(err_cp[0],
"is_feature_id_enabled")
966 return bool(c_ubyte(feature_supported))
970 Set the acquisition delay in microseconds. This may also be referred to as the
971 trigger delay. In any event, it is the time between some event (such as a request
972 for data, or an external trigger pulse) and when data acquisition begins.
973 @see get_acquisition_delay()
974 @param delayMicrosecond The new delay to use in microseconds.
976 err_cp = (c_long * 1)(0)
977 self.
oceandirectoceandirect.odapi_set_acquisition_delay_microseconds(self.
device_iddevice_id, err_cp, c_ulong(delayMicrosecond))
980 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_acquisition_delay_microseconds")
985 Get the acquisition delay in microseconds. This may also be referred to as the
986 trigger delay. In any event, it is the time between some event (such as a request
987 for data, or an external trigger pulse) and when data acquisition begins.
988 Note that not all devices support reading this value back. In these cases, the
989 returned value will be the last value sent to odapi_adv_set_acquisition_delay_microseconds().
990 If no value has been set and the value cannot be read back, this function will
992 @see set_acquisition_delay()
993 @return The acquisition delay in microseconds.
995 err_cp = (c_long * 1)(0)
996 delay_microsecond = self.
oceandirectoceandirect.odapi_get_acquisition_delay_microseconds(self.
device_iddevice_id, err_cp)
999 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_acquisition_delay_microseconds")
1001 return delay_microsecond
1005 Get the allowed step size for the acquisition delay in microseconds.
1006 @return The acquisition delay step size in microseconds.
1008 err_cp = (c_long * 1)(0)
1009 delay_increment_microsecond = self.
oceandirectoceandirect.odapi_get_acquisition_delay_increment_microseconds(self.
device_iddevice_id, err_cp)
1012 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_acquisition_delay_increment_microseconds")
1014 return delay_increment_microsecond
1018 Get the maximum allowed acquisition delay in microseconds.
1019 @return The maximum acquisition delay in microseconds.
1021 err_cp = (c_long * 1)(0)
1022 delay_maximum_microsecond = self.
oceandirectoceandirect.odapi_get_acquisition_delay_maximum_microseconds(self.
device_iddevice_id, err_cp)
1025 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_acquisition_delay_maximum_microseconds")
1027 return delay_maximum_microsecond
1031 Get the minimum allowed acquisition delay in microseconds.
1032 @return The minimum acquisition delay in microseconds.
1034 err_cp = (c_long * 1)(0)
1035 delay_minimum_microsecond = self.
oceandirectoceandirect.odapi_get_acquisition_delay_minimum_microseconds(self.
device_iddevice_id, err_cp)
1038 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_acquisition_delay_minimum_microseconds")
1040 return delay_minimum_microsecond
1044 Store a dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
1045 @see getStoredDarkSpectrum.
1046 @param darkSpectrum The buffer that contains the dark spectrum to be stored.
1048 if len(darkSpectrum) == 0:
1050 error_msg = self.
decode_errordecode_error(10,
"set_stored_dark_spectrum")
1053 err_cp = (c_long * 1)(0)
1054 double_array_count = len(darkSpectrum)
1055 double_array = (c_double * double_array_count)(0)
1056 for x
in range(double_array_count):
1057 double_array[x] = darkSpectrum[x]
1059 self.
oceandirectoceandirect.odapi_set_stored_dark_spectrum(self.
device_iddevice_id, err_cp, double_array, double_array_count)
1062 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_stored_dark_spectrum")
1067 Retrieve a previously stored dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
1068 @see setStoredDarkSpectrum.
1069 @return The dark spectrum.
1072 err_cp = (c_long * 1)(0)
1075 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_stored_dark_spectrum")
1077 return list(double_array)
1081 Acquire a spectrum and use the supplied dark spectrum to perform a dark correction then return the dark corrected spectrum.
1082 @param darkSpectrum The buffer that contains the dark spectrum to be used for the dark correction.
1083 @return The dark corrected spectrum.
1085 if len(darkSpectrum) == 0:
1087 error_msg = self.
decode_errordecode_error(10,
"get_dark_corrected_spectrum1")
1091 dark_spectrum_array_count = len(darkSpectrum)
1092 dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1093 err_cp = (c_long * 1)(0)
1094 for x
in range(dark_spectrum_array_count):
1095 dark_spectrum_array[x] = darkSpectrum[x]
1097 self.
oceandirectoceandirect.odapi_get_dark_corrected_spectrum1(self.
device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1100 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_dark_corrected_spectrum1")
1102 return list(corrected_spectrum_array)
1106 Dark correct a previously acquired illuminated spectrum and using a stored dark spectrum.
1107 @see setStoredDarkSpectrum
1108 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1109 @return The dark corrected spectrum.
1111 if len(illuminatedSpectrum) == 0:
1113 error_msg = self.
decode_errordecode_error(10,
"dark_correct_spectrum1")
1117 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1118 illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1119 err_cp = (c_long * 1)(0)
1120 for x
in range(illuminated_spectrum_array_count):
1121 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1123 self.
oceandirectoceandirect.odapi_dark_correct_spectrum1(self.
device_iddevice_id, err_cp, illuminated_spectrum_array, illuminated_spectrum_array_count,
1126 error_msg = self.
decode_errordecode_error(err_cp[0],
"dark_correct_spectrum1")
1128 return list(corrected_spectrum_array)
1132 Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction then return the dark corrected spectrum.
1133 @see setStoredDarkSpectrum.
1134 @return The dark corrected spectrum.
1137 err_cp = (c_long * 1)(0)
1140 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_dark_corrected_spectrum2")
1142 return list(corrected_spectrum_array)
1146 Dark correct a previously acquired illuminated spectrum and using a previously acquired dark spectrum.
1147 @param darkSpectrum The buffer that contains the dark spectrum to be used for the dark correction.
1148 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1149 @return The dark corrected spectrum.
1151 if len(darkSpectrum) == 0
or len(illuminatedSpectrum) == 0:
1153 error_msg = self.
decode_errordecode_error(10,
"dark_correct_spectrum2")
1157 dark_spectrum_array_count = len(darkSpectrum)
1158 dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1159 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1160 illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1161 err_cp = (c_long * 1)(0)
1162 for x
in range(dark_spectrum_array_count):
1163 dark_spectrum_array[x] = darkSpectrum[x]
1165 for x
in range(illuminated_spectrum_array_count):
1166 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1168 self.
oceandirectoceandirect.odapi_dark_correct_spectrum2(self.
device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1169 illuminated_spectrum_array, illuminated_spectrum_array_count,
1172 error_msg = self.
decode_errordecode_error(err_cp[0],
"dark_correct_spectrum2")
1174 return list(corrected_spectrum_array)
1178 Acquire a spectrum and use the supplied dark spectrum to perform a dark correction
1179 followed by the nonlinearity correction then return the nonlinearity corrected spectrum.
1180 @param darkSpectrum The buffer that contains the dark spectrum to be used for the dark correction.
1181 @return The nonlinearity corrected spectrum.
1183 if len(darkSpectrum) == 0:
1185 error_msg = self.
decode_errordecode_error(10,
"get_nonlinearity_corrected_spectrum1")
1189 dark_spectrum_array_count = len(darkSpectrum)
1190 dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1191 err_cp = (c_long * 1)(0)
1192 for x
in range(dark_spectrum_array_count):
1193 dark_spectrum_array[x] = darkSpectrum[x]
1195 self.
oceandirectoceandirect.odapi_get_nonlinearity_corrected_spectrum1(self.
device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1198 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_nonlinearity_corrected_spectrum1")
1200 return list(corrected_spectrum_array)
1204 Nonlinearity correct a previously acquired illuminated spectrum using a stored dark spectrum.
1205 This function performs a dark correction using a previously stored dark spectrum prior to performing the nonlinearity correction.
1206 @see setStoredDarkSpectrum
1207 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1208 @return The nonlinearity corrected spectrum.
1210 if len(illuminatedSpectrum) == 0:
1212 error_msg = self.
decode_errordecode_error(10,
"nonlinearity_correct_spectrum1")
1216 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1217 illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1218 err_cp = (c_long * 1)(0)
1219 for x
in range(illuminated_spectrum_array_count):
1220 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1222 self.
oceandirectoceandirect.odapi_nonlinearity_correct_spectrum1(self.
device_iddevice_id, err_cp, illuminated_spectrum_array, illuminated_spectrum_array_count,
1225 error_msg = self.
decode_errordecode_error(err_cp[0],
"nonlinearity_correct_spectrum1")
1227 return list(corrected_spectrum_array)
1231 Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction
1232 followed by a nonlinearity correction then return the nonlinearity corrected spectrum.
1233 @see setStoredDarkSpectrum.
1234 @return The nonlinearity corrected spectrum.
1237 err_cp = (c_long * 1)(0)
1241 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_nonlinearity_corrected_spectrum2")
1243 return list(corrected_spectrum_array)
1247 Nonlinearity correct a previously acquired illuminated spectrum after dark correction using a previously acquired dark spectrum.
1248 @param darkSpectrum The buffer that contains the dark spectrum to be used prior to the nonlinearity correction.
1249 @param illuminatedSpectrum The buffer that contains the illuminated spectrum to be corrected.
1250 @return The nonlinearity corrected spectrum.
1252 if len(darkSpectrum) == 0
or len(illuminatedSpectrum) == 0:
1254 error_msg = self.
decode_errordecode_error(10,
"nonlinearity_correct_spectrum2")
1258 dark_spectrum_array_count = len(darkSpectrum)
1259 dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1260 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1261 illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1262 err_cp = (c_long * 1)(0)
1264 for x
in range(dark_spectrum_array_count):
1265 dark_spectrum_array[x] = darkSpectrum[x]
1267 for x
in range(illuminated_spectrum_array_count):
1268 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1270 self.
oceandirectoceandirect.odapi_nonlinearity_correct_spectrum2(self.
device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1271 illuminated_spectrum_array, illuminated_spectrum_array_count,
1274 error_msg = self.
decode_errordecode_error(err_cp[0],
"nonlinearity_correct_spectrum2")
1276 return list(corrected_spectrum_array)
1280 Apply a boxcar correction on the given illuminated spectrum.
1281 @param illuminatedSpectrum The spectrum that will be boxcar corrected.
1282 @param boxcarWidth The boxcar width.
1283 @return The boxcar corrected spectrum.
1285 if len(illuminatedSpectrum) == 0:
1287 error_msg = self.
decode_errordecode_error(10,
"boxcar_correct_spectrum")
1290 self.
oceandirectoceandirect.odapi_boxcar_correct_spectrum.argtypes = [c_long, POINTER(c_int), POINTER(c_double), c_uint, c_uint, POINTER(c_double), c_uint]
1292 illuminated_spectrum_array_count = len(illuminatedSpectrum)
1293 illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1294 boxcar_corrected_spectrum_array = (c_double * illuminated_spectrum_array_count)(0)
1297 for x
in range(illuminated_spectrum_array_count):
1298 illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1300 self.
oceandirectoceandirect.odapi_boxcar_correct_spectrum(self.
device_iddevice_id, byref(err_cp),
1301 illuminated_spectrum_array, illuminated_spectrum_array_count, boxcarWidth,
1302 boxcar_corrected_spectrum_array, illuminated_spectrum_array_count)
1304 if err_cp.value != 0:
1305 error_msg = self.
decode_errordecode_error(err_cp.value,
"boxcar_correct_spectrum")
1307 return list(boxcar_corrected_spectrum_array)
1311 Enable or disable an electric dark correction.
1312 @see get_electric_dark_correction_usage()
1313 @param isEnabled True to enable electric dark correction otherwise it's False.
1315 err_cp = (c_long * 1)(0)
1316 self.
oceandirectoceandirect.odapi_apply_electric_dark_correction_usage(self.
device_iddevice_id, err_cp, isEnabled)
1319 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_electric_dark_correction_usage")
1324 Return electric dark correction usage.
1325 @see set_electric_dark_correction_usage()
1326 @return True if electric dark connection is applied otherwise it's False.
1328 err_cp = (c_long * 1)(0)
1329 correctionState = self.
oceandirectoceandirect.odapi_get_electric_dark_correction_usage(self.
device_iddevice_id, err_cp)
1332 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_electric_dark_correction_usage")
1334 return bool(c_ubyte(correctionState))
1338 Enable or disable nonlinearity correction.
1339 @see get_nonlinearity_correction_usage()
1340 @param isEnabled True to enable nonlinearity correction otherwise it's False.
1342 err_cp = (c_long * 1)(0)
1343 self.
oceandirectoceandirect.odapi_apply_nonlinearity_correct_usage(self.
device_iddevice_id, err_cp, isEnabled)
1346 error_msg = self.
decode_errordecode_error(err_cp[0],
"set_nonlinearity_correction_usage")
1351 Return nonlinearity correction usage.
1352 @see set_nonlinearity_correction_usage()
1353 @return True if nonlinearity connection is applied otherwise it's False.
1355 err_cp = (c_long * 1)(0)
1356 correctionState = self.
oceandirectoceandirect.odapi_get_nonlinearity_correct_usage(self.
device_iddevice_id, err_cp)
1359 error_msg = self.
decode_errordecode_error(err_cp[0],
"get_nonlinearity_correction_usage")
1361 return bool(c_ubyte(correctionState))
1366 Subclass containing advanced features that may or may not be in the spectrometer. The spectrometer
1367 specification guide (manual) should be consulted prior to using any of these features.
1369 lamp_on = c_ubyte(1)
1370 lamp_off = c_ubyte(0)
1371 num_nonlinearity_coeffs = 8
1379 Enable or disable the lamp.
1380 @see get_enable_lamp()
1381 @param enable True to enable lamp, False otherwise.
1383 err_cp = (c_long * 1)(0)
1386 self.
devicedevice.oceandirect.odapi_adv_set_lamp_enable(self.
devicedevice.device_id, err_cp, self.
lamp_onlamp_on)
1388 self.
devicedevice.oceandirect.odapi_adv_set_lamp_enable(self.
devicedevice.device_id, err_cp, self.
lamp_offlamp_off)
1396 Return the lamp state.
1397 @see set_enable_lamp()
1398 @return True if lamp is ON otherwise False.
1400 err_cp = (c_long * 1)(0)
1401 enabled = self.
devicedevice.oceandirect.odapi_adv_get_lamp_enable(self.
devicedevice.device_id, err_cp)
1406 return bool(c_ubyte(enabled))
1410 This function will open or close the shutter on the spectrometer.
1411 @param shutterState True will open the shutter. False will then close the shutter.
1413 err_cp = (c_long * 1)(0)
1414 enabled = self.
devicedevice.oceandirect.odapi_adv_set_shutter_open(self.
devicedevice.device_id, err_cp, c_ubyte(shutterState))
1422 This function returns the shutter state of the spectrometer.
1423 @return True if the shutter is opened otherwise returns False.
1425 err_cp = (c_long * 1)(0)
1426 shutterState = self.
devicedevice.oceandirect.odapi_adv_get_shutter_state(self.
devicedevice.device_id, err_cp)
1431 return bool(c_ubyte(shutterState))
1435 Read the wavelength coefficients from the device. This command is being used in OBP-2.0 enabled devices.
1436 If the device don't support this command then a non-zero error code will be returned.
1437 @return List of wavelength coefficient values.
1439 wl_c = (c_double * 20)()
1440 err_cp = (c_long * 1)(0)
1441 buffer_size = self.
devicedevice.oceandirect.odapi_get_wavelength_coeffs(self.
devicedevice.device_id, err_cp, wl_c, 20)
1443 logger.info(
"Buffer size returned: %d " % (buffer_size))
1447 return list(wl_c)[:buffer_size]
1451 Read the nonlinearity coefficients stored in the device. This command is being used in OBP-2.0 enabled devices.
1452 If the device don't support this command then a non-zero error code will be returned.
1453 @return A list of nonlinearity coefficients.
1456 nl_coeff = (c_double * num_coeffs)(0)
1457 err_cp = (c_long * 1)(0)
1458 self.
devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs(self.
devicedevice.device_id, err_cp, nl_coeff, num_coeffs)
1463 return list(nl_coeff)
1467 Read the nonlinearity coefficients count from the device. This command is being used in legacy devices.
1468 If the device don't support this command then a non-zero error code will be returned.
1469 @return The nonlinearity coefficients count.
1471 err_cp = (c_long * 1)(0)
1472 nl_count = self.
devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs_count1(self.
devicedevice.device_id, err_cp)
1475 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_nonlinearity_coeffs_count1")
1481 Read the nonlinearity coefficients count of a given position from the device. This command is being used in legacy devices.
1482 If the device don't support this command then a non-zero error code will be returned. Use the function
1483 "get_nonlinearity_coeffs_count1()" to get the correct range of the index value.
1484 @param index A zero based value referring to the coefficient position.
1485 @return The nonlinearity coefficients.
1487 self.
devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs1.restype = c_double
1489 err_cp = (c_long * 1)(0)
1490 nl_coefficient = self.
devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs1(self.
devicedevice.device_id, err_cp, c_int(index))
1495 return nl_coefficient
1499 Returns the temperature reading (celsius) of a detector thermistor. This is equivalent to calling
1500 get_temperature(index) where the "index" is a detector thermistor index. If this function is not
1501 supported by the device then an exception will be thrown.
1502 @return The temperature in degrees celsius.
1504 self.
devicedevice.oceandirect.odapi_adv_tec_get_temperature_degrees_C.restype = c_double
1505 err_cp = (c_long * 1)(0)
1506 temp = self.
devicedevice.oceandirect.odapi_adv_tec_get_temperature_degrees_C(self.
devicedevice.device_id, err_cp)
1509 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_tec_temperature_degrees_C")
1515 Apply the setpoint temperature (Celsius) in the thermo-electric cooler. If this function is not
1516 supported by the device then an exception will be thrown.
1517 @see get_temperature_setpoint_degrees_C()
1518 @param temp_C The setpoint temperature in celsius.
1520 err_cp = (c_long * 1)(0)
1521 temp = self.
devicedevice.oceandirect.odapi_adv_tec_set_temperature_setpoint_degrees_C(self.
devicedevice.device_id, err_cp, c_double(temp_C))
1524 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_temperature_setpoint_degrees_C")
1530 Enable or disable the thermo-electric cooler attached to the detector. If this function is not
1531 supported by the device then an exception will be thrown.
1532 @see get_tec_enable()
1533 @param coolerEnable True to enable the cooler, False otherwise.
1535 err_cp = (c_long * 1)(0)
1536 self.
devicedevice.oceandirect.odapi_adv_tec_set_enable(self.
devicedevice.device_id, err_cp, c_ubyte(coolerEnable))
1544 Read the state of the thermo-electric cooler whether it's enable or disable. If this function
1545 is not supported by the device then an exception will be thrown.
1546 @see set_tec_enable()
1547 @return True if the thermo-electric cooler is enabled, False otherwise.
1549 err_cp = (c_long * 1)(0)
1550 enabled = self.
devicedevice.oceandirect.odapi_adv_tec_get_enable(self.
devicedevice.device_id, err_cp)
1555 return bool(c_ubyte(enabled))
1559 Read the set point temperature of the thermo-electric cooler. If this function is not supported
1560 by the device then an exception will be thrown.
1561 @see set_temperature_setpoint_degrees_C()
1562 @return The temperature value in celsius.
1564 self.
devicedevice.oceandirect.odapi_adv_tec_get_temperature_setpoint_degrees_C.restype = c_float
1565 err_cp = (c_long * 1)(0)
1566 temp = self.
devicedevice.oceandirect.odapi_adv_tec_get_temperature_setpoint_degrees_C(self.
devicedevice.device_id, err_cp)
1569 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_temperature_setpoint_degrees_C")
1575 Returns the state of thermo-electric cooler temperature on whether it reached the stable
1576 temperature or not. If this function is not supported by the device then an exception will be thrown.
1577 @return True if it's stable, False otherwise.
1579 err_cp = (c_long * 1)(0)
1580 enabled = self.
devicedevice.oceandirect.odapi_adv_tec_get_stable(self.
devicedevice.device_id, err_cp)
1585 return bool(c_ubyte(enabled))
1589 Returns the thermo-electric cooler fan state whether it's enabled or not. Few devices have cooler fan.
1590 If this function is not supported by the device then an exception will be thrown.
1591 @return True if the fan is enabled, False otherwise.
1593 err_cp = (c_long * 1)(0)
1594 enabled = self.
devicedevice.oceandirect.odapi_adv_tec_get_fan_enable(self.
devicedevice.device_id, err_cp)
1599 return bool(c_ubyte(enabled))
1603 Gets the number of light sources that are represented by the given featureID. Such
1604 light sources could be individual LEDs, light bulbs, lasers, etc. Each of these light
1605 sources may have different capabilities, such as programmable intensities and enables,
1606 which should be queried before they are used.
1607 @return The number of light sources (e.g. bulbs) in the indicated feature
1609 err_cp = (c_long * 1)(0)
1610 light_source_count = self.
devicedevice.oceandirect.odapi_adv_get_light_source_count(self.
devicedevice.device_id, err_cp)
1618 Queries whether the indicated light source within the given feature instance has a usable
1619 enable/disable control. If this returns False (meaning no enable available) then calling enable_light_source()
1620 or is_light_source_enabled() is likely to result in an error.
1621 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1622 within the indicated feature instance to query
1623 @return False to indicate specified light source cannot be enabled/disabled. True to indicate specified
1624 light source can be enabled/disabled with enable_light_source()
1626 err_cp = (c_long * 1)(0)
1627 status = self.
devicedevice.oceandirect.odapi_adv_light_source_has_enable(self.
devicedevice.device_id, err_cp, light_source_index)
1636 Queries whether the indicated light source within the given feature instance is enabled (energized).
1637 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1638 within the indicated feature instance to query.
1639 @return False to indicate specified light source is disabled (should emit no light). True to indicate
1640 specified light source is enabled (should emit light depending on configured intensity setting).
1642 err_cp = (c_long * 1)(0)
1643 status = self.
devicedevice.oceandirect.odapi_adv_light_source_is_enabled(self.
devicedevice.device_id, err_cp, light_source_index)
1652 Attempts to enable or disable the indicated light source within the given feature instance. Not
1653 all light sources have an enable/disable control, and this capability can be queried with has_light_source_enable().
1654 Note that an enabled light source should emit light according to its last (or default) intensity
1655 setting which might be the minimum; in this case, the light source might appear to remain off.
1656 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs) within
1657 the indicated feature instance to query.
1658 @param enable Whether to enable the light source. A value of False will attempt to disable the
1659 light source, and any other value will enable it.
1661 err_cp = (c_long * 1)(0)
1664 self.
devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.
devicedevice.device_id, err_cp, light_source_index, self.
lamp_onlamp_on)
1666 self.
devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.
devicedevice.device_id, err_cp, light_source_index, self.
lamp_offlamp_off)
1674 Set the enable status of the single strobe signal. Note that on some
1675 devices the enable control is shared with other signals (e.g. lamp
1676 enable and continuous strobe) so this may have some side-effects and
1677 changing those features may affect the single strobe as well.
1678 @see get_single_strobe_enable()
1679 @param enable True to enable single strobe otherwise use False.
1681 err_cp = (c_long * 1)(0)
1684 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_onlamp_on)
1686 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_offlamp_off)
1694 Set the amount of time, in microseconds, that should elapse after a starting event before
1695 the single strobe should have a rising edge.
1696 @see get_single_strobe_delay()
1697 @param delayMicrosecond The delay, in microseconds, that the single strobe should wait before the pulse begins.
1699 err_cp = (c_long * 1)(0)
1700 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_delay(self.
devicedevice.device_id, err_cp, c_ulong(delayMicrosecond))
1708 Set the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1709 @see get_single_strobe_width()
1710 @param widthMicrosecond The duration, in microseconds, of the single strobe pulse after
1711 the rising edge occurs. Once this duration elapses, a falling edge
1714 err_cp = (c_long * 1)(0)
1715 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_width(self.
devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
1723 Get the enable status of the single strobe signal. Note that on some
1724 devices the enable control is shared with other signals (e.g. lamp
1725 enable and continuous strobe) so this may have some side-effects and
1726 changing those features may affect the single strobe as well.
1727 @see set_single_strobe_enable()
1728 @return True if single strobe is enabled otherwise it's False.
1730 err_cp = (c_long * 1)(0)
1731 enable = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_enable(self.
devicedevice.device_id, err_cp)
1736 return bool(c_ubyte(enable))
1740 Get the amount of time, in microseconds, that should elapse after
1741 a starting event before the single strobe should have a rising edge.
1742 @see set_single_strobe_delay()
1743 @return The delay in microseconds.
1745 err_cp = (c_long * 1)(0)
1746 delay_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_delay(self.
devicedevice.device_id, err_cp)
1751 return delay_microsecond
1755 Get the amount of time, in microseconds, that the single strobe pulse
1756 should remain high after it begins.
1757 @see set_single_strobe_width()
1758 @return The pulse width in microseconds.
1760 err_cp = (c_long * 1)(0)
1761 width_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_width(self.
devicedevice.device_id, err_cp)
1766 return width_microsecond
1770 Gets the number of light sources that are represented by the given featureID. Such
1771 light sources could be individual LEDs, light bulbs, lasers, etc. Each of these light
1772 sources may have different capabilities, such as programmable intensities and enables,
1773 which should be queried before they are used.
1774 @return The number of light sources (e.g. bulbs) in the indicated feature
1776 err_cp = (c_long * 1)(0)
1777 light_source_count = self.
devicedevice.oceandirect.odapi_adv_get_light_source_count(self.
devicedevice.device_id, err_cp)
1782 return light_source_count
1786 Queries whether the indicated light source within the given feature instance has a usable
1787 enable/disable control. If this returns False (meaning no enable available) then calling enable_light_source()
1788 or is_light_source_enabled() is likely to result in an error.
1789 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1790 within the indicated feature instance to query
1791 @return False to indicate specified light source cannot be enabled/disabled. True to indicate specified
1792 light source can be enabled/disabled with enable_light_source()
1794 err_cp = (c_long * 1)(0)
1795 status = self.
devicedevice.oceandirect.odapi_adv_light_source_has_enable(self.
devicedevice.device_id, err_cp, light_source_index)
1804 Queries whether the indicated light source within the given feature instance is enabled (energized).
1805 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1806 within the indicated feature instance to query.
1807 @return False to indicate specified light source is disabled (should emit no light). True to indicate
1808 specified light source is enabled (should emit light depending on configured intensity setting).
1810 err_cp = (c_long * 1)(0)
1811 status = self.
devicedevice.oceandirect.odapi_adv_light_source_is_enabled(self.
devicedevice.device_id, err_cp, light_source_index)
1820 Attempts to enable or disable the indicated light source within the given feature instance. Not
1821 all light sources have an enable/disable control, and this capability can be queried with has_light_source_enable().
1822 Note that an enabled light source should emit light according to its last (or default) intensity
1823 setting which might be the minimum; in this case, the light source might appear to remain off.
1824 @param light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs) within
1825 the indicated feature instance to query.
1826 @param enable Whether to enable the light source. A value of False will attempt to disable the
1827 light source, and any other value will enable it.
1829 err_cp = (c_long * 1)(0)
1832 self.
devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.
devicedevice.device_id, err_cp, light_source_index, self.
lamp_onlamp_on)
1834 self.
devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.
devicedevice.device_id, err_cp, light_source_index, self.
lamp_offlamp_off)
1842 Set the enable status of the single strobe signal. Note that on some devices the enable control is
1843 shared with other signals (e.g. lamp enable and continuous strobe) so this may have some side-effects and
1844 changing those features may affect the single strobe as well.
1845 @see get_single_strobe_enable()
1846 @param enable True to enable single strobe otherwise use False.
1848 err_cp = (c_long * 1)(0)
1851 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_onlamp_on)
1853 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_offlamp_off)
1861 Set the amount of time, in microseconds, that should elapse after a starting event before
1862 the single strobe should have a rising edge.
1863 @see get_single_strobe_delay()
1864 @param delayMicrosecond The delay, in microseconds, that the single strobe should wait before
1867 err_cp = (c_long * 1)(0)
1868 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_delay(self.
devicedevice.device_id, err_cp, c_ulong(delayMicrosecond))
1876 Set the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1877 @see get_single_strobe_width()
1878 @param widthMicrosecond The duration, in microseconds, of the single strobe pulse after
1879 the rising edge occurs. Once this duration elapses, a falling edge
1882 err_cp = (c_long * 1)(0)
1883 self.
devicedevice.oceandirect.odapi_adv_set_single_strobe_width(self.
devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
1891 Get the enable status of the single strobe signal. Note that on some devices the enable control is shared
1892 with other signals (e.g. lamp enable and continuous strobe) so this may have some side-effects and
1893 changing those features may affect the single strobe as well.
1894 @see set_single_strobe_enable()
1895 @return True if single strobe is enabled otherwise it's False.
1897 err_cp = (c_long * 1)(0)
1898 enable = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_enable(self.
devicedevice.device_id, err_cp)
1903 return bool(c_ubyte(enable))
1907 Get the amount of time, in microseconds, that should elapse after a starting event before the single
1908 strobe should have a rising edge
1909 @see set_single_strobe_delay()
1910 @return The delay in microseconds.
1912 err_cp = (c_long * 1)(0)
1913 delay_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_delay(self.
devicedevice.device_id, err_cp)
1918 return delay_microsecond
1922 Get the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1923 @see set_single_strobe_width()
1924 @return The pulse width in microseconds.
1926 err_cp = (c_long * 1)(0)
1927 width_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_width(self.
devicedevice.device_id, err_cp)
1932 return width_microsecond
1936 Get the minimum amount of time, in microseconds, that should elapse after a starting event before the single
1937 strobe should have a rising edge.
1938 @return The minimum delay in microseconds.
1940 err_cp = (c_long * 1)(0)
1941 minimum_microseconds = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_minimum(self.
devicedevice.device_id, err_cp)
1944 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_delay_minimum")
1946 return minimum_microseconds
1950 Get the maximum amount of time, in microseconds, that should elapse after a starting event before the single
1951 strobe should have a rising edge.
1952 @return The maximum delay in microseconds.
1954 err_cp = (c_long * 1)(0)
1955 maximum_microseconds = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_maximum(self.
devicedevice.device_id, err_cp)
1958 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_delay_maximum")
1960 return maximum_microseconds
1964 Gets the single strobe delay increment in microseconds.
1965 @return The delay increment.
1967 err_cp = (c_long * 1)(0)
1968 delay_increment = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_increment(self.
devicedevice.device_id, err_cp)
1971 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_delay_increment")
1973 return delay_increment
1977 Get the minimum amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1978 @return The minimum width in microseconds.
1980 err_cp = (c_long * 1)(0)
1981 width_minimum = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_width_minimum(self.
devicedevice.device_id, err_cp)
1984 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_width_minimum")
1986 return width_minimum
1990 Get the maximum amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1991 @return The maximum width in microseconds.
1993 err_cp = (c_long * 1)(0)
1994 width_maximum = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_width_maximum(self.
devicedevice.device_id, err_cp)
1997 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_width_maximum")
1999 return width_maximum
2003 Get the single strobe width increment.
2004 @return The width increment.
2006 err_cp = (c_long * 1)(0)
2007 width_increment = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_width_increment(self.
devicedevice.device_id, err_cp)
2010 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_width_increment")
2012 return width_increment
2016 Gets the single strobe cycle maximum in microseconds.
2017 @return The maximum cycle value.
2019 err_cp = (c_long * 1)(0)
2020 cyle_maximum = self.
devicedevice.oceandirect.odapi_adv_get_single_strobe_cycle_maximum(self.
devicedevice.device_id, err_cp)
2023 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_single_strobe_cycle_maximum")
2029 Sets the continuous strobe period in microseconds.
2030 @see get_continuous_strobe_period()
2031 @param period The new period of the continuous strobe measured in microseconds
2033 err_cp = (c_long * 1)(0)
2034 self.
devicedevice.oceandirect.odapi_adv_set_continuous_strobe_period_micros(self.
devicedevice.device_id, err_cp, period)
2037 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_continuous_strobe_period_micros")
2042 Sets the continuous strobe enable state on the device.
2043 @see get_continuous_strobe_enable()
2044 @param enable A boolean used for denoting the desired state (on/off) of the continuous
2045 strobe generator. If the value of enable is nonzero, then the continuous
2046 strobe will operate. If the value of enable is zero, then the continuous
2047 strobe will stop. Note that on some devices the continuous strobe enable
2048 is tied to other enables (such as lamp enable or single strobe enable)
2049 which may cause side effects.
2051 err_cp = (c_long * 1)(0)
2054 self.
devicedevice.oceandirect.odapi_adv_set_continuous_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_onlamp_on)
2056 self.
devicedevice.oceandirect.odapi_adv_set_continuous_strobe_enable(self.
devicedevice.device_id, err_cp, self.
lamp_offlamp_off)
2059 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_continuous_strobe_enable")
2064 Get the continuous strobe period in microseconds.
2065 @see set_continuous_strobe_period()
2066 @return the period in microseconds.
2068 err_cp = (c_long * 1)(0)
2069 period_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_micros(self.
devicedevice.device_id, err_cp)
2072 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_continuous_strobe_period")
2074 return period_microsecond
2078 Gets the continuous strobe state (enabled or disabled) of the device.
2079 @see set_continuous_strobe_enable()
2080 @return True if continuous strobe is enabled otherwise it's False.
2082 err_cp = (c_long * 1)(0)
2083 enable = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_enable(self.
devicedevice.device_id, err_cp)
2088 return bool(c_ubyte(enable))
2092 Gets the minimum continuous strobe period of the device in microseconds.
2093 @return The minimum strobe period in microseconds.
2095 err_cp = (c_long * 1)(0)
2096 minimum_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_minimum_micros(self.
devicedevice.device_id, err_cp)
2099 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_continuous_strobe_period_minimum")
2101 return minimum_microsecond
2105 Gets the maximum continuous strobe period of the device in microseconds.
2106 @return The maximum strobe period in microseconds.
2108 err_cp = (c_long * 1)(0)
2109 maximum_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_maximum_micros(self.
devicedevice.device_id, err_cp)
2112 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_continuous_strobe_period_maximum")
2114 return maximum_microsecond
2118 This function gets the current size of the strobe period increment of the device in microseconds.
2119 The increment is dependent on the strobe period. Small strobe periods i.e. less than about 1ms
2120 will have a small increment, typically 1 microsecond. Larger strobe periods will have larger
2121 increments, typically 1ms.
2122 @return The current strobe period increment in microseconds.
2124 err_cp = (c_long * 1)(0)
2125 increment_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_increment_micros(self.
devicedevice.device_id, err_cp)
2128 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_continuous_strobe_period_increment")
2130 return increment_microsecond
2134 Gets the strobe width of the device in microseconds.
2135 @see set_continuous_strobe_width()
2136 @return The current strobe width in microseconds.
2138 err_cp = (c_long * 1)(0)
2139 width_microsecond = self.
devicedevice.oceandirect.odapi_adv_get_continuous_strobe_width_micros(self.
devicedevice.device_id, err_cp)
2144 return width_microsecond
2148 Sets the continuous strobe width on the device.
2149 @see get_continuous_strobe_width()
2150 @param widthMicrosecond The new width of the continuous strobe measured in microseconds.
2152 err_cp = (c_long * 1)(0)
2153 self.
devicedevice.oceandirect.odapi_adv_set_continuous_strobe_width_micros(self.
devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
2161 Clear the data buffer. An exception will be thrown if the command is not supported by the device.
2163 err_cp = (c_long * 1)(0)
2164 self.
devicedevice.oceandirect.odapi_adv_clear_data_buffer(self.
devicedevice.device_id, err_cp)
2172 Get the number of data elements currently in the buffer. An exception will be thrown if
2173 the command is not supported by the device.
2174 @return A count of how many items are available for retrieval from the buffer.
2176 err_cp = (c_long * 1)(0)
2177 number_of_elements = self.
devicedevice.oceandirect.odapi_adv_get_data_buffer_number_of_elements(self.
devicedevice.device_id, err_cp)
2180 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_data_buffer_number_of_elements")
2182 return number_of_elements
2186 Get the present limit of how many data elements will be retained by the buffer. This value can be
2187 changed with set_data_buffer_capacity(). An exception will be thrown if the command is not supported by the device.
2188 @see set_data_buffer_capacity()
2189 @return A count of how many items the buffer will store before data may be lost.
2191 err_cp = (c_long * 1)(0)
2192 maximum_buffer = self.
devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity(self.
devicedevice.device_id, err_cp)
2197 return maximum_buffer
2201 Get the maximum possible configurable size for the data buffer. An exception will be thrown if
2202 the command is not supported by the device.
2203 @return The largest value that may be set with set_data_buffer_capacity().
2205 err_cp = (c_long * 1)(0)
2206 maximum_buffer_capacity = self.
devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity_maximum(self.
devicedevice.device_id, err_cp)
2209 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_data_buffer_capacity_maximum")
2211 return maximum_buffer_capacity
2215 Get the minimum possible configurable size for the data buffer. An exception will be thrown if
2216 the command is not supported by the device.
2217 @return The smallest value that may be set with set_data_buffer_capacity().
2219 err_cp = (c_long * 1)(0)
2220 minimum_buffer_capacity = self.
devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity_minimum(self.
devicedevice.device_id, err_cp)
2223 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_data_buffer_capacity_minimum")
2225 return minimum_buffer_capacity
2229 Set the number of data elements that the buffer should retain. This function must be used
2230 with "set_number_of_backtoback_scans()". An exception will be thrown if the command is
2231 not supported by the device.
2232 @see get_data_buffer_capacity()
2233 @param capacity Limit on the number of data elements to store. This is bounded by what is returned
2234 by get_data_buffer_capacity_minimum() and get_data_buffer_capacity_maximum().
2236 err_cp = (c_long * 1)(0)
2237 self.
devicedevice.oceandirect.odapi_adv_set_data_buffer_capacity(self.
devicedevice.device_id, err_cp, capacity)
2245 Enable or disable data buffering. An exception will be thrown if the command is not supported by the device.
2246 @see get_data_buffer_enable()
2247 @param enable True enable the buffer. False disable the buffer.
2250 if enable ==
True or enable == 1:
2253 err_cp = (c_long * 1)(0)
2254 self.
devicedevice.oceandirect.odapi_adv_set_data_buffer_enable(self.
devicedevice.device_id, err_cp, flag)
2262 Reads the device data buffering enable state. An exception will be thrown if the command is not supported by the device.
2263 @see set_data_buffer_enable()
2264 @return True if data buffering is enabled otherwise it's False.
2266 err_cp = (c_long * 1)(0)
2267 dataBufferState = self.
devicedevice.oceandirect.odapi_adv_get_data_buffer_enable(self.
devicedevice.device_id, err_cp)
2272 return bool(c_ubyte(dataBufferState))
2276 Abort spectra acquisition and put the device into an idle state. To resume spectra acquisition,
2277 you have to call acquire_spectra_to_buffer() first before calling the get spectra command. Very
2278 few devices supported this command.
2279 @see acquire_spectra_to_buffer()
2280 @see get_device_idle_state()
2282 err_cp = (c_long * 1)(0)
2283 self.
devicedevice.oceandirect.odapi_adv_abort_acquisition(self.
devicedevice.device_id, err_cp)
2291 Start spectra acquisition. This would transition the device into a non-idle state. Very
2292 few devices supported this command. An exception will be thrown if the command is
2293 not supported by the device.
2294 @see abort_acquisition()
2295 @see get_device_idle_state()
2297 err_cp = (c_long * 1)(0)
2298 self.
devicedevice.oceandirect.odapi_adv_acquire_spectra_to_buffer(self.
devicedevice.device_id, err_cp)
2306 Return device idle state. Very few devices supported this command. An exception will be thrown if
2307 the command is not supported by the device.
2308 @see abort_acquisition()
2309 @return True if the device is idle otherwise it's False.
2311 err_cp = (c_long * 1)(0)
2312 retval = self.
devicedevice.oceandirect.odapi_adv_get_device_idle_state(self.
devicedevice.device_id, err_cp)
2317 return bool(c_ubyte(retval))
2321 Get the number of back-to-back scans. See device manual if data buffering is supported.
2322 @see set_number_of_backtoback_scans()
2323 @return The back-to-back scan value.
2325 err_cp = (c_long * 1)(0)
2326 retval = self.
devicedevice.oceandirect.odapi_adv_get_number_of_backtoback_scans(self.
devicedevice.device_id, err_cp)
2329 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_number_of_backtoback_scans")
2335 Set the number of spectra that the device will capture per trigger event. This function requires
2336 data buffer to be enabled. See "set_data_buffer_enable()". See device manual if data buffering is supported.
2337 @see get_number_of_backtoback_scans()
2338 @param numScans The back-to-back scan value.
2340 err_cp = (c_long * 1)(0)
2341 self.
devicedevice.oceandirect.odapi_adv_set_number_of_backtoback_scans(self.
devicedevice.device_id, err_cp, numScans)
2344 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_number_of_backtoback_scans")
2349 Returns spectra with metadata information. For older devices such as FX/HDX, read a maximum of 15
2350 spectra from the data buffer. This function requires that both back to back scans and data buffer
2351 be enabled. See "set_data_buffer_enable()" and "set_number_of_backtoback_scans()". For newer devices
2352 such as Ocean SR2, you can call this function right away. See device manual if this command is supported.
2353 @param list_raw_spectra The spectra output buffer.
2354 @param list_timestamp The timestamp output buffer of each spectra.
2355 @param buffer_size The buffer array size (maximum is 15).
2356 @return The number of spectra read. It can be zero.
2358 buffer = (POINTER(c_double) * buffer_size)()
2359 for x
in range(buffer_size):
2360 buffer[x] = (c_double * self.
devicedevice.pixel_count_formatted)()
2362 timestamp = (c_longlong * buffer_size)(0)
2363 err_cp = (c_long * 1)(0)
2364 spectraCount = self.
devicedevice.oceandirect.odapi_get_raw_spectrum_with_metadata(self.
devicedevice.device_id, err_cp, buffer, buffer_size,
2365 self.
devicedevice.pixel_count_formatted, timestamp, buffer_size)
2368 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_raw_spectrum_with_metadata")
2371 for x
in range(spectraCount):
2372 spectra = [
None] * self.
devicedevice.pixel_count_formatted
2375 for y
in range(self.
devicedevice.pixel_count_formatted):
2376 spectra[y] = buffer[x][y]
2378 list_raw_spectra.append(spectra)
2380 list_timestamp.append(timestamp[x])
2385 This function returns the usb primary OUT endpoint for the type specified. If the type is not
2386 supported by the device, a zero is returned. 0 is normally the control endpoint. That
2387 value is not valid in this context.
2388 @return The usb endpoint address.
2390 err_cp = (c_long * 1)(0)
2391 usb_primary_endpoint_out = self.
devicedevice.oceandirect.odapi_get_device_usb_endpoint_primary_out(self.
devicedevice.device_id, err_cp)
2394 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_usb_endpoint_primary_out")
2396 return int(usb_primary_endpoint_out)
2400 This function returns the usb primary IN endpoint for the type specified. If the type is not
2401 supported by the device, a zero is returned. 0 is normally the control endpoint. That
2402 value is not valid in this context.
2403 @return The usb endpoint address.
2405 err_cp = (c_long * 1)(0)
2406 usb_primary_endpoint_in = self.
devicedevice.oceandirect.odapi_get_device_usb_endpoint_primary_in(self.
devicedevice.device_id, err_cp)
2411 return int(usb_primary_endpoint_in)
2415 This function returns the usb secondary OUT endpoint for the type specified. If the type is
2416 not supported by the device, a zero is returned. 0 is normally the control endpoint. That
2417 value is not valid in this context.
2418 @return The usb endpoint address.
2420 err_cp = (c_long * 1)(0)
2421 usb_secondary_endpoint_out = self.
devicedevice.oceandirect.odapi_get_device_usb_endpoint_secondary_out(self.
devicedevice.device_id, err_cp)
2424 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_usb_endpoint_secondary_out")
2426 return int(usb_secondary_endpoint_out)
2430 This function returns the usb secondary IN endpoint for the type specified. If the type is
2431 not supported by the device, a zero is returned. 0 is normally the control endpoint. That
2432 value is not valid in this context.
2433 @return The usb endpoint address.
2435 err_cp = (c_long * 1)(0)
2436 usb_secondary_endpoint_in = self.
devicedevice.oceandirect.odapi_get_device_usb_endpoint_secondary_in(self.
devicedevice.device_id, err_cp)
2438 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_usb_endpoint_secondary_in")
2440 return int(usb_secondary_endpoint_in)
2444 Reads out the firmware revision from the device's internal memory if that feature is supported.
2445 @return The firmware revision.
2447 self.
devicedevice.oceandirect.odapi_adv_get_revision_firmware.argtypes = [c_long, POINTER(c_int32), POINTER(c_char), c_int32]
2448 self.
devicedevice.oceandirect.odapi_adv_get_revision_firmware.restype = c_int32
2450 fw_revision_cp = create_string_buffer(b
'\000' * 100)
2451 bytesRead = self.
devicedevice.oceandirect.odapi_adv_get_revision_firmware(self.
devicedevice.device_id, byref(err_cp), fw_revision_cp, 100)
2453 if err_cp.value != 0:
2457 version = fw_revision_cp.value.decode()
2458 if "." not in version
and bytesRead == 3:
2459 version =
"{0}.{1}.{2}".format(chr(fw_revision_cp.value[0]),
2460 chr(fw_revision_cp.value[1]), chr(fw_revision_cp.value[2]))
2466 Reads out the FPGA revision from the device's internal memory if that feature is supported.
2467 @return The fpga revision.
2469 self.
devicedevice.oceandirect.odapi_adv_get_revision_fpga.argtypes = [c_long, POINTER(c_int32), POINTER(c_char), c_int32]
2470 self.
devicedevice.oceandirect.odapi_adv_get_revision_fpga.restype = c_int32
2472 fpga_revision_cp = create_string_buffer(b
'\000' * 100)
2473 bytesRead = self.
devicedevice.oceandirect.odapi_adv_get_revision_fpga(self.
devicedevice.device_id, byref(err_cp), fpga_revision_cp, 100)
2475 if err_cp.value != 0:
2479 version = fpga_revision_cp.value.decode()
2480 if "." not in version
and bytesRead == 3:
2481 version =
"{0}.{1}.{2}".format(chr(fpga_revision_cp.value[0]),
2482 chr(fpga_revision_cp.value[1]), chr(fpga_revision_cp.value[2]))
2487 Reads out the System revision from the device's internal memory if that feature is supported.
2488 @return The system revision.
2490 self.
devicedevice.oceandirect.odapi_adv_get_revision_system.argtypes = [c_long, POINTER(c_int32), POINTER(c_char), c_int32]
2491 self.
devicedevice.oceandirect.odapi_adv_get_revision_system.restype = c_int32
2493 sys_revision_cp = create_string_buffer(b
'\000' * 100)
2494 bytesRead = self.
devicedevice.oceandirect.odapi_adv_get_revision_system(self.
devicedevice.device_id, byref(err_cp), sys_revision_cp, 100)
2496 if err_cp.value != 0:
2500 version = sys_revision_cp.value.decode()
2501 if "." not in version
and bytesRead == 3:
2502 version =
"{0}.{1}.{2}".format(chr(sys_revision_cp.value[0]),
2503 chr(sys_revision_cp.value[1]), chr(sys_revision_cp.value[2]))
2508 Check to see if DHCP (client) is enabled on the specified interface. If DHCP is enabled then the
2509 device will be able to receive an IP address from a DHCP server in the network it is connected to. See
2510 device manual if TCP/IP connection is supported.
2511 @see ipv4_set_dhcp_enable()
2512 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2513 @return True if DHCP is enabled on the specified interface otherwise it's False.
2515 err_cp = (c_long * 1)(0)
2516 enable = self.
devicedevice.oceandirect.odapi_adv_ipv4_is_dhcp_enabled(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum))
2521 return bool(c_ubyte(enable))
2528 Turn the DHCP client on or off for the device on the specified interface. See device manual if TCP/IP
2529 connection is supported.
2530 @see ipv4_is_dhcp_enabled()
2531 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2532 @param enabled False turns the DHCP client off. True turns the DHCP client on.
2534 err_cp = (c_long * 1)(0)
2535 self.
devicedevice.oceandirect.odapi_adv_ipv4_set_dhcp_enable(self.
devicedevice.device_id, err_cp, ifNum, enabled)
2546 Get the number of IP addresses available on the specified interface. If DHCP is enabled on the
2547 specified interface then index 0 represents the DHCP address and the following addresses
2548 will be any static IP addresses. See device manual if TCP/IP connection is supported.
2549 @see ipv4_add_static_ip_address()
2550 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2551 @return The number of IP addresses on the specified interface.
2553 err_cp = (c_long * 1)(0)
2554 numIpAddress = self.
devicedevice.oceandirect.odapi_adv_ipv4_get_number_of_ip_addresses(self.
devicedevice.device_id, err_cp, ifNum)
2557 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"ipv4_get_number_of_ip_addresses")
2559 return numIpAddress;
2566 Get the assigned ip address provided by the index of a particular interface. See device manual if
2567 TCP/IP connection is supported.
2568 @see ipv4_add_static_ip_address()
2569 @param ifNum The network interface. 0 for ethernet, 1 for wifi.
2570 @param addressIndex The location of the ip address. Starts with 0.
2571 @return A tuple of ip address (4-byte) and network mask (int).
2573 err_cp = (c_long * 1)(0)
2574 netmask_cp = (c_uint * 1)(0)
2575 ip_address_cp = (c_ubyte * 4)(0)
2576 self.
devicedevice.oceandirect.odapi_adv_ipv4_read_ip_address(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum), c_ubyte(addressIndex),
2577 ip_address_cp, 4, netmask_cp)
2580 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"ipv4_get_number_of_ip_addresses")
2584 outNetmask = int(netmask_cp[0])
2585 for i
in range(len(ip_address_cp)):
2586 outIpAddress.append(int(ip_address_cp[i]))
2587 return (outIpAddress, outNetmask)
2594 Add a static IP address to the specified interface. The IP address is specified as 4 bytes in an
2595 array. The leading part of the IP address must contain the first element of the array, followed by the
2596 remaining parts in order to the last part of the IP address in the fourth element of the array. See
2597 device manual if TCP/IP connection is supported.
2598 @see ipv4_delete_static_ip_address()
2599 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2600 @param ipAddress The static IP address to be added. This is 4-byte array data.
2601 @param netmask An 8-bit network mask specifying the subnet of the network the device is on.
2603 err_cp = (c_long * 1)(0)
2605 if len(ipAddress) != 4:
2606 error_msg =
"ipv4_add_static_ip_address() error: ipAddress must be an array of 4 bytes long."
2609 ip_address_cp = (c_ubyte * 4)(0)
2611 ip_address_cp[i] = ipAddress[i]
2614 self.
devicedevice.oceandirect.odapi_adv_ipv4_add_static_ip_address(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum), ip_address_cp, 4, c_uint(netmask))
2624 Delete a static IP address on the specified interface. See device manual if TCP/IP connection is supported.
2625 @see ipv4_add_static_ip_address()
2626 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2627 @param addressIndex The index of the address to be deleted.
2629 err_cp = (c_long * 1)(0)
2630 self.
devicedevice.oceandirect.odapi_adv_ipv4_delete_static_ip_address(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum), c_ubyte(addressIndex))
2632 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"ipv4_delete_static_ip_address")
2640 Set the default gateway IP address to the specified interface. See device manual if TCP/IP connection is supported.
2641 @see ipv4_get_default_gateway_ip_address()
2642 @param ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2643 @param ipAddress The static IP address to be added. This is 4-byte array data.
2645 err_cp = (c_long * 1)(0)
2646 if len(ipAddress) != 4:
2647 error_msg =
"ipv4_set_default_gateway_ip_address() error: ipAddress must be an array of 4 bytes long."
2650 ip_address_cp = (c_ubyte * 4)(0)
2652 ip_address_cp[i] = ipAddress[i]
2655 self.
devicedevice.oceandirect.odapi_adv_ipv4_set_default_gateway_ip_address(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum), ip_address_cp, 4)
2657 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"ipv4_set_default_gateway_ip_address")
2665 Get the default gateway IP address to the specified interface. See device manual if TCP/IP connection is supported.
2666 @see ipv4_set_default_gateway_ip_address()
2667 @param ifNum The network interface. 0 for ethernet, 1 for wifi.
2668 @return The ip address (4-byte).
2670 err_cp = (c_long * 1)(0)
2671 ip_address_cp = (c_ubyte * 4)(0)
2672 self.
devicedevice.oceandirect.odapi_adv_ipv4_get_default_gateway_ip_address(self.
devicedevice.device_id, err_cp, c_ubyte(ifNum),
2676 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"ipv4_get_default_gateway_ip_address")
2680 for i
in range(len(ip_address_cp)):
2681 outIpAddress.append(int(ip_address_cp[i]))
2690 @return The pin count.
2692 err_cp = (c_long * 1)(0)
2693 gpioPinCount = self.
devicedevice.oceandirect.odapi_adv_get_gpio_pin_count(self.
devicedevice.device_id, err_cp)
2702 Sets the GPIO bit direction to either output or input.
2703 @see gpio_get_output_enable1()
2704 @param bit The bit position.
2705 @param isOutput The bit value which could be true(output) or false(input).
2707 err_cp = (c_long * 1)(0)
2708 self.
devicedevice.oceandirect.odapi_adv_gpio_set_output_enable1(self.
devicedevice.device_id, err_cp, bit, isOutput)
2716 Get GPIO bit direction.
2717 @see gpio_set_output_enable1()
2718 @param bit The bit position.
2719 @return The bit direction which could be True(out) or False(in)
2721 err_cp = (c_long * 1)(0)
2722 bitDirection = self.
devicedevice.oceandirect.odapi_adv_gpio_get_output_enable1(self.
devicedevice.device_id, err_cp, bit)
2727 return bool(c_ubyte(bitDirection))
2731 Set the direction (input/output) of the GPIO pins.
2732 @see gpio_get_output_enable2()
2733 @param bitmask The bit mask specifying the pin directions i.e. the nth bit set to 1 sets the nth pin to output.
2735 err_cp = (c_long * 1)(0)
2736 self.
devicedevice.oceandirect.odapi_adv_gpio_set_output_enable2(self.
devicedevice.device_id, err_cp, c_int(bitmask))
2744 Get all GPIO bit direction.
2745 @see gpio_set_output_enable2()
2746 @return All bit (int) direction where each bit could be True(out) or False(in).
2748 err_cp = (c_long * 1)(0)
2749 allBitDirection = self.
devicedevice.oceandirect.odapi_adv_gpio_get_output_enable2(self.
devicedevice.device_id, err_cp)
2754 return allBitDirection
2758 Sets the GPIO bit value to either high or low.
2759 @see gpio_get_value1()
2760 @param bit The bit position.
2761 @param isHigh The bit value which could be true(high) or false(low).
2763 err_cp = (c_long * 1)(0)
2764 self.
devicedevice.oceandirect.odapi_adv_gpio_set_value1(self.
devicedevice.device_id, err_cp, bit, isHigh)
2772 Get the GPIO bit value in whether it's high(true) or low(false).
2773 @see gpio_set_value1()
2774 @param bit The bit position.
2775 @return The bit value. True for high and False for low.
2777 err_cp = (c_long * 1)(0)
2778 bitValue = self.
devicedevice.oceandirect.odapi_adv_gpio_get_value1(self.
devicedevice.device_id, err_cp, bit)
2783 return bool(c_ubyte(bitValue))
2787 Set the logic value for all GPIO pins.
2788 @see gpio_get_value2()
2789 @param bitmask The bit mask specifying the logic level of each GPIO pin.
2791 err_cp = (c_long * 1)(0)
2792 self.
devicedevice.oceandirect.odapi_adv_gpio_set_value2(self.
devicedevice.device_id, err_cp, c_int(bitmask))
2800 Get all GPIO bit values.
2801 @see gpio_set_value2()
2802 @return All bit value (int) where each bit could be True(high) or False(low).
2804 err_cp = (c_long * 1)(0)
2805 allBitValue = self.
devicedevice.oceandirect.odapi_adv_gpio_get_value2(self.
devicedevice.device_id, err_cp)
2814 Set the alternate functionality for the specified pins (bits). Not
2815 all spectrometers support this functionality.
2816 @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2817 @see gpio_get_output_alternate1()
2818 @param bit The GPIO bit or pin to set.
2819 @param isAlternate Set true to enable the alternate functionality for the pin, false otherwise (pin is a GPIO pin).
2821 err_cp = (c_long * 1)(0)
2822 self.
devicedevice.oceandirect.odapi_adv_gpio_set_output_alternate1(self.
devicedevice.device_id, err_cp, bit, isAlternate)
2830 Set the alternate functionality for the specified pins (bits). Not
2831 all spectrometers support this functionality.
2832 @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2833 @see gpio_get_output_alternate2()
2834 @param bitmask The bits set to 1 to set enable the alternate functionality, 0 otherwise (pin is a GPIO pin).
2836 err_cp = (c_long * 1)(0)
2837 self.
devicedevice.oceandirect.odapi_adv_gpio_set_output_alternate2(self.
devicedevice.device_id, err_cp, c_int(bitmask))
2845 Get the setting for alternate functionality on the specified bit (pin). Not
2846 all spectrometers support this functionality.
2847 @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2848 @see gpio_set_output_alternate1()
2849 @param bit The GPIO bit or pin to set.
2850 @return The bit value. True if the pin is set to alternate functionality, false otherwise (pin is a GPIO pin).
2852 err_cp = (c_long * 1)(0)
2853 bitValue = self.
devicedevice.oceandirect.odapi_adv_gpio_get_output_alternate1(self.
devicedevice.device_id, err_cp, bit)
2858 return bool(c_ubyte(bitValue))
2862 Get the settings for alternate functionality on the GPIO pins. Not
2863 all spectrometers support this functionality.
2864 @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2865 @see gpio_set_output_alternate2()
2866 @return A bitmask with value 1 where the corresponding pin is set to alternate functionality, 0 otherwise (pin is a GPIO pin).
2868 err_cp = (c_long * 1)(0)
2869 allBitValue = self.
devicedevice.oceandirect.odapi_adv_gpio_get_output_alternate2(self.
devicedevice.device_id, err_cp)
2878 Enable or disable device LED. If the device don't have an LED then an exception will be thrown.
2879 @see get_led_enable()
2880 @param isEnabled True to enable LED blinking otherwise it's False.
2882 err_cp = (c_long * 1)(0)
2883 self.
devicedevice.oceandirect.odapi_adv_set_led_enable(self.
devicedevice.device_id, err_cp, isEnabled)
2891 Get device LED state. If the device don't have an LED then an exception will be thrown.
2892 @see set_led_enable()
2893 @return True if LED is enabled otherwise it's False.
2895 err_cp = (c_long * 1)(0)
2896 ledState = self.
devicedevice.oceandirect.odapi_adv_get_led_enable(self.
devicedevice.device_id, err_cp)
2901 return bool(c_ubyte(ledState))
2905 Get the original vendor id (VID) of the device.
2908 err_cp = (c_long * 1)(0)
2909 orig_vid = self.
devicedevice.oceandirect.odapi_adv_get_device_original_vid(self.
devicedevice.device_id, err_cp)
2918 Get the original product id (PID) of the device.
2921 err_cp = (c_long * 1)(0)
2922 orig_pid = self.
devicedevice.oceandirect.odapi_adv_get_device_original_pid(self.
devicedevice.device_id, err_cp)
2931 Get the current vendor id (VID) of the device.
2934 err_cp = (c_long * 1)(0)
2935 vid = self.
devicedevice.oceandirect.odapi_adv_get_device_vid(self.
devicedevice.device_id, err_cp)
2944 Get the current product id (PID) of the device.
2947 err_cp = (c_long * 1)(0)
2948 pid = self.
devicedevice.oceandirect.odapi_adv_get_device_pid(self.
devicedevice.device_id, err_cp)
2957 Get the original manufacturer string of the device.
2958 @return The manufacturer string.
2960 orig_manufacturer = create_string_buffer(b
'\000'*50)
2961 err_cp = (c_long * 1)(0)
2962 self.
devicedevice.oceandirect.odapi_adv_get_device_original_manufacturer_string(self.
devicedevice.device_id, err_cp, orig_manufacturer, 50)
2965 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_device_original_manufacturer_string")
2967 return orig_manufacturer.value.decode()
2971 Get the original model string of the device.
2972 @return The model string.
2974 orig_model = create_string_buffer(b
'\000'*50)
2975 err_cp = (c_long * 1)(0)
2976 self.
devicedevice.oceandirect.odapi_adv_get_device_original_model_string(self.
devicedevice.device_id, err_cp, orig_model, 50)
2979 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_device_original_model_string")
2981 return orig_model.value.decode()
2985 Get the current manufacturer string of the device.
2986 @see set_device_manufacturer_string()
2987 @return The manufacturer string.
2989 manufacturer = create_string_buffer(b
'\000'*50)
2990 err_cp = (c_long * 1)(0)
2991 self.
devicedevice.oceandirect.odapi_adv_get_device_manufacturer_string(self.
devicedevice.device_id, err_cp, manufacturer, 50)
2994 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_device_manufacturer_string")
2996 return manufacturer.value.decode()
3000 Get the current model string of the device.
3001 @see set_device_model_string()
3002 @return The model string.
3004 model = create_string_buffer(b
'\000'*50)
3005 err_cp = (c_long * 1)(0)
3006 self.
devicedevice.oceandirect.odapi_adv_get_device_model_string(self.
devicedevice.device_id, err_cp, model, 50)
3009 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_device_original_model_string")
3011 return model.value.decode()
3015 Set the current manufacturer string of the device.
3016 @see get_device_manufacturer_string()
3017 @param manufacturer The new manufacturer string.
3019 if not manufacturer:
3022 err_cp = (c_long * 1)(0)
3023 self.
devicedevice.oceandirect.odapi_adv_set_device_manufacturer_string(self.
devicedevice.device_id, err_cp, manufacturer.encode(
'utf-8'), len(manufacturer))
3026 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_device_manufacturer_string")
3031 Set the current model string of the device.
3032 @see get_device_model_string()
3033 @param model The new model string.
3038 err_cp = (c_long * 1)(0)
3039 self.
devicedevice.oceandirect.odapi_adv_set_device_model_string(self.
devicedevice.device_id, err_cp, model.encode(
'utf-8'), len(model))
3083 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.
3084 @see set_device_alias()
3085 @return The device alias.
3087 device_alias = create_string_buffer(b
'\000'*50)
3088 err_cp = (c_long * 1)(0)
3089 self.
devicedevice.oceandirect.odapi_adv_get_device_alias(self.
devicedevice.device_id, err_cp, device_alias, 50)
3094 return device_alias.value.decode()
3098 Set a new device alias to the device.
3099 @see get_device_alias()
3100 @param deviceAlias The device alias. If value is empty then an exception will be thrown.
3107 err_cp = (c_long * 1)(0)
3108 self.
devicedevice.oceandirect.odapi_adv_set_device_alias(self.
devicedevice.device_id, err_cp, deviceAlias.encode(
'utf-8'), len(deviceAlias))
3116 Restarts the device.
3118 err_cp = (c_long * 1)(0)
3119 self.
devicedevice.oceandirect.odapi_adv_reset_device(self.
devicedevice.device_id, err_cp)
3127 Read the user string from the device. If this field in the device is not yet populated then a
3128 non-zero(6) code will be returned. This is the command supported for the newer OBP2.0 enabled devices.
3129 @see set_user_string()
3130 @return The user string.
3132 user_string = create_string_buffer(b
'\000'*50)
3133 err_cp = (c_long * 1)(0)
3134 self.
devicedevice.oceandirect.odapi_get_user_string(self.
devicedevice.device_id, err_cp, user_string, 50)
3139 return user_string.value.decode()
3143 Set a new user string to the device. The maximum string length is 16. This is the command supported
3144 for the newer OBP2.0 enabled devices.
3145 @see get_user_string()
3146 @param userString The user string. If value is empty then an exception will be thrown.
3153 err_cp = (c_long * 1)(0)
3154 self.
devicedevice.oceandirect.odapi_set_user_string(self.
devicedevice.device_id, err_cp, userString.encode(
'utf-8'), len(userString))
3162 Read the total user string count from the device. If the device don't support this command
3163 then a non-zero error code will be returned. This command is used by legacy devices.
3164 @see set_user_string2()
3165 @return The string count.
3167 err_cp = (c_long * 1)(0)
3168 string_count = self.
devicedevice.oceandirect.odapi_get_user_string_count1(self.
devicedevice.device_id, err_cp)
3177 Read the user string from the device. If this field in the device is not yet populated then a
3178 non-zero(6) code will be returned. If the device don't support this command then a non-zero
3179 error code will be returned. This command is used by legacy devices.
3180 @see set_user_string2()
3181 @return The user string.
3183 user_string = create_string_buffer(b
'\000'*50)
3184 err_cp = (c_long * 1)(0)
3185 self.
devicedevice.oceandirect.odapi_get_user_string1(self.
devicedevice.device_id, err_cp, c_int(index), user_string, 50)
3190 return user_string.value.decode()
3194 Write the user string to the device. The maximum string length is 16. If the device don't support this command
3195 then a non-zero error code will be returned. This command is used by legacy devices.
3196 @see get_user_string2()
3197 @param index The user string index. If index is less than 0 then an exception will be thrown.
3198 @param userString The user string. If value is empty then an exception will be thrown.
3200 if index < 0
or not userString:
3205 err_cp = (c_long * 1)(0)
3206 self.
devicedevice.oceandirect.odapi_set_user_string1(self.
devicedevice.device_id, err_cp, c_int(index), userString.encode(
'utf-8'), len(userString))
3214 Read the maximum ADC counts.
3215 @return The ADC counts.
3217 err_cp = (c_long * 1)(0)
3218 adcCount = self.
devicedevice.oceandirect.odapi_adv_get_autonull_maximum_adc_count(self.
devicedevice.device_id, err_cp)
3221 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_autonull_maximum_adc_count")
3228 Read the baseline level.
3229 @return The baseline level.
3231 err_cp = (c_long * 1)(0)
3232 baseline = self.
devicedevice.oceandirect.odapi_adv_get_autonull_baseline_level(self.
devicedevice.device_id, err_cp)
3241 Read the saturation level. Most devices returns 65535.
3242 @return The saturation level.
3244 err_cp = (c_long * 1)(0)
3245 saturation = self.
devicedevice.oceandirect.odapi_adv_get_autonull_saturation_level(self.
devicedevice.device_id, err_cp)
3248 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_autonull_saturation_level")
3254 Read the fpga digital gain value.
3255 @return The digital gain value.
3257 self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_gain.restype = c_int32
3258 self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_gain.argtypes = [c_int32, POINTER(c_int32)]
3259 err_cp = (c_long * 1)(0)
3260 gain = self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_gain(self.
devicedevice.device_id, err_cp)
3263 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_autonull_fpga_digital_gain")
3269 Read the fpga digital gain offset.
3270 @return The digital offset value.
3272 self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_offset.restype = c_int32
3273 self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_offset.argtypes = [c_int32, POINTER(c_int32)]
3274 err_cp = (c_long * 1)(0)
3275 offset = self.
devicedevice.oceandirect.odapi_adv_get_autonull_fpga_digital_offset(self.
devicedevice.device_id, err_cp)
3278 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_autonull_fpga_digital_offset")
3284 Read the device RS-232 baud rate. Not all devices supported this command.
3285 @see set_baud_rate()
3286 @return The baud rate.
3288 err_cp = (c_long * 1)(0)
3289 baud_rate = self.
devicedevice.oceandirect.odapi_adv_get_baud_rate(self.
devicedevice.device_id, err_cp)
3298 Set a new baud rate for the RS-232 port. Not all devices supported this command.
3299 @see get_baud_rate()
3300 @param baudRate The baud rate value.
3302 err_cp = (c_long * 1)(0)
3303 self.
devicedevice.oceandirect.odapi_adv_set_baud_rate(self.
devicedevice.device_id, err_cp, c_int(baudRate))
3311 Save settings to flash. Not all devices supported this command.
3313 err_cp = (c_long * 1)(0)
3314 self.
devicedevice.oceandirect.odapi_adv_save_settings_to_flash(self.
devicedevice.device_id, err_cp)
3322 Read the active pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3323 If the device don't support this command then a non-zero error code will be returned.
3324 @return A list of active pixel range.
3327 err_cp = (c_long * 1)(0)
3333 return list(rangeVal)[0:elementCopied]
3337 Read the optical dark pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3338 If the device don't support this command then a non-zero error code will be returned.
3339 @return A list of optical dark pixel range.
3341 rangeVal = (c_int * 50)(0)
3342 err_cp = (c_long * 1)(0)
3343 elementCopied = self.
devicedevice.oceandirect.odapi_get_optical_dark_pixel_range(self.
devicedevice.device_id, err_cp, rangeVal, 50)
3348 return list(rangeVal)[0:elementCopied]
3352 Read the transition pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3353 If the device don't support this command then a non-zero error code will be returned.
3354 @return A list of transition pixel range.
3356 rangeVal = (c_int * 50)(0)
3357 err_cp = (c_long * 1)(0)
3358 elementCopied = self.
devicedevice.oceandirect.odapi_get_transition_pixel_range(self.
devicedevice.device_id, err_cp, rangeVal, 50)
3363 return list(rangeVal)[0:elementCopied]
3367 Read bad pixel indices from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3368 If the device don't support this command then a non-zero error code will be returned.
3369 @return A list of bad pixel indices.
3371 rangeVal = (c_int * 40)(0)
3372 err_cp = (c_long * 1)(0)
3373 elementCopied = self.
devicedevice.oceandirect.odapi_get_bad_pixel_indices(self.
devicedevice.device_id, err_cp, rangeVal, 40)
3378 return list(rangeVal)[0:elementCopied]
3382 Read the number of supported communication interface.
3383 @return The number of interface.
3385 err_cp = (c_long * 1)(0)
3386 if_count = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_count(self.
devicedevice.device_id, err_cp)
3395 Return the interface type of the given interface index.
3396 @param interfaceIndex The interface to look at.
3397 @return The interface type which could be one 0(Loopback), 1(wired ethernet), 2 (WIFI), and 3 (USB - CDC Ethernet).
3399 err_cp = (c_long * 1)(0)
3400 if_type = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_type(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3412 Return true if the interface is enabled otherwise it's false.
3413 @see set_network_interface_status()
3414 @param interfaceIndex The interface to look at.
3415 @return True if the interface if enabled otherwise it's False.
3417 err_cp = (c_long * 1)(0)
3418 enabled = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3421 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_network_interface_status")
3423 return bool(c_ubyte(enabled))
3430 Enable or disable the interface.
3431 @see get_network_interface_status()
3432 @param interfaceIndex The interface that will be enabled or disabled.
3433 @param enable True will enable the interface. False will disable it.
3435 err_cp = (c_long * 1)(0)
3438 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(1))
3440 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(0))
3443 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_network_interface_status")
3451 Save the network interface settings to the device.
3452 @param interfaceIndex The interface to saved to.
3454 err_cp = (c_long * 1)(0)
3455 self.
devicedevice.oceandirect.odapi_adv_network_conf_save_interface_setting(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3458 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"save_network_interface_setting")
3466 Return the status on whether the gigabit ethernet is enabled or not.
3467 @see set_ethernet_gigabit_enable_status()
3468 @param interfaceIndex The ethernet interface to look at.
3469 @return The interface status.
3471 err_cp = (c_long * 1)(0)
3472 status = self.
devicedevice.oceandirect.odapi_adv_ethernet_get_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3475 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_ethernet_gigabit_enable_status")
3484 Enable or disable the gigabit ethernet the status.
3485 @see get_ethernet_gigabit_enable_status()
3486 @param interfaceIndex The ethernet interface to look at.
3487 @param enable True will enable gigabit ethernet.
3489 err_cp = (c_long * 1)(0)
3491 self.
devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3493 self.
devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3496 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_ethernet_gigabit_enable_status")
3504 Read the number of supported communication interface.
3505 @return The number of interface.
3507 err_cp = (c_long * 1)(0)
3508 if_count = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_count(self.
devicedevice.device_id, err_cp)
3517 Return the interface type of the given interface index.
3518 @param interfaceIndex The interface to look at.
3519 @return The interface type which could be one 0(Loopback), 1(wired ethernet), 2 (WIFI), and 3 (USB - CDC Ethernet).
3521 err_cp = (c_long * 1)(0)
3522 if_type = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_type(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3534 Return true if the interface is enabled otherwise it's false.
3535 @see set_network_interface_status()
3536 @param interfaceIndex The interface to look at.
3537 @return True if the interface if enabled otherwise it's False.
3539 err_cp = (c_long * 1)(0)
3540 enabled = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3543 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_network_interface_status")
3545 return bool(c_ubyte(enabled))
3552 Enable or disable the interface.
3553 @see get_network_interface_status()
3554 @param interfaceIndex The interface that will be enabled or disabled.
3555 @param enable True will enable the interface. False will disable it.
3557 err_cp = (c_long * 1)(0)
3560 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(1))
3562 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(0))
3565 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_network_interface_status")
3573 Save the network interface settings to the device.
3574 @param interfaceIndex The interface to saved to.
3576 err_cp = (c_long * 1)(0)
3577 self.
devicedevice.oceandirect.odapi_adv_network_conf_save_interface_setting(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3580 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"save_network_interface_setting")
3588 Return the status on whether the gigabit ethernet is enabled or not.
3589 @see set_ethernet_gigabit_enable_status()
3590 @param interfaceIndex The ethernet interface to look at.
3591 @return The interface status.
3593 err_cp = (c_long * 1)(0)
3594 status = self.
devicedevice.oceandirect.odapi_adv_ethernet_get_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3597 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_ethernet_gigabit_enable_status")
3606 Enable or disable the gigabit ethernet the status.
3607 @see get_ethernet_gigabit_enable_status()
3608 @param interfaceIndex The ethernet interface to look at.
3609 @param enable True will enable gigabit ethernet.
3611 err_cp = (c_long * 1)(0)
3613 self.
devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3615 self.
devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3618 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_ethernet_gigabit_enable_status")
3627 Return true if the multicast group message is enabled otherwise it's false.
3628 @see set_multicast_group_enabled()
3629 @param interfaceIndex The ethernet interface to look at.
3630 @return The multicast group enable status.
3632 err_cp = (c_long * 1)(0)
3633 status = self.
devicedevice.oceandirect.odapi_adv_network_conf_get_multicast_group_enabled(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3645 Enable or disable the multicast message group.
3646 @see get_multicast_group_enabled()
3647 @param interfaceIndex The ethernet interface to look at.
3648 @param enable True will enable multicast message group.
3650 err_cp = (c_long * 1)(0)
3652 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_multicast_group_enabled(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3654 self.
devicedevice.oceandirect.odapi_adv_network_conf_set_multicast_group_enabled(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3666 Read the ethernet 6-byte mac address from the spectrometer.
3667 @see set_ethernet_mac_address()
3668 @param interfaceIndex The ethernet interface to look at.
3669 @return The mac address.
3671 err_cp = (c_long * 1)(0)
3673 mac_address_cp = (c_ubyte * array_len)(0)
3675 self.
devicedevice.oceandirect.odapi_adv_ethernet_get_mac_address(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), mac_address_cp, array_len)
3682 for i
in range(array_len):
3683 value.append(int(mac_address_cp[i]))
3691 Writes a new ethernet 6-byte mac address into the spectrometer.
3692 @see get_ethernet_mac_address()
3693 @param interfaceIndex The ethernet interface to look at.
3694 @param macAddress The new mac address which is 6-byte long.
3696 err_cp = (c_long * 1)(0)
3697 array_len = len(macAddress)
3700 error_msg =
"set_ethernet_mac_address() error: macAddress must be an array of 6 bytes long."
3703 mac_address_cp = (c_ubyte * array_len)(0)
3704 for i
in range(array_len):
3705 mac_address_cp[i] = macAddress[i]
3707 self.
devicedevice.oceandirect.odapi_adv_ethernet_set_mac_address(self.
devicedevice.device_id, err_cp, c_uint(interfaceIndex), mac_address_cp, array_len)
3718 Read the IP address mode from the OBP2 device.
3719 @see get_ip_address_assigned_mode()
3720 @return True if the ip address was generated via DHCP. False if the ip address was statically assigned.
3722 err_cp = (c_long * 1)(0)
3723 status = self.
devicedevice.oceandirect.odapi_adv_get_ip_address_assigned_mode(self.
devicedevice.device_id, err_cp)
3726 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_ip_address_assigned_mode")
3729 return bool(c_ubyte(status))
3733 Set the IP address mode to the OBP2 device.
3734 @see get_ip_address_assigned_mode()
3735 @param useDHCP True will use DHCP server for ip assignment. False will use statically assigned IP address.
3737 err_cp = (c_long * 1)(0)
3743 self.
devicedevice.oceandirect.odapi_adv_set_ip_address_assigned_mode(self.
devicedevice.device_id, err_cp, c_ubyte(useDHCP))
3746 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_ip_address_assigned_mode")
3751 Read the network configuration parameters from an OBP2 enabled device. This function
3752 will return a tuple of 6 objects in this order:
3753 address mode - True if it's using a DHCP IP address otherwise its False.
3754 list[int] - the static IP address.
3755 list[int] - the subnet mask.
3756 list[int] - the default gateway IP address.
3757 list[int] - the DNS server IP address.
3758 @see set_manual_network_configuration()
3759 @return A tuple of 5 object objects.
3761 err_cp = (c_long * 1)(0)
3762 outManualAssignment_cp = c_ubyte(0)
3763 ipv4_address_array_len = 4
3764 subnet_mask_array_len = 4
3765 default_gateway_array_len = 4
3766 dns_server_array_len = 4
3767 ipv4_address_cp = (c_ubyte * ipv4_address_array_len)(0)
3768 subnet_mask_cp = (c_ubyte * subnet_mask_array_len)(0)
3769 default_gateway_cp = (c_ubyte * default_gateway_array_len)(0)
3770 dns_server_cp = (c_ubyte * dns_server_array_len)(0)
3772 self.
devicedevice.oceandirect.odapi_adv_get_network_configuration(self.
devicedevice.device_id, err_cp,
3773 byref(outManualAssignment_cp),
3774 ipv4_address_cp, ipv4_address_array_len,
3775 subnet_mask_cp, subnet_mask_array_len,
3776 default_gateway_cp, default_gateway_array_len,
3777 dns_server_cp, dns_server_array_len)
3785 default_gateway = []
3787 for i
in range(ipv4_address_array_len):
3788 ipv4_address.append(int(ipv4_address_cp[i]))
3789 subnet_mask.append(int(subnet_mask_cp[i]))
3790 default_gateway.append(int(default_gateway_cp[i]))
3791 dns_server.append(int(dns_server_cp[i]))
3792 return (bool(outManualAssignment_cp), ipv4_address, subnet_mask, default_gateway, dns_server)
3796 defaultGateway: list[int], dnsServer: list[int]) ->
None:
3798 Write the network configuration parameters (static ip address) on OBP2 enabled device.
3799 @see get_manual_network_configuration()
3800 @see get_network_configuration()
3801 @param ipv4Address The static IP address.
3802 @param subnetMask The subnet mask.
3803 @param defaultGateway The default gateway IP address.
3804 @param dnsServer The DNS server IP address.
3806 err_cp = (c_long * 1)(0)
3807 ipv4Address_array_len = len(ipv4Address)
3808 subnetMask_array_len = len(subnetMask)
3809 defaultGateway_array_len = len(defaultGateway)
3810 dnsServer_array_len = len(dnsServer)
3812 if ipv4Address_array_len != 4
or subnetMask_array_len != 4
or defaultGateway_array_len != 4
or dnsServer_array_len != 4:
3813 error_msg =
"set_manual_network_configuration() error: an array must of 4 bytes long."
3816 ipv4Address_cp = (c_ubyte * ipv4Address_array_len)(0)
3817 subnetMask_cp = (c_ubyte * subnetMask_array_len)(0)
3818 defaultGateway_cp = (c_ubyte * defaultGateway_array_len)(0)
3819 dnsServer_cp = (c_ubyte * dnsServer_array_len)(0)
3820 for i
in range(ipv4Address_array_len):
3821 ipv4Address_cp[i] = ipv4Address[i]
3822 subnetMask_cp[i] = subnetMask[i]
3823 defaultGateway_cp[i] = defaultGateway[i]
3824 dnsServer_cp[i] = dnsServer[i]
3826 self.
devicedevice.oceandirect.odapi_adv_set_manual_network_configuration(self.
devicedevice.device_id, err_cp,
3827 ipv4Address_cp, ipv4Address_array_len,
3828 subnetMask_cp, subnetMask_array_len,
3829 defaultGateway_cp, defaultGateway_array_len,
3830 dnsServer_cp, dnsServer_array_len)
3833 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"set_manual_network_configuration")
3838 Read the network configuration parameters (static ip address) from an OBP2 enabled device. This
3839 function will return a tuple of 4 objects in this order:
3840 list[int] - the static IP address.
3841 list[int] - the subnet mask.
3842 list[int] - the default gateway IP address.
3843 list[int] - the DNS server IP address.
3844 @see set_manual_network_configuration()
3845 @return A tuple of 4 object objects.
3847 err_cp = (c_long * 1)(0)
3848 ipv4_address_array_len = 4
3849 subnet_mask_array_len = 4
3850 default_gateway_array_len = 4
3851 dns_server_array_len = 4
3852 ipv4_address_cp = (c_ubyte * ipv4_address_array_len)(0)
3853 subnet_mask_cp = (c_ubyte * subnet_mask_array_len)(0)
3854 default_gateway_cp = (c_ubyte * default_gateway_array_len)(0)
3855 dns_server_cp = (c_ubyte * dns_server_array_len)(0)
3857 self.
devicedevice.oceandirect.odapi_adv_get_manual_network_configuration(self.
devicedevice.device_id, err_cp,
3858 ipv4_address_cp, ipv4_address_array_len,
3859 subnet_mask_cp, subnet_mask_array_len,
3860 default_gateway_cp, default_gateway_array_len,
3861 dns_server_cp, dns_server_array_len)
3864 error_msg = self.
devicedevice.
decode_error(err_cp[0],
"get_manual_network_configuration")
3869 default_gateway = []
3871 for i
in range(ipv4_address_array_len):
3872 ipv4_address.append(int(ipv4_address_cp[i]))
3873 subnet_mask.append(int(subnet_mask_cp[i]))
3874 default_gateway.append(int(default_gateway_cp[i]))
3875 dns_server.append(int(dns_server_cp[i]))
3877 return (ipv4_address, subnet_mask, default_gateway, dns_server)
An enumerated class for feature id.
None close_all_devices(self)
'Spectrometer' get_device(self, int device_id)
None set_multicast_msg_send_retry(self, int retryCount)
Set the number of times to send multicast message for dynamic probing.
'Spectrometer' open_device(self, int device_id)
Attach to a device discovered by probe_devices or get_device_ids.
str decode_error(self, int errno, str caller)
str get_serial_number(self, int dev_id)
Gets the serial number of a specified device.
None add_network_device(self, str ipAddressStr, str deviceTypeStr)
Manually create an instance of the network attached device and then open it using the openDevice() fu...
None shutdown(self)
Closes the connection to OceanDirectAPI.
None set_multicast_msg_response_read_delay(self, int delayMs)
Set the delay between reading multicast response.
tuple[int, int, int] get_api_version_numbers(self)
Return OceanDirect api version information.
int find_usb_devices(self)
Finds all available Ocean devices by scanning on USB for devices with Ocean drivers.
int find_devices(self)
Finds all available Ocean devices by scanning on USB for devices with Ocean drivers,...
None set_multicast_msg_response_read_retry(self, int retryCount)
Set the number of times to read multicast message response.
None close_device(self, int device_id)
Detach from the device indicated by device_id.
def __getattr__(self, name)
'Spectrometer' from_serial_number(self, str serial_num)
Return a spectrometer object associated with device id.
None add_rs232_device(self, str device_type, str bus_path, int baud)
Adds a device connected via RS 232 to the device list.
list[int] get_network_device_ids(self)
Return a list of network device ids from devices that were probe.
list[int] get_device_ids(self)
Return a list of device ids from devices that were both probe or manually added.
int get_number_devices(self)
Returns the number of devices available.
None list_all_devices(self)
Lists defined details of all active devices.
An error code and error message object wrapper.
tuple[int, str] get_error_details(self)
def __init__(self, int errorCode, str errorMsg)
Subclass containing advanced features that may or may not be in the spectrometer.
None get_shutter_state(self)
This function returns the shutter state of the spectrometer.
None set_multicast_group_enabled2(self, bool enable)
int get_autonull_saturation_level(self)
Read the saturation level.
int get_continuous_strobe_period_maximum(self)
Gets the maximum continuous strobe period of the device in microseconds.
int get_usb_endpoint_secondary_in(self)
This function returns the usb secondary IN endpoint for the type specified.
int ipv4_get_number_of_ip_addresses(self, int ifNum)
Get the number of IP addresses available on the specified interface.
None gpio_set_output_enable1(self, int bit, bool isOutput)
Sets the GPIO bit direction to either output or input.
int get_device_original_vid(self)
Get the original vendor id (VID) of the device.
None set_single_strobe_enable(self, bool enable)
Set the enable status of the single strobe signal.
int get_data_buffer_capacity_maximum(self)
Get the maximum possible configurable size for the data buffer.
str get_revision_firmware(self)
Reads out the firmware revision from the device's internal memory if that feature is supported.
int get_single_strobe_delay_increment(self)
Gets the single strobe delay increment in microseconds.
int get_single_strobe_delay_minimum(self)
Get the minimum amount of time, in microseconds, that should elapse after a starting event before the...
None ipv4_add_static_ip_address2(self, list[int] ipAddress, int netmask)
int get_single_strobe_width_increment(self)
Get the single strobe width increment.
list[int] get_active_pixel_range(self)
Read the active pixel range from the sensor pixel array.
int get_device_pid(self)
Get the current product id (PID) of the device.
float get_tec_temperature_degrees_C(self)
Returns the temperature reading (celsius) of a detector thermistor.
str get_user_string(self)
Read the user string from the device.
int get_single_strobe_width_maximum(self)
Get the maximum amount of time, in microseconds, that the single strobe pulse should remain high afte...
int get_device_vid(self)
Get the current vendor id (VID) of the device.
str get_device_alias(self)
Read the device alias from the device.
None save_settings_to_flash(self)
Save settings to flash.
None set_data_buffer_enable(self, bool enable)
Enable or disable data buffering.
int get_data_buffer_number_of_elements(self)
Get the number of data elements currently in the buffer.
int get_baud_rate(self)
Read the device RS-232 baud rate.
int get_usb_endpoint_secondary_out(self)
This function returns the usb secondary OUT endpoint for the type specified.
None set_continuous_strobe_width(self, int widthMicrosecond)
Sets the continuous strobe width on the device.
int gpio_get_output_enable2(self)
Get all GPIO bit direction.
int get_light_source_count(self)
Gets the number of light sources that are represented by the given featureID.
int get_single_strobe_delay(self)
Get the amount of time, in microseconds, that should elapse after a starting event before the single ...
None set_ethernet_gigabit_enable_status(self, int interfaceIndex, bool enable)
Enable or disable the gigabit ethernet the status.
int get_autonull_baseline_level(self)
Read the baseline level.
bool gpio_get_output_alternate1(self, int bit)
Get the setting for alternate functionality on the specified bit (pin).
str get_device_original_manufacturer_string(self)
Get the original manufacturer string of the device.
list[int] get_ethernet_mac_address(self, int interfaceIndex)
Read the ethernet 6-byte mac address from the spectrometer.
list[float] get_nonlinearity_coeffs(self)
Read the nonlinearity coefficients stored in the device.
int get_continuous_strobe_period_minimum(self)
Gets the minimum continuous strobe period of the device in microseconds.
int get_single_strobe_cycle_maximum(self)
Gets the single strobe cycle maximum in microseconds.
int get_autonull_fpga_digital_gain(self)
Read the fpga digital gain value.
None gpio_set_value2(self, int bitmask)
Set the logic value for all GPIO pins.
def __init__(self, 'Spectrometer' device)
None set_enable_lamp(self, bool enable)
Enable or disable the lamp.
int get_data_buffer_capacity(self)
Get the present limit of how many data elements will be retained by the buffer.
list[int] ipv4_get_default_gateway_ip_address2(self)
int get_number_of_backtoback_scans(self)
Get the number of back-to-back scans.
float get_nonlinearity_coeffs1(self, int index)
Read the nonlinearity coefficients count of a given position from the device.
None save_network_interface_setting2(self)
None gpio_set_value1(self, int bit, bool isHigh)
Sets the GPIO bit value to either high or low.
None set_user_string1(self, int index, str userString)
Write the user string to the device.
None set_device_model_string(self, str model)
Set the current model string of the device.
int get_usb_endpoint_primary_in(self)
This function returns the usb primary IN endpoint for the type specified.
None set_single_strobe_delay(self, int delayMicrosecond)
Set the amount of time, in microseconds, that should elapse after a starting event before the single ...
None ipv4_add_static_ip_address(self, int ifNum, list[int] ipAddress, int netmask)
Add a static IP address to the specified interface.
None reset_device(self)
Restarts the device.
list[int] get_optical_dark_pixel_range(self)
Read the optical dark pixel range from the sensor pixel array.
None ipv4_set_dhcp_enable2(self, bool enabled)
None ipv4_delete_static_ip_address(self, int ifNum, int addressIndex)
Delete a static IP address on the specified interface.
int get_autonull_fpga_digital_offset(self)
Read the fpga digital gain offset.
None set_network_interface_status2(self, bool enable)
int get_data_buffer_capacity_minimum(self)
Get the minimum possible configurable size for the data buffer.
bool get_led_enable(self)
Get device LED state.
int gpio_get_value2(self)
Get all GPIO bit values.
bool get_multicast_group_enabled2(self)
None enable_light_source(self, int light_source_index, bool enable)
Attempts to enable or disable the indicated light source within the given feature instance.
bool get_ethernet_gigabit_enable_status(self, int interfaceIndex)
Return the status on whether the gigabit ethernet is enabled or not.
None abort_acquisition(self)
Abort spectra acquisition and put the device into an idle state.
int get_device_original_pid(self)
Get the original product id (PID) of the device.
int get_network_interface_type2(self)
str get_revision_fpga(self)
Reads out the FPGA revision from the device's internal memory if that feature is supported.
None set_single_strobe_width(self, 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(self)
Get the continuous strobe period in microseconds.
None set_tec_enable(self, bool coolerEnable)
Enable or disable the thermo-electric cooler attached to the detector.
bool get_continuous_strobe_enable(self)
Gets the continuous strobe state (enabled or disabled) of the device.
None gpio_set_output_alternate2(self, int bitmask)
Set the alternate functionality for the specified pins (bits).
None set_ip_address_assigned_mode(self, bool useDHCP)
Set the IP address mode to the OBP2 device.
None ipv4_delete_static_ip_address2(self, int addressIndex)
None set_continuous_strobe_enable(self, bool enable)
Sets the continuous strobe enable state on the device.
list[int] ipv4_get_default_gateway_ip_address(self, int ifNum)
Get the default gateway IP address to the specified interface.
None ipv4_set_default_gateway_ip_address(self, int ifNum, list[int] ipAddress)
Set the default gateway IP address to the specified interface.
tuple[list[int], int] ipv4_read_ip_address(self, int ifNum, int addressIndex)
Get the assigned ip address provided by the index of a particular interface.
None set_ethernet_mac_address2(self, list[int] macAddress)
None set_number_of_backtoback_scans(self, int numScans)
Set the number of spectra that the device will capture per trigger event.
bool get_device_idle_state(self)
Return device idle state.
bool gpio_get_value1(self, int bit)
Get the GPIO bit value in whether it's high(true) or low(false).
str get_user_string1(self, int index)
Read the user string from the device.
None set_ethernet_mac_address(self, int interfaceIndex, list[int] macAddress)
Writes a new ethernet 6-byte mac address into the spectrometer.
int get_continuous_strobe_period_increment(self)
This function gets the current size of the strobe period increment of the device in microseconds.
bool get_ethernet_gigabit_enable_status2(self)
bool get_enable_lamp(self)
Return the lamp state.
int gpio_get_output_alternate2(self)
Get the settings for alternate functionality on the GPIO pins.
bool ipv4_is_dhcp_enabled2(self)
None gpio_set_output_alternate1(self, int bit, bool isAlternate)
Set the alternate functionality for the specified pins (bits).
int get_usb_endpoint_primary_out(self)
This function returns the usb primary OUT endpoint for the type specified.
None clear_data_buffer(self)
Clear the data buffer.
str get_device_manufacturer_string(self)
Get the current manufacturer string of the device.
None set_ethernet_gigabit_enable_status2(self, bool enable)
bool get_ip_address_assigned_mode(self)
Read the IP address mode from the OBP2 device.
None gpio_set_output_enable2(self, int bitmask)
Set the direction (input/output) of the GPIO pins.
int get_continuous_strobe_width(self)
Gets the strobe width of the device in microseconds.
str get_revision_system(self)
Reads out the System revision from the device's internal memory if that feature is supported.
None acquire_spectra_to_buffer(self)
Start spectra acquisition.
None set_manual_network_configuration(self, list[int] ipv4Address, list[int] subnetMask, list[int] defaultGateway, list[int] dnsServer)
Write the network configuration parameters (static ip address) on OBP2 enabled device.
None set_data_buffer_capacity(self, int capacity)
Set the number of data elements that the buffer should retain.
tuple[list[int], int] ipv4_read_ip_address2(self, int addressIndex)
bool get_data_buffer_enable(self)
Reads the device data buffering enable state.
tuple[list[int], list[int], list[int], list[int]] get_manual_network_configuration(self)
Read the network configuration parameters (static ip address) from an OBP2 enabled device.
list[int] get_bad_pixel_indices(self)
Read bad pixel indices from the sensor pixel array.
bool get_single_strobe_enable(self)
Get the enable status of the single strobe signal.
bool has_light_source_enable(self, int light_source_index)
Queries whether the indicated light source within the given feature instance has a usable enable/disa...
None set_network_interface_status(self, int interfaceIndex, bool enable)
Enable or disable the interface.
None set_shutter_open(self, bool shutterState)
This function will open or close the shutter on the spectrometer.
bool get_network_interface_status2(self)
int get_single_strobe_width(self)
Get the amount of time, in microseconds, that the single strobe pulse should remain high after it beg...
None set_device_alias(self, str deviceAlias)
Set a new device alias to the device.
tuple[bool, list[int], list[int], list[int], list[int]] get_network_configuration(self)
Read the network configuration parameters from an OBP2 enabled device.
bool get_tec_stable(self)
Returns the state of thermo-electric cooler temperature on whether it reached the stable temperature ...
None set_continuous_strobe_period(self, int period)
Sets the continuous strobe period in microseconds.
None ipv4_set_dhcp_enable(self, int ifNum, bool enabled)
Turn the DHCP client on or off for the device on the specified interface.
bool get_tec_enable(self)
Read the state of the thermo-electric cooler whether it's enable or disable.
int get_gpio_pin_count(self)
Get GPIO pin count.
int get_network_interface_type(self, int interfaceIndex)
Return the interface type of the given interface index.
int get_single_strobe_width_minimum(self)
Get the minimum amount of time, in microseconds, that the single strobe pulse should remain high afte...
bool get_tec_fan_enable(self)
Returns the thermo-electric cooler fan state whether it's enabled or not.
list[int] get_ethernet_mac_address2(self)
int get_nonlinearity_coeffs_count1(self)
Read the nonlinearity coefficients count from the device.
str get_device_model_string(self)
Get the current model string of the device.
int get_single_strobe_delay_maximum(self)
Get the maximum amount of time, in microseconds, that should elapse after a starting event before the...
float get_temperature_setpoint_degrees_C(self)
Read the set point temperature of the thermo-electric cooler.
int get_autonull_maximum_adc_count(self)
Read the maximum ADC counts.
bool ipv4_is_dhcp_enabled(self, int ifNum)
Check to see if DHCP (client) is enabled on the specified interface.
int get_user_string_count1(self)
Read the total user string count from the device.
None set_device_manufacturer_string(self, str manufacturer)
Set the current manufacturer string of the device.
None set_baud_rate(self, int baudRate)
Set a new baud rate for the RS-232 port.
None set_user_string(self, str userString)
Set a new user string to the device.
None set_multicast_group_enabled(self, int interfaceIndex, bool enable)
Enable or disable the multicast message group.
bool get_network_interface_status(self, int interfaceIndex)
Return true if the interface is enabled otherwise it's false.
bool get_multicast_group_enabled(self, int interfaceIndex)
Return true if the multicast group message is enabled otherwise it's false.
str get_device_original_model_string(self)
Get the original model string of the device.
int get_raw_spectrum_with_metadata(self, list[list[float]] list_raw_spectra, list[int] list_timestamp, int buffer_size)
Returns spectra with metadata information.
bool gpio_get_output_enable1(self, int bit)
Get GPIO bit direction.
int ipv4_get_number_of_ip_addresses2(self)
list[int] get_transition_pixel_range(self)
Read the transition pixel range from the sensor pixel array.
None set_led_enable(self, bool isEnabled)
Enable or disable device LED.
int get_network_interface_count(self)
Read the number of supported communication interface.
None set_temperature_setpoint_degrees_C(self, float temp_C)
Apply the setpoint temperature (Celsius) in the thermo-electric cooler.
int num_nonlinearity_coeffs
None ipv4_set_default_gateway_ip_address2(self, list[int] ipAddress)
None save_network_interface_setting(self, int interfaceIndex)
Save the network interface settings to the device.
bool is_light_source_enabled(self, int light_source_index)
Queries whether the indicated light source within the given feature instance is enabled (energized).
list[float] get_wavelength_coeffs(self)
Read the wavelength coefficients from the device.
Class that models the individual spectrometer.
int get_acquisition_delay(self)
Get the acquisition delay in microseconds.
list[float] nonlinearity_correct_spectrum2(self, list[float] darkSpectrum, list[float] illuminatedSpectrum)
Nonlinearity correct a previously acquired illuminated spectrum after dark correction using a previou...
None open_device(self)
Open the current device associated with this spectrometer object.
int get_integration_time(self)
Returns the current integration time on the device.
tuple[int, float] get_index_at_wavelength(self, float wavelength)
Given an approximate wavelength, finds the closest wavelength and returns the index (pixel number) of...
str get_model(self)
Read the correct spectrometer model name assigned.
int get_acquisition_delay_minimum(self)
Get the minimum allowed acquisition delay in microseconds.
list[float] nonlinearity_correct_spectrum1(self, list[float] illuminatedSpectrum)
Nonlinearity correct a previously acquired illuminated spectrum using a stored dark spectrum.
int get_number_electric_dark_pixels(self)
This returns the number of pixels that are electrically active but optically masked (a....
list[float] boxcar_correct_spectrum(self, list[float] illuminatedSpectrum, int boxcarWidth)
Apply a boxcar correction on the given illuminated spectrum.
None set_electric_dark_correction_usage(self, bool isEnabled)
Enable or disable an electric dark correction.
None set_integration_time(self, int int_time)
Sets the integration time on the device.
list[float] get_formatted_spectrum(self)
Return a formatted spectrum.
int get_acquisition_delay_maximum(self)
Get the maximum allowed acquisition delay in microseconds.
list[float] get_stored_dark_spectrum(self)
Retrieve a previously stored dark spectrum for use in subsequent corrections i.e.
bool is_feature_id_enabled(self, FeatureID featureID)
Check if the given feature ID is supported by the device or not.
None details(self)
Prints the defined set of details about the device.
list[float] get_wavelengths(self)
This computes the wavelengths for the spectrometer and fills in the provided array (up to the given l...
list[float] dark_correct_spectrum1(self, list[float] illuminatedSpectrum)
Dark correct a previously acquired illuminated spectrum and using a stored dark spectrum.
int get_minimum_averaging_integration_time(self)
This function returns the smallest integration time setting, in microseconds, that is valid for the s...
int get_integration_time_increment(self)
Returns the integration time increment on the device.
tuple[list[int], list[float]] get_indices_at_wavelengths(self, list[float] wavelengths)
Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices (pixel...
int get_max_intensity(self)
Returns the maximum pixel value the detector can read.
None set_scans_to_average(self, int newScanToAverage)
Sets the number of spectra to average.
list[float] get_nonlinearity_corrected_spectrum1(self, list[float] darkSpectrum)
Acquire a spectrum and use the supplied dark spectrum to perform a dark correction followed by the no...
str decode_error(self, int errno, str caller)
Decodes the error string returned from device calls.
list[float] get_dark_corrected_spectrum2(self)
Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction then retu...
list[float] dark_correct_spectrum2(self, list[float] darkSpectrum, list[float] illuminatedSpectrum)
Dark correct a previously acquired illuminated spectrum and using a previously acquired dark spectrum...
bool get_nonlinearity_correction_usage(self)
Return nonlinearity correction usage.
int get_scans_to_average(self)
Gets the number of spectra to average.
def __init__(self, int dev_id, oceandirect)
None set_stored_dark_spectrum(self, list[float] darkSpectrum)
Store a dark spectrum for use in subsequent corrections i.e.
tuple[list[int], list[float]] get_indices_at_wavelength_range(self, float lo, float hi, int length)
Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices (pixel...
None set_trigger_mode(self, int mode)
Set the device trigger mode.
None set_nonlinearity_correction_usage(self, bool isEnabled)
Enable or disable nonlinearity correction.
int get_device_type(self)
Read the device type.
None use_nonlinearity(self, bool nonlinearity_flag)
Determine if nonlinearity correction should be used in calculations.
int get_maximum_integration_time(self)
Returns the maximum allowable integration time on the device.
list[int] get_electric_dark_pixel_indices(self)
This returns array (up to the given length) with the indices of the pixels that are electrically acti...
None set_boxcar_width(self, int newBoxcarWidth)
Sets the boxcar width to average the spectral data.
None set_acquisition_delay(self, int delayMicrosecond)
Set the acquisition delay in microseconds.
int get_acquisition_delay_increment(self)
Get the allowed step size for the acquisition delay in microseconds.
int get_formatted_spectrum_length(self)
Return the formatted spectra length.
str get_serial_number(self)
Read the device serial number.
None close_device(self)
Detaches the device to free it up for other users.
int get_boxcar_width(self)
Read the current boxcar width setting.
None get_trigger_mode(self)
Returns the current trigger mode from the device.
list[float] get_nonlinearity_corrected_spectrum2(self)
Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction followed ...
bool get_electric_dark_correction_usage(self)
Return electric dark correction usage.
int get_minimum_integration_time(self)
Returns the minimum allowable integration time on the device.
list[float] get_dark_corrected_spectrum1(self, list[float] darkSpectrum)
Acquire a spectrum and use the supplied dark spectrum to perform a dark correction then return the da...