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