00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #if ! defined( DigitalIOSubsystem_hpp )
00011 #define DigitalIOSubsystem_hpp
00012
00013
00014 #include <DeviceSubsystem.hpp>
00015
00016
00017 namespace AIOUSB {
00018
00025 class DigitalIOSubsystem : public DeviceSubsystem {
00026 friend class USB_AI16_Family;
00027 friend class USB_AO16_Family;
00028 friend class USB_DIO_Family;
00029 friend class USB_DIO_16_Family;
00030 friend class USB_DIO_32_Family;
00031
00032
00033 public:
00035 static const int BITS_PER_BYTE = 8;
00036
00037
00038
00039 protected:
00040 int numPorts;
00041 int numChannels;
00042 int numTristateGroups;
00043 int numTristateChannels;
00044 UCharArray writeValues;
00045
00046
00047
00048 UCharArray &bitsToBytes( UCharArray &dest, int bit, const BoolArray &src );
00049 BoolArray &bytesToBits( BoolArray &dest, const UCharArray &src, int bit );
00050 DigitalIOSubsystem( USBDevice &parent );
00051 virtual ~DigitalIOSubsystem();
00052
00053
00054
00055 public:
00056
00057
00058
00059
00060
00061 virtual std::ostream &print( std::ostream &out );
00062
00068 int getNumPorts() const {
00069 return numPorts;
00070 }
00071
00078 int getNumChannels() const {
00079 return numChannels;
00080 }
00081
00087 int getNumTristateGroups() const {
00088 return numTristateGroups;
00089 }
00090
00097 int getNumTristateChannels() const {
00098 return numTristateChannels;
00099 }
00100
00101
00102
00103
00104
00105 DigitalIOSubsystem &configure( bool tristate, const BoolArray &outputs, const BoolArray &values );
00106 DigitalIOSubsystem &configure( const BoolArray &tristates, const BoolArray &outputs, const BoolArray &values );
00107 DigitalIOSubsystem &getConfiguration( BoolArray *tristates, BoolArray *outputs );
00108
00109
00110
00111
00112
00113 bool read( int channel );
00114 BoolArray read( int startChannel, int numChannels );
00115 DigitalIOSubsystem &write( int channel, bool value );
00116 DigitalIOSubsystem &write( int startChannel, const BoolArray &values );
00117 };
00118
00119
00120
00121 }
00122
00123 #endif
00124
00125