source: trunk/MagicSoft/Cosy/main/MCosy.h@ 1822

Last change on this file since 1822 was 1817, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.3 KB
Line 
1#ifndef MCOSY_H
2#define MCOSY_H
3
4#include "coord.h"
5#include "msgqueue.h"
6#include "network.h"
7#include "MThread.h"
8#include "MBending.h"
9
10#ifndef MARS_Mobservatory
11#include "MObservatory.h"
12#endif
13
14#define kDEG ((char)0x9c) // Linux 'ø'
15
16#define WM_WAIT WM_NULL
17#define WM_PRESET 0x1000
18#define WM_POSITION 0x1001
19#define WM_TRACK 0x1002
20#define WM_STOP 0x1003
21#define WM_CALIB 0x1004
22#define WM_TPOINT 0x1005
23#define WM_NEWTRACK 0x1006
24#define WM_LOADBENDING 0x1007
25#define WM_RESETBENDING 0x1008
26#define WM_CALCALTAZ 0x1009
27#define WM_HOME 0x100a
28#define WM_TESTSE 0x100b
29#define WM_GEAR 0x100c
30#define WM_DISPLAY 0x100d
31
32class ShaftEncoder;
33class Macs;
34class MGCosy;
35class MCosy;
36class TH2F;
37
38class MTTalk : public MThread
39{
40private:
41 MCosy *fCosy;
42
43 void *Thread();
44
45public:
46 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
47 {
48 SetPriority(10);
49 Detach();
50 Start();
51 }
52 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
53};
54
55class TTimer;
56class MCosy : public Network, public MsgQueue, public TObject
57{
58 friend class MTTalk;
59
60private:
61 enum
62 {
63 kError = 0x01,
64 kMoving = 0x02,
65 kTracking = 0x04,
66 kStopping = 0x08,
67 kStopped = 0x10
68 };
69
70 const MObservatory::LocationName_t fObservatory;
71
72 ShaftEncoder *fZd1;
73 ShaftEncoder *fZd2;
74 ShaftEncoder *fAz;
75
76 Macs *fMac1;
77 Macs *fMac2;
78 Macs *fMac3;
79
80 MGCosy *fWin;
81
82 TTimer *fUpdateGui;
83 MTTalk *fTTalk; // should be outsourced, like the starguider.
84 // with a generic interface to both...
85
86 enum BackgroundAction_t
87 {
88 kBgdNone,
89 kBgdTracking,
90 kBgdSeTest,
91 kBgdSeTestDispl,
92 kBgdGear,
93 kBgdGearDispl
94 };
95
96 BackgroundAction_t fBackground; // Flag for present backgroundthread
97
98 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
99 ZdAz fOffset; // Offset between se and re coordinate system [re]
100 ZdAz fZdAzSoll; // Soll position when moving
101 RaDec fRaDec; // Position to track
102 ZdAz fAccuracy; // Actual accuracy of Tracking
103 ZdAz fVelocity; // Actual velocity of Tracking
104 ZdAz fMin;
105 ZdAz fMax;
106
107 TH2F *fHist;
108 Bool_t fTriggerDisplay;
109
110 XY kGearRatio; // describing the gear of the system [re/se]
111 XY kGearRatio2; // describing the gear of the system [re/deg]
112
113 MBending fBending;
114
115 UInt_t fStatus;
116
117 ofstream *tpout;
118
119 double Rad2SE(double rad) const;
120 double Rad2ZdRE(double rad) const;
121 double Rad2AzRE(double rad) const;
122 double Deg2ZdRE(double rad) const;
123 double Deg2AzRE(double rad) const;
124
125 void SetStatus(UInt_t stat) { fStatus = stat; }
126 UInt_t GetStatus() const { return fStatus; }
127
128 ZdAz GetRePos();
129 ZdAz GetRePosPdo();
130 ZdAz GetSePos(); // [se]
131
132 Bool_t RequestRePos();
133 Bool_t SetVelocity(const ZdAz &v);
134
135 void SetPosVelocity(const Float_t ratio, Float_t vel);
136
137 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
138
139 void InitSync();
140 bool InitTracking();
141 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
142
143 void TalkThread();
144 void TalkThreadTracking();
145 void TalkThreadSeTest();
146 void TalkThreadGear();
147
148 void DisplayHistTestSe(Bool_t del=kTRUE);
149 void DisplayHistGear(Bool_t del=kTRUE);
150
151 int SetPosition(const ZdAz &dst, Bool_t track=kFALSE);
152
153 void TerminateApp();
154
155 void TrackPosition(const RaDec &dst); // ra, dec [rad]
156
157 int StopWaitingForSDO() const;
158 void CheckForError();
159
160 void StopMovement();
161 void StopTracking();
162
163 void WaitForEndMovement();
164
165 void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
166 void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
167 void ConstructorDemo();
168
169 void ReadConfig();
170
171 bool CheckNetwork();
172
173public:
174 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
175 ~MCosy();
176
177 void Start();
178 void Stop();
179
180 void *Proc(int msg, void *mp);
181
182 Bool_t HandleTimer(TTimer *t);
183
184 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
185 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
186
187 ClassDef(MCosy, 0)
188};
189
190#endif
Note: See TracBrowser for help on using the repository browser.