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

Last change on this file since 2019 was 2019, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.5 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
33class ShaftEncoder;
34class Macs;
35class MGCosy;
36class MCosy;
37class TH1;
38
39class MTTalk : public MThread
40{
41private:
42 MCosy *fCosy;
43
44 void *Thread();
45
46public:
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
56class TTimer;
57class MCosy : public Network, public MsgQueue, public TObject
58{
59 friend class MTTalk;
60
61private:
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; // [rad] Tracking Offset between SE and calc-pos
100 ZdAz fOffset; // Offset between se and re coordinate system [re]
101 ZdAz fZdAzSoll; // [rad] 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 TH1 *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 Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za) const;
121 Bool_t CheckRange(const ZdAz &d) const;
122 Double_t Starguider(Double_t mjd, ZdAz &dest) const;
123
124 double Rad2SE(double rad) const;
125 double Rad2ZdRE(double rad) const;
126 double Rad2AzRE(double rad) const;
127 double Deg2ZdRE(double rad) const;
128 double Deg2AzRE(double rad) const;
129
130 void SetStatus(UInt_t stat) { fStatus = stat; }
131 UInt_t GetStatus() const { return fStatus; }
132
133 ZdAz GetRePos();
134 ZdAz GetRePosPdo();
135 ZdAz GetSePos() const; // [se]
136
137 Bool_t RequestRePos();
138 Bool_t SetVelocity(const ZdAz &v);
139
140 void SetPosVelocity(const Float_t ratio, Float_t vel);
141
142 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
143
144 void InitSync();
145 bool InitTracking();
146 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
147
148 void TalkThread();
149 void TalkThreadTracking();
150 void TalkThreadSeTest();
151 void TalkThreadGear();
152
153 void DisplayHistTestSe(Bool_t del=kTRUE);
154 void DisplayHistGear(Bool_t del=kTRUE);
155
156 int SetPosition(const ZdAz &dst, Bool_t track=kFALSE);
157
158 void TerminateApp();
159
160 void TrackPosition(const RaDec &dst); // ra, dec [rad]
161
162 int StopWaitingForSDO() const;
163 void CheckForError();
164
165 void StopMovement();
166 void StopTracking();
167
168 void WaitForEndMovement();
169
170 void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
171 void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
172 void ConstructorDemo();
173
174 void ReadConfig();
175
176 bool CheckNetwork();
177
178public:
179 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
180 ~MCosy();
181
182 void Start();
183 void Stop();
184
185 void *Proc(int msg, void *mp);
186
187 Bool_t HandleTimer(TTimer *t);
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
Note: See TracBrowser for help on using the repository browser.