00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if ! defined( CounterSubsystem_hpp )
00012 #define CounterSubsystem_hpp
00013
00014
00015 #include <DeviceSubsystem.hpp>
00016
00017
00018 namespace AIOUSB {
00019
00020
00021
00022
00023
00024
00025
00026 class CounterSubsystem;
00027
00028 class Counter {
00029 friend class CounterSubsystem;
00030
00031 protected:
00032 CounterSubsystem *parent;
00033 int counterIndex;
00034
00035 public:
00036
00037 enum {
00038 MODE_TERMINAL_COUNT = 0
00039 , MODE_ONE_SHOT = 1
00040 , MODE_RATE_GENERATOR = 2
00041 , MODE_SQUARE_WAVE = 3
00042 , MODE_SW_TRIGGERED = 4
00043 , MODE_HW_TRIGGERED = 5
00044 };
00045
00046 Counter( CounterSubsystem *parent, int counterIndex );
00047 int getDeviceIndex() const;
00048 Counter &setMode( int mode );
00049 Counter &setCount( unsigned short count );
00050 Counter &setModeAndCount( int mode, unsigned short count );
00051 unsigned short readCount();
00052 UShortArray readCountAndStatus();
00053 unsigned short readCountAndSetModeAndCount( int mode, unsigned short count );
00054 };
00055
00056
00057
00058
00059
00060 class CounterList : public std::vector<Counter*> {
00061 };
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 class CounterSubsystem : public DeviceSubsystem {
00072 protected:
00073 int numCounterBlocks;
00074 int numCounters;
00075 CounterList counters;
00076
00077 public:
00078 CounterSubsystem( USBDevice &parent );
00079 virtual ~CounterSubsystem();
00080
00081
00082
00083
00084
00085 virtual std::ostream &print( std::ostream &out );
00086
00087 int getNumCounterBlocks() const {
00088 return numCounterBlocks;
00089 }
00090
00091 int getNumCounters() const {
00092 return numCounters;
00093 }
00094
00095
00096
00097
00098
00099 Counter &getCounter( int counter );
00100 UShortArray readCounts( bool oldData );
00101 CounterSubsystem &selectGate( int counter );
00102 double startClock( int counterBlock, double clockHz );
00103
00104 CounterSubsystem &stopClock( int counterBlock ) {
00105 startClock( counterBlock, 0 );
00106 return *this;
00107 }
00108
00109 };
00110
00111
00112
00113 }
00114
00115 #endif
00116
00117
00118