00001 /* 00002 * $RCSfile: USBDevice.hpp,v $ 00003 * $Revision: 1.14 $ 00004 * $Date: 2010/01/18 19:40:28 $ 00005 * jEdit:tabSize=4:indentSize=4:collapseFolds=1: 00006 * 00007 * class BoolArray, UCharArray, UShortArray, IntArray, DoubleArray, USBDeviceArray, USBDevice declarations 00008 */ 00009 00010 #if ! defined( USBDevice_hpp ) 00011 #define USBDevice_hpp 00012 00013 // {{{ includes 00014 #include <vector> 00015 #include <string> 00016 #include <iostream> 00017 #include <aiousb.h> 00018 // }}} 00019 00020 namespace AIOUSB { 00021 00022 // {{{ class BoolArray, UCharArray, UShortArray, IntArray, DoubleArray, USBDeviceArray 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 class StringArray : public std::vector<std::string> { 00050 public: 00051 StringArray( int size = 0 ) : std::vector<std::string>( size ) {} 00052 }; // class StringArray 00053 00054 class USBDevice; 00055 class USBDeviceArray : public std::vector<USBDevice*> { 00056 public: 00057 USBDeviceArray( int size = 0 ) : std::vector<USBDevice*>( size ) {} 00058 }; // class USBDeviceArray 00059 00060 // }}} 00061 00062 // {{{ class USBDevice declarations 00063 00068 class USBDevice { 00069 friend class USBDeviceManager; 00070 friend class DIOStreamSubsystem; 00071 friend class AnalogInputSubsystem; 00072 00073 // {{{ public constants 00074 public: 00076 static const int CUSTOM_EEPROM_SIZE = 0x200; 00077 00079 static const int CLEAR_FIFO_METHOD_IMMEDIATE = 0; 00081 static const int CLEAR_FIFO_METHOD_AUTO = 1; 00083 static const int CLEAR_FIFO_METHOD_IMMEDIATE_AND_ABORT = 5; 00085 static const int CLEAR_FIFO_METHOD_WAIT = 86; 00086 // }}} 00087 00088 // {{{ protected members 00089 protected: 00090 int deviceIndex; // device index on bus 00091 int productID; // 16-bit product ID 00092 std::string name; // device name 00093 __uint64_t serialNumber; // 64-bit serial number or 0 00094 // }}} 00095 00096 // {{{ protected methods 00097 protected: 00098 USBDevice( int productID, int deviceIndex ); 00099 virtual ~USBDevice(); 00100 USBDevice &clearFIFO( int method ); 00101 00102 double getMiscClock() { 00103 return AIOUSB_GetMiscClock( deviceIndex ); 00104 } // getMiscClock() 00105 00106 USBDevice &setMiscClock( double clockHz ); 00107 int getStreamingBlockSize(); 00108 USBDevice &setStreamingBlockSize( int blockSize ); 00109 // }}} 00110 00111 // {{{ public methods 00112 public: 00113 00114 /* 00115 * properties 00116 */ 00117 00118 virtual std::ostream &print( std::ostream &out ); 00119 00127 int getDeviceIndex() const { 00128 return deviceIndex; 00129 } // getDeviceIndex() 00130 00136 int getProductID() const { 00137 return productID; 00138 } // getProductID() 00139 00145 const std::string &getName() const { 00146 return name; 00147 } // getName() 00148 00155 __uint64_t getSerialNumber() const { 00156 return serialNumber; 00157 } // getSerialNumber() 00158 00159 /* 00160 * configuration 00161 */ 00162 00163 int getCommTimeout() const; 00164 USBDevice &setCommTimeout( int timeout ); 00165 00166 /* 00167 * operations 00168 */ 00169 00170 USBDevice &reset(); 00171 USBDevice &customEEPROMWrite( int address, const UCharArray &data ); 00172 UCharArray customEEPROMRead( int address, int numBytes ); 00173 00174 // }}} 00175 00176 }; // class USBDevice 00177 00178 // }}} 00179 00180 // {{{ function declarations 00181 00182 extern std::ostream &operator<<( std::ostream &out, USBDevice &device ); 00183 extern std::ostream &operator<<( std::ostream &out, USBDevice *device ); 00184 00185 // }}} 00186 00187 } // namespace AIOUSB 00188 00189 #endif 00190 00191 /* end of file */