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

Last change on this file since 1767 was 1760, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.0 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
30
31class ShaftEncoder;
32class Macs;
33class MGCosy;
34class MCosy;
35class TH2F;
36
37class MTTalk : public MThread
38{
39private:
40 MCosy *fCosy;
41
42 void *Thread();
43
44public:
45 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
46 {
47 SetPriority(10);
48 Detach();
49 Start();
50 }
51 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
52};
53
54class TTimer;
55class MCosy : public Network, public MsgQueue, public TObject
56{
57 friend class MTTalk;
58
59private:
60 enum
61 {
62 kError = 0x01,
63 kMoving = 0x02,
64 kTracking = 0x04,
65 kStopping = 0x08,
66 kStopped = 0x10
67 };
68
69 const MObservatory::LocationName_t fObservatory;
70
71 ShaftEncoder *fZd1;
72 ShaftEncoder *fZd2;
73 ShaftEncoder *fAz;
74
75 Macs *fMac1;
76 Macs *fMac2;
77 Macs *fMac3;
78
79 MGCosy *fWin;
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 };
91
92 BackgroundAction_t fBackground; // Flag for present backgroundthread
93
94 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
95 ZdAz fOffset; // Offset between se and re coordinate system [re]
96 ZdAz fZdAzSoll; // Soll position when moving
97 RaDec fRaDec; // Position to track
98 ZdAz fAccuracy; // Actual accuracy of Tracking
99 ZdAz fVelocity; // Actual velocity of Tracking
100 ZdAz fMin;
101 ZdAz fMax;
102
103 TH2F *fHistTestSe;
104
105 XY kGearRatio; // describing the gear of the system [re/se]
106 XY kGearRatio2; // describing the gear of the system [re/deg]
107
108 MBending fBending;
109
110 UInt_t fStatus;
111
112 ofstream *tpout;
113
114 double Rad2SE(double rad) const;
115 double Rad2ZdRE(double rad) const;
116 double Rad2AzRE(double rad) const;
117 double Deg2ZdRE(double rad) const;
118 double Deg2AzRE(double rad) const;
119
120 void SetStatus(UInt_t stat) { fStatus = stat; }
121 UInt_t GetStatus() const { return fStatus; }
122
123 ZdAz GetRePos();
124 ZdAz GetRePosPdo();
125 ZdAz GetSePos(); // [se]
126
127 Bool_t RequestRePos();
128 Bool_t SetVelocity(const ZdAz &v);
129 void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc);
130
131 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
132
133 void InitSync();
134 bool InitTracking();
135 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
136
137 void TalkThread();
138 void TalkThreadTracking();
139 void TalkThreadSeTest();
140
141 void DisplayHistTestSe();
142
143 int SetPosition(const ZdAz &dst);
144
145 void TerminateApp();
146
147 void TrackPosition(const RaDec &dst); // ra, dec [rad]
148
149 int StopWaitingForSDO() const;
150 void CheckForError();
151
152 void StopMovement();
153 void WaitForEndMovement();
154
155 void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
156 void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
157 void ConstructorDemo();
158
159 void ReadConfig();
160
161 bool CheckNetwork();
162
163 virtual bool HasZombie() const;
164
165public:
166 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
167 ~MCosy();
168
169 void Start();
170 void Stop();
171
172 void *Proc(int msg, void *mp);
173
174 Bool_t HandleTimer(TTimer *t);
175
176 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
177 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
178
179 ClassDef(MCosy, 0)
180};
181
182#endif
Note: See TracBrowser for help on using the repository browser.