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

Last change on this file since 1703 was 1703, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.6 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#define kDEG ((char)0x9c) // Linux 'ø'
11
12#define WM_WAIT WM_NULL
13#define WM_PRESET 0x1000
14#define WM_POSITION 0x1001
15#define WM_TRACK 0x1002
16#define WM_STOP 0x1003
17#define WM_CALIB 0x1004
18#define WM_TPOINT 0x1005
19#define WM_NEWTRACK 0x1006
20#define WM_LOADBENDING 0x1007
21#define WM_RESETBENDING 0x1008
22#define WM_CALCALTAZ 0x1009
23#define WM_HOME 0x100a
24
25
26class ShaftEncoder;
27class Macs;
28class MGCosy;
29class MCosy;
30
31class MTTalk : public MThread
32{
33private:
34 MCosy *fCosy;
35
36 void *Thread();
37
38public:
39 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
40 {
41 SetPriority(10);
42 Detach();
43 Start();
44 }
45 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
46};
47
48
49class TTimer;
50class MCosy : public Network, public MsgQueue, public TObject
51{
52 friend class MTTalk;
53
54private:
55 enum
56 {
57 kError = 0x01,
58 kMoving = 0x02,
59 kTracking = 0x04,
60 kStopping = 0x08,
61 kStopped = 0x10
62 };
63
64 ShaftEncoder *fZd1;
65 ShaftEncoder *fZd2;
66 ShaftEncoder *fAz;
67
68 Macs *fMac1;
69 Macs *fMac2;
70 Macs *fMac3;
71
72 MGCosy *fWin;
73
74 TTimer *fUpdateGui;
75 MTTalk *fTTalk; // should be outsourced, like the starguider.
76 // with a generic interface to both...
77
78 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
79 ZdAz fOffset; // Offset between se and re coordinate system [re]
80 ZdAz fZdAzSoll; // Soll position when moving
81 RaDec fRaDec; // Position to track
82 int fTracking; // Flag for present tracking action
83 ZdAz fAccuracy; // Actual accuracy of Tracking
84 ZdAz fVelocity; // Actual velocity of Tracking
85
86 XY kGearRatio; // describing the gear of the system [re/se]
87 XY kGearRatio2; // describing the gear of the system [re/deg]
88
89 MBending fBending;
90
91 UInt_t fStatus;
92
93 ofstream *tpout;
94
95 double Rad2SE(double rad) const;
96 double Rad2ZdRE(double rad) const;
97 double Rad2AzRE(double rad) const;
98 double Deg2ZdRE(double rad) const;
99 double Deg2AzRE(double rad) const;
100
101 void SetStatus(UInt_t stat) { fStatus = stat; }
102 UInt_t GetStatus() const { return fStatus; }
103
104 ZdAz GetRePos();
105 ZdAz GetRePosPdo();
106 ZdAz GetSePos(); // [se]
107
108 Bool_t RequestRePos();
109 Bool_t SetVelocity(const ZdAz &v);
110 void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc);
111
112 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
113
114 void InitSync();
115 bool InitTracking();
116 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
117
118 void TalkThread();
119
120 int SetPosition(const ZdAz &dst);
121
122 void TerminateApp();
123
124 void TrackPosition(const RaDec &dst); // ra, dec [rad]
125
126 int StopWaitingForSDO() const;
127 void CheckForError();
128
129 void StopMovement();
130 void WaitForEndMovement();
131
132 void Constructor(Int_t id1, Int_t id2, Int_t id3, Int_t id4, Int_t id5, Int_t id6);
133 void ConstructorSE(Int_t id1, Int_t id2, Int_t id3);
134 void ConstructorDemo();
135
136 void ReadConfig();
137
138 bool CheckNetwork();
139
140public:
141 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
142 ~MCosy();
143
144 void Start();
145 void Stop();
146
147 void *Proc(int msg, void *mp);
148
149 Bool_t HandleTimer(TTimer *t);
150
151 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
152 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
153
154 ClassDef(MCosy, 0)
155};
156
157#endif
Note: See TracBrowser for help on using the repository browser.