Wasatch.VCPP 1.0.19
Visual C++ driver for Wasatch Photonics spectrometers
Public Types | Public Member Functions | Public Attributes | List of all members
WasatchVCPP::Spectrometer Class Reference

Internal class encapsulating state and control of one spectrometer. More...

#include <Spectrometer.h>

Public Types

enum  ErrorCodes {
  Success = 0 , Error = -1 , InvalidSpectrometer = -2 , InsufficientStorage = -3 ,
  NoLaser = -4 , NotInGaAs = -5 , InvalidGain = -256 , InvalidTemperature = -999 ,
  InvalidOffset = -32768
}
 keep synchronized with WasatchVCPP.h WP_ERROR_* More...
 

Public Member Functions

 Spectrometer (WPVCPP_UDEV_TYPE *udev, int pid, int index, Logger &logger)
 
bool close ()
 
bool isARM ()
 
bool isInGaAs ()
 
bool isMicro ()
 
bool setIntegrationTimeMS (unsigned long ms)
 
bool setLaserEnable (bool flag)
 
bool setDetectorGain (float value)
 
bool setDetectorGainOdd (float value)
 
bool setDetectorOffset (int16_t value)
 
bool setDetectorOffsetOdd (int16_t value)
 
bool setDetectorTECEnable (bool flag)
 
bool setDetectorTECSetpointDegC (int value)
 
bool setHighGainModeEnable (bool flag)
 
bool setLaserPowerPerc (float percent)
 
std::string getFirmwareVersion ()
 
std::string getFPGAVersion ()
 
int32_t getDetectorTemperatureRaw ()
 
float getDetectorTemperatureDegC ()
 
unsigned long getIntegrationTimeMS ()
 
bool getLaserEnable ()
 
float getDetectorGain ()
 
float getDetectorGainOdd ()
 
int getDetectorOffset ()
 
int getDetectorOffsetOdd ()
 
bool getDetectorTECEnable ()
 
int getDetectorTECSetpointDegC ()
 
bool getHighGainModeEnable ()
 
int sendCmd (uint8_t bRequest, uint16_t wValue=0, uint16_t wIndex=0, uint8_t *data=NULL, int len=0)
 Write data to the spectrometer. More...
 
bool setModEnable (bool flag)
 
bool setModPeriodus (int us)
 
bool setModWidthus (int us)
 
int getModEnabled (void)
 
uint64_t getModPeriodus (void)
 
bool setLaserPowermW (float mW_in)
 
std::vector< uint8_t > getCmd (uint8_t bRequest, int len, uint16_t wIndex=0, int fullLen=0)
 This is the standard "getter opcode" function. More...
 
std::vector< double > getSpectrum ()
 
bool cancelOperation (bool blocking)
 Attempt to cancel an ongoing integration. More...
 

Public Attributes

EEPROM eeprom
 
Driverdriver = nullptr
 
int pid = 0
 
int index = -1
 
std::vector< double > wavelengths
 
std::vector< double > wavenumbers
 
int maxTimeoutMS = 1000
 Other Wasatch drivers don't really have this concept...basically, all blocking reads to bulk endpoints (spectral reads) wait no longer than this, and loop over multiple reads if necessary, to fulfill the given integration time (plus unknown trigger wait). More...
 
int pixels = 0
 
std::string firmwareVersion
 
std::string fpgaVersion
 
int integrationTimeMS = 1
 
bool laserEnabled = false
 
bool laserPowerHighResolution = true
 
bool laserPowerRequireModulation = false
 
bool modEnabled = false
 
float laserPowerMw = 0.0
 
float modWidthus = 0.0
 
float modPeriodus = 0.0
 
float laserPowerPerc = 0.0
 
float lastAppliedLaserPower = 0.0
 
float nextAppliedLaserPower = 0.0
 
int detectorTECSetointDegC = ErrorCodes::InvalidTemperature
 
bool srm_in_EEPROM = false
 

Detailed Description

Internal class encapsulating state and control of one spectrometer.

All "Hungarian notation" parameter names (bRequest, wValue etc) are taken from public USB specifications to avoid confusion.

See also
https://www.beyondlogic.org/usbnutshell/usb6.shtml

Member Enumeration Documentation

◆ ErrorCodes

keep synchronized with WasatchVCPP.h WP_ERROR_*

Todo:
move to ErrorCodes.h so Driver.cpp can use

Member Function Documentation

◆ cancelOperation()

bool WasatchVCPP::Spectrometer::cancelOperation ( bool  blocking)

Attempt to cancel an ongoing integration.

Warning
this function will not work correctly without custom firmware

◆ getCmd()

vector< uint8_t > WasatchVCPP::Spectrometer::getCmd ( uint8_t  bRequest,
int  len,
uint16_t  wIndex = 0,
int  fullLen = 0 
)

This is the standard "getter opcode" function.

It doesn't take a "wValue" parameter because getters usually don't have one. (The main exception to that rule is so-called "2nd-tier" gettors, for which getCmd2 is provided.)

Parameters
request(Input) the opcode
len(Input) how many bytes the caller actually NEEDS back
fullLen(Input) how many bytes we think the spectrometer will actually send, with padding
Returns
vector of just the 'len' needed bytes

◆ getDetectorGain()

float WasatchVCPP::Spectrometer::getDetectorGain ( )
Returns
ErrorCodes::InvalidGain on error

◆ getDetectorGainOdd()

float WasatchVCPP::Spectrometer::getDetectorGainOdd ( )
Returns
ErrorCodes::InvalidGain on error

◆ getDetectorTemperatureRaw()

int32_t WasatchVCPP::Spectrometer::getDetectorTemperatureRaw ( )
Returns
negative on error, else valid uint16_t

◆ isInGaAs()

bool WasatchVCPP::Spectrometer::isInGaAs ( )
Todo:
support ARM-based InGaAs

◆ sendCmd()

int WasatchVCPP::Spectrometer::sendCmd ( uint8_t  bRequest,
uint16_t  wValue = 0,
uint16_t  wIndex = 0,
uint8_t *  data = NULL,
int  len = 0 
)

Write data to the spectrometer.

Parameters
bRequest(Input) the opcode being sent
wValue(Input) in general, the primary argument being sent; can also represent the "actual opcode" when bRequest is 0xff, indicating a so- called "second-tier command"
wIndex(Input) in general, a secondary argument being sent; in the case of "longer" primary arguments (larger than 16 bits), may represent an extra 8 or 16 bits of the primary argument; or in the case of "second-tier commands", may represent the "effective primary argument" (as the "effective opcode" is being sent as wValue)
data(Input) additional payload being sent along with the opcode and parameters; in the case of opcodes taking truly long arguments (larger than 32 bits, such as the uint40 values used for laser modulation), can provide additional bits of precision atop wValue and wIndex
len(Input) number of bytes provided in data
Returns
number of bytes written (not really indicative of success/failure).
Note
I think this actually indicates the number of DATA bytes transferred, and is not actually intended to include the "control packet" itself; therefore, bytes written will be ZERO for most successful setters, and negative for comms failures.

Member Data Documentation

◆ maxTimeoutMS

int WasatchVCPP::Spectrometer::maxTimeoutMS = 1000

Other Wasatch drivers don't really have this concept...basically, all blocking reads to bulk endpoints (spectral reads) wait no longer than this, and loop over multiple reads if necessary, to fulfill the given integration time (plus unknown trigger wait).

Keeping this value small and controllable is key to being able to interrupt and cancel long integrations (5-10min) within a reasonable response time.

Todo:
we probably need to remove this variable altogether when we implement "interruptable acquisitions" in the FPGA.

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