Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for HDX spectrometer #98

Merged
merged 3 commits into from
Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions os_support/10-oceanoptics.rules
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ ATTR{idVendor}=="0547", ATTR{idProduct}=="2131", SYMLINK+="ezUSB-%n", MODE:="066
ATTR{idVendor}=="0547", ATTR{idProduct}=="2235", SYMLINK+="ezUSB-FX-%n", MODE:="0666"
# unprogrammed EzUSB-FX2
ATTR{idVendor}=="04b4", ATTR{idProduct}=="8613", SYMLINK+="ezUSB-FX2-%n", MODE:="0666"
# Ocean Insight Inc. HDX spectrometer
ATTR{idVendor}=="2457", ATTR{idProduct}=="2003", SYMLINK+="oceanhdx-%n", MODE:="0666"

LABEL="oceanoptics_rules_end"
32 changes: 32 additions & 0 deletions src/seabreeze/pyseabreeze/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ class TriggerMode(enum.IntEnum):
OBP_NORMAL = 0x00
OBP_EXTERNAL = 0x01
OBP_INTERNAL = 0x02
OBP_EDGE = 0x01
OBP_LEVEL = 0x03

@classmethod
def supported(cls, *mode_strings):
Expand Down Expand Up @@ -1035,3 +1037,33 @@ class SPARK(SeaBreezeDevice):
sbf.spectrometer.SeaBreezeSpectrometerFeatureSPARK,
sbf.rawusb.SeaBreezeRawUSBBusAccessFeature,
)

class HDX(SeaBreezeDevice):

model_name = 'HDX'

# communication config
transport = (USBTransport, )
usb_product_id = 0x2003
usb_endpoint_map = EndPointMap(ep_out=0x01, lowspeed_in=0x81,
highspeed_in=0x82, highspeed_in2=0x86)
usb_protocol = OBPProtocol

# spectrometer config
dark_pixel_indices = DarkPixelIndices.from_ranges()
integration_time_min = 6000
integration_time_max = 10000000
integration_time_base = 1
spectrum_num_pixel = 2068
spectrum_raw_length = (2068 * 2) + 64 # XXX: Metadata
spectrum_max_value = 65535
trigger_modes = TriggerMode.supported("OBP_NORMAL", "OBP_LEVEL", "OBP_EDGE", "DISABLED")

# features
feature_classes = (
sbf.spectrometer.SeaBreezeSpectrometerFeatureHDX,
sbf.rawusb.SeaBreezeRawUSBBusAccessFeature,
sbf.nonlinearity.NonlinearityCoefficientsFeatureOBP,
#sbf.continuousstrobe.SeaBreezeContinuousStrobeFeatureOBP, # Implementation untested
#sbf.straylightcoefficients.StrayLightCoefficientsFeatureOBP, # Implementation untested
)
11 changes: 11 additions & 0 deletions src/seabreeze/pyseabreeze/features/spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,3 +565,14 @@ class SeaBreezeSpectrometerFeatureVENTANA(SeaBreezeSpectrometerFeatureOBP):

class SeaBreezeSpectrometerFeatureSPARK(SeaBreezeSpectrometerFeatureOBP):
pass

class SeaBreezeSpectrometerFeatureHDX(SeaBreezeSpectrometerFeatureOBP):
def _get_spectrum_raw(self):
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
)
# the message type is different than the default defined in the protocol,
# requires addition of a new message type in protocol to work
datastring = self.protocol.query(0x00101000, timeout_ms=timeout)
return numpy.fromstring(datastring, dtype=numpy.uint8)
1 change: 1 addition & 0 deletions src/seabreeze/pyseabreeze/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class OBPProtocol(ProtocolInterface):
for code, msg in {
0x00000100: "", # GET_SERIAL
0x00100928: "", # GET_BUF_SPEC32_META
0x00101000: "", # GET_RAW_SPECTRUM_NOW_HDX
0x00101100: "", # GET_RAW_SPECTRUM_NOW
0x00110010: "<L", # SET_ITIME_USEC
0x00110110: "<B", # SET_TRIG_MODE
Expand Down