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