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 |
|
---|
32 |
|
---|
33 | class ShaftEncoder;
|
---|
34 | class Macs;
|
---|
35 | class MGCosy;
|
---|
36 | class MCosy;
|
---|
37 | class TH2F;
|
---|
38 |
|
---|
39 | class MTTalk : public MThread
|
---|
40 | {
|
---|
41 | private:
|
---|
42 | MCosy *fCosy;
|
---|
43 |
|
---|
44 | void *Thread();
|
---|
45 |
|
---|
46 | public:
|
---|
47 | MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
|
---|
48 | {
|
---|
49 | SetPriority(10);
|
---|
50 | Detach();
|
---|
51 | Start();
|
---|
52 | }
|
---|
53 | ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
|
---|
54 | };
|
---|
55 |
|
---|
56 | class TTimer;
|
---|
57 | class MCosy : public Network, public MsgQueue, public TObject
|
---|
58 | {
|
---|
59 | friend class MTTalk;
|
---|
60 |
|
---|
61 | private:
|
---|
62 | enum
|
---|
63 | {
|
---|
64 | kError = 0x01,
|
---|
65 | kMoving = 0x02,
|
---|
66 | kTracking = 0x04,
|
---|
67 | kStopping = 0x08,
|
---|
68 | kStopped = 0x10
|
---|
69 | };
|
---|
70 |
|
---|
71 | const MObservatory::LocationName_t fObservatory;
|
---|
72 |
|
---|
73 | ShaftEncoder *fZd1;
|
---|
74 | ShaftEncoder *fZd2;
|
---|
75 | ShaftEncoder *fAz;
|
---|
76 |
|
---|
77 | Macs *fMac1;
|
---|
78 | Macs *fMac2;
|
---|
79 | Macs *fMac3;
|
---|
80 |
|
---|
81 | MGCosy *fWin;
|
---|
82 |
|
---|
83 | TTimer *fUpdateGui;
|
---|
84 | MTTalk *fTTalk; // should be outsourced, like the starguider.
|
---|
85 | // with a generic interface to both...
|
---|
86 |
|
---|
87 | enum BackgroundAction_t
|
---|
88 | {
|
---|
89 | kBgdNone,
|
---|
90 | kBgdTracking,
|
---|
91 | kBgdSeTest,
|
---|
92 | kBgdSeTestDispl,
|
---|
93 | kBgdGear,
|
---|
94 | kBgdGearDispl
|
---|
95 | };
|
---|
96 |
|
---|
97 | BackgroundAction_t fBackground; // Flag for present backgroundthread
|
---|
98 |
|
---|
99 | ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
|
---|
100 | ZdAz fOffset; // Offset between se and re coordinate system [re]
|
---|
101 | ZdAz fZdAzSoll; // Soll position when moving
|
---|
102 | RaDec fRaDec; // Position to track
|
---|
103 | ZdAz fAccuracy; // Actual accuracy of Tracking
|
---|
104 | ZdAz fVelocity; // Actual velocity of Tracking
|
---|
105 | ZdAz fMin;
|
---|
106 | ZdAz fMax;
|
---|
107 |
|
---|
108 | TH2F *fHist;
|
---|
109 | Bool_t fTriggerDisplay;
|
---|
110 |
|
---|
111 | XY kGearRatio; // describing the gear of the system [re/se]
|
---|
112 | XY kGearRatio2; // describing the gear of the system [re/deg]
|
---|
113 |
|
---|
114 | MBending fBending;
|
---|
115 |
|
---|
116 | UInt_t fStatus;
|
---|
117 |
|
---|
118 | ofstream *tpout;
|
---|
119 |
|
---|
120 | double Rad2SE(double rad) const;
|
---|
121 | double Rad2ZdRE(double rad) const;
|
---|
122 | double Rad2AzRE(double rad) const;
|
---|
123 | double Deg2ZdRE(double rad) const;
|
---|
124 | double Deg2AzRE(double rad) const;
|
---|
125 |
|
---|
126 | void SetStatus(UInt_t stat) { fStatus = stat; }
|
---|
127 | UInt_t GetStatus() const { return fStatus; }
|
---|
128 |
|
---|
129 | ZdAz GetRePos();
|
---|
130 | ZdAz GetRePosPdo();
|
---|
131 | ZdAz GetSePos(); // [se]
|
---|
132 |
|
---|
133 | Bool_t RequestRePos();
|
---|
134 | Bool_t SetVelocity(const ZdAz &v);
|
---|
135 | void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc);
|
---|
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);
|
---|
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 WaitForEndMovement();
|
---|
162 |
|
---|
163 | void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
|
---|
164 | void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
|
---|
165 | void ConstructorDemo();
|
---|
166 |
|
---|
167 | void ReadConfig();
|
---|
168 |
|
---|
169 | bool CheckNetwork();
|
---|
170 |
|
---|
171 | public:
|
---|
172 | MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
|
---|
173 | ~MCosy();
|
---|
174 |
|
---|
175 | void Start();
|
---|
176 | void Stop();
|
---|
177 |
|
---|
178 | void *Proc(int msg, void *mp);
|
---|
179 |
|
---|
180 | Bool_t HandleTimer(TTimer *t);
|
---|
181 |
|
---|
182 | static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
|
---|
183 | // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
|
---|
184 |
|
---|
185 | ClassDef(MCosy, 0)
|
---|
186 | };
|
---|
187 |
|
---|
188 | #endif
|
---|