PythonOceanDirect  2.4.0
OceanDirect Python API
OceanDirectAPI.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Created on Wed Jan 9 16:23:44 2019
4 @author: Ocean Insight Inc.
5 """
6 import traceback
7 import json
8 from typing import List
9 from ctypes import cdll, c_int, 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
13 
14 logger = od_logger()
15 
16 class OceanDirectError(Exception):
17  """!
18  An error code and error message object wrapper.
19  """
20 
21  def __init__(self, errorCode: int, errorMsg: str):
22  super(OceanDirectError, self).__init__(errorMsg)
23  self._error_code_error_code = errorCode
24  self._error_msg_error_msg = errorMsg
25 
26  def get_error_details(self) -> tuple[int, str]:
27  return (self._error_code_error_code, self._error_msg_error_msg)
28 
30 
32  def __init__(self):
33  self.oceandirectoceandirect = cdll.LoadLibrary(oceandirect_dll)
34  self.oceandirectoceandirect.odapi_initialize()
35  self.open_devicesopen_devices = dict()
36  self.num_devicesnum_devices = 0
37  self.usb_devicesusb_devices = 0
38 
39  def __del__(self):
40  """
41  Closes all open devices and the odapi singleton.
42  """
43  try:
44  self.close_all_devicesclose_all_devices()
45  self.shutdownshutdown()
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)
50 
51  def close_all_devices(self) -> None:
52  """
53  Closes all opened devices.
54  """
55  for dev in self.open_devicesopen_devices:
56  self.open_devicesopen_devices[dev].close_device()
57 
58  def shutdown(self) -> None:
59  """
60  Release any remaining used resources before shutting down the program.
61  """
62  self.oceandirectoceandirect.odapi_shutdown()
63 
64  instance = None
65 
66  def __init__(self):
67  """
68  Loads and initializes the OceanDirect dll and initializes internal variables.
69  """
70 
71  if not OceanDirectAPI.instance:
72  OceanDirectAPI.instance = OceanDirectAPI.__OceanDirectSingleton()
73 
74  def __getattr__(self, name):
75  return getattr(self.instanceinstance, name)
76 
77  def decode_error(self, errno: int, caller: str) -> str:
78  """
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.
82  :type errno: int
83  @param caller: The caller which produces the error code. Use for debugging purposes only.
84  :type caller: str
85  """
86 
87  error_str_len = self.oceandirect.odapi_get_error_string_length(errno)
88  errstr_cp = create_string_buffer(b'\000'*error_str_len)
89  self.oceandirect.odapi_get_error_string(errno, errstr_cp, error_str_len)
90  errstr = ("%s errcode(%d): %s" % (caller, errno, errstr_cp.value.decode()))
91  #logger.error(errstr)
92 # logger.error("%s errcode(%d): %s" % (caller, errno, errstr_cp.value.decode()))
93 # return errstr_cp.value.decode()
94  return errstr
95 
96  def get_api_version_numbers(self) -> tuple[int, int, int]:
97  """!
98  Return OceanDirect api version information.
99  @return An integer tuple of major, minor, and point value.
100  """
101 
102  major = c_uint(0)
103  minor = c_uint(0)
104  point = c_uint(0)
105 
106  self.oceandirect.odapi_get_api_version_numbers.argtypes = [POINTER(c_uint), POINTER(c_uint), POINTER(c_uint)]
107  self.oceandirect.odapi_get_api_version_numbers(byref(major), byref(minor), byref(point) )
108 
109  return (major.value, minor.value, point.value)
110 
111  def open_device(self, device_id: int) -> 'Spectrometer':
112  """!
113  Attach to a device discovered by probe_devices or get_device_ids. It also saves it to a map
114  keyed off of the device id. After the device is closed the device_id becomes invalid. You need to
115  call either find_devices()/find_usb_devices()/add_network_device() and get_device_ids() in order
116  to have a valid id before reopening the device again. For a network connected device this function
117  may return an error code if the device is not yet ready to accept incoming connection or the device is
118  unreachable. Note that this should only be done by one thread at a time. For multithreaded
119  application this function must be synchronized.
120  @param[in] device_id The device id.
121  @return The device object.
122  @see find_devices()
123  @see find_usb_devices()
124  @see add_network_device()
125  """
126  if device_id in self.open_devices:
127  device = self.open_devices[device_id]
128  else:
129  device = Spectrometer(device_id, self.oceandirect)
130  device.open_device()
131  self.open_devices[device_id] = device
132  return device
133 
134  def get_device(self, device_id: int) -> 'Spectrometer':
135  if device_id in self.open_devices:
136  return self.open_devices[device_id]
137  else:
138  return None
139 
140  def add_network_device(self, ipAddressStr: str, deviceTypeStr: str) -> None:
141  """!
142  Manually create an instance of the network attached device and then open it using
143  the openDevice() function. It is the responsiblitiy of the user to ensure that
144  the device exist and configured properly. Note that this should only be done by one thread
145  at a time. For multithreaded application this function must be synchronized.
146  @param[in] ipAddressStr The ip address of the device to be opened.
147  @param[in] deviceTypeStr The device type could be OceanFX or OceanHDX. This is case sensitive.
148  """
149 
150  if not ipAddressStr or not deviceTypeStr:
151  error_msg = self.decode_errordecode_error(15, "add_network_device")
152  raise OceanDirectError(15, error_msg)
153 
154  err_cp = (c_long * 1)(0)
155  self.oceandirect.odapi_add_network_devices(ipAddressStr.encode('utf-8'), deviceTypeStr.encode('utf-8'), err_cp)
156 
157  if err_cp[0] != 0:
158  error_msg = self.decode_errordecode_error(err_cp[0], "add_network_device")
159  raise OceanDirectError(err_cp[0], error_msg)
160 
161  def close_device(self, device_id: int) -> None:
162  """!
163  Detach from the device indicated by device_id. This persists the device for later use. The device_id becomes
164  invalid after closing the device. Note that this should only be done by one thread at a time.
165  For multithreaded application this function must be synchronized.
166  @param[in] device_id The id of the device to be closed.
167  @see open_device()
168  """
169 
170  if device_id in self.open_devices:
171  device = self.open_devices[device_id]
172  device.close_device()
173 
174  def list_all_devices(self) -> None:
175  """!
176  Lists defined details of all active devices.
177  """
178  for dev in self.open_devices:
179  self.open_devices[dev].details()
180 
181  def shutdown(self) -> None:
182  """!
183  Closes the connection to OceanDirectAPI. This is the last to be called before the program terminates.
184  """
185  self.oceandirect.odapi_shutdown()
186 
187  def find_devices(self) -> int:
188  """!
189  Finds all available Ocean devices by scanning on USB for devices with Ocean drivers, finding
190  devices that respond to UDP multicast (FX and HDX), and also returning IDs for any TCP-enabled
191  devices that have been manually specified using addTCPDeviceLocation(). Note that this should
192  only be done by one thread at a time. For multithreaded application this function must be synchronized.
193  @return Number of devices found.
194  @see open_device()
195  """
196 
197  try:
198  self.tcpip_devicestcpip_devices = self.oceandirect.odapi_detect_network_devices()
199  except Exception as e:
200  exe_msg = traceback.format_exc()
201  sdk_data_json = json.dumps(exe_msg)
202  logger.error(sdk_data_json)
203 
204  try:
205  self.usb_devicesusb_devices = self.oceandirect.odapi_probe_devices()
206  except Exception as e:
207  exe_msg = traceback.format_exc()
208  sdk_data_json = json.dumps(exe_msg)
209  logger.error(sdk_data_json)
210 
211  totalDevicesFound = 0
212  try:
213  totalDevicesFound = self.oceandirect.odapi_get_number_of_device_ids()
214  except OceanDirectError as err:
215  exe_msg = traceback.format_exc()
216  sdk_data_json = json.dumps(exe_msg)
217  logger.error(sdk_data_json)
218 
219  return totalDevicesFound
220 
221  def find_usb_devices(self) -> int:
222  """!
223  Finds all available Ocean devices by scanning on USB for devices with Ocean drivers. Note that
224  this should only be done by one thread at a time. For multithreaded application this function
225  must be synchronized.
226  @return Number of devices found.
227  @see open_device()
228  """
229 
230  try:
231  self.usb_devicesusb_devices = self.oceandirect.odapi_probe_devices()
232  except Exception as e:
233  exe_msg = traceback.format_exc()
234  sdk_data_json = json.dumps(exe_msg)
235  logger.error(sdk_data_json)
236  return self.usb_devicesusb_devices
237 
238  def add_network_device(self, ipAddress: str, deviceType: str) -> int:
239  """!
240  Manually create an instance of the network attached device and then open it using the openDevice() function. It
241  is the responsiblitiy of the user to ensure that the device exist and configured properly. Note that this
242  should only be done by one thread at a time.
243  @param[in] ipAddress The ip address as string (ex: "10.20.30.100" ) of the device to be opened.
244  @param[in] deviceType The device type could be OceanFX or OceanHDX. This is case sensitive.
245  @return The device id.
246  @see open_device()
247  """
248 
249  deviceId = -1
250  err_cp = (c_long * 1)(0)
251 
252  if not ipAddress or not deviceType:
253  #15 is an error code defined in OceanDirectAPIConstants.c
254  error_msg = self.decode_errordecode_error(15, "add_network_device")
255  raise OceanDirectError(15, error_msg)
256 
257  try:
258  deviceId = self.oceandirect.odapi_add_network_devices(ipAddress.encode('utf-8'), deviceType.encode('utf-8'), err_cp)
259  except Exception as e:
260  exe_msg = traceback.format_exc()
261  sdk_data_json = json.dumps(exe_msg)
262  logger.error(sdk_data_json)
263 
264  if err_cp[0] != 0:
265  error_msg = self.decode_errordecode_error(err_cp[0],"add_network_device")
266  raise OceanDirectError(err_cp[0], error_msg)
267 
268  return deviceId
269 
270  def get_number_devices(self) -> int:
271  """!
272  Returns the number of devices available. Note that this should only be done by
273  one thread at a time.
274  @return The number of connected(discovered) devices.
275  """
276 
277  try:
278  self.num_devicesnum_devices = self.oceandirect.odapi_get_number_of_device_ids()
279  except Exception as e:
280  exe_msg = traceback.format_exc()
281  sdk_data_json = json.dumps(exe_msg)
282  logger.error(sdk_data_json)
283 
284  return self.num_devicesnum_devices
285 
286  def get_device_ids(self) -> list[int]:
287  """!
288  Return a list of device ids from devices that were both probe or manually added. Note that
289  this should only be done by one thread at a time. For multithreaded application this
290  function must be synchronized.
291  @return List of device id's.
292  """
293 
294  #probed = self.probe_devices(devtype)
295  num_ids = self.get_number_devicesget_number_devices()
296  ids_cp = (c_long * num_ids)()
297  err_cp = (c_long * 1)()
298  n = self.oceandirect.odapi_get_device_ids(ids_cp, err_cp)
299 
300  if n > 0:
301  self.device_idsdevice_ids = list(ids_cp)
302  else:
303  self.device_idsdevice_ids =list()
304  if err_cp[0] != 0:
305  error_msg = self.decode_errordecode_error(err_cp[0], "get_device_ids")
306  raise OceanDirectError(err_cp[0], error_msg)
307 
308  return self.device_idsdevice_ids
309 
310  def get_network_device_ids(self) -> list[int]:
311  """!
312  Return a list of network device ids from devices that were probe. Note that
313  this should only be done by one thread at a time. For multithreaded application
314  this function must be synchronized.
315  @return List of network device id's.
316  """
317 
318  #probed = self.probe_devices(devtype)
319  num_ids = self.get_number_devicesget_number_devices()
320  ids_cp = (c_long * num_ids)()
321  err_cp = (c_long * 1)()
322  n = self.oceandirect.odapi_get_network_device_ids(ids_cp, err_cp)
323  networkIds = list()
324  if n > 0:
325  for i in range(n):
326  networkIds.append(int(ids_cp[i]))
327  if err_cp[0] != 0:
328  error_msg = self.decode_errordecode_error(err_cp[0], "get_network_device_ids")
329  raise OceanDirectError(err_cp[0], error_msg)
330 
331  return networkIds
332 
333  def from_serial_number(self, serial_num: str) -> 'Spectrometer':
334  """!
335  Return a spectrometer object associated with device id. User should not call this function. This function is
336  used internally in OceanDirect.
337  @param[in] serial_num The device serial number.
338  @return The spectrometer object if found, None otherwise.
339  """
340 
341  devids = self.get_device_idsget_device_ids()
342  dev = None
343 
344  if len(devids) > 0:
345  for dev_id in devids:
346  dev = self.open_deviceopen_device(dev_id)
347  od_status = dev.status
348  sn = self.get_serial_numberget_serial_number(dev_id)
349  if sn == serial_num:
350  break
351  if (od_status == 'closed'):
352  self.close_deviceclose_device(dev_id)
353  return dev
354 
355  def add_rs232_device(self, device_type: str, bus_path: str, baud: int) -> None:
356  """!
357  Adds a device connected via RS 232 to the device list. Untested.
358  @param[in] device_type The name of a type of device. This can be one of the following: QE-PRO, STS.
359  @param[in] bus_path The location of the device on the RS232 bus. This will be a platform-specific
360  location. Under Windows, this may be COM1, COM2, etc. Under Linux, this might
361  be /dev/ttyS0, /dev/ttyS1,
362  @param[in] baud The baud rate. See device manual for supported baud rate.
363  """
364 
365  dev_type_cp = create_string_buffer(str.encode(device_type), len(device_type))
366  bus_path_cp = create_string_buffer(str.encode(bus_path), len(bus_path))
367  added = self.oceandirect.odapi_add_RS232_device_location(dev_type_cp, bus_path_cp, baud)
368 
369  if added != 0:
370  error_msg = self.decode_errordecode_error(added, "add_rs232_device")
371  raise OceanDirectError(self.err_cp[0], error_msg)
372  logger.info("Add for %s at bus path %s result %d" % (device_type, bus_path, added))
373 
374  def get_serial_number(self, dev_id: int) -> str:
375  """!
376  Gets the serial number of a specified device. This is used internally to find the desired device.
377  @param[in] dev_id The id of a device.
378  @return The device serial number if found, None otherwise.
379  """
380 
381  serial_number = None
382  if dev_id in self.open_devices:
383  serial_number = self.open_devices[dev_id].serial_number
384  if serial_number is None:
385  serial_cp = create_string_buffer(b'\000'*32)
386  err_cp = (c_long * 1)()
387  self.oceandirect.odapi_get_serial_number(dev_id, err_cp, serial_cp, 32)
388  if err_cp[0] != 0:
389  error_msg = self.decode_errordecode_error(err_cp[0], "get_serial_number")
390  raise OceanDirectError(err_cp[0], error_msg)
391  serial_number = serial_cp.value
392  return serial_number
393 
394 
395 class FeatureID(Enum):
396  """!
397  An enumerated class for feature id. Use the method "is_feature_id()" and the id's below to check
398  if a feature is supported by the device or not.
399  NOTE:
400  Do not change the values and order below without synchronizing the changes from the C files.
401  """
402  SERIAL_NUMBER = 1
403  SPECTROMETER = auto()
404  THERMOELECTRIC = auto()
405  IRRADIANCE_CAL = auto()
406  EEPROM = auto()
407  STROBE_LAMP = auto()
408  WAVELENGTH_CAL = auto()
409  NONLINEARITY_CAL = auto()
410  STRAYLIGHT_CAL = auto()
411  RAW_BUS_ACCESS = auto()
412  CONTINUOUS_STROBE = auto()
413  LIGHT_SOURCE = auto()
414  TEMPERATURE = auto()
415  OPTICAL_BENCH = auto()
416  REVISION = auto()
417  PROCESSING = auto()
418  DATA_BUFFER = auto()
419  ACQUISITION_DELAY = auto()
420  PIXEL_BINNING = auto()
421  GPIO = auto()
422  SINGLE_STROBE = auto()
423  QUERY_STATUS = auto()
424  BACK_TO_BACK = auto()
425  LED_ACTIVITY = auto()
426  TIME_META = auto()
427  DHCP = auto()
428  #SHUTTER = auto()
429  IPV4_ADDRESS = auto()
430  PIXEL = auto()
431  AUTO_NULLING = auto()
432  USER_STRING = auto()
433  DEVICE_INFORMATION = auto()
434  DEVICE_ALIAS = auto()
435  SERIAL_PORT = auto()
436  SPECTRUM_ACQUISITION_CONTROL = auto()
437  NETWORK_CONFIGURATION = auto()
438  ETHERNET = auto()
439  SHUTTER = auto()
440  HIGH_GAIN_MODE = auto()
441 
442  @classmethod
443  def from_param(cls, obj):
444  if not isinstance(obj, FeatureID):
445  raise TypeError('not a FeatureID enumeration')
446  return c_int32(obj.value)
447 
448 
449 class Spectrometer():
450  """!
451  Class that models the individual spectrometer. Should be created by OceanDirectAPI instance. This
452  has an inner class called "Advanced" that contains functions to access other features of the device.
453  """
454 
455  def __init__(self, dev_id: int, oceandirect):
456  self.device_iddevice_id = dev_id
457  self.serial_numberserial_number = None
458  self.modelmodel = None
459  self.model_namemodel_name = None
460  self.integration_timeintegration_time = None
461  self.integration_minintegration_min = None
462  self.integration_maxintegration_max = None
463  self.pixel_count_formattedpixel_count_formatted = 0
464  self.num_electric_dark_pixelsnum_electric_dark_pixels = None
465  self.electric_dark_pixelselectric_dark_pixels = list()
466  self.statusstatus = 'closed'
467  self.wavelengthswavelengths = None
468  self.oceandirectoceandirect = oceandirect
469  self.AdvancedAdvancedAdvanced = self.AdvancedAdvancedAdvanced(device = self)
470  self.apply_nonlinearityapply_nonlinearity = True
471  self.scans_to_avgscans_to_avg = 1
472  self.boxcar_hwboxcar_hw = False
473  self.__nlflag__nlflag = c_ubyte(1)
474 
475  def get_serial_number(self) -> str:
476  """!
477  Read the device serial number.
478  @return The serial number.
479  """
480 
481  serial_cp = create_string_buffer(b'\000'*32)
482  err_cp = (c_long * 1)(0)
483  self.oceandirectoceandirect.odapi_get_serial_number(self.device_iddevice_id, err_cp, serial_cp, 32)
484 
485  if err_cp[0] != 0:
486  error_msg = self.decode_errordecode_error(err_cp[0], "get_serial_number")
487  raise OceanDirectError(err_cp[0], error_msg)
488 
489  self.serial_numberserial_number = serial_cp.value.decode()
490  return self.serial_numberserial_number
491 
492  def get_device_type(self) -> int:
493  """!
494  Read the device type.
495  @return The device type.
496  """
497 
498  device_type = create_string_buffer(b'\000' * 32)
499  err_cp = (c_long * 1)(0)
500  self.oceandirectoceandirect.odapi_get_device_type(self.device_iddevice_id, err_cp, device_type, 32)
501 
502  if err_cp[0] != 0:
503  error_msg = self.decode_errordecode_error(err_cp[0], "get_device_type")
504  raise OceanDirectError(err_cp[0], error_msg)
505 
506  return device_type.value.decode()
507 
508  def get_model(self) -> str:
509  """!
510  Read the correct spectrometer model name assigned.
511  @return The device model name.
512  """
513 
514  model_cp = create_string_buffer(b'\000'*32)
515  err_cp = (c_long * 1)(0)
516  self.oceandirectoceandirect.odapi_get_device_name(self.device_iddevice_id, err_cp, model_cp, 32)
517 
518  if err_cp[0] != 0:
519  error_msg = self.decode_errordecode_error(err_cp[0], "get_model")
520  raise OceanDirectError(err_cp[0], error_msg)
521 
522  self.model_namemodel_name = model_cp.value.decode()
523  return self.model_namemodel_name
524 
525  def decode_error(self, errno: int, caller: str) -> str:
526  """!
527  Decodes the error string returned from device calls.
528  @param[in] errno The error code.
529  @param[in] caller The method name that calls this function.
530  @return The string description of the error code.
531  """
532 
533  error_str_len = self.oceandirectoceandirect.odapi_get_error_string_length(errno)
534  errstr_cp = create_string_buffer(b'\000'*error_str_len)
535  self.oceandirectoceandirect.odapi_get_error_string(errno, errstr_cp, error_str_len)
536  #logger.error("%s errno(%d): %s" % (caller, errno, errstr_cp.value.decode()))
537  return errstr_cp.value.decode()
538 
539  def open_device(self) -> None:
540  """!
541  Open the current device associated with this spectrometer object.
542  """
543 
544  err_cp = (c_long * 1)(0)
545  self.oceandirectoceandirect.odapi_open_device(self.device_iddevice_id, err_cp)
546 
547  if err_cp[0] != 0:
548  #logger.error("open_device %s" % self.decode_error(err_cp[0], "open_device"))
549  error_msg = self.decode_errordecode_error(err_cp[0],"open_device")
550  raise OceanDirectError(err_cp[0], error_msg)
551  else:
552  self.statusstatus = 'open'
553  err_cp = (c_long * 1)(0)
554  self.pixel_count_formattedpixel_count_formatted = self.oceandirectoceandirect.odapi_get_formatted_spectrum_length(self.device_iddevice_id, err_cp)
555  if err_cp[0] != 0:
556  error_msg = self.decode_errordecode_error(err_cp[0], "get_formatted_spectrum_length")
557  raise OceanDirectError(err_cp[0], error_msg)
558  if self.serial_numberserial_number is None:
559  self.serial_numberserial_number = self.get_serial_numberget_serial_number()
560  self.get_wavelengthsget_wavelengths()
561 
562  def close_device(self) -> None:
563  """!
564  Detaches the device to free it up for other users. This function must be called when you're done using the device.
565  """
566 
567  err_cp = (c_long * 1)(0)
568  if self.statusstatus == 'open':
569  self.oceandirectoceandirect.odapi_close_device(self.device_iddevice_id, err_cp)
570  if err_cp[0] != 0:
571  error_msg = self.decode_errordecode_error(err_cp[0],"close_device")
572  raise OceanDirectError(err_cp[0], error_msg)
573  self.statusstatus = 'closed'
574 
575  def use_nonlinearity(self, nonlinearity_flag: bool) -> None:
576  """!
577  Determine if nonlinearity correction should be used in calculations. Typically should be set to true.
578  @param[in] nonlinearity_flag True to enable nonlinearity correction otherwise it's False.
579  """
580 
581  self.apply_nonlinearityapply_nonlinearity = nonlinearity_flag
582  if nonlinearity_flag:
583  self.__nlflag__nlflag = c_ubyte(1)
584  else:
585  self.__nlflag__nlflag = c_ubyte(0)
586 
587  def set_scans_to_average(self, newScanToAverage: int) -> None:
588  """!
589  Sets the number of spectra to average.
590  @param[in] newScanToAverage The number of spectra to average.
591  """
592 
593  err_cp = (c_long * 1)(0)
594  self.oceandirectoceandirect.odapi_set_scans_to_average(self.device_iddevice_id, err_cp, newScanToAverage)
595 
596  if err_cp[0] != 0:
597  error_msg = self.decode_errordecode_error(err_cp[0], "set_scans_to_average")
598  raise OceanDirectError(err_cp[0], error_msg)
599 
600  def get_scans_to_average(self) -> int:
601  """!
602  Gets the number of spectra to average.
603  @return The number of spectra to average.
604  """
605 
606  err_cp = (c_long * 1)(0)
607  scanToAverage = self.oceandirectoceandirect.odapi_get_scans_to_average(self.device_iddevice_id, err_cp)
608 
609  if err_cp[0] != 0:
610  error_msg = self.decode_errordecode_error(err_cp[0], "get_scans_to_average")
611  raise OceanDirectError(err_cp[0], error_msg)
612 
613  return scanToAverage
614 
615  def set_boxcar_width(self, newBoxcarWidth: int) -> None:
616  """!
617  Sets the boxcar width to average the spectral data.
618  @param[in] newBoxcarWidth The boxcar width.
619  """
620 
621  err_cp = (c_long * 1)(0)
622  self.oceandirectoceandirect.odapi_set_boxcar_width(self.device_iddevice_id, err_cp, newBoxcarWidth)
623 
624  if err_cp[0] != 0:
625  error_msg = self.decode_errordecode_error(err_cp[0], "set_boxcar_width")
626  raise OceanDirectError(err_cp[0], error_msg)
627 
628  def get_boxcar_width(self) -> int:
629  """!
630  Read the current boxcar width setting.
631  @return The boxcar width.
632  """
633 
634  err_cp = (c_long * 1)(0)
635  boxcarWidth = self.oceandirectoceandirect.odapi_get_boxcar_width(self.device_iddevice_id, err_cp)
636 
637  if err_cp[0] != 0:
638  error_msg = self.decode_errordecode_error(err_cp[0], "get_boxcar_width")
639  raise OceanDirectError(err_cp[0], error_msg)
640 
641  return boxcarWidth
642 
643  def get_max_intensity(self) -> int:
644  """!
645  Returns the maximum pixel value the detector can read.
646  @return The maximum intensity.
647  """
648 
649  self.oceandirectoceandirect.odapi_get_maximum_intensity.restype = c_double
650  err_cp = (c_long * 1)(0)
651  max_intensity = self.oceandirectoceandirect.odapi_get_maximum_intensity(self.device_iddevice_id, err_cp)
652 
653  if err_cp[0] != 0:
654  error_msg = self.decode_errordecode_error(err_cp[0], "max_intensity")
655  raise OceanDirectError(err_cp[0], error_msg)
656  return max_intensity
657 
658  def get_formatted_spectrum(self) -> list[float]:
659  """!
660  Return a formatted spectrum.
661  @return The formatted spectrum.
662  """
663 
664  spd_c = (c_double * self.pixel_count_formattedpixel_count_formatted)(0)
665  err_cp = (c_long * 1)(0)
666  copiedCount = self.oceandirectoceandirect.odapi_get_formatted_spectrum(self.device_iddevice_id, err_cp, spd_c, self.pixel_count_formattedpixel_count_formatted)
667  if err_cp[0] != 0:
668  error_msg = self.decode_errordecode_error(err_cp[0],"get_formatted_spectrum")
669  raise OceanDirectError(err_cp[0], error_msg)
670 
671  if copiedCount == 0:
672  return list()
673  else:
674  return list(spd_c)
675 
677  """!
678  Return the formatted spectra length.
679  @return The spectra length.
680  """
681 
682  return self.pixel_count_formattedpixel_count_formatted
683 
684  def get_wavelengths(self) -> list[float]:
685  """!
686  This computes the wavelengths for the spectrometer and fills in the
687  provided array (up to the given length) with those values.
688  @return The wavelength values for the device in a python list.
689  """
690 
691  if self.wavelengthswavelengths is None:
692  wl_c = (c_double * self.pixel_count_formattedpixel_count_formatted)()
693  err_cp = (c_long * 1)(0)
694  buffer_size = self.oceandirectoceandirect.odapi_get_wavelengths(self.device_iddevice_id, err_cp, wl_c, self.pixel_count_formattedpixel_count_formatted)
695  #logger.info("Buffer size returned: %d expected %d " % (buffer_size, self.pixel_count_formatted))
696  if err_cp[0] != 0:
697  error_msg = self.decode_errordecode_error(err_cp[0],"get_wavelengths")
698  raise OceanDirectError(err_cp[0], error_msg)
699  else:
700  self.wavelengthswavelengths = list(wl_c)
701  return self.wavelengthswavelengths
702 
704  """!
705  Returns the minimum allowable integration time on the device.
706  @return The minimum integration time.
707  """
708 
709  err_cp = (c_long * 1)(0)
710  int_time_min = self.oceandirectoceandirect.odapi_get_minimum_integration_time_micros(self.device_iddevice_id, err_cp)
711 
712  if err_cp[0] != 0:
713  error_msg = self.decode_errordecode_error(err_cp[0],"get_minimum_integration_time")
714  raise OceanDirectError(err_cp[0], error_msg)
715  self.integration_minintegration_min = int_time_min
716  return self.integration_minintegration_min
717 
719  """!
720  Returns the maximum allowable integration time on the device.
721  @return The maximum integration time.
722  """
723 
724  err_cp = (c_long * 1)(0)
725  int_time_max = self.oceandirectoceandirect.odapi_get_maximum_integration_time_micros(self.device_iddevice_id, err_cp)
726 
727  if err_cp[0] != 0:
728  error_msg = self.decode_errordecode_error(err_cp[0], "get_maximum_integration_time")
729  raise OceanDirectError(err_cp[0], error_msg)
730  self.integration_maxintegration_max = int_time_max
731  return self.integration_maxintegration_max
732 
734  """!
735  This function returns the smallest integration time setting, in microseconds, that is valid for the spectrometer.
736  NOTE: some devices that make use of onboard functionality to perform averaging have
737  a different, larger, minimum integration time for acquisition when averaging is enabled.
738  Refer to the documentation for your spectrometer to see if this is the case.
739  The minimum integration time when averaging is enabled can be determined
740  using odapi_get_minimum_averaging_integration_time_micros.
741  @return The minimum averaging integration time.
742  """
743 
744  err_cp = (c_long * 1)(0)
745  int_time_min = self.oceandirectoceandirect.odapi_get_minimum_averaging_integration_time_micros(self.device_iddevice_id, err_cp)
746 
747  if err_cp[0] != 0:
748  error_msg = self.decode_errordecode_error(err_cp[0],"get_minimum_averaging_integration_time")
749  raise OceanDirectError(err_cp[0], error_msg)
750  return int_time_min
751 
752  def set_integration_time(self, int_time: int) -> None:
753  """!
754  Sets the integration time on the device. This should be verified to be within range prior
755  to calling this function.
756  @param[in] int_time The new integration time in microseconds. See device manual for supported integration increment.
757  """
758 
759  self.integration_timeintegration_time = int_time
760  err_cp = (c_long * 1)(0)
761  error_msg = self.oceandirectoceandirect.odapi_set_integration_time_micros(self.device_iddevice_id, err_cp, c_ulong(int_time))
762 
763  if err_cp[0] != 0:
764  error_msg = self.decode_errordecode_error(err_cp[0],"set_integration_time")
765  raise OceanDirectError(err_cp[0], error_msg)
766 
767  def get_integration_time(self) -> int:
768  """!
769  Returns the current integration time on the device.
770  @return The integration time in microsecond.
771  """
772 
773  err_cp = (c_long * 1)(0)
774  int_time = self.oceandirectoceandirect.odapi_get_integration_time_micros(self.device_iddevice_id, err_cp)
775 
776  if err_cp[0] != 0:
777  error_msg = self.decode_errordecode_error(err_cp[0], "get_integration_time")
778  raise OceanDirectError(err_cp[0], error_msg)
779 
780  return int_time
781 
783  """!
784  Returns the integration time increment on the device.
785  @return The integration time increment in microsecond.
786  """
787 
788  err_cp = (c_long * 1)(0)
789  int_time = self.oceandirectoceandirect.odapi_get_integration_time_increment_micros(self.device_iddevice_id, err_cp)
790 
791  if err_cp[0] != 0:
792  error_msg = self.decode_errordecode_error(err_cp[0], "get_integration_time_increment")
793  raise OceanDirectError(err_cp[0], error_msg)
794 
795  return int_time
796 
797  def set_trigger_mode(self, mode: int) -> None:
798  """!
799  Set the device trigger mode.
800  @param[in] mode Trigger mode. See device manual for the supported trigger mode.
801  """
802 
803  err_cp = (c_long * 1)(0)
804  self.oceandirectoceandirect.odapi_adv_set_trigger_mode(self.device_iddevice_id, err_cp, mode)
805 
806  if err_cp[0] != 0:
807  error_msg = self.decode_errordecode_error(err_cp[0], "set_trigger_mode")
808  raise OceanDirectError(err_cp[0], error_msg)
809 
810  def get_trigger_mode(self) -> None:
811  """!
812  Returns the current trigger mode from the device. If this function is not
813  supported by the device then an exception will be thrown.
814  @return The trigger mode.
815  """
816 
817  err_cp = (c_long * 1)(0)
818  trigger = self.oceandirectoceandirect.odapi_adv_get_trigger_mode(self.device_iddevice_id, err_cp)
819 
820  if err_cp[0] != 0:
821  error_msg = self.decode_errordecode_error(err_cp[0], "get_trigger_mode")
822  raise OceanDirectError(err_cp[0], error_msg)
823 
824  return trigger
825 
826  def get_index_at_wavelength(self, wavelength: float) -> tuple[int, float]:
827  """!
828  Given an approximate wavelength, finds the closest wavelength and returns the index (pixel number) of that
829  wavelength, and the exact wavelength as an ordered pair
830  @param[in] wavelength A double value containing a best guess or approximate (this should be within bounds
831  of the entire wavelength array or an error is generated).
832  @return A pair value (tuple) of index (pixel) and wavelength value.
833  """
834 
835  new_wl = (c_double * 1)(0)
836  err_cp = (c_long * 1)(0)
837  index = self.oceandirectoceandirect.odapi_get_index_at_wavelength(self.device_iddevice_id, err_cp, new_wl, c_double(wavelength))
838 
839  if err_cp[0] != 0:
840  error_msg = self.decode_errordecode_error(err_cp[0],"get_index_at_wavelength")
841  raise OceanDirectError(err_cp[0], error_msg)
842  return index, new_wl[0]
843 
844  def get_indices_at_wavelengths(self, wavelengths: list[float]) -> tuple[list[int], list[float]]:
845  """!
846  Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices (pixel numbers) of those
847  wavelengths, and the exact wavelength as an ordered pair of lists
848  @param[in] wavelengths List of approximate wavelengths.
849  @return A pair value (tuple) of list(indices) and list(actual_wavelengths).
850  """
851  wavelengthCount = len(self.get_wavelengthsget_wavelengths())
852  length = len(wavelengths)
853  c_indices = (c_int * wavelengthCount)()
854  c_wavelength = (c_double * wavelengthCount)(*wavelengths)
855 
856  err_cp = (c_long * 1)(0)
857  indexCount = self.oceandirectoceandirect.odapi_get_indices_at_wavelengths(self.device_iddevice_id, err_cp, c_indices, length, c_wavelength, length)
858 
859  if err_cp[0] != 0:
860  error_msg = self.decode_errordecode_error(err_cp[0],"get_indices_at_wavelengths")
861  raise OceanDirectError(err_cp[0], error_msg)
862 
863  #trim the list
864  return list(c_indices[:indexCount]), list(c_wavelength[:indexCount])
865 
866  def get_indices_at_wavelength_range(self, lo: float, hi: float, length: int) -> tuple[list[int], list[float]]:
867  """!
868  Given a list of approximate wavelengths, finds the closest wavelengths and returns the indices
869  (pixel numbers) of those wavelengths, and the exact wavelength as an ordered pair of lists.
870  @param[in] lo Wavelength lower limit.
871  @param[in] hi Wavelength upper limit.
872  @param[in] length The number of wavelengths to return.
873  @return A pair value (tuple) of list(indices) and list(actual_wavelengths)
874  """
875 
876  wavelengthCount = len(self.get_wavelengthsget_wavelengths())
877  c_indices = (c_int * wavelengthCount)()
878  c_wavelength = (c_double * wavelengthCount)()
879  err_cp = (c_long * 1)(0)
880  wavelengthFoundCount = self.oceandirectoceandirect.odapi_get_indices_at_wavelength_range(self.device_iddevice_id, err_cp, c_indices, wavelengthCount,
881  c_wavelength, wavelengthCount, c_double(lo), c_double(hi))
882 
883  if err_cp[0] != 0:
884  error_msg = self.decode_errordecode_error(err_cp[0],"get_indices_at_wavelength_range")
885  raise OceanDirectError(err_cp[0], error_msg)
886 
887  if wavelengthFoundCount == 0:
888  return list(), list()
889  elif wavelengthFoundCount < length:
890  return list(c_indices[:wavelengthFoundCount]), list(c_wavelength[:wavelengthFoundCount])
891  else:
892  return list(c_indices[:length]), list(c_wavelength[:length])
893 
895  """!
896  This returns the number of pixels that are electrically active but optically
897  masked (a.k.a. electric dark pixels). Note that not all detectors have optically masked pixels;
898  in that case, this function will return zero.
899  @return The number of electric dark pixels on the spectrometer.
900  """
901 
902  err_cp = (c_long * 1)(0)
903  self.num_electric_dark_pixelsnum_electric_dark_pixels = self.oceandirectoceandirect.odapi_get_electric_dark_pixel_count(self.device_iddevice_id, err_cp)
904 
905  if err_cp[0] != 0:
906  error_msg = self.decode_errordecode_error(err_cp[0],"get_number_electric_dark_pixels")
907  raise OceanDirectError(err_cp[0], error_msg)
908 
909  return self.num_electric_dark_pixelsnum_electric_dark_pixels
910 
911  def get_electric_dark_pixel_indices(self) -> list[int]:
912  """!
913  This returns array (up to the given length) with the indices of the pixels that are electrically active
914  but optically masked (a.k.a. electric dark pixels). Note that not all detectors have optically
915  masked pixels; in that case, this function will return zero.
916  @return A list of pixels that are electric dark on that spectrometer.
917  """
918 
919  if self.num_electric_dark_pixelsnum_electric_dark_pixels is None:
920  self.get_number_electric_dark_pixelsget_number_electric_dark_pixels()
921  ed_idx_c = (c_int * self.num_electric_dark_pixelsnum_electric_dark_pixels)()
922  err_cp = (c_long * 1)(0)
923  self.oceandirectoceandirect.odapi_get_electric_dark_pixel_indices(self.device_iddevice_id, err_cp, ed_idx_c, self.num_electric_dark_pixelsnum_electric_dark_pixels)
924 
925  if err_cp[0] != 0:
926  error_msg = self.decode_errordecode_error(err_cp[0],"electric_dark_pixel_count")
927  raise OceanDirectError(err_cp[0], error_msg)
928  self.electric_dark_pixelselectric_dark_pixels = list(ed_idx_c)
929 
930  return self.electric_dark_pixelselectric_dark_pixels
931 
932  def details(self) -> None:
933  """!
934  Prints the defined set of details about the device.
935  """
936 
937  logger.info("Device ID : %d status %s" % (self.device_iddevice_id, self.statusstatus))
938  logger.info("Serial Number: %s" % self.get_serial_numberget_serial_number())
939  logger.info("Model : %s" % self.get_modelget_model())
940  logger.info("Number pixels: %d" % self.pixel_count_formattedpixel_count_formatted)
941 
942  def is_feature_id_enabled(self, featureID: FeatureID) -> bool:
943  """!
944  Check if the given feature ID is supported by the device or not.
945  @param[in] featureID An id from FeatureID enum.
946  @return True if the feature is supported otherwise it's false.
947  """
948  err_cp = (c_long * 1)(0)
949  feature_supported =self.oceandirectoceandirect.odapi_is_feature_enabled(self.device_iddevice_id, err_cp, featureID.value)
950 
951  if err_cp[0] != 0:
952  error_msg = self.decode_errordecode_error(err_cp[0], "is_feature_id_enabled")
953  raise OceanDirectError(err_cp[0], error_msg)
954 
955  return bool(c_ubyte(feature_supported))
956 
957  def set_acquisition_delay(self, delayMicrosecond: int) -> None:
958  """!
959  Set the acquisition delay in microseconds. This may also be referred to as the
960  trigger delay. In any event, it is the time between some event (such as a request
961  for data, or an external trigger pulse) and when data acquisition begins.
962  @param[in] delayMicrosecond The new delay to use in microseconds.
963  """
964 
965  err_cp = (c_long * 1)(0)
966  self.oceandirectoceandirect.odapi_set_acquisition_delay_microseconds(self.device_iddevice_id, err_cp, c_ulong(delayMicrosecond))
967 
968  if err_cp[0] != 0:
969  error_msg = self.decode_errordecode_error(err_cp[0], "set_acquisition_delay_microseconds")
970  raise OceanDirectError(err_cp[0], error_msg)
971 
972  def get_acquisition_delay(self) -> int:
973  """!
974  Get the acquisition delay in microseconds. This may also be referred to as the
975  trigger delay. In any event, it is the time between some event (such as a request
976  for data, or an external trigger pulse) and when data acquisition begins.
977  Note that not all devices support reading this value back. In these cases, the
978  returned value will be the last value sent to odapi_adv_set_acquisition_delay_microseconds().
979  If no value has been set and the value cannot be read back, this function will
980  indicate an error.
981  @return The acquisition delay in microseconds.
982  """
983 
984  err_cp = (c_long * 1)(0)
985  delay_microsecond = self.oceandirectoceandirect.odapi_get_acquisition_delay_microseconds(self.device_iddevice_id, err_cp)
986 
987  if err_cp[0] != 0:
988  error_msg = self.decode_errordecode_error(err_cp[0], "get_acquisition_delay_microseconds")
989  raise OceanDirectError(err_cp[0], error_msg)
990  return delay_microsecond
991 
993  """!
994  Get the allowed step size for the acquisition delay in microseconds.
995  @return The acquisition delay step size in microseconds.
996  """
997 
998  err_cp = (c_long * 1)(0)
999  delay_increment_microsecond = self.oceandirectoceandirect.odapi_get_acquisition_delay_increment_microseconds(self.device_iddevice_id, err_cp)
1000 
1001  if err_cp[0] != 0:
1002  error_msg = self.decode_errordecode_error(err_cp[0], "get_acquisition_delay_increment_microseconds")
1003  raise OceanDirectError(err_cp[0], error_msg)
1004  return delay_increment_microsecond
1005 
1007  """!
1008  Get the maximum allowed acquisition delay in microseconds.
1009  @return The maximum acquisition delay in microseconds.
1010  """
1011 
1012  err_cp = (c_long * 1)(0)
1013  delay_maximum_microsecond = self.oceandirectoceandirect.odapi_get_acquisition_delay_maximum_microseconds(self.device_iddevice_id, err_cp)
1014 
1015  if err_cp[0] != 0:
1016  error_msg = self.decode_errordecode_error(err_cp[0], "get_acquisition_delay_maximum_microseconds")
1017  raise OceanDirectError(err_cp[0], error_msg)
1018  return delay_maximum_microsecond
1019 
1021  """!
1022  Get the minimum allowed acquisition delay in microseconds.
1023  @return The minimum acquisition delay in microseconds.
1024  """
1025 
1026  err_cp = (c_long * 1)(0)
1027  delay_minimum_microsecond = self.oceandirectoceandirect.odapi_get_acquisition_delay_minimum_microseconds(self.device_iddevice_id, err_cp)
1028 
1029  if err_cp[0] != 0:
1030  error_msg = self.decode_errordecode_error(err_cp[0], "get_acquisition_delay_minimum_microseconds")
1031  raise OceanDirectError(err_cp[0], error_msg)
1032  return delay_minimum_microsecond
1033 
1034  def set_stored_dark_spectrum(self, darkSpectrum: list[float]) -> None:
1035  """!
1036  Store a dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
1037  @see getStoredDarkSpectrum.
1038  @param darkSpectrum[in] the buffer that contains the dark spectrum to be stored.
1039  """
1040 
1041  if len(darkSpectrum) == 0:
1042  #code 10 means missing value
1043  error_msg = self.decode_errordecode_error(10,"set_stored_dark_spectrum")
1044  raise OceanDirectError(10, error_msg)
1045 
1046  err_cp = (c_long * 1)(0)
1047  double_array_count = len(darkSpectrum)
1048  double_array = (c_double * double_array_count)(0)
1049  for x in range(double_array_count):
1050  double_array[x] = darkSpectrum[x]
1051 
1052  self.oceandirectoceandirect.odapi_set_stored_dark_spectrum(self.device_iddevice_id, err_cp, double_array, double_array_count)
1053 
1054  if err_cp[0] != 0:
1055  error_msg = self.decode_errordecode_error(err_cp[0],"set_stored_dark_spectrum")
1056  raise OceanDirectError(err_cp[0], error_msg)
1057 
1058  def get_stored_dark_spectrum(self) -> list[float]:
1059  """!
1060  Retrieve a previously stored dark spectrum for use in subsequent corrections i.e. dark correction and nonlinearity correction.
1061  @see setStoredDarkSpectrum.
1062  @return The dark spectrum.
1063  """
1064 
1065  double_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1066  err_cp = (c_long * 1)(0)
1067  self.oceandirectoceandirect.odapi_get_stored_dark_spectrum(self.device_iddevice_id, err_cp, double_array, self.pixel_count_formattedpixel_count_formatted)
1068  if err_cp[0] != 0:
1069  error_msg = self.decode_errordecode_error(err_cp[0],"get_stored_dark_spectrum")
1070  raise OceanDirectError(err_cp[0], error_msg)
1071  return list(double_array)
1072 
1073  def get_dark_corrected_spectrum1(self, darkSpectrum: list[float]) -> list[float]:
1074  """!
1075  Acquire a spectrum and use the supplied dark spectrum to perform a dark correction then return the dark corrected spectrum.
1076  @param darkSpectrum[in] the buffer that contains the dark spectrum to be used for the dark correction.
1077  @return The dark corrected spectrum.
1078  """
1079 
1080  if len(darkSpectrum) == 0:
1081  #code 10 means missing value
1082  error_msg = self.decode_errordecode_error(10,"get_dark_corrected_spectrum1")
1083  raise OceanDirectError(10, error_msg)
1084 
1085  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1086  dark_spectrum_array_count = len(darkSpectrum)
1087  dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1088  err_cp = (c_long * 1)(0)
1089  for x in range(dark_spectrum_array_count):
1090  dark_spectrum_array[x] = darkSpectrum[x]
1091 
1092  self.oceandirectoceandirect.odapi_get_dark_corrected_spectrum1(self.device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1093  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1094  if err_cp[0] != 0:
1095  error_msg = self.decode_errordecode_error(err_cp[0],"get_dark_corrected_spectrum1")
1096  raise OceanDirectError(err_cp[0], error_msg)
1097  return list(corrected_spectrum_array)
1098 
1099  def dark_correct_spectrum1(self, illuminatedSpectrum: list[float]) -> list[float]:
1100  """!
1101  Dark correct a previously acquired illuminated spectrum and using a stored dark spectrum.
1102  @see setStoredDarkSpectrum
1103  @param illuminatedSpectrum[in] the buffer that contains the illuminated spectrum to be corrected.
1104  @return The dark corrected spectrum.
1105  """
1106 
1107  if len(illuminatedSpectrum) == 0:
1108  #code 10 means missing value
1109  error_msg = self.decode_errordecode_error(10,"dark_correct_spectrum1")
1110  raise OceanDirectError(10, error_msg)
1111 
1112  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1113  illuminated_spectrum_array_count = len(illuminatedSpectrum)
1114  illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1115  err_cp = (c_long * 1)(0)
1116  for x in range(illuminated_spectrum_array_count):
1117  illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1118 
1119  self.oceandirectoceandirect.odapi_dark_correct_spectrum1(self.device_iddevice_id, err_cp, illuminated_spectrum_array, illuminated_spectrum_array_count,
1120  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1121  if err_cp[0] != 0:
1122  error_msg = self.decode_errordecode_error(err_cp[0],"dark_correct_spectrum1")
1123  raise OceanDirectError(err_cp[0], error_msg)
1124  return list(corrected_spectrum_array)
1125 
1126  def get_dark_corrected_spectrum2(self) -> list[float]:
1127  """!
1128  Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction then return the dark corrected spectrum.
1129  @see setStoredDarkSpectrum.
1130  @return The dark corrected spectrum.
1131  """
1132 
1133  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1134  err_cp = (c_long * 1)(0)
1135  self.oceandirectoceandirect.odapi_get_dark_corrected_spectrum2(self.device_iddevice_id, err_cp, corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1136  if err_cp[0] != 0:
1137  error_msg = self.decode_errordecode_error(err_cp[0],"get_dark_corrected_spectrum2")
1138  raise OceanDirectError(err_cp[0], error_msg)
1139  return list(corrected_spectrum_array)
1140 
1141  def dark_correct_spectrum2(self, darkSpectrum: list[float], illuminatedSpectrum: list[float]) -> list[float]:
1142  """!
1143  Dark correct a previously acquired illuminated spectrum and using a previously acquired dark spectrum.
1144  @param darkSpectrum[in] the buffer that contains the dark spectrum to be used for the dark correction.
1145  @param illuminatedSpectrum[in] the buffer that contains the illuminated spectrum to be corrected.
1146  @return The dark corrected spectrum.
1147  """
1148 
1149  if len(darkSpectrum) == 0 or len(illuminatedSpectrum) == 0:
1150  #code 10 means missing value
1151  error_msg = self.decode_errordecode_error(10,"dark_correct_spectrum2")
1152  raise OceanDirectError(10, error_msg)
1153 
1154  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1155  dark_spectrum_array_count = len(darkSpectrum)
1156  dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1157  illuminated_spectrum_array_count = len(illuminatedSpectrum)
1158  illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1159  err_cp = (c_long * 1)(0)
1160  for x in range(dark_spectrum_array_count):
1161  dark_spectrum_array[x] = darkSpectrum[x]
1162 
1163  for x in range(illuminated_spectrum_array_count):
1164  illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1165 
1166  self.oceandirectoceandirect.odapi_dark_correct_spectrum2(self.device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1167  illuminated_spectrum_array, illuminated_spectrum_array_count,
1168  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1169  if err_cp[0] != 0:
1170  error_msg = self.decode_errordecode_error(err_cp[0],"dark_correct_spectrum2")
1171  raise OceanDirectError(err_cp[0], error_msg)
1172  return list(corrected_spectrum_array)
1173 
1174  def get_nonlinearity_corrected_spectrum1(self, darkSpectrum: list[float]) -> list[float]:
1175  """!
1176  Acquire a spectrum and use the supplied dark spectrum to perform a dark correction
1177  followed by the nonlinearity correction then return the nonlinearity corrected spectrum.
1178  @param darkSpectrum[in] the buffer that contains the dark spectrum to be used for the dark correction.
1179  @return The nonlinearity corrected spectrum.
1180  """
1181 
1182  if len(darkSpectrum) == 0:
1183  #code 10 means missing value
1184  error_msg = self.decode_errordecode_error(10,"get_nonlinearity_corrected_spectrum1")
1185  raise OceanDirectError(10, error_msg)
1186 
1187  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1188  dark_spectrum_array_count = len(darkSpectrum)
1189  dark_spectrum_array = (c_double * dark_spectrum_array_count)()
1190  err_cp = (c_long * 1)(0)
1191  for x in range(dark_spectrum_array_count):
1192  dark_spectrum_array[x] = darkSpectrum[x]
1193 
1194  self.oceandirectoceandirect.odapi_get_nonlinearity_corrected_spectrum1(self.device_iddevice_id, err_cp, dark_spectrum_array, dark_spectrum_array_count,
1195  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1196  if err_cp[0] != 0:
1197  error_msg = self.decode_errordecode_error(err_cp[0],"get_nonlinearity_corrected_spectrum1")
1198  raise OceanDirectError(err_cp[0], error_msg)
1199  return list(corrected_spectrum_array)
1200 
1201  def nonlinearity_correct_spectrum1(self, illuminatedSpectrum: list[float]) -> list[float]:
1202  """!
1203  Nonlinearity correct a previously acquired illuminated spectrum using a stored dark spectrum.
1204  This function performs a dark correction using a previously stored dark spectrum prior to performing the nonlinearity correction.
1205  @see setStoredDarkSpectrum
1206  @param illuminatedSpectrum[in] the buffer that contains the illuminated spectrum to be corrected.
1207  @return The nonlinearity corrected spectrum.
1208  """
1209  if len(illuminatedSpectrum) == 0:
1210  #code 10 means missing value
1211  error_msg = self.decode_errordecode_error(10,"nonlinearity_correct_spectrum1")
1212  raise OceanDirectError(10, error_msg)
1213 
1214  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1215  illuminated_spectrum_array_count = len(illuminatedSpectrum)
1216  illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1217  err_cp = (c_long * 1)(0)
1218  for x in range(illuminated_spectrum_array_count):
1219  illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1220 
1221  self.oceandirectoceandirect.odapi_nonlinearity_correct_spectrum1(self.device_iddevice_id, err_cp, illuminated_spectrum_array, illuminated_spectrum_array_count,
1222  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1223  if err_cp[0] != 0:
1224  error_msg = self.decode_errordecode_error(err_cp[0],"nonlinearity_correct_spectrum1")
1225  raise OceanDirectError(err_cp[0], error_msg)
1226  return list(corrected_spectrum_array)
1227 
1228  def get_nonlinearity_corrected_spectrum2(self) -> list[float]:
1229  """!
1230  Acquire a spectrum and use the previously stored dark spectrum to perform a dark correction
1231  followed by a nonlinearity correction then return the nonlinearity corrected spectrum.
1232  @see setStoredDarkSpectrum.
1233  @return The nonlinearity corrected spectrum.
1234  """
1235 
1236  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
1237  err_cp = (c_long * 1)(0)
1238 
1239  self.oceandirectoceandirect.odapi_get_nonlinearity_corrected_spectrum2(self.device_iddevice_id, err_cp, corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1240  if err_cp[0] != 0:
1241  error_msg = self.decode_errordecode_error(err_cp[0],"get_nonlinearity_corrected_spectrum2")
1242  raise OceanDirectError(err_cp[0], error_msg)
1243  return list(corrected_spectrum_array)
1244 
1245  def nonlinearity_correct_spectrum2(self, darkSpectrum: list[float], illuminatedSpectrum: list[float]) -> list[float]:
1246  """!
1247  Nonlinearity correct a previously acquired illuminated spectrum after dark correction using a previously acquired dark spectrum.
1248  @param darkSpectrum[in] the buffer that contains the dark spectrum to be used prior to the nonlinearity correction.
1249  @param illuminatedSpectrum[in] the buffer that contains the illuminated spectrum to be corrected.
1250  @return The nonlinearity corrected spectrum.
1251  """
1252  if len(darkSpectrum) == 0 or len(illuminatedSpectrum) == 0:
1253  #code 10 means missing value
1254  error_msg = self.decode_errordecode_error(10,"nonlinearity_correct_spectrum2")
1255  raise OceanDirectError(10, error_msg)
1256 
1257  corrected_spectrum_array = (c_double * self.pixel_count_formattedpixel_count_formatted)()
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)
1263 
1264  for x in range(dark_spectrum_array_count):
1265  dark_spectrum_array[x] = darkSpectrum[x]
1266 
1267  for x in range(illuminated_spectrum_array_count):
1268  illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1269 
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,
1272  corrected_spectrum_array, self.pixel_count_formattedpixel_count_formatted)
1273  if err_cp[0] != 0:
1274  error_msg = self.decode_errordecode_error(err_cp[0],"nonlinearity_correct_spectrum2")
1275  raise OceanDirectError(err_cp[0], error_msg)
1276  return list(corrected_spectrum_array)
1277 
1278  def boxcar_correct_spectrum(self, illuminatedSpectrum: list[float], boxcarWidth: int) -> list[float]:
1279  """!
1280  Apply a boxcar correction on the given illuminated spectrum.
1281  @param illuminatedSpectrum[in] the spectrum that will be boxcar corrected.
1282  @param boxcarWidth[in] the boxcar width.
1283  @return The boxcar corrected spectrum.
1284  """
1285  if len(illuminatedSpectrum) == 0:
1286  #code 10 means missing value
1287  error_msg = self.decode_errordecode_error(10,"boxcar_correct_spectrum")
1288  raise OceanDirectError(10, error_msg)
1289 
1290  illuminated_spectrum_array_count = len(illuminatedSpectrum)
1291  illuminated_spectrum_array = (c_double * illuminated_spectrum_array_count)()
1292  err_cp = (c_long * 1)(0)
1293 
1294  for x in range(illuminated_spectrum_array_count):
1295  illuminated_spectrum_array[x] = illuminatedSpectrum[x]
1296 
1297  self.oceandirectoceandirect.odapi_boxcar_correct_spectrum(self.device_iddevice_id, err_cp,
1298  illuminated_spectrum_array, illuminated_spectrum_array_count,
1299  boxcarWidth)
1300 
1301  if err_cp[0] != 0:
1302  error_msg = self.decode_errordecode_error(err_cp[0],"boxcar_correct_spectrum")
1303  raise OceanDirectError(err_cp[0], error_msg)
1304 
1305  return list(illuminated_spectrum_array)
1306 
1307  def set_electric_dark_correction_usage(self, isEnabled: bool) -> None:
1308  """!
1309  Enable or disable an electric dark correction.
1310  @param[in] isEnabled True to enable electric dark correction otherwise it's False.
1311  """
1312 
1313  err_cp = (c_long * 1)(0)
1314  self.oceandirectoceandirect.odapi_apply_electric_dark_correction_usage(self.device_iddevice_id, err_cp, isEnabled)
1315 
1316  if err_cp[0] != 0:
1317  error_msg = self.decode_errordecode_error(err_cp[0], "set_electric_dark_correction_usage")
1318  raise OceanDirectError(err_cp[0], error_msg)
1319 
1321  """!
1322  Return electric dark correction usage.
1323  @return True if electric dark connection is applied otherwise it's False.
1324  """
1325 
1326  err_cp = (c_long * 1)(0)
1327  correctionState = self.oceandirectoceandirect.odapi_get_electric_dark_correction_usage(self.device_iddevice_id, err_cp)
1328 
1329  if err_cp[0] != 0:
1330  error_msg = self.decode_errordecode_error(err_cp[0], "get_electric_dark_correction_usage")
1331  raise OceanDirectError(err_cp[0], error_msg)
1332 
1333  return bool(c_ubyte(correctionState))
1334 
1335  def set_nonlinearity_correction_usage(self, isEnabled: bool) -> None:
1336  """!
1337  Enable or disable nonlinearity correction.
1338  @param[in] isEnabled True to enable nonlinearity correction otherwise it's False.
1339  """
1340 
1341  err_cp = (c_long * 1)(0)
1342  self.oceandirectoceandirect.odapi_apply_nonlinearity_correct_usage(self.device_iddevice_id, err_cp, isEnabled)
1343 
1344  if err_cp[0] != 0:
1345  error_msg = self.decode_errordecode_error(err_cp[0], "set_nonlinearity_correction_usage")
1346  raise OceanDirectError(err_cp[0], error_msg)
1347 
1349  """!
1350  Return nonlinearity correction usage.
1351  @return True if nonlinearity connection is applied otherwise it's False.
1352  """
1353 
1354  err_cp = (c_long * 1)(0)
1355  correctionState = self.oceandirectoceandirect.odapi_get_nonlinearity_correct_usage(self.device_iddevice_id, err_cp)
1356 
1357  if err_cp[0] != 0:
1358  error_msg = self.decode_errordecode_error(err_cp[0], "get_nonlinearity_correction_usage")
1359  raise OceanDirectError(err_cp[0], error_msg)
1360 
1361  return bool(c_ubyte(correctionState))
1362 
1363 
1364  class Advanced():
1365  """!
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.
1368  """
1369 
1370  lamp_on = c_ubyte(1)
1371  lamp_off = c_ubyte(0)
1372  num_nonlinearity_coeffs = 8
1373 
1374  def __init__(self, device: 'Spectrometer'):
1375  self.devicedevice = device
1376  self._temperature_count_temperature_count = None
1377 
1378  def set_enable_lamp(self, enable: bool) -> None:
1379  """!
1380  Enable or disable the lamp.
1381  @param[in] enable True to enable lamp, False otherwise.
1382  """
1383 
1384  err_cp = (c_long * 1)(0)
1385 
1386  if enable :
1387  self.devicedevice.oceandirect.odapi_adv_set_lamp_enable(self.devicedevice.device_id, err_cp, self.lamp_onlamp_on)
1388  else:
1389  self.devicedevice.oceandirect.odapi_adv_set_lamp_enable(self.devicedevice.device_id, err_cp, self.lamp_offlamp_off)
1390 
1391  if err_cp[0] != 0:
1392  error_msg = self.devicedevice.decode_error(err_cp[0],"enable_lamp")
1393  raise OceanDirectError(err_cp[0], error_msg)
1394 
1395  def get_enable_lamp(self) -> bool:
1396  """!
1397  Return the lamp state.
1398  @return True if lamp is ON otherwise False.
1399  """
1400 
1401  err_cp = (c_long * 1)(0)
1402  enabled = self.devicedevice.oceandirect.odapi_adv_get_lamp_enable(self.devicedevice.device_id, err_cp)
1403 
1404  if err_cp[0] != 0:
1405  error_msg = self.devicedevice.decode_error(err_cp[0],"get_enable_lamp")
1406  raise OceanDirectError(err_cp[0], error_msg)
1407  return bool(c_ubyte(enabled))
1408 
1409  def set_shutter_open(self, shutterState: bool) -> None:
1410  """!
1411  This function will open or close the shutter on the spectrometer.
1412  @param[in[ shutterState True will open the shutter. False will then close the shutter.
1413  """
1414  err_cp = (c_long * 1)(0)
1415  enabled = self.devicedevice.oceandirect.odapi_adv_set_shutter_open(self.devicedevice.device_id, err_cp, c_ubyte(shutterState))
1416 
1417  if err_cp[0] != 0:
1418  error_msg = self.devicedevice.decode_error(err_cp[0],"set_shutter_open")
1419  raise OceanDirectError(err_cp[0], error_msg)
1420 
1421  def get_shutter_state(self) -> None:
1422  """!
1423  This function returns the shutter state of the spectrometer.
1424  @return True if the shutter is opened otherwise returns False.
1425  """
1426  err_cp = (c_long * 1)(0)
1427  shutterState = self.devicedevice.oceandirect.odapi_adv_get_shutter_state(self.devicedevice.device_id, err_cp)
1428 
1429  if err_cp[0] != 0:
1430  error_msg = self.devicedevice.decode_error(err_cp[0],"get_shutter_state")
1431  raise OceanDirectError(err_cp[0], error_msg)
1432  return bool(c_ubyte(shutterState))
1433 
1434  def get_wavelength_coeffs(self) -> list[float]:
1435  """!
1436  Read the wavelength coefficients from the device. This command is being used in OBP-2.0 enabled devices.
1437  If the device don't support this command then a non-zero error code will be returned.
1438  @return List of wavelength coefficient values.
1439  """
1440 
1441  wl_c = (c_double * 20)()
1442  err_cp = (c_long * 1)(0)
1443  buffer_size = self.devicedevice.oceandirect.odapi_get_wavelength_coeffs(self.devicedevice.device_id, err_cp, wl_c, 20)
1444 
1445  logger.info("Buffer size returned: %d " % (buffer_size))
1446  if err_cp[0] != 0:
1447  error_msg = self.devicedevice.decode_error(err_cp[0], "get_wavelength_coeffs")
1448  raise OceanDirectError(err_cp[0], error_msg)
1449 
1450  return list(wl_c)[:buffer_size]
1451 
1452  def get_nonlinearity_coeffs(self) -> list[float]:
1453  """!
1454  Read the nonlinearity coefficients stored in the device. This command is being used in OBP-2.0 enabled devices.
1455  If the device don't support this command then a non-zero error code will be returned.
1456  @return A list of nonlinearity coefficients.
1457  """
1458 
1459  num_coeffs = self.num_nonlinearity_coeffsnum_nonlinearity_coeffs
1460  nl_coeff = (c_double * num_coeffs)(0)
1461  err_cp = (c_long * 1)(0)
1462  self.devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs(self.devicedevice.device_id, err_cp, nl_coeff, num_coeffs)
1463 
1464  if err_cp[0] != 0:
1465  error_msg = self.devicedevice.decode_error(err_cp[0],"get_nonlinearity_coeffs")
1466  raise OceanDirectError(err_cp[0], error_msg)
1467 
1468  return list(nl_coeff)
1469 
1471  """!
1472  Read the nonlinearity coefficients count from the device. This command is being used in legacy devices.
1473  If the device don't support this command then a non-zero error code will be returned.
1474  @return The nonlinearity coefficients count.
1475  """
1476 
1477  err_cp = (c_long * 1)(0)
1478  nl_count = self.devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs_count1(self.devicedevice.device_id, err_cp)
1479 
1480  if err_cp[0] != 0:
1481  error_msg = self.devicedevice.decode_error(err_cp[0], "get_nonlinearity_coeffs_count1")
1482  raise OceanDirectError(err_cp[0], error_msg)
1483 
1484  return nl_count
1485 
1486  def get_nonlinearity_coeffs1(self, index: int) -> float:
1487  """!
1488  Read the nonlinearity coefficients count of a given position from the device. This command is being used in legacy devices.
1489  If the device don't support this command then a non-zero error code will be returned. Use the function
1490  "get_nonlinearity_coeffs_count1()" to get the correct range of the index value.
1491  @param[in] index A zero based value referring to the coefficient position.
1492  @return The nonlinearity coefficients.
1493  """
1494 
1495  self.devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs1.restype = c_double
1496 
1497  err_cp = (c_long * 1)(0)
1498  nl_coefficient = self.devicedevice.oceandirect.odapi_adv_get_nonlinearity_coeffs1(self.devicedevice.device_id, err_cp, c_int(index))
1499 
1500  if err_cp[0] != 0:
1501  error_msg = self.devicedevice.decode_error(err_cp[0], "get_nonlinearity_coeffs1")
1502  raise OceanDirectError(err_cp[0], error_msg)
1503 
1504  return nl_coefficient
1505 
1506  def get_tec_temperature_degrees_C(self) -> float:
1507  """!
1508  Returns the temperature reading (celsius) of a detector thermistor. This is equivalent to calling
1509  get_temperature(index) where the "index" is a detector thermistor index. If this function is not
1510  supported by the device then an exception will be thrown.
1511  @return The temperature in degrees celsius.
1512  """
1513 
1514  self.devicedevice.oceandirect.odapi_adv_tec_get_temperature_degrees_C.restype = c_double
1515  err_cp = (c_long * 1)(0)
1516  temp = self.devicedevice.oceandirect.odapi_adv_tec_get_temperature_degrees_C(self.devicedevice.device_id, err_cp)
1517 
1518  if err_cp[0] != 0:
1519  error_msg = self.devicedevice.decode_error(err_cp[0],"get_tec_temperature_degrees_C")
1520  raise OceanDirectError(err_cp[0], error_msg)
1521  return temp
1522 
1523  def set_temperature_setpoint_degrees_C(self, temp_C: float) -> None:
1524  """!
1525  Apply the setpoint temperature (Celsius) in the thermo-electric cooler. If this function is not
1526  supported by the device then an exception will be thrown.
1527  @param[in] temp_C The setpoint temperature in celsius.
1528  """
1529 
1530  err_cp = (c_long * 1)(0)
1531  temp = self.devicedevice.oceandirect.odapi_adv_tec_set_temperature_setpoint_degrees_C(self.devicedevice.device_id, err_cp, c_double(temp_C))
1532 
1533  if err_cp[0] != 0:
1534  error_msg = self.devicedevice.decode_error(err_cp[0],"set_temperature_setpoint_degrees_C")
1535  raise OceanDirectError(err_cp[0], error_msg)
1536  #return temp
1537 
1538  def set_tec_enable(self, coolerEnable: bool) -> None:
1539  """!
1540  Enable or disable the thermo-electric cooler attached to the detector. If this function is not
1541  supported by the device then an exception will be thrown.
1542  @param[in] coolerEnable True to enable the cooler, False otherwise.
1543  """
1544 
1545  err_cp = (c_long * 1)(0)
1546  self.devicedevice.oceandirect.odapi_adv_tec_set_enable(self.devicedevice.device_id, err_cp, c_ubyte(coolerEnable))
1547 
1548  if err_cp[0] != 0:
1549  error_msg = self.devicedevice.decode_error(err_cp[0], "set_tec_enable")
1550  raise OceanDirectError(err_cp[0], error_msg)
1551 
1552  def get_tec_enable(self) -> bool:
1553  """!
1554  Read the state of the thermo-electric cooler whether it's enable or disable. If this function
1555  is not supported by the device then an exception will be thrown.
1556  @return True if the thermo-electric cooler is enabled, False otherwise.
1557  """
1558 
1559  err_cp = (c_long * 1)(0)
1560  enabled = self.devicedevice.oceandirect.odapi_adv_tec_get_enable(self.devicedevice.device_id, err_cp)
1561 
1562  if err_cp[0] != 0:
1563  error_msg = self.devicedevice.decode_error(err_cp[0], "get_tec_enable")
1564  raise OceanDirectError(err_cp[0], error_msg)
1565  return bool(c_ubyte(enabled))
1566 
1568  """!
1569  Read the set point temperature of the thermo-electric cooler. If this function is not supported
1570  by the device then an exception will be thrown.
1571  @return The temperature value in celsius.
1572  """
1573 
1574  self.devicedevice.oceandirect.odapi_adv_tec_get_temperature_setpoint_degrees_C.restype = c_float
1575  err_cp = (c_long * 1)(0)
1576  temp = self.devicedevice.oceandirect.odapi_adv_tec_get_temperature_setpoint_degrees_C(self.devicedevice.device_id, err_cp)
1577 
1578  if err_cp[0] != 0:
1579  error_msg = self.devicedevice.decode_error(err_cp[0], "get_temperature_setpoint_degrees_C")
1580  raise OceanDirectError(err_cp[0], error_msg)
1581  return temp
1582 
1583  def get_tec_stable(self) -> bool:
1584  """!
1585  Returns the state of thermo-electric cooler temperature on whether it reached the stable
1586  temperature or not. If this function is not supported by the device then an exception will be thrown.
1587  @return True if it's stable, False otherwise.
1588  """
1589 
1590  err_cp = (c_long * 1)(0)
1591  enabled = self.devicedevice.oceandirect.odapi_adv_tec_get_stable(self.devicedevice.device_id, err_cp)
1592 
1593  if err_cp[0] != 0:
1594  error_msg = self.devicedevice.decode_error(err_cp[0], "get_tec_stable")
1595  raise OceanDirectError(err_cp[0], error_msg)
1596  return bool(c_ubyte(enabled))
1597 
1598  def get_tec_fan_enable(self) -> bool:
1599  """!
1600  Returns the thermo-electric cooler fan state whether it's enabled or not. Few devices have cooler fan.
1601  If this function is not supported by the device then an exception will be thrown.
1602  @return True if the fan is enabled, False otherwise.
1603  """
1604 
1605  err_cp = (c_long * 1)(0)
1606  enabled = self.devicedevice.oceandirect.odapi_adv_tec_get_fan_enable(self.devicedevice.device_id, err_cp)
1607 
1608  if err_cp[0] != 0:
1609  error_msg = self.devicedevice.decode_error(err_cp[0],"get_tec_fan_enable")
1610  raise OceanDirectError(err_cp[0], error_msg)
1611  return bool(c_ubyte(enabled))
1612 
1613  def get_light_source_count(self) -> int:
1614  """!
1615  Gets the number of light sources that are represented by the given featureID. Such
1616  light sources could be individual LEDs, light bulbs, lasers, etc. Each of these light
1617  sources may have different capabilities, such as programmable intensities and enables,
1618  which should be queried before they are used.
1619  @return The number of light sources (e.g. bulbs) in the indicated feature
1620  """
1621 
1622  err_cp = (c_long * 1)(0)
1623  light_source_count = self.devicedevice.oceandirect.odapi_adv_get_light_source_count(self.devicedevice.device_id, err_cp)
1624 
1625  if err_cp[0] != 0:
1626  error_msg = self.devicedevice.decode_error(err_cp[0], "get_light_source_count")
1627  raise OceanDirectError(err_cp[0], error_msg)
1628 
1629  def has_light_source_enable(self, light_source_index: int) -> bool:
1630  """!
1631  Queries whether the indicated light source within the given feature instance has a usable
1632  enable/disable control. If this returns False (meaning no enable available) then calling enable_light_source()
1633  or is_light_source_enabled() is likely to result in an error.
1634  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1635  within the indicated feature instance to query
1636  @return False to indicate specified light source cannot be enabled/disabled. True to indicate specified
1637  light source can be enabled/disabled with enable_light_source()
1638  """
1639 
1640  err_cp = (c_long * 1)(0)
1641  status = self.devicedevice.oceandirect.odapi_adv_light_source_has_enable(self.devicedevice.device_id, err_cp, light_source_index)
1642 
1643  if err_cp[0] != 0:
1644  error_msg = self.devicedevice.decode_error(err_cp[0], "has_light_source_enable")
1645  raise OceanDirectError(err_cp[0], error_msg)
1646  return bool(status)
1647 
1648  def is_light_source_enabled(self, light_source_index: int) -> bool:
1649  """!
1650  Queries whether the indicated light source within the given feature instance is enabled (energized).
1651  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1652  within the indicated feature instance to query.
1653  @return False to indicate specified light source is disabled (should emit no light). True to indicate
1654  specified light source is enabled (should emit light depending on configured intensity setting).
1655  """
1656 
1657  err_cp = (c_long * 1)(0)
1658  status = self.devicedevice.oceandirect.odapi_adv_light_source_is_enabled(self.devicedevice.device_id, err_cp, light_source_index)
1659 
1660  if err_cp[0] != 0:
1661  error_msg = self.devicedevice.decode_error(err_cp[0], "is_light_source_enabled")
1662  raise OceanDirectError(err_cp[0], error_msg)
1663  return bool(status)
1664 
1665  def enable_light_source(self, light_source_index: int, enable: bool) -> None:
1666  """!
1667  Attempts to enable or disable the indicated light source within the given feature instance. Not
1668  all light sources have an enable/disable control, and this capability can be queried with has_light_source_enable().
1669  Note that an enabled light source should emit light according to its last (or default) intensity
1670  setting which might be the minimum; in this case, the light source might appear to remain off.
1671  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs) within
1672  the indicated feature instance to query.
1673  @param[in] enable Whether to enable the light source. A value of False will attempt to disable the
1674  light source, and any other value will enable it.
1675  """
1676 
1677  err_cp = (c_long * 1)(0)
1678 
1679  if enable :
1680  self.devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.devicedevice.device_id, err_cp, light_source_index, self.lamp_onlamp_on)
1681  else:
1682  self.devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.devicedevice.device_id, err_cp, light_source_index, self.lamp_offlamp_off)
1683 
1684  if err_cp[0] != 0:
1685  error_msg = self.devicedevice.decode_error(err_cp[0], "enable_light_source")
1686  raise OceanDirectError(err_cp[0], error_msg)
1687 
1688  def set_single_strobe_enable(self, enable: bool) -> None:
1689  """!
1690  Set the enable status of the single strobe signal. Note that on some
1691  devices the enable control is shared with other signals (e.g. lamp
1692  enable and continuous strobe) so this may have some side-effects and
1693  changing those features may affect the single strobe as well.
1694  @param[in] enable True to enable single strobe otherwise use False.
1695  """
1696 
1697  err_cp = (c_long * 1)(0)
1698 
1699  if enable :
1700  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_onlamp_on)
1701  else:
1702  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_offlamp_off)
1703 
1704  if err_cp[0] != 0:
1705  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_enable")
1706  raise OceanDirectError(err_cp[0], error_msg)
1707 
1708  def set_single_strobe_delay(self, delayMicrosecond: int) -> None:
1709  """!
1710  Set the amount of time, in microseconds, that should elapse after a starting event before
1711  the single strobe should have a rising edge.
1712  @param[in] delayMicrosecond The delay, in microseconds, that the single strobe should wait before
1713  the pulse begins.
1714  """
1715 
1716  err_cp = (c_long * 1)(0)
1717  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_delay(self.devicedevice.device_id, err_cp, c_ulong(delayMicrosecond))
1718 
1719  if err_cp[0] != 0:
1720  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_delay")
1721  raise OceanDirectError(err_cp[0], error_msg)
1722 
1723  def set_single_strobe_width(self, widthMicrosecond: int) -> None:
1724  """!
1725  Set the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1726  @param[in] widthMicrosecond The duration, in microseconds, of the single strobe pulse after
1727  the rising edge occurs. Once this duration elapses, a falling edge
1728  will be generated.
1729  """
1730 
1731  err_cp = (c_long * 1)(0)
1732  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_width(self.devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
1733 
1734  if err_cp[0] != 0:
1735  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_width")
1736  raise OceanDirectError(err_cp[0], error_msg)
1737 
1738  def get_single_strobe_enable(self) -> bool:
1739  """!
1740  Get the enable status of the single strobe signal. Note that on some
1741  devices the enable control is shared with other signals (e.g. lamp
1742  enable and continuous strobe) so this may have some side-effects and
1743  changing those features may affect the single strobe as well.
1744  @return True if single strobe is enabled otherwise it's False.
1745  """
1746 
1747  err_cp = (c_long * 1)(0)
1748  enable = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_enable(self.devicedevice.device_id, err_cp)
1749 
1750  if err_cp[0] != 0:
1751  error_msg = self.devicedevice.decode_error(err_cp[0], "is_single_strobe_enable")
1752  raise OceanDirectError(err_cp[0], error_msg)
1753  return bool(c_ubyte(enable))
1754 
1755  def get_single_strobe_delay(self) -> int:
1756  """!
1757  Get the amount of time, in microseconds, that should elapse after
1758  a starting event before the single strobe should have a rising edge
1759  @return The delay in microseconds.
1760  """
1761 
1762  err_cp = (c_long * 1)(0)
1763  delay_microsecond = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_delay(self.devicedevice.device_id, err_cp)
1764 
1765  if err_cp[0] != 0:
1766  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_delay")
1767  raise OceanDirectError(err_cp[0], error_msg)
1768  return delay_microsecond
1769 
1770  def get_single_strobe_width(self) -> int:
1771  """!
1772  Get the amount of time, in microseconds, that the single strobe pulse
1773  should remain high after it begins.
1774  @return The pulse width in microseconds.
1775  """
1776 
1777  err_cp = (c_long * 1)(0)
1778  width_microsecond = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_width(self.devicedevice.device_id, err_cp)
1779 
1780  if err_cp[0] != 0:
1781  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_width")
1782  raise OceanDirectError(err_cp[0], error_msg)
1783  return width_microsecond
1784 
1785  def get_light_source_count(self) -> int:
1786  """!
1787  Gets the number of light sources that are represented by the given featureID. Such
1788  light sources could be individual LEDs, light bulbs, lasers, etc. Each of these light
1789  sources may have different capabilities, such as programmable intensities and enables,
1790  which should be queried before they are used.
1791 
1792  @return The number of light sources (e.g. bulbs) in the indicated feature
1793  """
1794 
1795  err_cp = (c_long * 1)(0)
1796  light_source_count = self.devicedevice.oceandirect.odapi_adv_get_light_source_count(self.devicedevice.device_id, err_cp)
1797 
1798  if err_cp[0] != 0:
1799  error_msg = self.devicedevice.decode_error(err_cp[0], "get_light_source_count")
1800  raise OceanDirectError(err_cp[0], error_msg)
1801  return light_source_count
1802 
1803  def has_light_source_enable(self, light_source_index: int) -> bool:
1804  """!
1805  Queries whether the indicated light source within the given feature instance has a usable
1806  enable/disable control. If this returns False (meaning no enable available) then calling enable_light_source()
1807  or is_light_source_enabled() is likely to result in an error.
1808 
1809  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1810  within the indicated feature instance to query
1811  @return False to indicate specified light source cannot be enabled/disabled. True to indicate specified
1812  light source can be enabled/disabled with enable_light_source()
1813  """
1814 
1815  err_cp = (c_long * 1)(0)
1816  status = self.devicedevice.oceandirect.odapi_adv_light_source_has_enable(self.devicedevice.device_id, err_cp, light_source_index)
1817 
1818  if err_cp[0] != 0:
1819  error_msg = self.devicedevice.decode_error(err_cp[0], "has_light_source_enable")
1820  raise OceanDirectError(err_cp[0], error_msg)
1821  return bool(status)
1822 
1823  def is_light_source_enabled(self, light_source_index: int) -> bool:
1824  """!
1825  Queries whether the indicated light source within the given feature instance is enabled (energized).
1826 
1827  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs)
1828  within the indicated feature instance to query.
1829  @return False to indicate specified light source is disabled (should emit no light). True to indicate
1830  specified light source is enabled (should emit light depending on configured intensity setting).
1831  """
1832 
1833  err_cp = (c_long * 1)(0)
1834  status = self.devicedevice.oceandirect.odapi_adv_light_source_is_enabled(self.devicedevice.device_id, err_cp, light_source_index)
1835 
1836  if err_cp[0] != 0:
1837  error_msg = self.devicedevice.decode_error(err_cp[0], "is_light_source_enabled")
1838  raise OceanDirectError(err_cp[0], error_msg)
1839  return bool(status)
1840 
1841  def enable_light_source(self, light_source_index: int, enable: bool) -> None:
1842  """!
1843  Attempts to enable or disable the indicated light source within the given feature instance. Not
1844  all light sources have an enable/disable control, and this capability can be queried with has_light_source_enable().
1845  Note that an enabled light source should emit light according to its last (or default) intensity
1846  setting which might be the minimum; in this case, the light source might appear to remain off.
1847 
1848  @param[in] light_source_index Which of potentially many light sources (LEDs, lasers, light bulbs) within
1849  the indicated feature instance to query.
1850  @param[in] enable Whether to enable the light source. A value of False will attempt to disable the
1851  light source, and any other value will enable it.
1852  """
1853 
1854  err_cp = (c_long * 1)(0)
1855 
1856  if enable :
1857  self.devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.devicedevice.device_id, err_cp, light_source_index, self.lamp_onlamp_on)
1858  else:
1859  self.devicedevice.oceandirect.odapi_adv_light_source_set_enable(self.devicedevice.device_id, err_cp, light_source_index, self.lamp_offlamp_off)
1860 
1861  if err_cp[0] != 0:
1862  error_msg = self.devicedevice.decode_error(err_cp[0], "enable_light_source")
1863  raise OceanDirectError(err_cp[0], error_msg)
1864 
1865  def set_single_strobe_enable(self, enable: bool) -> None:
1866  """!
1867  Set the enable status of the single strobe signal. Note that on some
1868  devices the enable control is shared with other signals (e.g. lamp
1869  enable and continuous strobe) so this may have some side-effects and
1870  changing those features may affect the single strobe as well.
1871 
1872  @param[in] enable True to enable single strobe otherwise use False.
1873  """
1874 
1875  err_cp = (c_long * 1)(0)
1876 
1877  if enable :
1878  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_onlamp_on)
1879  else:
1880  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_offlamp_off)
1881 
1882  if err_cp[0] != 0:
1883  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_enable")
1884  raise OceanDirectError(err_cp[0], error_msg)
1885 
1886  def set_single_strobe_delay(self, delayMicrosecond: int) -> None:
1887  """!
1888  Set the amount of time, in microseconds, that should elapse after a starting event before
1889  the single strobe should have a rising edge.
1890 
1891  @param[in] delayMicrosecond The delay, in microseconds, that the single strobe should wait before
1892  the pulse begins.
1893  """
1894 
1895  err_cp = (c_long * 1)(0)
1896  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_delay(self.devicedevice.device_id, err_cp, c_ulong(delayMicrosecond))
1897 
1898  if err_cp[0] != 0:
1899  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_delay")
1900  raise OceanDirectError(err_cp[0], error_msg)
1901 
1902  def set_single_strobe_width(self, widthMicrosecond: int) -> None:
1903  """!
1904  Set the amount of time, in microseconds, that the single strobe pulse should remain high after it begins.
1905 
1906  @param[in] widthMicrosecond The duration, in microseconds, of the single strobe pulse after
1907  the rising edge occurs. Once this duration elapses, a falling edge
1908  will be generated.
1909  """
1910 
1911  err_cp = (c_long * 1)(0)
1912  self.devicedevice.oceandirect.odapi_adv_set_single_strobe_width(self.devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
1913 
1914  if err_cp[0] != 0:
1915  error_msg = self.devicedevice.decode_error(err_cp[0], "set_single_strobe_width")
1916  raise OceanDirectError(err_cp[0], error_msg)
1917 
1918  def get_single_strobe_enable(self) -> bool:
1919  """!
1920  Get the enable status of the single strobe signal. Note that on some
1921  devices the enable control is shared with other signals (e.g. lamp
1922  enable and continuous strobe) so this may have some side-effects and
1923  changing those features may affect the single strobe as well.
1924 
1925  @return True if single strobe is enabled otherwise it's False.
1926  """
1927 
1928  err_cp = (c_long * 1)(0)
1929  enable = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_enable(self.devicedevice.device_id, err_cp)
1930 
1931  if err_cp[0] != 0:
1932  error_msg = self.devicedevice.decode_error(err_cp[0], "is_single_strobe_enable")
1933  raise OceanDirectError(err_cp[0], error_msg)
1934  return bool(c_ubyte(enable))
1935 
1936  def get_single_strobe_delay(self) -> int:
1937  """!
1938  Get the amount of time, in microseconds, that should elapse after
1939  a starting event before the single strobe should have a rising edge
1940 
1941  @return The delay in microseconds.
1942  """
1943 
1944  err_cp = (c_long * 1)(0)
1945  delay_microsecond = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_delay(self.devicedevice.device_id, err_cp)
1946 
1947  if err_cp[0] != 0:
1948  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_delay")
1949  raise OceanDirectError(err_cp[0], error_msg)
1950  return delay_microsecond
1951 
1952  def get_single_strobe_width(self) -> int:
1953  """!
1954  Get the amount of time, in microseconds, that the single strobe pulse
1955  should remain high after it begins.
1956 
1957  @return The pulse width in microseconds.
1958  """
1959 
1960  err_cp = (c_long * 1)(0)
1961  width_microsecond = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_width(self.devicedevice.device_id, err_cp)
1962 
1963  if err_cp[0] != 0:
1964  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_width")
1965  raise OceanDirectError(err_cp[0], error_msg)
1966  return width_microsecond
1967 
1969  """!
1970  Get the minimum amount of time, in microseconds, that should elapse after
1971  a starting event before the single strobe should have a rising edge.
1972 
1973  @return The minimum delay in microseconds.
1974  """
1975 
1976  err_cp = (c_long * 1)(0)
1977  minimum_microseconds = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_minimum(self.devicedevice.device_id, err_cp)
1978 
1979  if err_cp[0] != 0:
1980  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_delay_minimum")
1981  raise OceanDirectError(err_cp[0], error_msg)
1982  return minimum_microseconds
1983 
1985  """!
1986  Get the maximum amount of time, in microseconds, that should elapse after
1987  a starting event before the single strobe should have a rising edge.
1988 
1989  @return The maximum delay in microseconds.
1990  """
1991 
1992  err_cp = (c_long * 1)(0)
1993  maximum_microseconds = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_maximum(self.devicedevice.device_id, err_cp)
1994 
1995  if err_cp[0] != 0:
1996  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_delay_maximum")
1997  raise OceanDirectError(err_cp[0], error_msg)
1998  return maximum_microseconds
1999 
2001  """!
2002  Gets the single strobe delay increment in microseconds.
2003  @return The delay increment.
2004  """
2005  err_cp = (c_long * 1)(0)
2006  delay_increment = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_delay_increment(self.devicedevice.device_id, err_cp)
2007 
2008  if err_cp[0] != 0:
2009  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_delay_increment")
2010  raise OceanDirectError(err_cp[0], error_msg)
2011  return delay_increment
2012 
2014  """!
2015  Get the minimum amount of time, in microseconds, that the single strobe pulse
2016  should remain high after it begins.
2017  @return The minimum width in microseconds.
2018  """
2019 
2020  err_cp = (c_long * 1)(0)
2021  width_minimum = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_width_minimum(self.devicedevice.device_id, err_cp)
2022 
2023  if err_cp[0] != 0:
2024  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_width_minimum")
2025  raise OceanDirectError(err_cp[0], error_msg)
2026  return width_minimum
2027 
2029  """!
2030  Get the maximum amount of time, in microseconds, that the single strobe pulse
2031  should remain high after it begins.
2032  @return The maximum width in microseconds.
2033  """
2034  err_cp = (c_long * 1)(0)
2035  width_maximum = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_width_maximum(self.devicedevice.device_id, err_cp)
2036 
2037  if err_cp[0] != 0:
2038  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_width_maximum")
2039  raise OceanDirectError(err_cp[0], error_msg)
2040  return width_maximum
2041 
2043  """!
2044  Get the single strobe width increment.
2045  @return The width increment.
2046  """
2047  err_cp = (c_long * 1)(0)
2048  width_increment = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_width_increment(self.devicedevice.device_id, err_cp)
2049 
2050  if err_cp[0] != 0:
2051  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_width_increment")
2052  raise OceanDirectError(err_cp[0], error_msg)
2053  return width_increment
2054 
2056  """!
2057  Gets the single strobe cycle maximum in microseconds.
2058  @return The maximum cycle value.
2059  """
2060 
2061  err_cp = (c_long * 1)(0)
2062  cyle_maximum = self.devicedevice.oceandirect.odapi_adv_get_single_strobe_cycle_maximum(self.devicedevice.device_id, err_cp)
2063 
2064  if err_cp[0] != 0:
2065  error_msg = self.devicedevice.decode_error(err_cp[0], "get_single_strobe_cycle_maximum")
2066  raise OceanDirectError(err_cp[0], error_msg)
2067  return cyle_maximum
2068 
2069  def set_continuous_strobe_period(self, period: int) -> None:
2070  """!
2071  Sets the continuous strobe period in microseconds.
2072  @param[in] period The new period of the continuous strobe measured in microseconds
2073  """
2074 
2075  err_cp = (c_long * 1)(0)
2076  self.devicedevice.oceandirect.odapi_adv_set_continuous_strobe_period_micros(self.devicedevice.device_id, err_cp, period)
2077 
2078  if err_cp[0] != 0:
2079  error_msg = self.devicedevice.decode_error(err_cp[0], "set_continuous_strobe_period_micros")
2080  raise OceanDirectError(err_cp[0], error_msg)
2081 
2082  def set_continuous_strobe_enable(self, enable: bool) -> None:
2083  """!
2084  Sets the continuous strobe enable state on the device.
2085  @param[in] enable A boolean used for denoting the desired state (on/off) of the continuous
2086  strobe generator. If the value of enable is nonzero, then the continuous
2087  strobe will operate. If the value of enable is zero, then the continuous
2088  strobe will stop. Note that on some devices the continuous strobe enable
2089  is tied to other enables (such as lamp enable or single strobe enable)
2090  which may cause side effects.
2091  """
2092 
2093  err_cp = (c_long * 1)(0)
2094 
2095  if enable :
2096  self.devicedevice.oceandirect.odapi_adv_set_continuous_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_onlamp_on)
2097  else:
2098  self.devicedevice.oceandirect.odapi_adv_set_continuous_strobe_enable(self.devicedevice.device_id, err_cp, self.lamp_offlamp_off)
2099 
2100  if err_cp[0] != 0:
2101  error_msg = self.devicedevice.decode_error(err_cp[0], "set_continuous_strobe_enable")
2102  raise OceanDirectError(err_cp[0], error_msg)
2103 
2105  """!
2106  Get the continuous strobe period in microseconds.
2107  @return the period in microseconds.
2108  """
2109 
2110  err_cp = (c_long * 1)(0)
2111  period_microsecond = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_micros(self.devicedevice.device_id, err_cp)
2112 
2113  if err_cp[0] != 0:
2114  error_msg = self.devicedevice.decode_error(err_cp[0], "get_continuous_strobe_period")
2115  raise OceanDirectError(err_cp[0], error_msg)
2116  return period_microsecond
2117 
2118  def get_continuous_strobe_enable(self) -> bool:
2119  """!
2120  Gets the continuous strobe state (enabled or disabled) of the device.
2121  @return True if continuous strobe is enabled otherwise it's False.
2122  """
2123 
2124  err_cp = (c_long * 1)(0)
2125  enable = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_enable(self.devicedevice.device_id, err_cp)
2126 
2127  if err_cp[0] != 0:
2128  error_msg = self.devicedevice.decode_error(err_cp[0], "is_continuous_strobe_enable")
2129  raise OceanDirectError(err_cp[0], error_msg)
2130  return bool(c_ubyte(enable))
2131 
2133  """!
2134  Gets the minimum continuous strobe period of the device in microseconds.
2135  @return The minimum strobe period in microseconds.
2136  """
2137 
2138  err_cp = (c_long * 1)(0)
2139  minimum_microsecond = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_minimum_micros(self.devicedevice.device_id, err_cp)
2140 
2141  if err_cp[0] != 0:
2142  error_msg = self.devicedevice.decode_error(err_cp[0], "get_continuous_strobe_period_minimum")
2143  raise OceanDirectError(err_cp[0], error_msg)
2144  return minimum_microsecond
2145 
2147  """!
2148  Gets the maximum continuous strobe period of the device in microseconds.
2149  @return The maximum strobe period in microseconds.
2150  """
2151 
2152  err_cp = (c_long * 1)(0)
2153  maximum_microsecond = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_maximum_micros(self.devicedevice.device_id, err_cp)
2154 
2155  if err_cp[0] != 0:
2156  error_msg = self.devicedevice.decode_error(err_cp[0], "get_continuous_strobe_period_maximum")
2157  raise OceanDirectError(err_cp[0], error_msg)
2158  return maximum_microsecond
2159 
2161  """!
2162  This function gets the current size of the strobe period increment of the device in microseconds.
2163  The increment is dependent on the strobe period. Small strobe periods i.e. less than about 1ms
2164  will have a small increment, typically 1 microsecond. Larger strobe periods will have larger
2165  increments, typically 1ms.
2166  @return The current strobe period increment in microseconds.
2167  """
2168 
2169  err_cp = (c_long * 1)(0)
2170  increment_microsecond = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_period_increment_micros(self.devicedevice.device_id, err_cp)
2171 
2172  if err_cp[0] != 0:
2173  error_msg = self.devicedevice.decode_error(err_cp[0], "get_continuous_strobe_period_increment")
2174  raise OceanDirectError(err_cp[0], error_msg)
2175  return increment_microsecond
2176 
2178  """!
2179  Gets the strobe width of the device in microseconds.
2180  @return The current strobe width in microseconds.
2181  """
2182  err_cp = (c_long * 1)(0)
2183  width_microsecond = self.devicedevice.oceandirect.odapi_adv_get_continuous_strobe_width_micros(self.devicedevice.device_id, err_cp)
2184 
2185  if err_cp[0] != 0:
2186  error_msg = self.devicedevice.decode_error(err_cp[0], "get_continuous_strobe_width")
2187  raise OceanDirectError(err_cp[0], error_msg)
2188  return width_microsecond
2189 
2190  def set_continuous_strobe_width(self, widthMicrosecond: int) -> None:
2191  """!
2192  Sets the continuous strobe width on the device.
2193  @param[in] widthMicrosecond The new width of the continuous strobe measured in microseconds.
2194  """
2195 
2196  err_cp = (c_long * 1)(0)
2197  self.devicedevice.oceandirect.odapi_adv_set_continuous_strobe_width_micros(self.devicedevice.device_id, err_cp, c_ulong(widthMicrosecond))
2198 
2199  if err_cp[0] != 0:
2200  error_msg = self.devicedevice.decode_error(err_cp[0], "set_continuous_strobe_width")
2201  raise OceanDirectError(err_cp[0], error_msg)
2202 
2203  def clear_data_buffer(self) -> None:
2204  """!
2205  Clear the data buffer. An exception will be thrown if the command is not supported by the device.
2206  """
2207 
2208  err_cp = (c_long * 1)(0)
2209  self.devicedevice.oceandirect.odapi_adv_clear_data_buffer(self.devicedevice.device_id, err_cp)
2210 
2211  if err_cp[0] != 0:
2212  error_msg = self.devicedevice.decode_error(err_cp[0], "clear_data_buffer")
2213  raise OceanDirectError(err_cp[0], error_msg)
2214 
2216  """!
2217  Get the number of data elements currently in the buffer. An exception will be thrown if
2218  the command is not supported by the device.
2219  @return A count of how many items are available for retrieval from the buffer.
2220  """
2221 
2222  err_cp = (c_long * 1)(0)
2223  number_of_elements = self.devicedevice.oceandirect.odapi_adv_get_data_buffer_number_of_elements(self.devicedevice.device_id, err_cp)
2224 
2225  if err_cp[0] != 0:
2226  error_msg = self.devicedevice.decode_error(err_cp[0], "get_data_buffer_number_of_elements")
2227  raise OceanDirectError(err_cp[0], error_msg)
2228  return number_of_elements
2229 
2230  def get_data_buffer_capacity(self) -> int:
2231  """!
2232  Get the present limit of how many data elements will be retained by the buffer. This value can be
2233  changed with set_data_buffer_capacity(). An exception will be thrown if the command is
2234  not supported by the device.
2235  @return A count of how many items the buffer will store before data may be lost.
2236  """
2237 
2238  err_cp = (c_long * 1)(0)
2239  maximum_buffer = self.devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity(self.devicedevice.device_id, err_cp)
2240 
2241  if err_cp[0] != 0:
2242  error_msg = self.devicedevice.decode_error(err_cp[0], "get_data_buffer_capacity")
2243  raise OceanDirectError(err_cp[0], error_msg)
2244  return maximum_buffer
2245 
2247  """!
2248  Get the maximum possible configurable size for the data buffer. An exception will be thrown if
2249  the command is not supported by the device.
2250  @return The largest value that may be set with set_data_buffer_capacity().
2251  """
2252 
2253  err_cp = (c_long * 1)(0)
2254  maximum_buffer_capacity = self.devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity_maximum(self.devicedevice.device_id, err_cp)
2255 
2256  if err_cp[0] != 0:
2257  error_msg = self.devicedevice.decode_error(err_cp[0], "get_data_buffer_capacity_maximum")
2258  raise OceanDirectError(err_cp[0], error_msg)
2259  return maximum_buffer_capacity
2260 
2262  """!
2263  Get the minimum possible configurable size for the data buffer. An exception will be thrown if
2264  the command is not supported by the device.
2265  @return The smallest value that may be set with set_data_buffer_capacity().
2266  """
2267 
2268  err_cp = (c_long * 1)(0)
2269  minimum_buffer_capacity = self.devicedevice.oceandirect.odapi_adv_get_data_buffer_capacity_minimum(self.devicedevice.device_id, err_cp)
2270 
2271  if err_cp[0] != 0:
2272  error_msg = self.devicedevice.decode_error(err_cp[0], "get_data_buffer_capacity_minimum")
2273  raise OceanDirectError(err_cp[0], error_msg)
2274  return minimum_buffer_capacity
2275 
2276  def set_data_buffer_capacity(self, capacity: int) -> None:
2277  """!
2278  Set the number of data elements that the buffer should retain. This function must be used
2279  with "set_number_of_backtoback_scans()". An exception will be thrown if the command is
2280  not supported by the device.
2281  @param[in] capacity Limit on the number of data elements to store. This is bounded by what is returned
2282  by get_data_buffer_capacity_minimum() and get_data_buffer_capacity_maximum().
2283  """
2284 
2285  err_cp = (c_long * 1)(0)
2286  self.devicedevice.oceandirect.odapi_adv_set_data_buffer_capacity(self.devicedevice.device_id, err_cp, capacity)
2287 
2288  if err_cp[0] != 0:
2289  error_msg = self.devicedevice.decode_error(err_cp[0], "set_data_buffer_capacity")
2290  raise OceanDirectError(err_cp[0], error_msg)
2291 
2292  def set_data_buffer_enable(self, enable: bool) -> None:
2293  """!
2294  Enable or disable data buffering. An exception will be thrown if the command is
2295  not supported by the device.
2296  @param[in] enable True enable the buffer. False disable the buffer.
2297  """
2298 
2299  flag = c_ubyte(0)
2300  if enable == True or enable == 1:
2301  flag = c_ubyte(1)
2302 
2303  err_cp = (c_long * 1)(0)
2304  self.devicedevice.oceandirect.odapi_adv_set_data_buffer_enable(self.devicedevice.device_id, err_cp, flag)
2305 
2306  if err_cp[0] != 0:
2307  error_msg = self.devicedevice.decode_error(err_cp[0], "set_data_buffer_enable")
2308  raise OceanDirectError(err_cp[0], error_msg)
2309 
2310  def get_data_buffer_enable(self) -> bool:
2311  """!
2312  Reads the device data buffering enable state. An exception will be thrown if the command
2313  is not supported by the device.
2314  @return True if data buffering is enabled otherwise it's False.
2315  """
2316 
2317  err_cp = (c_long * 1)(0)
2318  dataBufferState = self.devicedevice.oceandirect.odapi_adv_get_data_buffer_enable(self.devicedevice.device_id, err_cp)
2319 
2320  if err_cp[0] != 0:
2321  error_msg = self.devicedevice.decode_error(err_cp[0], "get_data_buffer_enable")
2322  raise OceanDirectError(err_cp[0], error_msg)
2323  return bool(c_ubyte(dataBufferState))
2324 
2325  def abort_acquisition(self) -> None:
2326  """!
2327  Abort spectra acquisition and put the device into an idle state. To resume spectra acquisition,
2328  you have to call acquire_spectra_to_buffer() first before calling the get spectra command. Very
2329  few devices supported this command.
2330  """
2331 
2332  err_cp = (c_long * 1)(0)
2333  self.devicedevice.oceandirect.odapi_adv_abort_acquisition(self.devicedevice.device_id, err_cp)
2334 
2335  if err_cp[0] != 0:
2336  error_msg = self.devicedevice.decode_error(err_cp[0], "abort_acquisition")
2337  raise OceanDirectError(err_cp[0], error_msg)
2338 
2339  def acquire_spectra_to_buffer(self) -> None:
2340  """!
2341  Start spectra acquisition. This would transition the device into a non-idle state. Very
2342  few devices supported this command. An exception will be thrown if the command is
2343  not supported by the device.
2344  """
2345 
2346  err_cp = (c_long * 1)(0)
2347  self.devicedevice.oceandirect.odapi_adv_acquire_spectra_to_buffer(self.devicedevice.device_id, err_cp)
2348 
2349  if err_cp[0] != 0:
2350  error_msg = self.devicedevice.decode_error(err_cp[0], "acquire_spectra_to_buffer")
2351  raise OceanDirectError(err_cp[0], error_msg)
2352 
2353  def get_device_idle_state(self) -> bool:
2354  """!
2355  Return device idle state. Very few devices supported this command. An exception will be thrown if
2356  the command is not supported by the device.
2357  @return True if the device is idle otherwise it's False.
2358  """
2359 
2360  err_cp = (c_long * 1)(0)
2361  retval = self.devicedevice.oceandirect.odapi_adv_get_device_idle_state(self.devicedevice.device_id, err_cp)
2362 
2363  if err_cp[0] != 0:
2364  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_idle_state")
2365  raise OceanDirectError(err_cp[0], error_msg)
2366 
2367  return bool(c_ubyte(retval))
2368 
2370  """!
2371  Get the number of back-to-back scans. See device manual if data buffering is supported.
2372  @return The back-to-back scan value.
2373  """
2374 
2375  err_cp = (c_long * 1)(0)
2376  retval = self.devicedevice.oceandirect.odapi_adv_get_number_of_backtoback_scans(self.devicedevice.device_id, err_cp)
2377 
2378  if err_cp[0] != 0:
2379  error_msg = self.devicedevice.decode_error(err_cp[0], "get_number_of_backtoback_scans")
2380  raise OceanDirectError(err_cp[0], error_msg)
2381 
2382  return retval
2383 
2384  def set_number_of_backtoback_scans(self, numScans: int) -> None:
2385  """!
2386  Set the number of spectra that the device will capture per trigger event. This function requires
2387  data buffer to be enabled. See "set_data_buffer_enable()". See device manual if data buffering is supported.
2388  @param[in] numScans The back-to-back scan value.
2389  """
2390 
2391  err_cp = (c_long * 1)(0)
2392  self.devicedevice.oceandirect.odapi_adv_set_number_of_backtoback_scans(self.devicedevice.device_id, err_cp, numScans)
2393 
2394  if err_cp[0] != 0:
2395  error_msg = self.devicedevice.decode_error(err_cp[0], "set_number_of_backtoback_scans")
2396  raise OceanDirectError(err_cp[0], error_msg)
2397 
2398  def get_raw_spectrum_with_metadata(self, list_raw_spectra: list[list[float]], list_timestamp: list[int], buffer_size: int) -> int:
2399  """!
2400  Returns spectra with metadata information. For older devices such as FX/HDX, read a maximum of 15
2401  spectra from the data buffer. This function requires that both back to back scans and data buffer
2402  be enabled. See "set_data_buffer_enable()" and "set_number_of_backtoback_scans()". For newer devices
2403  such as Ocean SR2, you can call this function right away. See device manual if this command is supported.
2404  @param[in] list_raw_spectra The spectra output buffer.
2405  @param[in] list_timestamp The timestamp output buffer of each spectra.
2406  @param[in] buffer_size The buffer array size (maximum is 15).
2407  @return The number of spectra read. It can be zero.
2408  """
2409 
2410  buffer = (POINTER(c_double) * buffer_size)()
2411  for x in range(buffer_size):
2412  buffer[x] = (c_double * self.devicedevice.pixel_count_formatted)()
2413 
2414  timestamp = (c_longlong * buffer_size)(0)
2415  err_cp = (c_long * 1)(0)
2416  spectraCount = self.devicedevice.oceandirect.odapi_get_raw_spectrum_with_metadata(self.devicedevice.device_id, err_cp, buffer, buffer_size,
2417  self.devicedevice.pixel_count_formatted, timestamp, buffer_size)
2418 
2419  if err_cp[0] != 0:
2420  error_msg = self.devicedevice.decode_error(err_cp[0], "get_raw_spectrum_with_metadata")
2421  raise OceanDirectError(err_cp[0], error_msg)
2422 
2423  for x in range(spectraCount):
2424  spectra = [None] * self.devicedevice.pixel_count_formatted
2425 
2426  #Convert c-types into python. There might be a better way to do this.
2427  for y in range(self.devicedevice.pixel_count_formatted):
2428  spectra[y] = buffer[x][y]
2429 
2430  list_raw_spectra.append(spectra)
2431  #list_raw_spectra.append(buffer[x])
2432  list_timestamp.append(timestamp[x])
2433 
2434  return spectraCount
2435 
2437  """!
2438  This function returns the usb primary OUT endpoint for the type specified. If the type is not
2439  supported by the device, a zero is returned. 0 is normally the control endpoint. That
2440  value is not valid in this context.
2441  @return The usb endpoint address.
2442  """
2443 
2444  err_cp = (c_long * 1)(0)
2445  usb_primary_endpoint_out = self.devicedevice.oceandirect.odapi_get_device_usb_endpoint_primary_out(self.devicedevice.device_id, err_cp)
2446 
2447  if err_cp[0] != 0:
2448  error_msg = self.devicedevice.decode_error(err_cp[0], "get_usb_endpoint_primary_out")
2449  raise OceanDirectError(err_cp[0], error_msg)
2450  return int(usb_primary_endpoint_out)
2451 
2453  """!
2454  This function returns the usb primary IN endpoint for the type specified. If the type is not
2455  supported by the device, a zero is returned. 0 is normally the control endpoint. That
2456  value is not valid in this context.
2457  @return The usb endpoint address.
2458  """
2459 
2460  err_cp = (c_long * 1)(0)
2461  usb_primary_endpoint_in = self.devicedevice.oceandirect.odapi_get_device_usb_endpoint_primary_in(self.devicedevice.device_id, err_cp)
2462 
2463  if err_cp[0] != 0:
2464  error_msg = self.devicedevice.decode_error(err_cp[0], "get_usb_endpoint_primary_in")
2465  raise OceanDirectError(err_cp[0], error_msg)
2466  return int(usb_primary_endpoint_in)
2467 
2469  """!
2470  This function returns the usb secondary OUT endpoint for the type specified. If the type is
2471  not supported by the device, a zero is returned. 0 is normally the control endpoint. That
2472  value is not valid in this context.
2473  @return The usb endpoint address.
2474  """
2475 
2476  err_cp = (c_long * 1)(0)
2477  usb_secondary_endpoint_out = self.devicedevice.oceandirect.odapi_get_device_usb_endpoint_secondary_out(self.devicedevice.device_id, err_cp)
2478 
2479  if err_cp[0] != 0:
2480  error_msg = self.devicedevice.decode_error(err_cp[0], "get_usb_endpoint_secondary_out")
2481  raise OceanDirectError(err_cp[0], error_msg)
2482  return int(usb_secondary_endpoint_out)
2483 
2485  """!
2486  This function returns the usb secondary IN endpoint for the type specified. If the type is
2487  not supported by the device, a zero is returned. 0 is normally the control endpoint. That
2488  value is not valid in this context.
2489  @return The usb endpoint address.
2490  """
2491 
2492  err_cp = (c_long * 1)(0)
2493 
2494  usb_secondary_endpoint_in = self.devicedevice.oceandirect.odapi_get_device_usb_endpoint_secondary_in(self.devicedevice.device_id, err_cp)
2495  if err_cp[0] != 0:
2496  error_msg = self.devicedevice.decode_error(err_cp[0], "get_usb_endpoint_secondary_in")
2497  raise OceanDirectError(err_cp[0], error_msg)
2498  return int(usb_secondary_endpoint_in)
2499 
2500  def get_revision_firmware(self) -> str:
2501  """!
2502  Reads out the firmware revision from the device's internal memory if that feature is supported.
2503  @return The firmware revision.
2504  """
2505 
2506  err_cp = (c_long * 1)(0)
2507  fw_revision_cp = create_string_buffer(b'\000' * 100)
2508  bytesRead = self.devicedevice.oceandirect.odapi_adv_get_revision_firmware(self.devicedevice.device_id, err_cp, fw_revision_cp, 100)
2509 
2510  if err_cp[0] != 0:
2511  error_msg = self.devicedevice.decode_error(err_cp[0], "get_revision_firmware")
2512  raise OceanDirectError(err_cp[0], error_msg)
2513  return fw_revision_cp.value.decode()
2514 
2515  def get_revision_fpga(self) -> str:
2516  """!
2517  Reads out the FPGA revision from the device's internal memory if that feature is supported.
2518  @return The fpga revision.
2519  """
2520 
2521  err_cp = (c_long * 1)(0)
2522  fpga_revision_cp = create_string_buffer(b'\000' * 100)
2523  bytesRead = self.devicedevice.oceandirect.odapi_adv_get_revision_fpga(self.devicedevice.device_id, err_cp, fpga_revision_cp, 100)
2524 
2525  if err_cp[0] != 0:
2526  error_msg = self.devicedevice.decode_error(err_cp[0], "get_revision_fpga")
2527  raise OceanDirectError(err_cp[0], error_msg)
2528  return fpga_revision_cp.value.decode()
2529 
2530  def ipv4_is_dhcp_enabled(self, ifNum: int) -> bool:
2531  """!
2532  Check to see if DHCP (client) is enabled on the specified interface. If DHCP is enabled then the
2533  device will be able to receive an IP address from a DHCP server in the network it is connected to. See
2534  device manual if TCP/IP connection is supported.
2535  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2536  @return True if DHCP is enabled on the specified interface otherwise it's False.
2537  """
2538 
2539  err_cp = (c_long * 1)(0)
2540  enable = self.devicedevice.oceandirect.odapi_adv_ipv4_is_dhcp_enabled(self.devicedevice.device_id, err_cp, c_ubyte(ifNum))
2541 
2542  if err_cp[0] != 0:
2543  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_is_dhcp_enabled")
2544  raise OceanDirectError(err_cp[0], error_msg)
2545  return bool(c_ubyte(enable))
2546 
2547  def ipv4_is_dhcp_enabled2(self) -> bool:
2548  return self.ipv4_is_dhcp_enabledipv4_is_dhcp_enabled(0)
2549 
2550  def ipv4_set_dhcp_enable(self, ifNum: int, enabled: bool) -> None:
2551  """!
2552  Turn the DHCP client on or off for the device on the specified interface. See device manual if TCP/IP
2553  connection is supported.
2554  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2555  @param[in] enabled False turns the DHCP client off. True turns the DHCP client on.
2556  """
2557 
2558  err_cp = (c_long * 1)(0)
2559  self.devicedevice.oceandirect.odapi_adv_ipv4_set_dhcp_enable(self.devicedevice.device_id, err_cp, ifNum, enabled)
2560 
2561  if err_cp[0] != 0:
2562  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_set_dhcp_enable")
2563  raise OceanDirectError(err_cp[0], error_msg)
2564 
2565  def ipv4_set_dhcp_enable2(self, enabled: bool) -> None:
2566  self.ipv4_set_dhcp_enableipv4_set_dhcp_enable(0, enabled)
2567 
2568  def ipv4_get_number_of_ip_addresses(self, ifNum: int) -> int:
2569  """!
2570  Get the number of IP addresses available on the specified interface. If DHCP is enabled on the
2571  specified interface then index 0 represents the DHCP address and the following addresses
2572  will be any static IP addresses. See device manual if TCP/IP connection is supported.
2573  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2574  @return The number of IP addresses on the specified interface.
2575  """
2576 
2577  err_cp = (c_long * 1)(0)
2578  numIpAddress = self.devicedevice.oceandirect.odapi_adv_ipv4_get_number_of_ip_addresses(self.devicedevice.device_id, err_cp, ifNum)
2579 
2580  if err_cp[0] != 0:
2581  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_get_number_of_ip_addresses")
2582  raise OceanDirectError(err_cp[0], error_msg)
2583  return numIpAddress;
2584 
2586  return self.ipv4_get_number_of_ip_addressesipv4_get_number_of_ip_addresses(0)
2587 
2588  def ipv4_read_ip_address(self, ifNum: int, addressIndex: int) -> tuple[list[int], int]:
2589  """!
2590  Get the assigned ip address provided by the index of a particular interface. See device manual if
2591  TCP/IP connection is supported.
2592  @param[in] ifNum The network interface. 0 for ethernet, 1 for wifi.
2593  @param[in] addressIndex The location of the ip address. Starts with 0.
2594  @return A tuple of ip address (4-byte) and network mask (int).
2595  """
2596  err_cp = (c_long * 1)(0)
2597  netmask_cp = (c_uint * 1)(0)
2598  ip_address_cp = (c_ubyte * 4)(0)
2599  self.devicedevice.oceandirect.odapi_adv_ipv4_read_ip_address(self.devicedevice.device_id, err_cp, c_ubyte(ifNum), c_ubyte(addressIndex),
2600  ip_address_cp, 4, netmask_cp)
2601 
2602  if err_cp[0] != 0:
2603  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_get_number_of_ip_addresses")
2604  raise OceanDirectError(err_cp[0], error_msg)
2605 
2606  outIpAddress = []
2607  outNetmask = int(netmask_cp[0])
2608  for i in range(len(ip_address_cp)):
2609  outIpAddress.append(int(ip_address_cp[i]))
2610  return (outIpAddress, outNetmask)
2611 
2612  def ipv4_read_ip_address2(self, addressIndex: int) -> tuple[list[int], int]:
2613  return self.ipv4_read_ip_addressipv4_read_ip_address(0, addressIndex)
2614 
2615  def ipv4_add_static_ip_address(self, ifNum: int, ipAddress: list[int], netmask: int) -> None:
2616  """!
2617  Add a static IP address to the specified interface. The IP address is specified as 4 bytes in an
2618  array. The leading part of the IP address must contain the first element of the array, followed by the
2619  remaining parts in order to the last part of the IP address in the fourth element of the array. See
2620  device manual if TCP/IP connection is supported.
2621  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2622  @param[in] ipAddress The static IP address to be added. This is 4-byte array data.
2623  @param[in] netmask An 8-bit network mask specifying the subnet of the network the device is on.
2624  """
2625 
2626  err_cp = (c_long * 1)(0)
2627 
2628  if len(ipAddress) != 4:
2629  error_msg = "ipv4_add_static_ip_address() error: ipAddress must be an array of 4 bytes long."
2630  raise OceanDirectError(err_cp[0], error_msg)
2631 
2632  ip_address_cp = (c_ubyte * 4)(0)
2633  for i in range(4):
2634  ip_address_cp[i] = ipAddress[i]
2635 
2636 
2637  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))
2638  if err_cp[0] != 0:
2639  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_add_static_ip_address")
2640  raise OceanDirectError(err_cp[0], error_msg)
2641 
2642  def ipv4_add_static_ip_address2(self, ipAddress: list[int], netmask: int) -> None:
2643  self.ipv4_add_static_ip_addressipv4_add_static_ip_address(0, ipAddress, netmask)
2644 
2645  def ipv4_delete_static_ip_address(self, ifNum: int, addressIndex: int) -> None:
2646  """!
2647  Delete a static IP address on the specified interface. See device manual if TCP/IP connection is supported.
2648  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2649  @param[in] addressIndex The index of the address to be deleted.
2650  """
2651 
2652  err_cp = (c_long * 1)(0)
2653 
2654  self.devicedevice.oceandirect.odapi_adv_ipv4_delete_static_ip_address(self.devicedevice.device_id, err_cp, c_ubyte(ifNum), c_ubyte(addressIndex))
2655  if err_cp[0] != 0:
2656  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_delete_static_ip_address")
2657  raise OceanDirectError(err_cp[0], error_msg)
2658 
2659  def ipv4_delete_static_ip_address2(self, addressIndex: int) -> None:
2660  self.ipv4_delete_static_ip_addressipv4_delete_static_ip_address(0, addressIndex)
2661 
2662  def ipv4_set_default_gateway_ip_address(self, ifNum: int, ipAddress: list[int]) -> None:
2663  """!
2664  Set the default gateway IP address to the specified interface. See device manual if TCP/IP connection is supported.
2665 
2666  @param[in] ifNum The interface number: 0 for Ethernet, 1 for wi-fi.
2667  @param[in] addressIndex The index of the address to be deleted.
2668  @param[in] ipAddress The static IP address to be added. This is 4-byte array data.
2669  """
2670 
2671  err_cp = (c_long * 1)(0)
2672 
2673  if len(ipAddress) != 4:
2674  error_msg = "ipv4_set_default_gateway_ip_address() error: ipAddress must be an array of 4 bytes long."
2675  raise OceanDirectError(err_cp[0], error_msg)
2676 
2677  ip_address_cp = (c_ubyte * 4)(0)
2678  for i in range(4):
2679  ip_address_cp[i] = ipAddress[i]
2680 
2681 
2682  self.devicedevice.oceandirect.odapi_adv_ipv4_set_default_gateway_ip_address(self.devicedevice.device_id, err_cp, c_ubyte(ifNum), ip_address_cp, 4)
2683  if err_cp[0] != 0:
2684  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_set_default_gateway_ip_address")
2685  raise OceanDirectError(err_cp[0], error_msg)
2686 
2687  def ipv4_set_default_gateway_ip_address2(self, ipAddress: list[int]) -> None:
2688  self.ipv4_set_default_gateway_ip_addressipv4_set_default_gateway_ip_address(0, ipAddress)
2689 
2690  def ipv4_get_default_gateway_ip_address(self, ifNum: int) -> list[int]:
2691  """!
2692  Get the default gateway IP address to the specified interface. See device manual if TCP/IP connection is supported.
2693 
2694  @param[in] ifNum The network interface. 0 for ethernet, 1 for wifi.
2695  @return The ip address (4-byte).
2696  """
2697  err_cp = (c_long * 1)(0)
2698  ip_address_cp = (c_ubyte * 4)(0)
2699  self.devicedevice.oceandirect.odapi_adv_ipv4_get_default_gateway_ip_address(self.devicedevice.device_id, err_cp, c_ubyte(ifNum),
2700  ip_address_cp, 4)
2701 
2702  if err_cp[0] != 0:
2703  error_msg = self.devicedevice.decode_error(err_cp[0], "ipv4_get_default_gateway_ip_address")
2704  raise OceanDirectError(err_cp[0], error_msg)
2705 
2706  outIpAddress = []
2707  for i in range(len(ip_address_cp)):
2708  outIpAddress.append(int(ip_address_cp[i]))
2709  return outIpAddress
2710 
2712  return self.ipv4_get_default_gateway_ip_addressipv4_get_default_gateway_ip_address(0)
2713 
2714  def get_gpio_pin_count(self) -> int:
2715  """!
2716  Get GPIO pin count.
2717  @return The pin count.
2718  """
2719 
2720  err_cp = (c_long * 1)(0)
2721  gpioPinCount = self.devicedevice.oceandirect.odapi_adv_get_gpio_pin_count(self.devicedevice.device_id, err_cp)
2722 
2723  if err_cp[0] != 0:
2724  error_msg = self.devicedevice.decode_error(err_cp[0], "get_gpio_pin_count")
2725  raise OceanDirectError(err_cp[0], error_msg)
2726 
2727  return gpioPinCount
2728 
2729  def gpio_set_output_enable1(self, bit: int, isOutput: bool) -> None:
2730  """!
2731  Sets the GPIO bit direction to either output or input.
2732  @param[in] bit The bit position.
2733  @param[in] isOutput The bit value which could be true(output) or false(input).
2734  """
2735 
2736  err_cp = (c_long * 1)(0)
2737  self.devicedevice.oceandirect.odapi_adv_gpio_set_output_enable1(self.devicedevice.device_id, err_cp, bit, isOutput)
2738 
2739  if err_cp[0] != 0:
2740  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_output_enable")
2741  raise OceanDirectError(err_cp[0], error_msg)
2742 
2743  def gpio_get_output_enable1(self, bit: int) -> bool:
2744  """!
2745  Get GPIO bit direction.
2746  @param[in] bit The bit position.
2747  @return The bit direction which could be True(out) or False(in)
2748  """
2749 
2750  err_cp = (c_long * 1)(0)
2751  bitDirection = self.devicedevice.oceandirect.odapi_adv_gpio_get_output_enable1(self.devicedevice.device_id, err_cp, bit)
2752 
2753  if err_cp[0] != 0:
2754  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_output_enable")
2755  raise OceanDirectError(err_cp[0], error_msg)
2756 
2757  return bool(c_ubyte(bitDirection))
2758 
2759  def gpio_set_output_enable2(self, bitmask: int) -> None:
2760  """!
2761  Set the direction (input/output) of the GPIO pins.
2762  @param[in] bitmask The bit mask specifying the pin directions i.e. the nth bit set to 1 sets the nth pin to output.
2763  """
2764 
2765  err_cp = (c_long * 1)(0)
2766  self.devicedevice.oceandirect.odapi_adv_gpio_set_output_enable2(self.devicedevice.device_id, err_cp, c_int(bitmask))
2767 
2768  if err_cp[0] != 0:
2769  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_output_enable2")
2770  raise OceanDirectError(err_cp[0], error_msg)
2771 
2772  def gpio_get_output_enable2(self) -> int:
2773  """!
2774  Get all GPIO bit direction.
2775  @return All bit (int) direction where each bit could be True(out) or False(in).
2776  """
2777 
2778  err_cp = (c_long * 1)(0)
2779  allBitDirection = self.devicedevice.oceandirect.odapi_adv_gpio_get_output_enable2(self.devicedevice.device_id, err_cp)
2780 
2781  if err_cp[0] != 0:
2782  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_output_enable2")
2783  raise OceanDirectError(err_cp[0], error_msg)
2784 
2785  return allBitDirection
2786 
2787  def gpio_set_value1(self, bit: int, isHigh: bool) -> None:
2788  """!
2789  Sets the GPIO bit value to either high or low.
2790  @param[in] bit The bit position.
2791  @param[in] isHigh The bit value which could be true(high) or false(low).
2792  """
2793 
2794  err_cp = (c_long * 1)(0)
2795  self.devicedevice.oceandirect.odapi_adv_gpio_set_value1(self.devicedevice.device_id, err_cp, bit, isHigh)
2796 
2797  if err_cp[0] != 0:
2798  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_value")
2799  raise OceanDirectError(err_cp[0], error_msg)
2800 
2801  def gpio_get_value1(self, bit: int) -> bool:
2802  """!
2803  Get the GPIO bit value in whether it's high(true) or low(false).
2804  @param[in] bit The bit position.
2805  @return The bit value. True for high and False for low.
2806  """
2807 
2808  err_cp = (c_long * 1)(0)
2809  bitValue = self.devicedevice.oceandirect.odapi_adv_gpio_get_value1(self.devicedevice.device_id, err_cp, bit)
2810 
2811  if err_cp[0] != 0:
2812  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_value")
2813  raise OceanDirectError(err_cp[0], error_msg)
2814 
2815  return bool(c_ubyte(bitValue))
2816 
2817  def gpio_set_value2(self, bitmask: int) -> None:
2818  """!
2819  Set the logic value for all GPIO pins.
2820  @param[in] bitmask The bit mask specifying the logic level of each GPIO pin.
2821  """
2822 
2823  err_cp = (c_long * 1)(0)
2824  self.devicedevice.oceandirect.odapi_adv_gpio_set_value2(self.devicedevice.device_id, err_cp, c_int(bitmask))
2825 
2826  if err_cp[0] != 0:
2827  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_value2")
2828  raise OceanDirectError(err_cp[0], error_msg)
2829 
2830  def gpio_get_value2(self) -> int:
2831  """!
2832  Get all GPIO bit values.
2833  @return All bit value (int) where each bit could be True(high) or False(low).
2834  """
2835 
2836  err_cp = (c_long * 1)(0)
2837  allBitValue = self.devicedevice.oceandirect.odapi_adv_gpio_get_value2(self.devicedevice.device_id, err_cp)
2838 
2839  if err_cp[0] != 0:
2840  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_value2")
2841  raise OceanDirectError(err_cp[0], error_msg)
2842 
2843  return allBitValue
2844 
2845  def gpio_set_output_alternate1(self, bit: int, isAlternate: bool) -> None:
2846  """!
2847  Set the alternate functionality for the specified pins (bits). Not
2848  all spectrometers support this functionality.
2849  @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2850  @param[in] bit The GPIO bit or pin to set.
2851  @param[in] isAlternate Set true to enable the alternate functionality for the pin, false otherwise (pin is a GPIO pin).
2852  """
2853 
2854  err_cp = (c_long * 1)(0)
2855  self.devicedevice.oceandirect.odapi_adv_gpio_set_output_alternate1(self.devicedevice.device_id, err_cp, bit, isAlternate)
2856 
2857  if err_cp[0] != 0:
2858  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_output_alternate1")
2859  raise OceanDirectError(err_cp[0], error_msg)
2860 
2861  def gpio_set_output_alternate2(self, bitmask: int) -> None:
2862  """!
2863  Set the alternate functionality for the specified pins (bits). Not
2864  all spectrometers support this functionality.
2865  @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2866  @param[in] bitmask The bits set to 1 to set enable the alternate functionality, 0 otherwise (pin is a GPIO pin).
2867  """
2868 
2869  err_cp = (c_long * 1)(0)
2870  self.devicedevice.oceandirect.odapi_adv_gpio_set_output_alternate2(self.devicedevice.device_id, err_cp, c_int(bitmask))
2871 
2872  if err_cp[0] != 0:
2873  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_set_output_alternate2")
2874  raise OceanDirectError(err_cp[0], error_msg)
2875 
2876  def gpio_get_output_alternate1(self, bit: int) -> bool:
2877  """!
2878  Get the setting for alternate functionality on the specified bit (pin). Not
2879  all spectrometers support this functionality.
2880  @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2881  @param[in] bit The GPIO bit or pin to set.
2882  @return The bit value. True if the pin is set to alternate functionality, false otherwise (pin is a GPIO pin).
2883  """
2884 
2885  err_cp = (c_long * 1)(0)
2886  bitValue = self.devicedevice.oceandirect.odapi_adv_gpio_get_output_alternate1(self.devicedevice.device_id, err_cp, bit)
2887 
2888  if err_cp[0] != 0:
2889  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_output_alternate1")
2890  raise OceanDirectError(err_cp[0], error_msg)
2891 
2892  return bool(c_ubyte(bitValue))
2893 
2894  def gpio_get_output_alternate2(self) -> int:
2895  """!
2896  Get the settings for alternate functionality on the GPIO pins. Not
2897  all spectrometers support this functionality.
2898  @deprecated This function is deprecated starting with release 2.1 and will be removed in the future release.
2899  @return A bitmask with value 1 where the corresponding pin is set to alternate functionality, 0 otherwise (pin is a GPIO pin).
2900  """
2901 
2902  err_cp = (c_long * 1)(0)
2903  allBitValue = self.devicedevice.oceandirect.odapi_adv_gpio_get_output_alternate2(self.devicedevice.device_id, err_cp)
2904 
2905  if err_cp[0] != 0:
2906  error_msg = self.devicedevice.decode_error(err_cp[0], "gpio_get_output_alternate2")
2907  raise OceanDirectError(err_cp[0], error_msg)
2908 
2909  return allBitValue
2910 
2911  def set_led_enable(self, isEnabled: bool) -> None:
2912  """!
2913  Enable or disable device LED. If the device don't have an LED then an exception will be thrown.
2914  @param[in] isEnabled True to enable LED blinking otherwise it's False.
2915  """
2916 
2917  err_cp = (c_long * 1)(0)
2918  self.devicedevice.oceandirect.odapi_adv_set_led_enable(self.devicedevice.device_id, err_cp, isEnabled)
2919 
2920  if err_cp[0] != 0:
2921  error_msg = self.devicedevice.decode_error(err_cp[0], "set_led_enable")
2922  raise OceanDirectError(err_cp[0], error_msg)
2923 
2924  def get_led_enable(self) -> bool:
2925  """!
2926  Get device LED state. If the device don't have an LED then an exception will be thrown.
2927  @return True if LED is enabled otherwise it's False.
2928  """
2929 
2930  err_cp = (c_long * 1)(0)
2931  ledState = self.devicedevice.oceandirect.odapi_adv_get_led_enable(self.devicedevice.device_id, err_cp)
2932 
2933  if err_cp[0] != 0:
2934  error_msg = self.devicedevice.decode_error(err_cp[0], "get_led_enable")
2935  raise OceanDirectError(err_cp[0], error_msg)
2936 
2937  return bool(c_ubyte(ledState))
2938 
2939  def get_device_original_vid(self) -> int:
2940  """!
2941  Get the original vendor id (VID) of the device.
2942  @return The VID.
2943  """
2944 
2945  err_cp = (c_long * 1)(0)
2946  orig_vid = self.devicedevice.oceandirect.odapi_adv_get_device_original_vid(self.devicedevice.device_id, err_cp)
2947 
2948  if err_cp[0] != 0:
2949  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_original_vid")
2950  raise OceanDirectError(err_cp[0], error_msg)
2951 
2952  return orig_vid
2953 
2954  def get_device_original_pid(self) -> int:
2955  """!
2956  Get the original product id (PID) of the device.
2957  @return The PID.
2958  """
2959 
2960  err_cp = (c_long * 1)(0)
2961  orig_pid = self.devicedevice.oceandirect.odapi_adv_get_device_original_pid(self.devicedevice.device_id, err_cp)
2962 
2963  if err_cp[0] != 0:
2964  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_original_pid")
2965  raise OceanDirectError(err_cp[0], error_msg)
2966 
2967  return orig_pid
2968 
2969  def get_device_vid(self) -> int:
2970  """!
2971  Get the current vendor id (VID) of the device.
2972  @return The VID.
2973  """
2974 
2975  err_cp = (c_long * 1)(0)
2976  vid = self.devicedevice.oceandirect.odapi_adv_get_device_vid(self.devicedevice.device_id, err_cp)
2977 
2978  if err_cp[0] != 0:
2979  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_vid")
2980  raise OceanDirectError(err_cp[0], error_msg)
2981 
2982  return vid
2983 
2984  def get_device_pid(self) -> int:
2985  """!
2986  Get the current product id (PID) of the device.
2987  @return The PID.
2988  """
2989 
2990  err_cp = (c_long * 1)(0)
2991  pid = self.devicedevice.oceandirect.odapi_adv_get_device_pid(self.devicedevice.device_id, err_cp)
2992 
2993  if err_cp[0] != 0:
2994  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_pid")
2995  raise OceanDirectError(err_cp[0], error_msg)
2996 
2997  return pid
2998 
3000  """!
3001  Get the original manufacturer string of the device.
3002  @return The manufacturer string.
3003  """
3004 
3005  orig_manufacturer = create_string_buffer(b'\000'*50)
3006  err_cp = (c_long * 1)(0)
3007  self.devicedevice.oceandirect.odapi_adv_get_device_original_manufacturer_string(self.devicedevice.device_id, err_cp, orig_manufacturer, 50)
3008 
3009  if err_cp[0] != 0:
3010  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_original_manufacturer_string")
3011  raise OceanDirectError(err_cp[0], error_msg)
3012 
3013  return orig_manufacturer.value.decode()
3014 
3016  """!
3017  Get the original model string of the device.
3018  @return The model string.
3019  """
3020 
3021  orig_model = create_string_buffer(b'\000'*50)
3022  err_cp = (c_long * 1)(0)
3023  self.devicedevice.oceandirect.odapi_adv_get_device_original_model_string(self.devicedevice.device_id, err_cp, orig_model, 50)
3024 
3025  if err_cp[0] != 0:
3026  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_original_model_string")
3027  raise OceanDirectError(err_cp[0], error_msg)
3028 
3029  return orig_model.value.decode()
3030 
3032  """!
3033  Get the current manufacturer string of the device.
3034  @return The manufacturer string.
3035  """
3036 
3037  manufacturer = create_string_buffer(b'\000'*50)
3038  err_cp = (c_long * 1)(0)
3039  self.devicedevice.oceandirect.odapi_adv_get_device_manufacturer_string(self.devicedevice.device_id, err_cp, manufacturer, 50)
3040 
3041  if err_cp[0] != 0:
3042  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_manufacturer_string")
3043  raise OceanDirectError(err_cp[0], error_msg)
3044 
3045  return manufacturer.value.decode()
3046 
3047  def get_device_model_string(self) -> str:
3048  """!
3049  Get the current model string of the device.
3050  @return The model string.
3051  """
3052 
3053  model = create_string_buffer(b'\000'*50)
3054  err_cp = (c_long * 1)(0)
3055  self.devicedevice.oceandirect.odapi_adv_get_device_model_string(self.devicedevice.device_id, err_cp, model, 50)
3056 
3057  if err_cp[0] != 0:
3058  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_original_model_string")
3059  raise OceanDirectError(err_cp[0], error_msg)
3060 
3061  return model.value.decode()
3062 
3063  def set_device_manufacturer_string(self, manufacturer: str) -> None:
3064  """!
3065  Set the current manufacturer string of the device.
3066  @param[in] manufacturer The new manufacturer string.
3067  """
3068 
3069  if not manufacturer:
3070  manufacturer = " "
3071 
3072  err_cp = (c_long * 1)(0)
3073  self.devicedevice.oceandirect.odapi_adv_set_device_manufacturer_string(self.devicedevice.device_id, err_cp, manufacturer.encode('utf-8'), len(manufacturer))
3074 
3075  if err_cp[0] != 0:
3076  error_msg = self.devicedevice.decode_error(err_cp[0], "set_device_manufacturer_string")
3077  raise OceanDirectError(err_cp[0], error_msg)
3078 
3079  def set_device_model_string(self, model: str) -> None:
3080  """!
3081  Set the current model string of the device.
3082  @param[in] model The new model string.
3083  """
3084 
3085  if not model:
3086  model = " "
3087 
3088  err_cp = (c_long * 1)(0)
3089  self.devicedevice.oceandirect.odapi_adv_set_device_model_string(self.devicedevice.device_id, err_cp, model.encode('utf-8'), len(model))
3090 
3091  if err_cp[0] != 0:
3092  error_msg = self.devicedevice.decode_error(err_cp[0], "set_device_model_string")
3093  raise OceanDirectError(err_cp[0], error_msg)
3094 
3095  # def set_device_vid(self, vid: int) -> None:
3096  # """!
3097  # Sets the vendor id (VID) of the device.
3098  #
3099  # NOTE:
3100  # Use with caution. If the current version of OceanDirect don't have support for the new VID/PID then the
3101  # device will not be recognized.
3102  #
3103  # @param[in] vid The device VID.
3104  # """
3105  #
3106  # err_cp = (c_long * 1)(0)
3107  # error_msg = self.device.oceandirect.odapi_adv_set_device_vid(self.device.device_id, err_cp, c_int(vid))
3108  #
3109  # if err_cp[0] != 0:
3110  # error_msg = self.device.decode_error(err_cp[0],"set_device_vid")
3111  # raise OceanDirectError(err_cp[0], error_msg)
3112  #
3113  # def set_device_pid(self, pid: int) -> None:
3114  # """!
3115  # Sets the product id (PID) of the device.
3116  #
3117  # NOTE:
3118  # Use with caution. If the current version of OceanDirect don't have support for the new VID/PID then the
3119  # device will not be recognized.
3120  #
3121  # @param[in] pid The device PID.
3122  # """
3123  #
3124  # err_cp = (c_long * 1)(0)
3125  # error_msg = self.device.oceandirect.odapi_adv_set_device_pid(self.device.device_id, err_cp, c_int(pid))
3126  #
3127  # if err_cp[0] != 0:
3128  # error_msg = self.device.decode_error(err_cp[0],"set_device_pid")
3129  # raise OceanDirectError(err_cp[0], error_msg)
3130 
3131  def get_device_alias(self) -> str:
3132  """!
3133  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.
3134  @return The device alias.
3135  """
3136 
3137  device_alias = create_string_buffer(b'\000'*50)
3138  err_cp = (c_long * 1)(0)
3139  self.devicedevice.oceandirect.odapi_adv_get_device_alias(self.devicedevice.device_id, err_cp, device_alias, 50)
3140 
3141  if err_cp[0] != 0:
3142  error_msg = self.devicedevice.decode_error(err_cp[0], "get_device_alias")
3143  raise OceanDirectError(err_cp[0], error_msg)
3144 
3145  return device_alias.value.decode()
3146 
3147  def set_device_alias(self, deviceAlias: str) -> None:
3148  """!
3149  Set a new device alias to the device.
3150  @param[in] deviceAlias The device alias. If value is empty then an exception will be thrown.
3151  """
3152 
3153  if not deviceAlias:
3154  #15 is an error code defined in OceanDirectAPIConstants.c
3155  error_msg = self.devicedevice.decode_error(15, "set_device_alias")
3156  raise OceanDirectError(15, error_msg)
3157 
3158  err_cp = (c_long * 1)(0)
3159  self.devicedevice.oceandirect.odapi_adv_set_device_alias(self.devicedevice.device_id, err_cp, deviceAlias.encode('utf-8'), len(deviceAlias))
3160 
3161  if err_cp[0] != 0:
3162  error_msg = self.devicedevice.decode_error(err_cp[0],"set_device_alias")
3163  raise OceanDirectError(err_cp[0], error_msg)
3164 
3165  def reset_device(self) -> None:
3166  """!
3167  Restarts the device.
3168  """
3169 
3170  err_cp = (c_long * 1)(0)
3171  self.devicedevice.oceandirect.odapi_adv_reset_device(self.devicedevice.device_id, err_cp)
3172 
3173  if err_cp[0] != 0:
3174  error_msg = self.devicedevice.decode_error(err_cp[0],"reset_device")
3175  raise OceanDirectError(err_cp[0], error_msg)
3176 
3177  def get_user_string(self) -> str:
3178  """!
3179  Read the user string from the device. If this field in the device is not yet populated then a
3180  non-zero(6) code will be returned. This is the command supported for the newer OBP2.0 enabled devices.
3181  @return The user string.
3182  """
3183 
3184  user_string = create_string_buffer(b'\000'*50)
3185  err_cp = (c_long * 1)(0)
3186  self.devicedevice.oceandirect.odapi_get_user_string(self.devicedevice.device_id, err_cp, user_string, 50)
3187 
3188  if err_cp[0] != 0:
3189  error_msg = self.devicedevice.decode_error(err_cp[0], "get_user_string")
3190  raise OceanDirectError(err_cp[0], error_msg)
3191 
3192  return user_string.value.decode()
3193 
3194  def set_user_string(self, userString: str) -> None:
3195  """!
3196  Set a new user string to the device. The maximum string length is 16. This is the command supported
3197  for the newer OBP2.0 enabled devices.
3198  @param[in] userString The user string. If value is empty then an exception will be thrown.
3199  """
3200 
3201  if not userString:
3202  #15 is an error code defined in OceanDirectAPIConstants.c
3203  error_msg = self.devicedevice.decode_error(15, "set_user_string")
3204  raise OceanDirectError(15, error_msg)
3205 
3206  err_cp = (c_long * 1)(0)
3207  self.devicedevice.oceandirect.odapi_set_user_string(self.devicedevice.device_id, err_cp, userString.encode('utf-8'), len(userString))
3208 
3209  if err_cp[0] != 0:
3210  error_msg = self.devicedevice.decode_error(err_cp[0],"set_user_string")
3211  raise OceanDirectError(err_cp[0], error_msg)
3212 
3213  def get_user_string_count2(self) -> int:
3214  """!
3215  Read the total user string count from the device. If the device don't support this command
3216  then a non-zero error code will be returned. This command is used by legacy devices.
3217  @return The string count.
3218  """
3219 
3220  err_cp = (c_long * 1)(0)
3221  string_count = self.devicedevice.oceandirect.odapi_get_user_string_count1(self.devicedevice.device_id, err_cp)
3222 
3223  if err_cp[0] != 0:
3224  error_msg = self.devicedevice.decode_error(err_cp[0], "get_user_string_count")
3225  raise OceanDirectError(err_cp[0], error_msg)
3226 
3227  return string_count
3228 
3229  def get_user_string2(self, index: int) -> str:
3230  """!
3231  Read the user string from the device. If this field in the device is not yet populated then a
3232  non-zero(6) code will be returned. If the device don't support this command then a non-zero
3233  error code will be returned. This command is used by legacy devices.
3234  @return The user string.
3235  """
3236 
3237  user_string = create_string_buffer(b'\000'*50)
3238  err_cp = (c_long * 1)(0)
3239  self.devicedevice.oceandirect.odapi_get_user_string1(self.devicedevice.device_id, err_cp, c_int(index), user_string, 50)
3240 
3241  if err_cp[0] != 0:
3242  error_msg = self.devicedevice.decode_error(err_cp[0], "get_user_string2")
3243  raise OceanDirectError(err_cp[0], error_msg)
3244 
3245  return user_string.value.decode()
3246 
3247  def set_user_string2(self, index: int, userString: str) -> None:
3248  """!
3249  Write the user string to the device. The maximum string length is 16. If the device don't support this command
3250  then a non-zero error code will be returned. This command is used by legacy devices.
3251  @param[in] index The user string index. If index is less than 0 then an exception will be thrown.
3252  @param[in] userString The user string. If value is empty then an exception will be thrown.
3253  """
3254 
3255  if index < 0 or not userString:
3256  #15 is an error code defined in OceanDirectAPIConstants.c
3257  error_msg = self.devicedevice.decode_error(15, "set_user_string")
3258  raise OceanDirectError(15, error_msg)
3259 
3260  err_cp = (c_long * 1)(0)
3261  self.devicedevice.oceandirect.odapi_set_user_string1(self.devicedevice.device_id, err_cp, c_int(index), userString.encode('utf-8'), len(userString))
3262 
3263  if err_cp[0] != 0:
3264  error_msg = self.devicedevice.decode_error(err_cp[0],"set_user_string2")
3265  raise OceanDirectError(err_cp[0], error_msg)
3266 
3268  """!
3269  Read the maximum ADC counts.
3270  @return The ADC counts.
3271  """
3272 
3273  err_cp = (c_long * 1)(0)
3274  adcCount = self.devicedevice.oceandirect.odapi_adv_get_autonull_maximum_adc_count(self.devicedevice.device_id, err_cp)
3275 
3276  if err_cp[0] != 0:
3277  error_msg = self.devicedevice.decode_error(err_cp[0], "get_autonull_maximum_adc_count")
3278  raise OceanDirectError(err_cp[0], error_msg)
3279 
3280  return adcCount
3281 
3282 
3284  """!
3285  Read the baseline level.
3286  @return The baseline level.
3287  """
3288 
3289  err_cp = (c_long * 1)(0)
3290  baseline = self.devicedevice.oceandirect.odapi_adv_get_autonull_baseline_level(self.devicedevice.device_id, err_cp)
3291 
3292  if err_cp[0] != 0:
3293  error_msg = self.devicedevice.decode_error(err_cp[0], "get_autonull_baseline_level")
3294  raise OceanDirectError(err_cp[0], error_msg)
3295 
3296  return baseline
3297 
3299  """!
3300  Read the saturation level. Most devices returns 65535.
3301  @return The saturation level.
3302  """
3303 
3304  err_cp = (c_long * 1)(0)
3305  saturation = self.devicedevice.oceandirect.odapi_adv_get_autonull_saturation_level(self.devicedevice.device_id, err_cp)
3306 
3307  if err_cp[0] != 0:
3308  error_msg = self.devicedevice.decode_error(err_cp[0], "get_autonull_saturation_level")
3309  raise OceanDirectError(err_cp[0], error_msg)
3310 
3311  return saturation
3312 
3313  def get_baud_rate(self) -> int:
3314  """!
3315  Read the device RS-232 baud rate. Not all devices supported this command.
3316  @return The baud rate.
3317  """
3318 
3319  err_cp = (c_long * 1)(0)
3320  baud_rate = self.devicedevice.oceandirect.odapi_adv_get_baud_rate(self.devicedevice.device_id, err_cp)
3321 
3322  if err_cp[0] != 0:
3323  error_msg = self.devicedevice.decode_error(err_cp[0], "get_baud_rate")
3324  raise OceanDirectError(err_cp[0], error_msg)
3325 
3326  return baud_rate
3327 
3328  def set_baud_rate(self, baudRate: int) -> None:
3329  """!
3330  Set a new baud rate for the RS-232 port. Not all devices supported this command.
3331  @param[in] baudRate The baud rate value.
3332  """
3333 
3334  err_cp = (c_long * 1)(0)
3335  self.devicedevice.oceandirect.odapi_adv_set_baud_rate(self.devicedevice.device_id, err_cp, c_int(baudRate))
3336 
3337  if err_cp[0] != 0:
3338  error_msg = self.devicedevice.decode_error(err_cp[0], "set_baud_rate")
3339  raise OceanDirectError(err_cp[0], error_msg)
3340 
3341  def save_settings_to_flash(self) -> None:
3342  """!
3343  Save settings to flash. Not all devices supported this command.
3344  """
3345 
3346  err_cp = (c_long * 1)(0)
3347  self.devicedevice.oceandirect.odapi_adv_save_settings_to_flash(self.devicedevice.device_id, err_cp)
3348 
3349  if err_cp[0] != 0:
3350  error_msg = self.devicedevice.decode_error(err_cp[0], "save_settings_to_flash")
3351  raise OceanDirectError(err_cp[0], error_msg)
3352 
3353  def get_active_pixel_range(self) -> list[int]:
3354  """!
3355  Read the active pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3356  If the device don't support this command then a non-zero error code will be returned.
3357  @return A list of active pixel range.
3358  """
3359 
3360  range = (c_int * 10)(0)
3361  err_cp = (c_long * 1)(0)
3362  elementCopied = self.devicedevice.oceandirect.odapi_get_active_pixel_range(self.devicedevice.device_id, err_cp, range, 10)
3363 
3364  if err_cp[0] != 0:
3365  error_msg = self.devicedevice.decode_error(err_cp[0],"get_active_pixel_range")
3366  raise OceanDirectError(err_cp[0], error_msg)
3367 
3368  return list(range)[0:elementCopied]
3369 
3370  def get_optical_dark_pixel_range(self) -> list[int]:
3371  """!
3372  Read the optical dark pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3373  If the device don't support this command then a non-zero error code will be returned.
3374  @return A list of optical dark pixel range.
3375  """
3376 
3377  range = (c_int * 10)(0)
3378  err_cp = (c_long * 1)(0)
3379  elementCopied = self.devicedevice.oceandirect.odapi_get_optical_dark_pixel_range(self.devicedevice.device_id, err_cp, range, 10)
3380 
3381  if err_cp[0] != 0:
3382  error_msg = self.devicedevice.decode_error(err_cp[0],"get_optical_dark_pixel_range")
3383  raise OceanDirectError(err_cp[0], error_msg)
3384 
3385  return list(range)[0:elementCopied]
3386 
3387  def get_transition_pixel_range(self) -> list[int]:
3388  """!
3389  Read the transition pixel range from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3390  If the device don't support this command then a non-zero error code will be returned.
3391  @return A list of transition pixel range.
3392  """
3393 
3394  range = (c_int * 10)(0)
3395  err_cp = (c_long * 1)(0)
3396  elementCopied = self.devicedevice.oceandirect.odapi_get_transition_pixel_range(self.devicedevice.device_id, err_cp, range, 10)
3397 
3398  if err_cp[0] != 0:
3399  error_msg = self.devicedevice.decode_error(err_cp[0],"get_transition_pixel_range")
3400  raise OceanDirectError(err_cp[0], error_msg)
3401 
3402  return list(range)[0:elementCopied]
3403 
3404  def get_bad_pixel_indices(self) -> list[int]:
3405  """!
3406  Read bad pixel indices from the sensor pixel array. This command is being used in OBP-2.0 enabled devices.
3407  If the device don't support this command then a non-zero error code will be returned.
3408  @return A list of bad pixel indices.
3409  """
3410 
3411  range = (c_int * 40)(0)
3412  err_cp = (c_long * 1)(0)
3413  elementCopied = self.devicedevice.oceandirect.odapi_get_bad_pixel_indices(self.devicedevice.device_id, err_cp, range, 40)
3414 
3415  if err_cp[0] != 0:
3416  error_msg = self.devicedevice.decode_error(err_cp[0],"get_bad_pixel_indices")
3417  raise OceanDirectError(err_cp[0], error_msg)
3418 
3419  return list(range)[0:elementCopied]
3420 
3422  """!
3423  Read the number of supported communication interface.
3424  @return The number of interface.
3425  """
3426  err_cp = (c_long * 1)(0)
3427  if_count = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_count(self.devicedevice.device_id, err_cp)
3428 
3429  if err_cp[0] != 0:
3430  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_count")
3431  raise OceanDirectError(err_cp[0], error_msg)
3432 
3433  return if_count
3434 
3435  def get_network_interface_type(self, interfaceIndex: int) -> int:
3436  """!
3437  Return the interface type of the given interface index.
3438  @param interfaceIndex[in] The interface to look at.
3439  @return The interface type which could be one 0(Loopback), 1(wired ethernet), 2 (WIFI), and 3 (USB - CDC Ethernet).
3440  """
3441  err_cp = (c_long * 1)(0)
3442  if_type = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_type(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3443 
3444  if err_cp[0] != 0:
3445  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_type")
3446  raise OceanDirectError(err_cp[0], error_msg)
3447 
3448  return if_type
3449 
3451  return self.get_network_interface_typeget_network_interface_typeget_network_interface_type(0)
3452 
3453  def get_network_interface_status(self, interfaceIndex: int) -> bool:
3454  """!
3455  Return true if the interface is enabled otherwise it's false.
3456  @param interfaceIndex[in] The interface to look at.
3457  @return True if the interface if enabled otherwise it's False.
3458  """
3459  err_cp = (c_long * 1)(0)
3460  enabled = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3461 
3462  if err_cp[0] != 0:
3463  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_status")
3464  raise OceanDirectError(err_cp[0], error_msg)
3465 
3466  return bool(c_ubyte(enabled))
3467 
3469  return self.get_network_interface_statusget_network_interface_statusget_network_interface_status(0)
3470 
3471  def set_network_interface_status(self, interfaceIndex: int, enable: bool) -> None:
3472  """!
3473  Enable or disable the interface.
3474 
3475  @param interfaceIndex[in] The interface that will be enabled or disabled.
3476  @param enable[in] True will enable the interface. False will disable it.
3477  """
3478  err_cp = (c_long * 1)(0)
3479 
3480  if enable:
3481  self.devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(1))
3482  else:
3483  self.devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(0))
3484 
3485  if err_cp[0] != 0:
3486  error_msg = self.devicedevice.decode_error(err_cp[0], "set_network_interface_status")
3487  raise OceanDirectError(err_cp[0], error_msg)
3488 
3489  def set_network_interface_status2(self, enable: bool) -> None:
3490  self.set_network_interface_statusset_network_interface_statusset_network_interface_status(0, enable)
3491 
3492  def save_network_interface_setting(self, interfaceIndex: int) -> None:
3493  """!
3494  Save the network interface settings to the device.
3495 
3496  @param interfaceIndex[in] The interface to saved to.
3497  """
3498  err_cp = (c_long * 1)(0)
3499  self.devicedevice.oceandirect.odapi_adv_network_conf_save_interface_setting(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3500 
3501  if err_cp[0] != 0:
3502  error_msg = self.devicedevice.decode_error(err_cp[0], "save_network_interface_setting")
3503  raise OceanDirectError(err_cp[0], error_msg)
3504 
3506  self.save_network_interface_settingsave_network_interface_settingsave_network_interface_setting(0)
3507 
3508  def get_ethernet_gigabit_enable_status(self, interfaceIndex: int) -> bool:
3509  """!
3510  Return the status on whether the gigabit ethernet is enabled or not.
3511 
3512  @param interfaceIndex[in] The ethernet interface to look at.
3513  @return The interface status.
3514  """
3515  err_cp = (c_long * 1)(0)
3516  status = self.devicedevice.oceandirect.odapi_adv_ethernet_get_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3517 
3518  if err_cp[0] != 0:
3519  error_msg = self.devicedevice.decode_error(err_cp[0], "get_ethernet_gigabit_enable_status")
3520  raise OceanDirectError(err_cp[0], error_msg)
3521 
3522  return bool(status)
3523 
3525  return self.get_ethernet_gigabit_enable_statusget_ethernet_gigabit_enable_statusget_ethernet_gigabit_enable_status(0)
3526 
3527  def set_ethernet_gigabit_enable_status(self, interfaceIndex: int, enable: bool) -> None:
3528  """!
3529  Enable or disable the gigabit ethernet the status.
3530  @param interfaceIndex[in] The ethernet interface to look at.
3531  @param enable True will enable gigabit ethernet.
3532  """
3533  err_cp = (c_long * 1)(0)
3534  if enable:
3535  self.devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3536  else:
3537  self.devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3538 
3539  if err_cp[0] != 0:
3540  error_msg = self.devicedevice.decode_error(err_cp[0], "set_ethernet_gigabit_enable_status")
3541  raise OceanDirectError(err_cp[0], error_msg)
3542 
3543  def set_ethernet_gigabit_enable_status2(self, enable: bool) -> None:
3544  self.set_ethernet_gigabit_enable_statusset_ethernet_gigabit_enable_statusset_ethernet_gigabit_enable_status(0, enable)
3545 
3547  """!
3548  Read the number of supported communication interface.
3549 
3550  @return The number of interface.
3551  """
3552  err_cp = (c_long * 1)(0)
3553  if_count = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_count(self.devicedevice.device_id, err_cp)
3554 
3555  if err_cp[0] != 0:
3556  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_count")
3557  raise OceanDirectError(err_cp[0], error_msg)
3558 
3559  return if_count
3560 
3561  def get_network_interface_type(self, interfaceIndex: int) -> int:
3562  """!
3563  Return the interface type of the given interface index.
3564 
3565  @param interfaceIndex[in] The interface to look at.
3566  @return The interface type which could be one 0(Loopback), 1(wired ethernet), 2 (WIFI), and 3 (USB - CDC Ethernet).
3567  """
3568  err_cp = (c_long * 1)(0)
3569  if_type = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_type(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3570 
3571  if err_cp[0] != 0:
3572  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_type")
3573  raise OceanDirectError(err_cp[0], error_msg)
3574 
3575  return if_type
3576 
3578  return self.get_network_interface_typeget_network_interface_typeget_network_interface_type(0)
3579 
3580  def get_network_interface_status(self, interfaceIndex: int) -> bool:
3581  """!
3582  Return true if the interface is enabled otherwise it's false.
3583 
3584  @param interfaceIndex[in] The interface to look at.
3585  @return True if the interface if enabled otherwise it's False.
3586  """
3587  err_cp = (c_long * 1)(0)
3588  enabled = self.devicedevice.oceandirect.odapi_adv_network_conf_get_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3589 
3590  if err_cp[0] != 0:
3591  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_interface_status")
3592  raise OceanDirectError(err_cp[0], error_msg)
3593 
3594  return bool(c_ubyte(enabled))
3595 
3597  return self.get_network_interface_statusget_network_interface_statusget_network_interface_status(0)
3598 
3599  def set_network_interface_status(self, interfaceIndex: int, enable: bool) -> None:
3600  """!
3601  Enable or disable the interface.
3602 
3603  @param interfaceIndex[in] The interface that will be enabled or disabled.
3604  @param enable[in] True will enable the interface. False will disable it.
3605  """
3606  err_cp = (c_long * 1)(0)
3607 
3608  if enable:
3609  self.devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(1))
3610  else:
3611  self.devicedevice.oceandirect.odapi_adv_network_conf_set_interface_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), c_ubyte(0))
3612 
3613  if err_cp[0] != 0:
3614  error_msg = self.devicedevice.decode_error(err_cp[0], "set_network_interface_status")
3615  raise OceanDirectError(err_cp[0], error_msg)
3616 
3617  def set_network_interface_status2(self, enable: bool) -> None:
3618  self.set_network_interface_statusset_network_interface_statusset_network_interface_status(0, enable)
3619 
3620  def save_network_interface_setting(self, interfaceIndex: int) -> None:
3621  """!
3622  Save the network interface settings to the device.
3623 
3624  @param interfaceIndex[in] The interface to saved to.
3625  """
3626  err_cp = (c_long * 1)(0)
3627  self.devicedevice.oceandirect.odapi_adv_network_conf_save_interface_setting(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3628 
3629  if err_cp[0] != 0:
3630  error_msg = self.devicedevice.decode_error(err_cp[0], "save_network_interface_setting")
3631  raise OceanDirectError(err_cp[0], error_msg)
3632 
3634  self.save_network_interface_settingsave_network_interface_settingsave_network_interface_setting(0)
3635 
3636  def get_ethernet_gigabit_enable_status(self, interfaceIndex: int) -> bool:
3637  """!
3638  Return the status on whether the gigabit ethernet is enabled or not.
3639 
3640  @param interfaceIndex[in] The ethernet interface to look at.
3641  @return The interface status.
3642  """
3643  err_cp = (c_long * 1)(0)
3644  status = self.devicedevice.oceandirect.odapi_adv_ethernet_get_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3645 
3646  if err_cp[0] != 0:
3647  error_msg = self.devicedevice.decode_error(err_cp[0], "get_ethernet_gigabit_enable_status")
3648  raise OceanDirectError(err_cp[0], error_msg)
3649 
3650  return bool(status)
3651 
3653  return self.get_ethernet_gigabit_enable_statusget_ethernet_gigabit_enable_statusget_ethernet_gigabit_enable_status(0)
3654 
3655  def set_ethernet_gigabit_enable_status(self, interfaceIndex: int, enable: bool) -> None:
3656  """!
3657  Enable or disable the gigabit ethernet the status.
3658 
3659  @param interfaceIndex[in] The ethernet interface to look at.
3660  @param enable True will enable gigabit ethernet.
3661  """
3662  err_cp = (c_long * 1)(0)
3663  if enable:
3664  self.devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3665  else:
3666  self.devicedevice.oceandirect.odapi_adv_ethernet_set_gigabit_enable_status(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3667 
3668  if err_cp[0] != 0:
3669  error_msg = self.devicedevice.decode_error(err_cp[0], "set_ethernet_gigabit_enable_status")
3670  raise OceanDirectError(err_cp[0], error_msg)
3671 
3672  def set_ethernet_gigabit_enable_status2(self, enable: bool) -> None:
3673  self.set_ethernet_gigabit_enable_statusset_ethernet_gigabit_enable_statusset_ethernet_gigabit_enable_status(0, enable)
3674 
3675 
3676  def get_multicast_group_enabled(self, interfaceIndex: int) -> bool:
3677  """!
3678  Return true if the multicast group message is enabled otherwise it's false.
3679 
3680  @param interfaceIndex[in] The ethernet interface to look at.
3681  @return The multicast group enable status.
3682  """
3683  err_cp = (c_long * 1)(0)
3684  status = self.devicedevice.oceandirect.odapi_adv_network_conf_get_multicast_group_enabled(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex))
3685 
3686  if err_cp[0] != 0:
3687  error_msg = self.devicedevice.decode_error(err_cp[0], "get_multicast_group_enabled")
3688  raise OceanDirectError(err_cp[0], error_msg)
3689 
3690  return bool(status)
3691 
3692  def get_multicast_group_enabled2(self) -> bool:
3693  return self.get_multicast_group_enabledget_multicast_group_enabled(0)
3694 
3695  def set_multicast_group_enabled(self, interfaceIndex: int, enable: bool) -> None:
3696  """!
3697  Enable or disable the multicast message group.
3698 
3699  @param interfaceIndex[in] The ethernet interface to look at.
3700  @param enable True will enable multicast message group.
3701  """
3702  err_cp = (c_long * 1)(0)
3703  if enable:
3704  self.devicedevice.oceandirect.odapi_adv_network_conf_set_multicast_group_enabled(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 1)
3705  else:
3706  self.devicedevice.oceandirect.odapi_adv_network_conf_set_multicast_group_enabled(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), 0)
3707 
3708  if err_cp[0] != 0:
3709  error_msg = self.devicedevice.decode_error(err_cp[0], "set_multicast_group_enabled")
3710  raise OceanDirectError(err_cp[0], error_msg)
3711 
3712  def set_multicast_group_enabled2(self, enable: bool) -> None:
3713  self.set_multicast_group_enabledset_multicast_group_enabled(0, enable)
3714 
3715 
3716  def get_ethernet_mac_address(self, interfaceIndex: int) -> list[int]:
3717  """!
3718  Read the ethernet 6-byte mac address from the spectrometer.
3719 
3720  @param interfaceIndex[in] The ethernet interface to look at.
3721  @return The mac address.
3722  """
3723  err_cp = (c_long * 1)(0)
3724  array_len = 6
3725  mac_address_cp = (c_ubyte * array_len)(0)
3726 
3727  self.devicedevice.oceandirect.odapi_adv_ethernet_get_mac_address(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), mac_address_cp, array_len)
3728 
3729  if err_cp[0] != 0:
3730  error_msg = self.devicedevice.decode_error(err_cp[0], "get_ethernet_mac_address")
3731  raise OceanDirectError(err_cp[0], error_msg)
3732 
3733  value = []
3734  for i in range(array_len):
3735  value.append(int(mac_address_cp[i]))
3736  return value
3737 
3738  def get_ethernet_mac_address2(self) -> list[int]:
3739  return self.get_ethernet_mac_addressget_ethernet_mac_address(0)
3740 
3741  def set_ethernet_mac_address(self, interfaceIndex: int, macAddress: list[int]) -> None:
3742  """!
3743  Writes a new ethernet 6-byte mac address into the spectrometer.
3744 
3745  @param interfaceIndex[in] The ethernet interface to look at.
3746  @param macAddress[in] The new mac address which is 6-byte long.
3747  """
3748 
3749  err_cp = (c_long * 1)(0)
3750  array_len = len(macAddress)
3751 
3752  if array_len != 6:
3753  error_msg = "set_ethernet_mac_address() error: macAddress must be an array of 6 bytes long."
3754  raise OceanDirectError(err_cp[0], error_msg)
3755 
3756  mac_address_cp = (c_ubyte * array_len)(0)
3757  for i in range(array_len):
3758  mac_address_cp[i] = macAddress[i]
3759 
3760  self.devicedevice.oceandirect.odapi_adv_ethernet_set_mac_address(self.devicedevice.device_id, err_cp, c_uint(interfaceIndex), mac_address_cp, array_len)
3761  if err_cp[0] != 0:
3762  error_msg = self.devicedevice.decode_error(err_cp[0], "set_ethernet_mac_address")
3763  raise OceanDirectError(err_cp[0], error_msg)
3764 
3765  def set_ethernet_mac_address2(self, macAddress: list[int]) -> None:
3766  self.set_ethernet_mac_addressset_ethernet_mac_address(0, macAddress)
3767 
3768  #OBP2 Commands
3769  def get_ip_address_assigned_mode(self) -> bool:
3770  """!
3771  Read the IP address mode from the OBP2 device.
3772  @return True if the ip address was statically assigned. False if the ip address was generated via DHCP.
3773  """
3774  err_cp = (c_long * 1)(0)
3775  status = self.devicedevice.oceandirect.odapi_adv_get_ip_address_assigned_mode(self.devicedevice.device_id, err_cp)
3776 
3777  if err_cp[0] != 0:
3778  error_msg = self.devicedevice.decode_error(err_cp[0], "get_ip_address_assigned_mode")
3779  raise OceanDirectError(err_cp[0], error_msg)
3780 
3781  return bool(c_ubyte(status))
3782 
3783  def set_ip_address_assigned_mode(self, useStaticIP: bool) -> None:
3784  """!
3785  Set the IP address mode to the OBP2 device.
3786  @param useStaticIP[in] True will use statically assigned IP address. False will use DHCP server for ip assignment.
3787  """
3788  err_cp = (c_long * 1)(0)
3789  if useStaticIP:
3790  self.devicedevice.oceandirect.odapi_adv_set_ip_address_assigned_mode(self.devicedevice.device_id, err_cp, 1)
3791  else:
3792  self.devicedevice.oceandirect.odapi_adv_set_ip_address_assigned_mode(self.devicedevice.device_id, err_cp, 0)
3793 
3794  if err_cp[0] != 0:
3795  error_msg = self.devicedevice.decode_error(err_cp[0], "set_ip_address_assigned_mode")
3796  raise OceanDirectError(err_cp[0], error_msg)
3797 
3798  def get_network_configuration(self) -> tuple[bool, list[int], list[int], list[int], list[int]]:
3799  """!
3800  Read the network configuration parameters from an OBP2 enabled device. This function
3801  will return a tuple of 6 objects in this order:
3802  address mode - True if it's using static IP address otherwise its False.
3803  list[int] - the static IP address.
3804  list[int] - the subnet mask.
3805  list[int] - the default gateway IP address.
3806  list[int] - the DNS server IP address.
3807  @return A tuple of 5 object objects.
3808  """
3809  err_cp = (c_long * 1)(0)
3810  outManualAssignment_cp = c_ubyte(0)
3811  ipv4_address_array_len = 4
3812  subnet_mask_array_len = 4
3813  default_gateway_array_len = 4
3814  dns_server_array_len = 4
3815  ipv4_address_cp = (c_ubyte * ipv4_address_array_len)(0)
3816  subnet_mask_cp = (c_ubyte * subnet_mask_array_len)(0)
3817  default_gateway_cp = (c_ubyte * default_gateway_array_len)(0)
3818  dns_server_cp = (c_ubyte * dns_server_array_len)(0)
3819 
3820  self.devicedevice.oceandirect.odapi_adv_get_network_configuration(self.devicedevice.device_id, err_cp,
3821  byref(outManualAssignment_cp),
3822  ipv4_address_cp, ipv4_address_array_len,
3823  subnet_mask_cp, subnet_mask_array_len,
3824  default_gateway_cp, default_gateway_array_len,
3825  dns_server_cp, dns_server_array_len)
3826 
3827  if err_cp[0] != 0:
3828  error_msg = self.devicedevice.decode_error(err_cp[0], "get_network_configuration")
3829  raise OceanDirectError(err_cp[0], error_msg)
3830 
3831  ipv4_address = []
3832  subnet_mask = []
3833  default_gateway = []
3834  dns_server = []
3835  for i in range(ipv4_address_array_len):
3836  ipv4_address.append(int(ipv4_address_cp[i]))
3837  subnet_mask.append(int(subnet_mask_cp[i]))
3838  default_gateway.append(int(default_gateway_cp[i]))
3839  dns_server.append(int(dns_server_cp[i]))
3840 
3841  return (bool(outManualAssignment_cp), ipv4_address, subnet_mask, default_gateway, dns_server)
3842 
3843 
3844  def set_manual_network_configuration(self, ipv4Address: list[int], subnetMask: list[int],
3845  defaultGateway: list[int], dnsServer: list[int]) -> None:
3846  """!
3847  Write the network configuration parameters (static ip address) on OBP2 enabled device.
3848 
3849  @param ipv4Address[in] The static IP address.
3850  @param subnetMask[in] The subnet mask.
3851  @param defaultGateway[in] The default gateway IP address.
3852  @param dnsServer[in] The DNS server IP address.
3853  """
3854  err_cp = (c_long * 1)(0)
3855  ipv4Address_array_len = len(ipv4Address)
3856  subnetMask_array_len = len(subnetMask)
3857  defaultGateway_array_len = len(defaultGateway)
3858  dnsServer_array_len = len(dnsServer)
3859 
3860  if ipv4Address_array_len != 4 or subnetMask_array_len != 4 or defaultGateway_array_len != 4 or dnsServer_array_len != 4:
3861  error_msg = "set_manual_network_configuration() error: an array must of 4 bytes long."
3862  raise OceanDirectError(err_cp[0], error_msg)
3863 
3864  ipv4Address_cp = (c_ubyte * ipv4Address_array_len)(0)
3865  subnetMask_cp = (c_ubyte * subnetMask_array_len)(0)
3866  defaultGateway_cp = (c_ubyte * defaultGateway_array_len)(0)
3867  dnsServer_cp = (c_ubyte * dnsServer_array_len)(0)
3868  for i in range(ipv4Address_array_len):
3869  ipv4Address_cp[i] = ipv4Address[i]
3870  subnetMask_cp[i] = subnetMask[i]
3871  defaultGateway_cp[i] = defaultGateway[i]
3872  dnsServer_cp[i] = dnsServer[i]
3873 
3874  self.devicedevice.oceandirect.odapi_adv_set_manual_network_configuration(self.devicedevice.device_id, err_cp,
3875  ipv4Address_cp, ipv4Address_array_len,
3876  subnetMask_cp, subnetMask_array_len,
3877  defaultGateway_cp, defaultGateway_array_len,
3878  dnsServer_cp, dnsServer_array_len)
3879 
3880  if err_cp[0] != 0:
3881  error_msg = self.devicedevice.decode_error(err_cp[0], "set_manual_network_configuration")
3882  raise OceanDirectError(err_cp[0], error_msg)
3883 
3884  def get_manual_network_configuration(self) -> tuple[list[int], list[int], list[int], list[int]]:
3885  """!
3886  Read the network configuration parameters (static ip address) from an OBP2 enabled device. This
3887  function will return a tuple of 4 objects in this order:
3888  list[int] - the static IP address.
3889  list[int] - the subnet mask.
3890  list[int] - the default gateway IP address.
3891  list[int] - the DNS server IP address.
3892  @return A tuple of 4 object objects.
3893  """
3894  err_cp = (c_long * 1)(0)
3895  ipv4_address_array_len = 4
3896  subnet_mask_array_len = 4
3897  default_gateway_array_len = 4
3898  dns_server_array_len = 4
3899  ipv4_address_cp = (c_ubyte * ipv4_address_array_len)(0)
3900  subnet_mask_cp = (c_ubyte * subnet_mask_array_len)(0)
3901  default_gateway_cp = (c_ubyte * default_gateway_array_len)(0)
3902  dns_server_cp = (c_ubyte * dns_server_array_len)(0)
3903 
3904  self.devicedevice.oceandirect.odapi_adv_get_manual_network_configuration(self.devicedevice.device_id, err_cp,
3905  ipv4_address_cp, ipv4_address_array_len,
3906  subnet_mask_cp, subnet_mask_array_len,
3907  default_gateway_cp, default_gateway_array_len,
3908  dns_server_cp, dns_server_array_len)
3909 
3910  if err_cp[0] != 0:
3911  error_msg = self.devicedevice.decode_error(err_cp[0], "get_manual_network_configuration")
3912  raise OceanDirectError(err_cp[0], error_msg)
3913 
3914  ipv4_address = []
3915  subnet_mask = []
3916  default_gateway = []
3917  dns_server = []
3918  for i in range(ipv4_address_array_len):
3919  ipv4_address.append(int(ipv4_address_cp[i]))
3920  subnet_mask.append(int(subnet_mask_cp[i]))
3921  default_gateway.append(int(default_gateway_cp[i]))
3922  dns_server.append(int(dns_server_cp[i]))
3923 
3924  return (ipv4_address, subnet_mask, default_gateway, dns_server)
An enumerated class for feature id.
'Spectrometer' get_device(self, int device_id)
'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.
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 close_device(self, int device_id)
Detach from the device indicated by device_id.
'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.
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.
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.
None set_user_string2(self, int index, str userString)
Write the user string to the device.
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.
None set_ip_address_assigned_mode(self, bool useStaticIP)
Set the IP address mode to the OBP2 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.
None gpio_set_value2(self, int bitmask)
Set the logic value for all GPIO pins.
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.
int get_user_string_count2(self)
Read the total user string count from the device.
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 gpio_set_value1(self, int bit, bool isHigh)
Sets the GPIO bit value to either high or low.
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.
str get_user_string2(self, int index)
Read the user string from the device.
list[int] get_optical_dark_pixel_range(self)
Read the optical dark pixel range from the sensor pixel array.
None ipv4_delete_static_ip_address(self, int ifNum, int addressIndex)
Delete a static IP address on the specified interface.
int get_data_buffer_capacity_minimum(self)
Get the minimum possible configurable size for the data buffer.
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.
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_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).
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.
int gpio_get_output_alternate2(self)
Get the settings for alternate functionality on the GPIO pins.
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.
str get_device_manufacturer_string(self)
Get the current manufacturer string of the device.
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.
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.
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_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.
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.
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.
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.
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...