Wasatch.PY
Python application driver for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
wasatch.InterfaceDevice.InterfaceDevice Class Reference
Inheritance diagram for wasatch.InterfaceDevice.InterfaceDevice:
wasatch.AndorDevice.AndorDevice wasatch.BLEDevice.BLEDevice wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice wasatch.IDSDevice.IDSDevice wasatch.OceanDevice.OceanDevice wasatch.SPIDevice.SPIDevice wasatch.TCPDevice.TCPDevice wasatch.WasatchDevice.WasatchDevice

Public Member Functions

 __init__ (self, device_id, message_queue=None, alert_queue=None)
 
 change_setting (self, setting, value=None)
 Request Handlers.
 
 check_alert (self, name)
 
 handle_cmd (self, cmd, arg=None, force=False)
 
 handle_request (self, request)
 
 handle_requests (self, requests)
 
 queue_message (self, setting, value)
 Outgoing Sideline Messages.
 

Public Attributes

 alert_queue = alert_queue
 
 device_id = device_id
 
 message_queue = message_queue
 
dict process_f = {}
 
int remaining_throwaways = 0
 

Protected Member Functions

 _refresh_alerts (self)
 Incoming Sideline Messages.
 

Protected Attributes

 _alerts = set()
 
dict _supported_message_queue_types
 

Detailed Description

An InterfaceDevice is the top-level interface to communicating with any 
spectrometer supported by Wasatch.PY.

# Sub-Classes

These are the currently supported sub-classes at writing:

- WasatchDevice: all Wasatch-manufactured USB spectrometers using VID 0x24aa
  and PID 0x1000 (FX2 with Hamamatsu CCD), 0x2000 (FX2 with Hamamamsu InGaAs)
  or 0x4000 (ARM, typically IMX CMOS).

    - FeatureInterfaceDevice (FID): a lower-level "hardware access layer" 
      (HAL) implementing the ENG-0001 USB protocol, used exclusively by 
      WasatchDevice. FID also inherits from InterfaceDevice for convenience. 
      Developers may choose to instantiate and communicate with FID directly,
      bypassing WasatchDevice, but will miss out on some automated higher-
      level functions (and sadly twisted logic) involving AutoRaman, scan 
      averaging, BatchCollections etc. 

- BLEDevice: a Wasatch XS spectrometer communicating over Bluetooth®,
  implementing the ENG-0120 Wasatch BLE GATT profile.

- AndorDevice: a Wasatch XL spectrometer using an Andor camera via Oxford 
  Instruments' SDK.

- IDSDevice: a prototype spectrometer using an IDS camera via their IDSPeak
  SDK.

- TCPDevice: a Wasatch Ethernet-capable spectrometer implementing the
  ENG-0196 WISP protocol.

- SPIDevice: a Wasatch SPI-based spectrometer implementing the ENG-0150
  SPI spectrometer protocol.

- OceanDevice: an experimental wrapper to communicate with Ocean Optics
  spectrometers using their SeaBreeze library.

# Request Handling

InterfaceDevices primarily communicate by receiving SpectrometerRequests
and returning SpectrometerResponses. 

A SpectrometerRequest is basically a command name coupled with a few 
positional or keyword arguments (in other words, a deconstructed Python 
function call).

A SpectrometerResponse contains a .data object which could include a
requested spectrum or spectrometer setting, as well as a few fields
to indicate error conditions.

Constructor & Destructor Documentation

◆ __init__()

wasatch.InterfaceDevice.InterfaceDevice.__init__ ( self,
device_id,
message_queue = None,
alert_queue = None )
Any class that communicates to a spectrometer should inherit this class.
It provides the common functions that avoid repeated code.

@param device_id     either DeviceID or string equiv ("USB:0x24aa:0x1000:1:24")
@param message_queue if provided, used to send status back to caller
@param alert_queue   if provided, used to receive hints and realtime 
                     interrupts from caller, including cancellation of 
                     long-running tasks like AutoRaman

@todo move scan averaging, TakeOneRequest logic upstream from 
      WasatchDevice, AndorDevice etc to here (simplify children of this 
      class while while increasing code-reuse and consistency across all
      InterfaceDevice variants)

Member Function Documentation

◆ _refresh_alerts()

wasatch.InterfaceDevice.InterfaceDevice._refresh_alerts ( self)
protected

Incoming Sideline Messages.

Retreive any fresh alerts from the caller (automatically called by
check_alert).

◆ change_setting()

wasatch.InterfaceDevice.InterfaceDevice.change_setting ( self,
setting,
value = None )

Request Handlers.

Convenience shortcut for old function name. Also, allows WasatchDevice
to mimic WasatchDeviceWrapper interface.

◆ check_alert()

wasatch.InterfaceDevice.InterfaceDevice.check_alert ( self,
name )
Check whether a specific alert has been raised.

◆ handle_cmd()

wasatch.InterfaceDevice.InterfaceDevice.handle_cmd ( self,
cmd,
arg = None,
force = False )
handle_cmd("get_laser_temperature_deg_c") 
    is a shortcut to 
handle_request(SpectrometerRequest("get_laser_temperature_deg_c"))

handle_cmd("select_adc", 1) 
    is a shortcut to
handle_request(SpectrometerRequest("select_adc", args=[1]))

handle_cmd("take_one_request", None, force=True) 
    is a shortcut to
handle_request(SpectrometerRequest("select_adc", args=[None]))

◆ handle_request()

wasatch.InterfaceDevice.InterfaceDevice.handle_request ( self,
request )
handle_request(SpectrometerRequest("get_laser_temperature_deg_c")) 
    is a shortcut to
handle_requests([SpectrometerRequest("get_laser_temperature_deg_c")])[0]

◆ handle_requests()

wasatch.InterfaceDevice.InterfaceDevice.handle_requests ( self,
requests )

◆ queue_message()

wasatch.InterfaceDevice.InterfaceDevice.queue_message ( self,
setting,
value )

Outgoing Sideline Messages.

If an upstream queue is defined, send the name-value pair.  Does nothing
if the caller hasn't provided a queue.

@see enlighten.controller.process_status_message

Reimplemented in wasatch.BLEDevice.BLEDevice.

Member Data Documentation

◆ _alerts

wasatch.InterfaceDevice.InterfaceDevice._alerts = set()
protected

◆ _supported_message_queue_types

dict wasatch.InterfaceDevice.InterfaceDevice._supported_message_queue_types
protected
Initial value:
= {
"progress_bar",
"firmware_log",
"marquee_info",
"marquee_error",
"scan_averaging",
"laser_firing_indicators",
"received_ble_firmware_version"
}

◆ alert_queue

wasatch.InterfaceDevice.InterfaceDevice.alert_queue = alert_queue

◆ device_id

wasatch.InterfaceDevice.InterfaceDevice.device_id = device_id

◆ message_queue

wasatch.InterfaceDevice.InterfaceDevice.message_queue = message_queue

◆ process_f

dict wasatch.InterfaceDevice.InterfaceDevice.process_f = {}

◆ remaining_throwaways

int wasatch.InterfaceDevice.InterfaceDevice.remaining_throwaways = 0

The documentation for this class was generated from the following file: