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

Last change on this file since 2568 was 2518, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.6 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#define WM_TRACKPOS 0x100e
32#define WM_POSITION1 0x100f
33#define WM_ENDSWITCH 0x1010
34
35class ShaftEncoder;
36class Macs;
37class MGCosy;
38class MCosy;
39class TH1;
40class MStarguider;
41class MDriveCom;
42
43class MTTalk : public MThread
44{
45private:
46 MCosy *fCosy;
47
48 void *Thread();
49
50public:
51 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
52 {
53 SetPriority(10);
54 Detach();
55 Start();
56 }
57 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
58};
59
60class TTimer;
61class MCosy : public Network, public MsgQueue, public TObject
62{
63 friend class MTTalk;
64
65private:
66 const MObservatory::LocationName_t fObservatory;
67
68 MStarguider *fStarguider;
69
70 ShaftEncoder *fZd1;
71 ShaftEncoder *fZd2;
72 ShaftEncoder *fAz;
73
74 Macs *fMac1;
75 Macs *fMac2;
76 Macs *fMac3;
77
78 MGCosy *fWin;
79 MDriveCom *fCom;
80
81 TTimer *fUpdateGui;
82 MTTalk *fTTalk; // should be outsourced, like the starguider.
83 // with a generic interface to both...
84
85 enum BackgroundAction_t
86 {
87 kBgdNone,
88 kBgdTracking,
89 kBgdSeTest,
90 kBgdSeTestDispl,
91 kBgdGear,
92 kBgdGearDispl
93 };
94
95 BackgroundAction_t fBackground; // Flag for present backgroundthread
96
97 ZdAz fTrackingError; // [rad] Tracking Offset between SE and calc-pos
98 ZdAz fOffset; // Offset between se and re coordinate system [re]
99 ZdAz fZdAzSoll; // [rad] Soll position when moving
100 RaDec fRaDec; // Position to track
101 ZdAz fAccuracy; // Actual accuracy of Tracking
102 ZdAz fVelocity; // Actual velocity of Tracking
103 ZdAz fMin;
104 ZdAz fMax;
105
106 TH1 *fHist;
107 Bool_t fTriggerDisplay;
108
109 XY kGearRatio; // describing the gear of the system [re/se]
110 XY kGearRatio2; // describing the gear of the system [re/deg]
111
112 MBending fBending;
113
114 UInt_t fStatus;
115
116 ofstream *tpout;
117
118 //Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za) const;
119 ZdAz AlignTrackingPos(ZdAz pointing) const;
120 Bool_t CheckRange(const ZdAz &d) const;
121 Double_t Starguider(Double_t mjd, ZdAz &dest) const;
122
123 double Rad2SE(double rad) const;
124 double Rad2ZdRE(double rad) const;
125 double Rad2AzRE(double rad) const;
126 double Deg2ZdRE(double rad) const;
127 double Deg2AzRE(double rad) const;
128
129 void SetStatus(UInt_t stat) { fStatus = stat; }
130 UInt_t GetStatus() const { return fStatus; }
131
132 ZdAz GetRePos();
133 ZdAz GetRePosPdo();
134 ZdAz GetSePos() const; // [se]
135
136 Bool_t RequestRePos();
137 Bool_t SetVelocity(const ZdAz &v);
138
139 void SetPosVelocity(const Float_t ratio, Float_t vel);
140
141 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
142
143 void InitSync();
144 bool InitTracking();
145 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
146
147 void TalkThread();
148 void TalkThreadTracking();
149 void TalkThreadSeTest();
150 void TalkThreadGear();
151
152 void DisplayHistTestSe(Bool_t del=kTRUE);
153 void DisplayHistGear(Bool_t del=kTRUE);
154
155 int SetPosition(const ZdAz &dst, Bool_t track=kFALSE);
156
157 void TerminateApp();
158
159 void TrackPosition(const RaDec &dst); // ra, dec [rad]
160
161 int StopWaitingForSDO() const;
162 void CheckForError();
163
164 void StopMovement();
165 void StopTracking();
166
167 void WaitForEndMovement();
168
169 void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
170 void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
171 void ConstructorDemo();
172
173 void ReadConfig();
174
175 bool CheckNetwork();
176
177public:
178 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
179 ~MCosy();
180
181 void Start();
182 void Stop();
183
184 void *Proc(int msg, void *mp);
185
186 Bool_t HandleTimer(TTimer *t);
187
188 ZdAz GetPointingPos(void) const;
189 void SetStarguider(MStarguider *s) { fStarguider = s; }
190
191 // static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
192 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
193
194 ClassDef(MCosy, 0)
195};
196
197#endif
Note: See TracBrowser for help on using the repository browser.