File: INCLUDE\DETECUSE\detectorcontroller.h
1 /*//////////////////////////////////////////////////////////////////////////////
2 // //
3 // DETECTORCONTROLLER.H //
4 // //
5 // Subsystem : Detektornutzung / Hardwarezugriff //
6 //----------------------------------------------------------------------------//
7 // Autoren: René Harder, Alexander Paschold (2003) //
8 // //
9 // Stand : 23.05.2003 //
10 // letzter vollständiger Test: //
11 // //
12 //////////////////////////////////////////////////////////////////////////////*/
13
14 #ifndef _DETECTORCONTROLLER_H
15 #define _DETECTORCONTROLLER_H
16
17 #include "hardware\hwio.h"
18
19 #ifndef _COUNTERCLASS
20 #if defined (Build_Counters)
22 #elif defined(Use_Counters)
24 #else
25 #define _COUNTERCLASS
26 #endif
27 #endif
28
29
30 /////////////////////////////////////////////////////////////////
31 // Controller für BraunPsd
32 class _COUNTERCLASS TBraunPsdController : public Controller
33 {
34 private:
35 BraunPsdIo* SpecialHardware;
36
37 public:
38 TBraunPsdController(EDeviceType DeviceID, LPTSTR HardwareID, DeviceList* Devices);
39 virtual ~TBraunPsdController();
40
41 virtual BOOL Check();
42
43 BOOL SetTimeout(unsigned long Cycles);
44 BOOL GetData(IrpParamsGetData *Params);
45 };
46
47 /////////////////////////////////////////////////////////////////
48 //Controller für Radicon
49 class _COUNTERCLASS TRadiconController : public Controller
50 {
51 public:
52 //! how to readout the measured values
53 enum EReadoutMode
54 {
55 final, // receive result time and pulses
56 intermediate // receive current time and pulses
57 };
58
59 //! tells the detector's controller what to do
60 enum EOperationMode
61 {
62 fixedExposureCounts, // count pulses during exposure time
63 fixedImpulseCounts, // count time when number of pulses is set
64 intensimeter, // intensimeter
65 stop // stop controller
66 };
67
68
69 TRadiconController(EDeviceType DeviceID, LPTSTR HardwareID, DeviceList* Devices);
70 virtual ~TRadiconController();
71
72 virtual BOOL Check();
73
74 int UploadFirmware(void);
75 int SetParameters(unsigned short upperThreshold, unsigned short lowerThreshold,
76 int highvoltage, double exposureTime, unsigned long impulseCount,
77 BOOL bSound);
78 int Execute(EOperationMode mode);
79 int GetValues(EReadoutMode, double *exposureTime, unsigned long *impulseCount);
80 void reset();
81
82 private:
83 int TransmitMessage(int nFunctionCode, unsigned char* lpszMessage= 0, int nMessageLength= 0);
84 int ReceiveMessage(int nFunctionCode, unsigned char* lpszMessage, int nMaxMessageLength,
85 int& nRealMessageLength);
86 int TransmitFunctionCode(int nFunctionCode);
87 BOOL out_byte(unsigned char d);
88 BOOL in_byte(unsigned char &d);
89 BOOL IsReadyToRead();
90 BOOL IsReadyToWrite();
91 DWORD CurrentTime(void);
92
93 DWORD controlPort;
94 DWORD dataPort;
95 };
96
97
98 /////////////////////////////////////////////////////////////////
99 // Controller für Detektor an TAm9513 Steuerkarte
100
101 enum EIOCCmd
102 {
103 iocSetCounts= 1,
104 iocSetTimeTicks,
105 iocStartCounting,
106 iocStopCounting,
107 iocIsCountingReady,
108 iocReadTicks,
109 iocReadCounts,
110 iocConfigureAcustic,
111 iocStopCCDTiming,
112 iocStartCCDTiming,
113 iocStartCCDShot
114 };
115
116 class _COUNTERCLASS TGenericController : public Controller
117 {
118 public:
119 TGenericController(EDeviceType DeviceID, LPTSTR HardwareID, DeviceList* Devices);
120 virtual ~TGenericController();
121
122 virtual BOOL Check();
123
124 int Init(float fTimeCorrection);
125 int IOCTL( EIOCCmd, DWORD& );
126 int IOCTL( EIOCCmd );
127 void DigitalOut( BYTE );
128 void DigitalIn( BYTE* );
129 void SetSound(BOOL param); //ap - neu !!!
130 DWORD GetTicksPerSecond( void );
131 void ClearToggleOut( BYTE );
132 void SetToggleOut( BYTE );
133
134 protected:
135 BOOL SelectChip();
136 void WriteCmd( BYTE cmd );
137 void ChooseDataPtr( BYTE group, BYTE reg );
138 void WriteData( WORD );
139 WORD ReadData( void );
140 WORD ReadStatus( void );
141 void LoadAndArmC( BYTE );
142 void LoadC( BYTE );
143 void DisarmAndSaveC( BYTE );
144 void DisarmC( BYTE );
145 void LatchToHoldC( BYTE );
146 void ArmC( BYTE );
147 void Reset( void );
148
149 BYTE nbChipId;
150
151 private:
152 float fTimeCorrection;
153 BOOL SplitNumber( DWORD, WORD&, WORD& );
154
155 BOOL bIsLatched;
156 BOOL bIsStopped;
157 WORD wLowTicks;
158 WORD wHighTicks;
159 WORD wLowCounts;
160 WORD wHighCounts;
161 };
162
163 #endif
164