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

Last change on this file since 1953 was 1953, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.4 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);
121 Bool_t CheckRange(const ZdAz &d) 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(); // [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 // static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
189 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
190
191 ClassDef(MCosy, 0)
192};
193
194#endif
Note: See TracBrowser for help on using the repository browser.