first commnit
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
/***************************************************//**
|
||||
* @file ByteVector.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_BYTEVECTOR_H
|
||||
#define SEABREEZE_BYTEVECTOR_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/Data.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ByteVector : public Data {
|
||||
public:
|
||||
ByteVector();
|
||||
/* Constructor that makes a copy of the given vector for internal use */
|
||||
ByteVector(const std::vector<byte> &that);
|
||||
virtual ~ByteVector();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
|
||||
/* Get the data associated with this instance */
|
||||
std::vector<byte> &getByteVector();
|
||||
|
||||
private:
|
||||
std::vector<byte> *data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
62
othersoft/shuttercali/source/OSIF/include/common/Data.h
Normal file
62
othersoft/shuttercali/source/OSIF/include/common/Data.h
Normal file
@ -0,0 +1,62 @@
|
||||
/***************************************************//**
|
||||
* @file Data.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a sort of a wrapper class that can encapsulate
|
||||
* different kinds of data that may be returned as the
|
||||
* result of a protocol transfer. The idea is that the
|
||||
* data being passed back up from the device probably needs
|
||||
* to be in some specific form, but we need to be able
|
||||
* to convert it to whatever the receiver can use.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_DATA_H
|
||||
#define SEABREEZE_DATA_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/UnitDescriptor.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Data {
|
||||
public:
|
||||
Data();
|
||||
virtual ~Data();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,62 @@
|
||||
/***************************************************//**
|
||||
* @file DoubleVector.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_DOUBLEVECTOR_H
|
||||
#define SEABREEZE_DOUBLEVECTOR_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class DoubleVector : public Data {
|
||||
public:
|
||||
DoubleVector();
|
||||
DoubleVector(const std::vector<double> &that);
|
||||
virtual ~DoubleVector();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
|
||||
/* Get the data associated with this instance */
|
||||
std::vector<double> &getDoubleVector();
|
||||
|
||||
private:
|
||||
std::vector<double> *data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,62 @@
|
||||
/***************************************************//**
|
||||
* @file FloatVector.h
|
||||
* @date March 2010
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_FLOATVECTOR_H
|
||||
#define SEABREEZE_FLOATVECTOR_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class FloatVector : public Data {
|
||||
public:
|
||||
FloatVector();
|
||||
FloatVector(const std::vector<float> &that);
|
||||
virtual ~FloatVector();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
|
||||
/* Get the data associated with this instance */
|
||||
std::vector<float> &getFloatVector();
|
||||
|
||||
private:
|
||||
std::vector<float> *data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
132
othersoft/shuttercali/source/OSIF/include/common/Log.h
Normal file
132
othersoft/shuttercali/source/OSIF/include/common/Log.h
Normal file
@ -0,0 +1,132 @@
|
||||
/**
|
||||
@file Log.h
|
||||
@brief Interface to Log
|
||||
@author Mark Zieg <mark.zieg@oceanoptics.com>
|
||||
|
||||
LICENSE:
|
||||
|
||||
SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject
|
||||
to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SEABREEZE_LOG_H
|
||||
#define SEABREEZE_LOG_H
|
||||
|
||||
#include "api/DllDecl.h"
|
||||
|
||||
#include <string>
|
||||
#include <stack>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef OOI_DEBUG
|
||||
#define OOI_LOG_PRINT 1
|
||||
#else
|
||||
#define OOI_LOG_PRINT 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/**
|
||||
* @brief instantiate logger in the current function
|
||||
* @param s (Input) function name (typically __FUNCTION__)
|
||||
*/
|
||||
#define LOG(s) Log logger(s);
|
||||
|
||||
/**
|
||||
* @brief log a printf string (and optional arguments) if debugging is enabled
|
||||
* @note double parens: call as LOG_DEBUG(("variable x is %d, y is %f", x, y));
|
||||
* @see http://stackoverflow.com/questions/1644868/c-define-macro-for-debug-printing
|
||||
*/
|
||||
#define LOG_DEBUG(s) do { if (OOI_LOG_PRINT) logger.debug s; } while (0)
|
||||
|
||||
//! @see LOG_DEBUG
|
||||
#define LOG_INFO(s) do { if (OOI_LOG_PRINT) logger.info s; } while (0)
|
||||
|
||||
//! @see LOG_DEBUG
|
||||
#define LOG_WARN(s) do { if (OOI_LOG_PRINT) logger.warn s; } while (0)
|
||||
|
||||
//! @see LOG_DEBUG
|
||||
#define LOG_ERROR(s) do { if (OOI_LOG_PRINT) logger.error s; } while (0)
|
||||
|
||||
#define OOI_LOG_LEVEL_NEVER 0
|
||||
#define OOI_LOG_LEVEL_ERROR 1
|
||||
#define OOI_LOG_LEVEL_WARN 2
|
||||
#define OOI_LOG_LEVEL_INFO 3
|
||||
#define OOI_LOG_LEVEL_DEBUG 4
|
||||
#define OOI_LOG_LEVEL_TRACE 5
|
||||
|
||||
/**
|
||||
* @brief Simple logger for OOI applications.
|
||||
* @todo Provide better thread support (hard to tell what thread model
|
||||
* the caller may be using...)
|
||||
* @todo Provide flat C interface (e.g. for NativeUSBWinUSB.c, test apps)
|
||||
*
|
||||
* Provides automatic heirarchical call-stack indentation.
|
||||
*/
|
||||
class DLL_DECL Log
|
||||
{
|
||||
public:
|
||||
Log(const char *s);
|
||||
~Log();
|
||||
|
||||
// public class methods
|
||||
static void setLogLevel(int lvl);
|
||||
static void setLogLevel(const std::string& s);
|
||||
static void setLogFile(void *f);
|
||||
|
||||
// public instance methods
|
||||
void debug(const char *fmt, ...);
|
||||
void info (const char *fmt, ...);
|
||||
void warn (const char *fmt, ...);
|
||||
void error(const char *fmt, ...);
|
||||
|
||||
// these must be public for C interface to work
|
||||
static unsigned logLevel;
|
||||
void formatAndSend(int lvl, const char *lvlName,
|
||||
const char *separator, const char *fmt, va_list args);
|
||||
|
||||
private:
|
||||
// private class attributes
|
||||
static FILE *logFile;
|
||||
static std::stack<std::string>* callstack;
|
||||
|
||||
// private instance methods
|
||||
void trace(const char *fmt, ...);
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
// We need the flattened C interface if we want to call from Cygwin (mainly
|
||||
// to set log level)...see http://cygwin.com/ml/cygwin/2006-04/msg00251.html
|
||||
void DLL_DECL seabreeze_log_set_level_int(int lvl);
|
||||
void DLL_DECL seabreeze_log_set_level_string(const char *s);
|
||||
void DLL_DECL seabreeze_log_debug(const char *fmt, ...);
|
||||
void DLL_DECL seabreeze_log_info (const char *fmt, ...);
|
||||
void DLL_DECL seabreeze_log_warn (const char *fmt, ...);
|
||||
void DLL_DECL seabreeze_log_error(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
45
othersoft/shuttercali/source/OSIF/include/common/SeaBreeze.h
Normal file
45
othersoft/shuttercali/source/OSIF/include/common/SeaBreeze.h
Normal file
@ -0,0 +1,45 @@
|
||||
/***************************************************//**
|
||||
* @file SeaBreeze.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides some project-wide constants and definitions.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_H
|
||||
#define SEABREEZE_H
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
#ifdef WINDOWS
|
||||
/* Visual studio does not implement declared exception
|
||||
* specification but accepts it with a warning. This
|
||||
* suppresses the warning (4290).
|
||||
*/
|
||||
#pragma warning( disable : 4290 )
|
||||
#endif /* WINDOWS */
|
||||
|
||||
#endif /* SEABREEZE_H */
|
77
othersoft/shuttercali/source/OSIF/include/common/U32Vector.h
Normal file
77
othersoft/shuttercali/source/OSIF/include/common/U32Vector.h
Normal file
@ -0,0 +1,77 @@
|
||||
/***************************************************//**
|
||||
* @file U32Vector.h
|
||||
* @date September 2013
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_U32VECTOR_H
|
||||
#define SEABREEZE_U32VECTOR_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
/* This class requires a 32-bit integer type. This will need a little help
|
||||
* to know what the target machine is, so this tries to work it out.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
/* Visual Studio */
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#else
|
||||
/* C99 compatible */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class U32Vector : public Data {
|
||||
public:
|
||||
U32Vector();
|
||||
/* Constructor that makes a copy of the given vector for internal use */
|
||||
U32Vector(const std::vector<uint32_t> &that);
|
||||
U32Vector(unsigned int length);
|
||||
virtual ~U32Vector();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
|
||||
/* Get the data associated with this instance */
|
||||
std::vector<uint32_t> &getU32Vector();
|
||||
|
||||
private:
|
||||
std::vector<uint32_t> *data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
/***************************************************//**
|
||||
* @file UShortVector.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_USHORTVECTOR_H
|
||||
#define SEABREEZE_USHORTVECTOR_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class UShortVector : public Data {
|
||||
public:
|
||||
UShortVector();
|
||||
/* Constructor that makes a copy of the given vector for internal use */
|
||||
UShortVector(const std::vector<unsigned short> &that);
|
||||
UShortVector(unsigned int length);
|
||||
virtual ~UShortVector();
|
||||
/* Dimensionality of data. 0 for scalar, 1 for vector,
|
||||
* 2 for a pair of related vectors (e.g. [X, Y] or matrix),
|
||||
* 3 for 3D, etc.
|
||||
*/
|
||||
virtual int getNumberOfDimensions();
|
||||
|
||||
/* Get all of the unit descriptors associated with this Data. */
|
||||
virtual std::vector<UnitDescriptor *> *getUnits();
|
||||
|
||||
/* Get the data associated with this instance */
|
||||
std::vector<unsigned short> &getUShortVector();
|
||||
|
||||
private:
|
||||
std::vector<unsigned short> *data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,46 @@
|
||||
/***************************************************//**
|
||||
* @file UnitDescriptor.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_UNITDESCRIPTOR_H
|
||||
#define SEABREEZE_UNITDESCRIPTOR_H
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class UnitDescriptor {
|
||||
public:
|
||||
UnitDescriptor();
|
||||
~UnitDescriptor();
|
||||
|
||||
/* FIXME: need to define unit property getters */
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
66
othersoft/shuttercali/source/OSIF/include/common/buses/Bus.h
Normal file
66
othersoft/shuttercali/source/OSIF/include/common/buses/Bus.h
Normal file
@ -0,0 +1,66 @@
|
||||
/***************************************************//**
|
||||
* @file Bus.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a base class for all sorts of buses. A bus
|
||||
* is a mechanism for transferring a stream of data from one
|
||||
* point to another. The bus does not concern itself with the
|
||||
* contents of the data stream. At most, it may use hints to
|
||||
* determine how a particular message will be moved if this
|
||||
* is necessary to complete the operation.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_BUS_H
|
||||
#define SEABREEZE_BUS_H
|
||||
|
||||
#include "common/protocols/ProtocolHint.h"
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "common/buses/BusFamily.h"
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
#include "common/exceptions/IllegalArgumentException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Bus {
|
||||
public:
|
||||
Bus();
|
||||
virtual ~Bus();
|
||||
virtual TransferHelper *getHelper(const std::vector<ProtocolHint *> &hints) const = 0;
|
||||
virtual BusFamily getBusFamily() const = 0;
|
||||
/* Associate this Bus instance with a particular device location.
|
||||
* This MUST be done before open or close can be used.
|
||||
*/
|
||||
virtual void setLocation(const DeviceLocatorInterface &location)
|
||||
throw (IllegalArgumentException) = 0;
|
||||
virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual DeviceLocatorInterface *getLocation() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,86 @@
|
||||
/***************************************************//**
|
||||
* @file BusFamilies.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a way to get references to different kinds of buses
|
||||
* (e.g. USB, Ethernet, serial) generically.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef BUSFAMILIES_H
|
||||
#define BUSFAMILIES_H
|
||||
|
||||
#include "common/buses/BusFamily.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class USBBusFamily : public BusFamily {
|
||||
public:
|
||||
USBBusFamily();
|
||||
virtual ~USBBusFamily();
|
||||
};
|
||||
|
||||
class EthernetBusFamily : public BusFamily {
|
||||
public:
|
||||
EthernetBusFamily();
|
||||
virtual ~EthernetBusFamily();
|
||||
};
|
||||
|
||||
class RS232BusFamily : public BusFamily {
|
||||
public:
|
||||
RS232BusFamily();
|
||||
virtual ~RS232BusFamily();
|
||||
};
|
||||
|
||||
class TCPIPv4BusFamily : public BusFamily {
|
||||
public:
|
||||
TCPIPv4BusFamily();
|
||||
virtual ~TCPIPv4BusFamily();
|
||||
};
|
||||
|
||||
class UDPIPv4BusFamily : public BusFamily {
|
||||
public:
|
||||
UDPIPv4BusFamily();
|
||||
virtual ~UDPIPv4BusFamily();
|
||||
};
|
||||
|
||||
class BusFamilies {
|
||||
public:
|
||||
const USBBusFamily USB;
|
||||
const EthernetBusFamily ETHERNET;
|
||||
const RS232BusFamily RS232;
|
||||
const TCPIPv4BusFamily TCPIPv4;
|
||||
const UDPIPv4BusFamily UDPIPv4;
|
||||
|
||||
BusFamilies();
|
||||
~BusFamilies();
|
||||
std::vector<BusFamily *> getAllBusFamilies();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* BUSFAMILIES_H */
|
@ -0,0 +1,54 @@
|
||||
/***************************************************//**
|
||||
* @file BusFamily.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a way to describe different kinds of buses
|
||||
* (e.g. USB, Ethernet, serial) generically.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
#ifndef BUSFAMILY_H
|
||||
#define BUSFAMILY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class BusFamily {
|
||||
public:
|
||||
virtual ~BusFamily();
|
||||
virtual std::string getName() const;
|
||||
virtual bool equals(const BusFamily &that);
|
||||
|
||||
protected:
|
||||
BusFamily(std::string name, int id);
|
||||
|
||||
private:
|
||||
std::string busName;
|
||||
int type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* BUSFAMILY_H */
|
@ -0,0 +1,58 @@
|
||||
/***************************************************//**
|
||||
* @file DeviceLocationProberInterface.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* DeviceLocatorInterface provides a base interface for
|
||||
* classes that allow the location of a device to be
|
||||
* probed in a bus-specific way.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef DEVICELOCATIONPROBERINTERFACE_H
|
||||
#define DEVICELOCATIONPROBERINTERFACE_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class DeviceLocationProberInterface {
|
||||
public:
|
||||
virtual ~DeviceLocationProberInterface() = 0;
|
||||
|
||||
/* Report how many devices of this type are available */
|
||||
virtual std::vector<DeviceLocatorInterface *> *probeDevices() = 0;
|
||||
|
||||
protected:
|
||||
DeviceLocationProberInterface();
|
||||
};
|
||||
|
||||
/* Default implementation for (otherwise) pure virtual destructor */
|
||||
inline DeviceLocationProberInterface::~DeviceLocationProberInterface() {}
|
||||
|
||||
}
|
||||
|
||||
#endif /* DEVICELOCATIONPROBERINTERFACE_H */
|
@ -0,0 +1,82 @@
|
||||
/***************************************************//**
|
||||
* @file DeviceLocatorInterface.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* DeviceLocatorInterface provides a base interface for
|
||||
* classes that allow the location of a device to be
|
||||
* specified in a bus-specific way. For instance, a
|
||||
* USB DeviceLocator might include a device path or
|
||||
* index, and a socket DeviceLocator might include an
|
||||
* IP address and port number. This allows
|
||||
* devices that cannot be identified by probing to still
|
||||
* be found easily.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef DEVICELOCATORINTERFACE_H
|
||||
#define DEVICELOCATORINTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include "common/buses/BusFamily.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class DeviceLocatorInterface {
|
||||
public:
|
||||
virtual ~DeviceLocatorInterface() = 0;
|
||||
|
||||
/**
|
||||
* Get a unique identifier for this location. This can be any value
|
||||
* as long as it is globally unique.
|
||||
*/
|
||||
virtual unsigned long getUniqueLocation() const = 0;
|
||||
|
||||
/**
|
||||
* Determine whether this DeviceLocator refers to the same device
|
||||
* as another.
|
||||
*/
|
||||
virtual bool equals(DeviceLocatorInterface &that) = 0;
|
||||
|
||||
/**
|
||||
* Get a human-readable string that describes the location
|
||||
*/
|
||||
virtual std::string getDescription() = 0;
|
||||
|
||||
/**
|
||||
* Get a description of the type of bus that the device is associated with
|
||||
*/
|
||||
virtual BusFamily getBusFamily() const = 0;
|
||||
|
||||
/* Get an exact copy of this instance */
|
||||
virtual DeviceLocatorInterface *clone() const = 0;
|
||||
};
|
||||
|
||||
/* Default implementation for (otherwise) pure virtual destructor */
|
||||
inline DeviceLocatorInterface::~DeviceLocatorInterface() {}
|
||||
|
||||
}
|
||||
|
||||
#endif /* DEVICELOCATORINTERFACE_H */
|
@ -0,0 +1,58 @@
|
||||
/***************************************************//**
|
||||
* @file TransferHelper.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is effectively an interface for wrappers around bus
|
||||
* activity. These wrappers may be selected from a Bus
|
||||
* based on certain hints provided by a Protocol or its
|
||||
* various Exchanges. All that this specifies is that a
|
||||
* given object must be able to send() and receive() data
|
||||
* across its particular (encapsulated) Bus.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_TRANSFERHELPER_H
|
||||
#define SEABREEZE_TRANSFERHELPER_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/exceptions/BusTransferException.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class TransferHelper {
|
||||
public:
|
||||
TransferHelper();
|
||||
virtual ~TransferHelper();
|
||||
virtual int receive(std::vector<byte> &buffer, unsigned int length)
|
||||
throw (BusTransferException) = 0;
|
||||
virtual int send(const std::vector<byte> &buffer, unsigned int length) const
|
||||
throw (BusTransferException) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,75 @@
|
||||
/***************************************************//**
|
||||
* @file IPv4NetworkProtocol.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_IPV4NETWORKPROTOCOL_H
|
||||
#define SEABREEZE_IPV4NETWORKPROTOCOL_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
class IPv4NetworkProtocol {
|
||||
public:
|
||||
virtual ~IPv4NetworkProtocol();
|
||||
virtual std::string getName() const;
|
||||
virtual bool equals(const IPv4NetworkProtocol &that) const;
|
||||
|
||||
protected:
|
||||
IPv4NetworkProtocol(std::string name, int id);
|
||||
|
||||
private:
|
||||
std::string protocolName;
|
||||
int type;
|
||||
};
|
||||
|
||||
class TCP_IPv4 : public IPv4NetworkProtocol {
|
||||
public:
|
||||
TCP_IPv4();
|
||||
virtual ~TCP_IPv4();
|
||||
};
|
||||
|
||||
class UDP_IPv4 : public IPv4NetworkProtocol {
|
||||
public:
|
||||
UDP_IPv4();
|
||||
virtual ~UDP_IPv4();
|
||||
};
|
||||
|
||||
class IPv4NetworkProtocols {
|
||||
public:
|
||||
const TCP_IPv4 TCP_IP4;
|
||||
const UDP_IPv4 UDP_IP4;
|
||||
|
||||
IPv4NetworkProtocols();
|
||||
~IPv4NetworkProtocols();
|
||||
std::vector<IPv4NetworkProtocol *> getAllIPv4NetworkProtocols();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_IPV4NETWORKPROTOCOL_H */
|
||||
|
@ -0,0 +1,66 @@
|
||||
/***************************************************//**
|
||||
* @file IPv4SocketDeviceLocator.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_IPV4SOCKETDEVICELOCATOR_H
|
||||
#define SEABREEZE_IPV4SOCKETDEVICELOCATOR_H
|
||||
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
#include "common/buses/network/IPv4NetworkProtocol.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class IPv4SocketDeviceLocator : public DeviceLocatorInterface {
|
||||
public:
|
||||
IPv4SocketDeviceLocator(const IPv4NetworkProtocol &proto, std::string ip,
|
||||
int portNumber);
|
||||
virtual ~IPv4SocketDeviceLocator();
|
||||
|
||||
std::string getIPv4Address();
|
||||
int getPort();
|
||||
IPv4NetworkProtocol getIPv4NetworkProtocol();
|
||||
|
||||
/* Inherited from DeviceLocatorInterface */
|
||||
virtual unsigned long getUniqueLocation() const;
|
||||
virtual bool equals(DeviceLocatorInterface &that);
|
||||
virtual std::string getDescription();
|
||||
virtual BusFamily getBusFamily() const;
|
||||
virtual DeviceLocatorInterface *clone() const;
|
||||
|
||||
protected:
|
||||
unsigned long computeLocationHash();
|
||||
|
||||
IPv4NetworkProtocol protocol;
|
||||
std::string ipAddr;
|
||||
int port;
|
||||
unsigned long locationHash;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_IPV4SOCKETDEVICELOCATOR_H */
|
||||
|
@ -0,0 +1,75 @@
|
||||
/***************************************************//**
|
||||
* @file TCPIPv4SocketBus.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_TCPIPV4SOCKETBUS_H
|
||||
#define SEABREEZE_TCPIPV4SOCKETBUS_H
|
||||
|
||||
#include "common/buses/Bus.h"
|
||||
#include "common/exceptions/IllegalArgumentException.h"
|
||||
#include "native/network/Socket.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
class TCPIPv4SocketBus : public Bus {
|
||||
public:
|
||||
TCPIPv4SocketBus();
|
||||
virtual ~TCPIPv4SocketBus();
|
||||
|
||||
virtual Socket *getSocketDescriptor();
|
||||
|
||||
virtual BusFamily getBusFamily() const;
|
||||
|
||||
virtual void setLocation(const DeviceLocatorInterface &location)
|
||||
throw (IllegalArgumentException);
|
||||
virtual DeviceLocatorInterface *getLocation();
|
||||
virtual TransferHelper *getHelper(
|
||||
const std::vector<ProtocolHint *> &hints) const;
|
||||
|
||||
/* Pure virtual methods */
|
||||
virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
|
||||
protected:
|
||||
void addHelper(ProtocolHint *hint, TransferHelper *helper);
|
||||
void clearHelpers();
|
||||
|
||||
Socket *socket;
|
||||
DeviceLocatorInterface *deviceLocator;
|
||||
|
||||
/* These vectors should really be in a map, but that didn't want to
|
||||
* work easily. Since there will likely be about 2 entries in here,
|
||||
* storing in a pair of vectors for now won't hurt anything.
|
||||
*/
|
||||
std::vector<ProtocolHint *> helperKeys;
|
||||
std::vector<TransferHelper *> helperValues;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_TCPIPV4SOCKETBUS_H */
|
@ -0,0 +1,52 @@
|
||||
/***************************************************//**
|
||||
* @file TCPIPv4SocketTransferHelper.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_TCPIPV4SOCKETTRANSFERHELPER_H
|
||||
#define SEABREEZE_TCPIPV4SOCKETTRANSFERHELPER_H
|
||||
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "native/network/Socket.h"
|
||||
|
||||
namespace seabreeze {
|
||||
class TCPIPv4SocketTransferHelper : public TransferHelper {
|
||||
public:
|
||||
TCPIPv4SocketTransferHelper(Socket *sock);
|
||||
virtual ~TCPIPv4SocketTransferHelper();
|
||||
|
||||
virtual int receive(std::vector<byte> &buffer, unsigned int length)
|
||||
throw (BusTransferException);
|
||||
virtual int send(const std::vector<byte> &buffer, unsigned int length) const
|
||||
throw (BusTransferException);
|
||||
|
||||
protected:
|
||||
Socket *socket;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_TCPIPV4SOCKETTRANSFERHELPER_H */
|
@ -0,0 +1,65 @@
|
||||
/***************************************************//**
|
||||
* @file RS232DeviceLocator.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This class encapsulates the information needed to open
|
||||
* a device on an RS232 bus.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef RS232DEVICELOCATOR_H
|
||||
#define RS232DEVICELOCATOR_H
|
||||
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class RS232DeviceLocator : public DeviceLocatorInterface {
|
||||
public:
|
||||
RS232DeviceLocator(std::string devicePath, int baudRate);
|
||||
virtual ~RS232DeviceLocator();
|
||||
|
||||
std::string &getDevicePath();
|
||||
int getBaudRate();
|
||||
|
||||
/* Inherited from DeviceLocatorInterface */
|
||||
virtual unsigned long getUniqueLocation() const;
|
||||
virtual bool equals(DeviceLocatorInterface &that);
|
||||
virtual std::string getDescription();
|
||||
virtual BusFamily getBusFamily() const;
|
||||
virtual DeviceLocatorInterface *clone() const;
|
||||
|
||||
private:
|
||||
void computeLocationHash();
|
||||
std::string devicePath;
|
||||
int baudRate;
|
||||
unsigned long locationHash;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* RS232DEVICELOCATOR_H */
|
@ -0,0 +1,63 @@
|
||||
/***************************************************//**
|
||||
* @file RS232Interface.h
|
||||
* @date April 2011
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef RS232INTERFACE_H
|
||||
#define RS232INTERFACE_H
|
||||
|
||||
#include "common/buses/Bus.h"
|
||||
#include "native/rs232/NativeRS232.h"
|
||||
#include "native/rs232/RS232.h"
|
||||
#include "common/exceptions/IllegalArgumentException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class RS232Interface : public Bus {
|
||||
public:
|
||||
RS232Interface();
|
||||
virtual ~RS232Interface();
|
||||
virtual RS232 *getRS232Descriptor();
|
||||
virtual DeviceLocatorInterface *getLocation();
|
||||
virtual void setLocation(const DeviceLocatorInterface &location)
|
||||
throw (IllegalArgumentException);
|
||||
virtual BusFamily getBusFamily() const;
|
||||
|
||||
/* Pure virtual methods */
|
||||
virtual TransferHelper *getHelper(
|
||||
const std::vector<ProtocolHint *> &hints) const = 0;
|
||||
virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
protected:
|
||||
RS232 *rs232;
|
||||
DeviceLocatorInterface *deviceLocator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* RS232INTERFACE_H */
|
@ -0,0 +1,65 @@
|
||||
/***************************************************//**
|
||||
* @file RS232TransferHelper.h
|
||||
* @date April 2011
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides an abstraction around the RS232 bus.
|
||||
* RS232 is pretty simple once the port is opened and
|
||||
* configured, so this mostly just takes care of ensuring
|
||||
* that all bytes are sent and received as required.
|
||||
*
|
||||
* This will effectively block on reads and writes until
|
||||
* they are complete. A non-blocking transfer helper
|
||||
* could be created to complement this if there was
|
||||
* some need, but it is not clear who would be responsible
|
||||
* for delayed reads or retransmits.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef RS232TRANSFERHELPER_H
|
||||
#define RS232TRANSFERHELPER_H
|
||||
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "native/rs232/RS232.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class RS232TransferHelper : public TransferHelper {
|
||||
public:
|
||||
RS232TransferHelper(RS232 *rs232Descriptor);
|
||||
virtual ~RS232TransferHelper();
|
||||
|
||||
virtual int receive(std::vector<byte> &buffer, unsigned int length)
|
||||
throw (BusTransferException);
|
||||
virtual int send(const std::vector<byte> &buffer, unsigned int length) const
|
||||
throw (BusTransferException);
|
||||
|
||||
protected:
|
||||
RS232 *rs232;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* USBTRANSFERHELPER_H */
|
@ -0,0 +1,59 @@
|
||||
/***************************************************//**
|
||||
* @file USBDeviceLocator.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This class encapsulates the information needed to open
|
||||
* a device on a USB bus.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef USBDEVICELOCATOR_H
|
||||
#define USBDEVICELOCATOR_H
|
||||
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class USBDeviceLocator : public DeviceLocatorInterface {
|
||||
public:
|
||||
USBDeviceLocator(unsigned long ID);
|
||||
virtual ~USBDeviceLocator();
|
||||
|
||||
/* Inherited from DeviceLocatorInterface */
|
||||
virtual unsigned long getUniqueLocation() const;
|
||||
virtual bool equals(DeviceLocatorInterface &that);
|
||||
virtual std::string getDescription();
|
||||
virtual BusFamily getBusFamily() const;
|
||||
virtual DeviceLocatorInterface *clone() const;
|
||||
|
||||
private:
|
||||
unsigned long deviceID;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* USBDEVICELOCATOR_H */
|
@ -0,0 +1,64 @@
|
||||
/***************************************************//**
|
||||
* @file USBInterface.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is an abstract base class intended to be an interface
|
||||
* for USB control objects. This allows USB devices to
|
||||
* be opened generically (just by providing the index of
|
||||
* the device on the bus) without any concern for
|
||||
* the vendor ID, product ID, or underlying USB implementation.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef USBINTERFACE_H
|
||||
#define USBINTERFACE_H
|
||||
|
||||
#include "common/buses/Bus.h"
|
||||
#include "native/usb/NativeUSB.h"
|
||||
#include "native/usb/USB.h"
|
||||
#include "common/exceptions/IllegalArgumentException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class USBInterface : public Bus {
|
||||
public:
|
||||
USBInterface();
|
||||
virtual ~USBInterface();
|
||||
virtual USB *getUSBDescriptor() const;
|
||||
virtual DeviceLocatorInterface *getLocation();
|
||||
virtual void setLocation(const DeviceLocatorInterface &location) throw (IllegalArgumentException);
|
||||
virtual BusFamily getBusFamily() const;
|
||||
virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
protected:
|
||||
USB *usb;
|
||||
DeviceLocatorInterface *deviceLocator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* USBINTERFACE_H */
|
@ -0,0 +1,66 @@
|
||||
/***************************************************//**
|
||||
* @file USBTransferHelper.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a TransferHelper intended for USB communications.
|
||||
* Each USBTransferHelper must specify a sending and
|
||||
* receiving endpoint, which will tend to vary according to
|
||||
* the type of data transfer being conducted. This adapts
|
||||
* the send() and receive() methods required of a TransferHelper
|
||||
* according to a particular type of transfer, which may be
|
||||
* inferred from a ProtocolHint.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef USBTRANSFERHELPER_H
|
||||
#define USBTRANSFERHELPER_H
|
||||
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "native/usb/USB.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class USBTransferHelper : public TransferHelper {
|
||||
public:
|
||||
USBTransferHelper(USB *usbDescriptor, int sendEndpoint,
|
||||
int receiveEndpoint);
|
||||
USBTransferHelper(USB *usbDescriptor);
|
||||
virtual ~USBTransferHelper();
|
||||
|
||||
virtual int receive(std::vector<byte> &buffer, unsigned int length)
|
||||
throw (BusTransferException);
|
||||
virtual int send(const std::vector<byte> &buffer, unsigned int length) const
|
||||
throw (BusTransferException);
|
||||
|
||||
protected:
|
||||
USB *usb;
|
||||
int sendEndpoint;
|
||||
int receiveEndpoint;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* USBTRANSFERHELPER_H */
|
@ -0,0 +1,129 @@
|
||||
/***************************************************//**
|
||||
* @file Device.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a base class for all sorts of devices. A
|
||||
* device is really just an aggregation of features
|
||||
* with the protocols and buses required to access them.
|
||||
* A Device is intended to represent a single discrete
|
||||
* piece of equipment that may have several capabilities
|
||||
* (features) inside. The device may communicate to the
|
||||
* outside world via seqences of bytes (a protocol) that
|
||||
* are transferred across a physical medium (the bus).
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "common/buses/Bus.h"
|
||||
#include "common/buses/BusFamily.h"
|
||||
#include "common/buses/DeviceLocatorInterface.h"
|
||||
#include "common/features/Feature.h"
|
||||
#include "common/features/FeatureFamily.h"
|
||||
#include "common/protocols/Protocol.h"
|
||||
|
||||
|
||||
// usb endpoints are associated with a particular device.
|
||||
typedef enum usbEndpointType
|
||||
{
|
||||
kEndpointTypePrimaryOut, // slow speed
|
||||
kEndpointTypePrimaryIn, // slow speed
|
||||
kEndpointTypeSecondaryOut, // could be high speed
|
||||
kEndpointTypeSecondaryIn, // could be high speed
|
||||
kEndpointTypeSecondaryIn2 // generally high speed
|
||||
} usbEndpointType;
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Device {
|
||||
public:
|
||||
Device();
|
||||
virtual ~Device();
|
||||
std::vector<Bus *> &getBuses();
|
||||
std::vector<Feature *> &getFeatures();
|
||||
std::vector<Protocol *> &getProtocols();
|
||||
std::string &getName();
|
||||
|
||||
// get the usb endpoints, according to the endpointType enumerator,
|
||||
// if the endpoint type is not used, a 0 is returned
|
||||
// TODO: this should be delegated down into a Bus instance
|
||||
// (e.g. found by getBusesByFamily()) for USB. It is inappropriate here.
|
||||
unsigned char getEndpoint(int *errorCode, usbEndpointType endpointType);
|
||||
|
||||
/* This will allow the driver to probe the device and initialize itself
|
||||
* based on what it finds there. This should be called shortly after
|
||||
* open(). The Device instance should use the indicated Bus instance to
|
||||
* communicate with the hardware and get everything set up. It can
|
||||
* use any appropriate protocol or protocols that are valid for the Bus.
|
||||
*/
|
||||
virtual bool initialize(const Bus &bus);
|
||||
|
||||
/* Each instance of a device is assumed to be associated with a unique
|
||||
* location on a bus. If the device is connected via multiple buses, then
|
||||
* a special DeviceLocator and TransferHelper will have to hide those
|
||||
* details. Otherwise, each connection to the device will be considered
|
||||
* independent of all others.
|
||||
*/
|
||||
virtual DeviceLocatorInterface *getLocation();
|
||||
virtual void setLocation(const DeviceLocatorInterface &loc);
|
||||
|
||||
virtual int open();
|
||||
|
||||
virtual void close();
|
||||
|
||||
virtual std::vector<Bus *> getBusesByFamily(BusFamily &family);
|
||||
|
||||
virtual seabreeze::ProtocolFamily getSupportedProtocol(
|
||||
seabreeze::FeatureFamily family, BusFamily bus) = 0;
|
||||
|
||||
virtual std::vector<Protocol *> getProtocolsByFamily(
|
||||
seabreeze::ProtocolFamily &family);
|
||||
|
||||
virtual Bus *getOpenedBus();
|
||||
|
||||
protected:
|
||||
std::vector<Bus *> buses;
|
||||
std::vector<Feature *> features;
|
||||
std::vector<Protocol *> protocols;
|
||||
|
||||
std::string name;
|
||||
unsigned char usbEndpoint_primary_out;
|
||||
unsigned char usbEndpoint_primary_in;
|
||||
unsigned char usbEndpoint_secondary_out;
|
||||
unsigned char usbEndpoint_secondary_in;
|
||||
unsigned char usbEndpoint_secondary_in2;
|
||||
|
||||
|
||||
DeviceLocatorInterface *location;
|
||||
Bus *openedBus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DEVICE_H */
|
@ -0,0 +1,49 @@
|
||||
/***************************************************//**
|
||||
* @file BusConnectException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when an error is
|
||||
* encountered when trying to connect to a bus,
|
||||
* generally a failed open() or socket connect() call, or
|
||||
* a failed read() or write() due to an EOF.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef BUSCONNECTEXCEPTION_H
|
||||
#define BUSCONNECTEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/BusException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class BusConnectException : public BusException {
|
||||
public:
|
||||
BusConnectException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* BUSCONNECTEXCEPTION_H */
|
@ -0,0 +1,50 @@
|
||||
/***************************************************//**
|
||||
* @file BusException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a base class for a family of exceptions that
|
||||
* arise from errors in bus transfers. These may be thrown
|
||||
* at the bus layer, and all exceptions thrown at
|
||||
* that layer must extend this class so that they can be
|
||||
* uniformly handled.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_BUSEXCEPTION_H
|
||||
#define SEABREEZE_BUSEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class BusException : public std::runtime_error {
|
||||
public:
|
||||
BusException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,48 @@
|
||||
/***************************************************//**
|
||||
* @file BusTransferException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when an error is
|
||||
* encountered when trying to read from or write to
|
||||
* a bus.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef BUSTRANSFEREXCEPTION_H
|
||||
#define BUSTRANSFEREXCEPTION_H
|
||||
|
||||
#include "common/exceptions/BusException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class BusTransferException : public BusException {
|
||||
public:
|
||||
BusTransferException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* BUSTRANSFEREXCEPTION_H */
|
@ -0,0 +1,47 @@
|
||||
/***************************************************//**
|
||||
* @file FeatureControlException.h
|
||||
* @date March 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when an error is
|
||||
* encountered when trying to interact with a feature.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef FEATURECONTROLEXCEPTION_H
|
||||
#define FEATURECONTROLEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/FeatureException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class FeatureControlException : public FeatureException {
|
||||
public:
|
||||
FeatureControlException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* FEATURECONTROLEXCEPTION_H */
|
@ -0,0 +1,50 @@
|
||||
/***************************************************//**
|
||||
* @file FeatureException.h
|
||||
* @date March 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a base class for a family of exceptions that
|
||||
* arise from errors in feature interaction. These may be thrown
|
||||
* at the feature layer, and all exceptions thrown at
|
||||
* that layer must extend this class so that they can be
|
||||
* uniformly handled.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_FEATUREEXCEPTION_H
|
||||
#define SEABREEZE_FEATUREEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class FeatureException : public std::runtime_error {
|
||||
public:
|
||||
FeatureException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,48 @@
|
||||
/***************************************************//**
|
||||
* @file FeatureProtocolNotFoundException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when a protocol is
|
||||
* specified, but no matching implementation of that
|
||||
* protocol can be found for a particular feature.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef FEATUREPROTOCOLNOTFOUNDEXCEPTION_H
|
||||
#define FEATUREPROTOCOLNOTFOUNDEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/FeatureException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class FeatureProtocolNotFoundException : public FeatureException {
|
||||
public:
|
||||
FeatureProtocolNotFoundException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* FEATUREPROTOCOLNOTFOUNDEXCEPTION_H */
|
@ -0,0 +1,50 @@
|
||||
/***************************************************//**
|
||||
* @file IllegalArgumentException.h
|
||||
* @date March 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is an exception for use when a value is passed to
|
||||
* a method that is not permitted. This may include
|
||||
* specifying a parameter that is out of bounds or of
|
||||
* the wrong type.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_ILLEGALARGUMENTEXCEPTION_H
|
||||
#define SEABREEZE_ILLEGALARGUMENTEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class IllegalArgumentException : public std::invalid_argument {
|
||||
public:
|
||||
IllegalArgumentException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
/***************************************************//**
|
||||
* @file NumberFormatException.h
|
||||
* @date March 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is an exception for use when a string is to be
|
||||
* parsed into a number but the string does not contain
|
||||
* a recognizable number.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_NUMBERFORMATEXCEPTION_H
|
||||
#define SEABREEZE_NUMBERFORMATEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class NumberFormatException : public std::runtime_error {
|
||||
public:
|
||||
NumberFormatException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolBusMismatchException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when a protocol is
|
||||
* specified, but the bus and protocol are not suited to
|
||||
* each other (e.g. there is no bus helper for the hints
|
||||
* the protocol can provide).
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef PROTOCOLBUSMISMATCHEXCEPTION_H
|
||||
#define PROTOCOLBUSMISMATCHEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/ProtocolException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolBusMismatchException : public ProtocolException {
|
||||
public:
|
||||
ProtocolBusMismatchException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* PROTOCOLBUSMISMATCHEXCEPTION_H */
|
@ -0,0 +1,51 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a base class for a family of exceptions that
|
||||
* arise from errors in protocols. These may be thrown
|
||||
* at the protocol layer, and all exceptions thrown at
|
||||
* that layer must extend this class so that they can be
|
||||
* uniformly handled.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOLEXCEPTION_H
|
||||
#define SEABREEZE_PROTOCOLEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolException : public std::runtime_error {
|
||||
public:
|
||||
ProtocolException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,50 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolFormatException.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This exception should be used when a protocol message
|
||||
* cannot be decoded, fails a checksum, or otherwise is
|
||||
* out of spec. This may indicate that the driver is now
|
||||
* out of synch with this code and that measures should be
|
||||
* taken to re-establish communications.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef PROTOCOLFORMATEXCEPTION_H
|
||||
#define PROTOCOLFORMATEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/ProtocolException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolFormatException : public ProtocolException {
|
||||
public:
|
||||
ProtocolFormatException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* PROTOCOLFORMATEXCEPTION_H */
|
@ -0,0 +1,51 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolTransactionException.h
|
||||
* @date January 2015
|
||||
* @author Ocean Optics, Inc., Kirk Clendinning, Heliospectra
|
||||
*
|
||||
* This is a base class for a family of exceptions that
|
||||
* arise from errors in during OBPTransactions. These may be thrown
|
||||
* at the protocol layer, and all exceptions thrown at
|
||||
* that layer must extend this class so that they can be
|
||||
* uniformly handled.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOLTRANSACTIONEXCEPTION_H
|
||||
#define SEABREEZE_PROTOCOLTRANSACTIONEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolTransactionException : public std::runtime_error {
|
||||
public:
|
||||
ProtocolTransactionException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,71 @@
|
||||
/***************************************************//**
|
||||
* @file Feature.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is an abstract interface that other feature types will
|
||||
* implement. A Feature is taken to be some capability of
|
||||
* a Device that is relatively self-contained. For instance,
|
||||
* an analog output voltage would be a Feature. Features can
|
||||
* also contain multiple functions; for instance, a TEC may
|
||||
* be able to report a temperature, take a temperature as a
|
||||
* set point, and turn on or off. These capabilities are
|
||||
* interrelated, and would be considered a single feature.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef FEATURE_H
|
||||
#define FEATURE_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/buses/Bus.h"
|
||||
#include "common/features/FeatureFamily.h"
|
||||
#include "common/exceptions/FeatureException.h"
|
||||
#include "common/protocols/Protocol.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Feature {
|
||||
public:
|
||||
virtual ~Feature() = 0;
|
||||
|
||||
/* Allow the object that represents a given feature to initialize
|
||||
* itself by reading from the corresponding feature on the real
|
||||
* device, and/or put the real device feature into a known state.
|
||||
* This should return true if the feature is ready to be used, and false
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool initialize(const Protocol &protocol, const Bus &bus)
|
||||
throw (FeatureException) = 0;
|
||||
|
||||
virtual FeatureFamily getFeatureFamily() = 0;
|
||||
};
|
||||
|
||||
/* Default implementation for (otherwise) pure virtual destructor */
|
||||
inline Feature::~Feature() {}
|
||||
}
|
||||
|
||||
#endif /* FEATURE_H */
|
@ -0,0 +1,56 @@
|
||||
/***************************************************//**
|
||||
* @file FeatureFamily.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a way to describe different kinds
|
||||
* features (e.g. spectrometer, TEC) generically.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_FEATUREFAMILY_H
|
||||
#define SEABREEZE_FEATUREFAMILY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class FeatureFamily {
|
||||
public:
|
||||
FeatureFamily();
|
||||
virtual ~FeatureFamily();
|
||||
virtual std::string getName();
|
||||
virtual bool equals(const FeatureFamily &that);
|
||||
virtual unsigned short getType();
|
||||
|
||||
protected:
|
||||
FeatureFamily(std::string name, unsigned short id);
|
||||
|
||||
private:
|
||||
std::string featureName;
|
||||
unsigned short type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,88 @@
|
||||
/***************************************************//**
|
||||
* @file FeatureImpl.h
|
||||
* @date March 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a simple base class that other feature types will
|
||||
* extend. A Feature is taken to be some capability of
|
||||
* a Device that is relatively self-contained. For instance,
|
||||
* an analog output voltage would be a Feature. Features can
|
||||
* also contain multiple functions; for instance, a TEC may
|
||||
* be able to report a temperature, take a temperature as a
|
||||
* set point, and turn on or off. These capabilities are
|
||||
* interrelated, and would be considered a single feature.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef FEATUREIMPL_H
|
||||
#define FEATUREIMPL_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/exceptions/FeatureProtocolNotFoundException.h"
|
||||
#include "common/features/Feature.h"
|
||||
#include "common/protocols/ProtocolHelper.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
/* This does virtual inheritance from Feature because it is assumed that
|
||||
* in some cases there will be diamond inheritance. This will generally
|
||||
* only happen where one top-level Feature is implemented by deriving from
|
||||
* another Feature.
|
||||
*/
|
||||
class FeatureImpl : public virtual Feature {
|
||||
public:
|
||||
FeatureImpl();
|
||||
virtual ~FeatureImpl();
|
||||
|
||||
/* Allow the object that represents a given feature to initialize
|
||||
* itself by reading from the corresponding feature on the real
|
||||
* device, and/or put the real device feature into a known state.
|
||||
* Overriding this is not required. This should return true if
|
||||
* the feature is ready to be used, and false otherwise.
|
||||
*/
|
||||
virtual bool initialize(const Protocol &protocol, const Bus &bus)
|
||||
throw (FeatureException);
|
||||
|
||||
virtual FeatureFamily getFeatureFamily() = 0;
|
||||
|
||||
protected:
|
||||
std::vector<ProtocolHelper *> protocols;
|
||||
|
||||
/* Protocols are described by their base class (Protocol)
|
||||
* and may be designated that way. However, different
|
||||
* functionality within a given command set may be broken
|
||||
* into different implementation types, all of which extend
|
||||
* the base Protocol class. This is a simple lookup mechanism
|
||||
* to use the Protocol that some anonymous caller might
|
||||
* provide as a point of reference to then find the extended
|
||||
* Protocol class that can be used to access certain features.
|
||||
*/
|
||||
ProtocolHelper *lookupProtocolImpl(const Protocol &protocol)
|
||||
throw (FeatureProtocolNotFoundException);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* FEATUREIMPL_H */
|
65
othersoft/shuttercali/source/OSIF/include/common/globals.h
Normal file
65
othersoft/shuttercali/source/OSIF/include/common/globals.h
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @file globals.h
|
||||
* @author Mark Zieg <mark.zieg@oceanoptics.com>
|
||||
* @date Sep 26, 2012
|
||||
* @brief Provides a single point of maintenance for anything you want
|
||||
* included, defined, or set across every file in the application
|
||||
* (such as memory profiling, etc). Normally empty.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SEABREEZE_GLOBALS_H
|
||||
#define SEABREEZE_GLOBALS_H
|
||||
|
||||
// change to "#if 1" to enable memory heap debugging under Visual Studio
|
||||
#if 0
|
||||
#ifdef _WINDOWS
|
||||
|
||||
// For these to work right, you need to #define _CRTDBG_MAP_ALLOC and
|
||||
// _CRTDBG_MAP_ALLOC_NEW in your Visual Studio project (i.e., Project
|
||||
// -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor
|
||||
// Definitions). #Defining them here in your header files DOES NOT
|
||||
// WORK, because Visual Studio will internally include many system
|
||||
// headers (including stdafx.h) long before you get here.
|
||||
//
|
||||
// @see http://msdn.microsoft.com/en-us/library/e5ewb1h3%28v=vs.80%29.aspx
|
||||
// @see http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/ebc7dd7a-f3c6-49f1-8a60-e381052f21b6,
|
||||
|
||||
#pragma message(" (Windows memory debugging enabled)")
|
||||
|
||||
// these will provide leak profiling for C malloc(), etc
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
// these will provide leak profiling for C++ 'new'
|
||||
#ifndef DBG_NEW
|
||||
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
|
||||
#define new DBG_NEW
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,59 @@
|
||||
/***************************************************//**
|
||||
* @file Exchange.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is simply an interface that other classes will
|
||||
* extend to have a common transfer() and getHints methods
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_EXCHANGE_H
|
||||
#define SEABREEZE_EXCHANGE_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "common/protocols/ProtocolHint.h"
|
||||
#include "common/Data.h"
|
||||
#include "common/exceptions/ProtocolException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Exchange {
|
||||
public:
|
||||
Exchange();
|
||||
Exchange(std::vector<ProtocolHint *> *hints);
|
||||
virtual ~Exchange();
|
||||
virtual Data *transfer(TransferHelper *helper) throw (ProtocolException) = 0;
|
||||
virtual const std::vector<ProtocolHint *> &getHints();
|
||||
|
||||
protected:
|
||||
std::vector<ProtocolHint *> *hints;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_EXCHANGE_H */
|
||||
|
@ -0,0 +1,62 @@
|
||||
/***************************************************//**
|
||||
* @file Protocol.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This is a simple identifier cookie that will allow two
|
||||
* objects to agree on whether they support a given command
|
||||
* set (protocol). Each will hold Protocol objects that they
|
||||
* can then compare to see if they agree. This allows a loose
|
||||
* binding between sets of Exchanges (elsewhere called protocols)
|
||||
* and buses.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOL_H
|
||||
#define SEABREEZE_PROTOCOL_H
|
||||
|
||||
#include "common/protocols/ProtocolFamily.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Protocol {
|
||||
public:
|
||||
Protocol(int id);
|
||||
/* Copy constructor */
|
||||
Protocol(Protocol const &that);
|
||||
virtual ~Protocol();
|
||||
bool equals(Protocol const &that);
|
||||
|
||||
virtual ProtocolFamily getProtocolFamily() = 0;
|
||||
|
||||
protected:
|
||||
/* Protected for derived classes to use. */
|
||||
Protocol();
|
||||
int id;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,55 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolFamily.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a way to describe different kinds
|
||||
* protocols (e.g. OOI, OBP) generically.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOLFAMILY_H
|
||||
#define SEABREEZE_PROTOCOLFAMILY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class ProtocolFamily {
|
||||
public:
|
||||
virtual ~ProtocolFamily();
|
||||
virtual std::string getName();
|
||||
virtual bool equals(const ProtocolFamily &that);
|
||||
virtual unsigned short getType();
|
||||
|
||||
protected:
|
||||
ProtocolFamily(std::string name, unsigned short id);
|
||||
|
||||
private:
|
||||
std::string protocolName;
|
||||
unsigned short type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,60 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolHelper.h
|
||||
* @date July 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* Feature instances may look up an implementation object
|
||||
* that matches a particular Protocol. All such implementations
|
||||
* should in some way derive from ProtocolHelper so that
|
||||
* Feature's look up mechanism can return them. It is
|
||||
* expected that each Feature will have a corresponding
|
||||
* interface at the Protocol layer; those interface classes
|
||||
* should derive from this class, and their implementations
|
||||
* will thus extend this as well.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOLHELPER_H
|
||||
#define SEABREEZE_PROTOCOLHELPER_H
|
||||
|
||||
#include "common/protocols/Protocol.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolHelper {
|
||||
public:
|
||||
ProtocolHelper(Protocol *proto);
|
||||
virtual ~ProtocolHelper();
|
||||
Protocol &getProtocol();
|
||||
|
||||
protected:
|
||||
/* Protected for derived classes to use. */
|
||||
ProtocolHelper();
|
||||
Protocol *protocol;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,73 @@
|
||||
/***************************************************//**
|
||||
* @file ProtocolHint.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* Hints are used to identify particular characteristics about
|
||||
* protocol Transfer objects. A hint may be used to indicate
|
||||
* to a bus some detail it needs about making a transfer, e.g.
|
||||
* what endpoint would be appropriate for USB. Note that the
|
||||
* bus (or its helpers) are under no obligation to respect hints.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_PROTOCOLHINT_H
|
||||
#define SEABREEZE_PROTOCOLHINT_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class ProtocolHint {
|
||||
public:
|
||||
ProtocolHint(int id, std::string desc);
|
||||
|
||||
/* For derived classes that will fill in their own values
|
||||
* and for containers to be able to initialize themselves.
|
||||
* This does not set any meaningful values and should not be
|
||||
* relied on to create a proper instance.
|
||||
*/
|
||||
ProtocolHint();
|
||||
|
||||
virtual ~ProtocolHint();
|
||||
std::string getDescription();
|
||||
int getID() const;
|
||||
|
||||
/* Overloading the equality operator so that this can be
|
||||
* used as a key for hash_map associations without the actual
|
||||
* key objects having to be identical.
|
||||
*/
|
||||
bool operator==(const ProtocolHint &that);
|
||||
|
||||
protected:
|
||||
int id;
|
||||
std::string description;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_PROTOCOLHINT_H */
|
||||
|
@ -0,0 +1,82 @@
|
||||
/***************************************************//**
|
||||
* @file Transaction.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* The Transaction class is simply a wrapper
|
||||
* around one or more Transfer objects that must
|
||||
* be executed in a particular order. This is
|
||||
* provided for convenience. Some transfers
|
||||
* to Ocean Optics spectrometers put the spectrometer
|
||||
* into a particular state where it expects another
|
||||
* action to be taken, and Transaction objects can
|
||||
* be used to ensure that all expected operations occur.
|
||||
*
|
||||
* Some actions, like requesting a spectrum, do not
|
||||
* necessarily require that the next action be a read
|
||||
* operation. Thus, some Transfers that appear to follow
|
||||
* a causal chain may not in fact make good Transactions.
|
||||
* In this case, reading the status of the device until
|
||||
* it reports data ready is a common operation before
|
||||
* reading the spectrum.
|
||||
*
|
||||
* Note that the Transaction class has no notion of buses
|
||||
* or protocols, and this is by design.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_TRANSACTION_H
|
||||
#define SEABREEZE_TRANSACTION_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/protocols/Exchange.h"
|
||||
#include "common/protocols/Transfer.h"
|
||||
#include "common/buses/TransferHelper.h"
|
||||
#include "common/protocols/ProtocolHint.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Transaction : public Exchange {
|
||||
public:
|
||||
Transaction();
|
||||
virtual ~Transaction();
|
||||
void addTransfer(Transfer *xfer);
|
||||
|
||||
/* Inherited from Exchange */
|
||||
virtual Data *transfer(TransferHelper *helper) throw (ProtocolException);
|
||||
|
||||
protected:
|
||||
std::vector<Transfer *> transfers;
|
||||
|
||||
private:
|
||||
void updateHints();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_TRANSACTION_H */
|
||||
|
@ -0,0 +1,93 @@
|
||||
/***************************************************//**
|
||||
* @file Transfer.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* The Transfer class captures a simplex
|
||||
* data transfer to or from a device. At this
|
||||
* level, there is no notion of a particular bus,
|
||||
* just data, length, and direction.
|
||||
*
|
||||
* The bus aspects are encapsulated in a "helper"
|
||||
* object that must be provided when the Transfer
|
||||
* is executed. The helper must provide send() and
|
||||
* receive() methods taking a buffer and length
|
||||
* only. All of the details in getting the transfer to
|
||||
* or from the other end must be handled by the helper.
|
||||
* The helper is expected to be created by some aspect
|
||||
* of the driver for the device in question. It contains
|
||||
* information about the connection and the particulars
|
||||
* about routing data in and out.
|
||||
*
|
||||
* Note that the Transfer class is completely orthagonal to any
|
||||
* particular protocol. It is expected that a protocol may be
|
||||
* built up as a collection of related Transfer types.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_TRANSFER_H
|
||||
#define SEABREEZE_TRANSFER_H
|
||||
|
||||
#include <vector>
|
||||
#include "common/protocols/Exchange.h"
|
||||
#include "common/protocols/ProtocolHint.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
typedef unsigned int direction_t;
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Transfer : public Exchange {
|
||||
public:
|
||||
|
||||
/* Note that the size of the provided buffer and the specified length
|
||||
* of the transfer itself do not need to agree. If the transfer requires
|
||||
* more space than the buffer provides, the buffer will be resized.
|
||||
* If the buffer is created larger than is needed, only the given length
|
||||
* will be sent or received. This allows for some freedom in buffer
|
||||
* management.
|
||||
*/
|
||||
Transfer(std::vector<ProtocolHint *> *hints, std::vector<byte> *buffer,
|
||||
direction_t direction, unsigned int length);
|
||||
|
||||
virtual ~Transfer();
|
||||
virtual Data *transfer(TransferHelper *helper) throw (ProtocolException);
|
||||
|
||||
static const direction_t TO_DEVICE;
|
||||
static const direction_t FROM_DEVICE;
|
||||
|
||||
protected:
|
||||
Transfer();
|
||||
void checkBufferSize();
|
||||
|
||||
unsigned int length;
|
||||
std::vector<byte> *buffer;
|
||||
direction_t direction;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_TRANSFER_H */
|
||||
|
Reference in New Issue
Block a user