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