point::Diss5 Class Reference

The class responsible for communication with the DISS-5. More...

List of all members.

Public Types

enum  error_code_t {
  UNKNOWN = -1, USB_NOT_FOUND, USB_CONFIGURATION, USB_INTERFACE,
  USB_READ, USB_WRITE, DISS5_DATA_OVERFLOW, DISS5_SCAN_PARAMS_NOT_FOUND
}
 Possible errors that this driver will throw. More...

Public Member Functions

 Diss5 ()
 constructor
 ~Diss5 ()
 destructor
void Send (ScanParams &aParams)
 Sends a set of scan parameters to the DISS-5.
void Send (RoiScan &aParams)
 Sends a set of ROI scan parameters to the DISS-5.
void Send (const AdjustParams &aParams)
 Sends a set of adjustment parameters to the DISS-5.
void Reset ()
 Sends the reset command to the DISS-5 on the USB bus.
bool Read (uint16_t *aPoint, double aTimeout=0)
 Read the intensity value back for a single point.
bool ReadBlk (Image *aImage, double aTimeout=0)
bool ReadBlk (RoiImage *aRoiImage, double aTimeout=0)
bool Read (Image *aImage, double aTimeout=0)
bool Read (RoiImage *aRoiImage, double aTimeout=0)
bool Read (Footer *aFooter, double aTimeout=0)
void ClearFifo ()
 clears out any extra data which may be still in the read buffer
void SendStop (bool aKeepExtern=false)
 sends a set of ScanParams to stop the current scan
void Debug (uint aLevel)
bool ReadTimeout (uint aBytes)
 checks to see if we read 0 bytes more than READ_TIMEOUT times

Private Member Functions

void UsbWrite (const char *aMsg, uint aSize)
int UsbRead (Footer *aFooter, uint16_t *aData, uint aSize)
void CheckMessageQueue (const Footer &aFooter)
 looks through the messages and finds the one we received
std::string GetConfigPath () const
void LoadDefaultXml ()
 Load the XML config file and parse it.

Private Attributes

USB::Device * mUsbDevice
 The USB device handle.
USB::Configuration * mUsbConfig
 The USB configuration we will use. The DISS-5 currently only supports configuration 1.
USB::Interface * mUsbInterface
 The interface that will use. It should have 2 EndPoints (pipes). We have to release it when we are finished.
USB::Endpoint * mReadEndpoint
 The read interface is pipe 0.
USB::Endpoint * mWriteEndpoint
 The write interface is pipe 1.
std::queue< ScanParamsmParamQueue
 A queue of ScanParams so we can match up with what we read.
std::queue< RoiScanmRoiScanQueue
 A queue of ScanParams so we can match up with what we read.
char * mReadBuf
 The image buffer to be used on Read().
char * mExtraBuf
uint mExtraSize
point::Footer mExtraFooter
 We also need the footer if we have extra data.
uint mScanId
 the current scan identifier
uint mRoiId
 the current Roi identifier
uint mZeroReadCount
 a counter for how many times we read 0 bytes
bool mNewScan
 flag stating if a scan is new (and thus we don't worry about timeouts)


Detailed Description

The class responsible for communication with the DISS-5.

Member Enumeration Documentation

enum point::Diss5::error_code_t

Possible errors that this driver will throw.

Enumerator:
UNKNOWN  This should not occur.
USB_NOT_FOUND  We could not locate the device on the USB bus.
USB_CONFIGURATION  We could not set the configuration.
USB_INTERFACE  We could not claim the DISS-5 USB interface.
USB_READ  There was a USB read error.
USB_WRITE  There was a USB write error.
DISS5_DATA_OVERFLOW  We have received too much data for the image.
DISS5_SCAN_PARAMS_NOT_FOUND  could not find the correct scan params


Constructor & Destructor Documentation

point::Diss5::Diss5 (  ) 

constructor

The constructor instantiates the USB driver and searches the bus for a DISS-5.


Member Function Documentation

bool point::Diss5::ReadBlk ( Image aImage,
double  aTimeout = 0 
)

Retrieve a complete image. This function blocks until we've read an entire image.

Parameters:
aImage where we will store the new image.
aTimeout the maximum time will will block on Read in [s]. A value of 0 means infinite wait.
Returns:
returns false if unsuccessful

bool point::Diss5::ReadBlk ( RoiImage aRoiImage,
double  aTimeout = 0 
)

Retrieve a complete image. This function blocks until we've read an entire image.

Parameters:
aRoiImage where we will store the new image.
aTimeout the maximum time will will block on Read in [s]. A value of 0 means infinite wait.
Returns:
returns false if unsuccessful

bool point::Diss5::Read ( Image aImage,
double  aTimeout = 0 
)

Retrieve an image from the Diss5. If the entire image is not available, just return what we have so far.

Parameters:
aImage where we will store the new image.
aTimeout the maximum time will will block on Read in [s]. A value of 0 means infinite wait.
Returns:
returns false if unsuccessful

bool point::Diss5::Read ( RoiImage aRoiImage,
double  aTimeout = 0 
)

Retrieve an image from the Diss5. If the entire image is not available, just return what we have so far.

Parameters:
aRoiImage where we will store the new image.
aTimeout the maximum time will will block on Read in [s]. A value of 0 means infinite wait.
Returns:
returns false if unsuccessful

bool point::Diss5::Read ( Footer aFooter,
double  aTimeout = 0 
)

Retrieve a Footer

Parameters:
aFooter where we will store the footer data.
aTimeout the maximum time will will block on Read in [s]. A value of 0 means infinite wait.
Returns:
returns false if unsuccessful

void point::Diss5::Debug ( uint  aLevel  )  [inline]

General messages. Use level to indicate the message importance

void point::Diss5::UsbWrite ( const char *  aMsg,
uint  aSize 
) [private]

Write a character stream directly to the USB port we have open.

Parameters:
aMsg the raw byte array we will send out
aSize the number of bytes we will send out

int point::Diss5::UsbRead ( Footer aFooter,
uint16_t *  aData,
uint  aSize 
) [private]

Read a footer and a message directly from the USB port.

Parameters:
aFooter The footer we would like to store the data in. This variable must already be allocated.
aData A data pointer for raw storage. Must be already allocated and ACQ_BUF_SIZE*sizeof(uint8_t) bytes large.
aSize The size available in aData for the image [bytes]
Returns:
The number of uint16_t image pixels read

std::string point::Diss5::GetConfigPath (  )  const [private]

Returns the path to the diss5.xml file. This path can be set by changing the DISS5_PATH environment variable. Otherwise, it will default to the share folder of the install location of libdiss5 (ie /usr/local/share/libdiss5).

void point::Diss5::LoadDefaultXml (  )  [private]

Load the XML config file and parse it.

The XML has the following format. There are currently no default values implemented, so please be sure to include all the values. The XML file can be located either at a location specified by LIBDISS5_PATH as an environment variable or by default a location configured with the package (ie /usr/local/share/libdiss5). After parsing the XML, this command sends an AdjustParams message to the Diss5 specifying the imaging parameters.

<?xml version="1.0" standalone="no" ?>
<!-- diss5 config file -->
<diss5>
  <adjust_params>
    <bias>
      <channel id="1" val="575" />
      <channel id="2" val="555" />
      <channel id="3" val="555" />
      <channel id="4" val="555" />
      <channel id="12" val="85" />
      <channel id="34" val="85" />
    </bias>
    <offset x="485" y="485" />
    <gain x="800" y="800" />
  </adjust_params>
</diss5>


Member Data Documentation

char* point::Diss5::mExtraBuf [private]

If there is extra data from a Read(), this is the pointer to the remainder inside mReadBuf

uint point::Diss5::mExtraSize [private]

If there is extra data from a Read(), this is the number of bytes of extra data we have inside mReadBuf


Generated on Fri Mar 20 12:42:21 2009 for libdiss5 by  doxygen 1.5.3