00001 /* 00002 * $RCSfile: USBDevice.hpp,v $ 00003 * $Revision: 1.9 $ 00004 * $Date: 2009/11/22 19:07:37 $ 00005 * jEdit:tabSize=4:indentSize=4:collapseFolds=1: 00006 * 00007 * class BoolArray, UCharArray, UShortArray, IntArray, DoubleArray, USBDevice declarations 00008 */ 00009 00010 00011 #if ! defined( USBDevice_hpp ) 00012 #define USBDevice_hpp 00013 00014 // {{{ includes 00015 #include <vector> 00016 #include <string> 00017 #include <iostream> 00018 // }}} 00019 00020 namespace AIOUSB { 00021 00022 // {{{ class BoolArray, UCharArray, UShortArray, IntArray, DoubleArray declarations 00023 00024 class BoolArray : public std::vector<bool> { 00025 public: 00026 BoolArray( int size = 0 ) : std::vector<bool>( size ) {} 00027 }; // class BoolArray 00028 00029 class UCharArray : public std::vector<unsigned char> { 00030 public: 00031 UCharArray( int size = 0 ) : std::vector<unsigned char>( size ) {} 00032 }; // class UCharArray 00033 00034 class UShortArray : public std::vector<unsigned short> { 00035 public: 00036 UShortArray( int size = 0 ) : std::vector<unsigned short>( size ) {} 00037 }; // class UShortArray 00038 00039 class IntArray : public std::vector<int> { 00040 public: 00041 IntArray( int size = 0 ) : std::vector<int>( size ) {} 00042 }; // class IntArray 00043 00044 class DoubleArray : public std::vector<double> { 00045 public: 00046 DoubleArray( int size = 0 ) : std::vector<double>( size ) {} 00047 }; // class DoubleArray 00048 00049 // }}} 00050 00051 // {{{ class USBDevice declarations 00052 00053 /* 00054 * class USBDevice is the base class for all ACCES USB device classes; 00055 * this class hierarchy is designed to be a fairly lightweight wrapper around 00056 * the AIOUSB library; the primary goal of this class hierarchy is to provide 00057 * a pure C++ interface, as well as to facilitate using AIOUSB 00058 */ 00059 00060 class USBDevice { 00061 friend class DIOStreamSubsystem; 00062 friend class AnalogInputSubsystem; 00063 00064 public: 00065 static const int CUSTOM_EEPROM_SIZE; 00066 00067 protected: 00068 int deviceIndex; // device index on bus 00069 int productID; // 16-bit product ID 00070 std::string name; // device name 00071 __uint64_t serialNumber; // 64-bit serial number or 0 00072 00073 USBDevice &clearFIFO( int method ); 00074 USBDevice &setMiscClock( double clockHz ); 00075 00076 public: 00077 USBDevice( int productID, int deviceIndex ); 00078 virtual ~USBDevice(); 00079 00080 /* 00081 * properties 00082 */ 00083 00084 virtual std::ostream &print( std::ostream &out ); 00085 00086 int getDeviceIndex() const { 00087 return deviceIndex; 00088 } // getDeviceIndex() 00089 00090 int getProductID() const { 00091 return productID; 00092 } // getProductID() 00093 00094 const std::string &getName() const { 00095 return name; 00096 } // getName() 00097 00098 __uint64_t getSerialNumber() const { 00099 return serialNumber; 00100 } // getSerialNumber() 00101 00102 /* 00103 * configuration 00104 */ 00105 00106 int getCommTimeout() const; 00107 USBDevice &setCommTimeout( int timeout ); 00108 00109 /* 00110 * operations 00111 */ 00112 00113 USBDevice &reset(); 00114 USBDevice &customEEPROMWrite( int address, const UCharArray &data ); 00115 UCharArray customEEPROMRead( int address, int numBytes ); 00116 }; // class USBDevice 00117 00118 // }}} 00119 00120 // {{{ function declarations 00121 00122 extern std::ostream &operator<<( std::ostream &out, USBDevice &device ); 00123 extern std::ostream &operator<<( std::ostream &out, USBDevice *device ); 00124 00125 // }}} 00126 00127 } // namespace AIOUSB 00128 00129 #endif 00130 00131 00132 /* end of file */