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

Last change on this file since 1190 was 1111, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.7 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
9#define kDEG ((char)0x9c) // Linux 'ø'
10
11#define WM_WAIT WM_NULL
12#define WM_PRESET 0x1000
13#define WM_POSITION 0x1001
14#define WM_TRACK 0x1002
15#define WM_STOP 0x1003
16#define WM_POLARIS 0x1004
17#define WM_QUIT 0x1005
18
19class ShaftEncoder;
20class Macs;
21class MGCosy;
22class MCosy;
23
24class MTTalk : public MThread
25{
26private:
27 MCosy *fCosy;
28
29 void *Thread();
30
31public:
32 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
33 {
34 SetPriority(10);
35 Start();
36 }
37};
38
39
40class TTimer;
41class MCosy : public Network, public MsgQueue, public TObject
42{
43 friend class MTGui;
44 friend class MTTalk;
45
46private:
47 enum
48 {
49 kError = 0x01,
50 kMoving = 0x02,
51 kTracking = 0x04,
52 kStopping = 0x08,
53 kStopped = 0x10
54 };
55
56 ShaftEncoder *fZd1;
57 ShaftEncoder *fZd2;
58 ShaftEncoder *fAz;
59
60 Macs *fMac1;
61 Macs *fMac2;
62 Macs *fMac3;
63
64 MGCosy *fWin;
65
66 TTimer *fUpdateGui;
67 MTTalk *fTTalk; // should be outsourced, like the starguider.
68 // with a generic interface to both...
69
70 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
71 ZdAz fOffset; // Offset between se and re coordinate system [re]
72 RaDec fRaDec; // Position to track
73 int fTracking; // Flag for present tracking action
74 ZdAz fAccuracy; // Actual accuracy of Tracking
75 ZdAz fVelocity; // Actual velocity of Tracking
76
77 UInt_t fStatus;
78
79 void SetStatus(UInt_t stat) { fStatus = stat; }
80 UInt_t GetStatus() const { return fStatus; }
81
82 ZdAz GetRePos();
83 ZdAz GetRePosPdo();
84 ZdAz GetSePos(); // [se]
85
86 Bool_t RequestRePos();
87 Bool_t SetVelocity(ZdAz v);
88 void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc);
89
90 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
91
92 void InitTracking();
93 void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
94
95 void TalkThread();
96 void GuiThread(MTGui *t);
97
98 int SetPosition(const ZdAz &dst);
99
100 void TerminateApp();
101
102 void TrackPosition(const RaDec &dst); // ra, dec [rad]
103
104 int StopWaitingForSDO() const;
105 void CheckForError();
106
107 void StopMovement();
108 void WaitForEndMovement();
109
110public:
111 MCosy(const char *dev, const int baud, MLog &out=gLog);
112 ~MCosy();
113
114 void Start();
115 void Stop();
116
117 void *Proc(int msg, void *mp);
118
119 Bool_t HandleTimer(TTimer *t);
120
121 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
122 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
123
124 ClassDef(MCosy, 0)
125};
126
127#endif
Note: See TracBrowser for help on using the repository browser.