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

Last change on this file since 1275 was 1275, checked in by tbretz, 22 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
18class ShaftEncoder;
19class Macs;
20class MGCosy;
21class MCosy;
22
23class MTTalk : public MThread
24{
25private:
26 MCosy *fCosy;
27
28 void *Thread();
29
30public:
31 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy)
32 {
33 SetPriority(10);
34 Detach();
35 Start();
36 }
37 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; }
38};
39
40
41class TTimer;
42class MCosy : public Network, public MsgQueue, public TObject
43{
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
97 int SetPosition(const ZdAz &dst);
98
99 void TerminateApp();
100
101 void TrackPosition(const RaDec &dst); // ra, dec [rad]
102
103 int StopWaitingForSDO() const;
104 void CheckForError();
105
106 void StopMovement();
107 void WaitForEndMovement();
108
109public:
110 MCosy(const char *dev, const int baud, MLog &out=gLog);
111 ~MCosy();
112
113 void Start();
114 void Stop();
115
116 void *Proc(int msg, void *mp);
117
118 Bool_t HandleTimer(TTimer *t);
119
120 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
121 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
122
123 ClassDef(MCosy, 0)
124};
125
126#endif
Note: See TracBrowser for help on using the repository browser.