source: trunk/MagicSoft/Cosy/MCosy.h@ 1259

Last change on this file since 1259 was 921, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
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#define kError 0x01
40#define kMoving 0x02
41#define kTracking 0x04
42#define kStopping 0x08
43#define kStopped 0x10
44
45class TTimer;
46class MCosy : public Network, public MsgQueue, public TObject
47{
48 friend class MTGui;
49 friend class MTTalk;
50
51private:
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
107public:
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
Note: See TracBrowser for help on using the repository browser.