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