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

Last change on this file since 919 was 918, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.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
9#define kDEG ((char)0xb0) // 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 Detach();
36 Start();
37 }
38};
39
40#define kError 0x01
41#define kMoving 0x02
42#define kTracking 0x04
43#define kStopping 0x08
44#define kStopped 0x10
45
46class TTimer;
47class MCosy : public Network, public MsgQueue, public TObject
48{
49 friend class MTGui;
50 friend class MTTalk;
51
52private:
53 ShaftEncoder *fAlt1;
54 ShaftEncoder *fAlt2;
55 ShaftEncoder *fAz;
56
57 Macs *fMac1;
58 Macs *fMac2;
59 Macs *fMac3;
60
61 MGCosy *fWin;
62
63 TTimer *fUpdateGui;
64 MTTalk *fTTalk; // should be outsourced, like the starguider.
65 // with a generic interface to both...
66
67 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]
68 ZdAz fOffset; // Offset between se and re coordinate system [re]
69 RaDec fRaDec; // Position to track
70 int fTracking; // Flag for present tracking action
71 ZdAz fAccuracy; // Actual accuracy of Tracking
72 ZdAz fVelocity; // Actual velocity of Tracking
73
74 UInt_t fStatus;
75
76 void SetStatus(UInt_t stat) { fStatus = stat; }
77 UInt_t GetStatus() const { return fStatus; }
78
79 ZdAz GetRePos();
80 ZdAz GetRePosPdo();
81 ZdAz GetSePos(); // [se]
82
83 Bool_t RequestRePos();
84 Bool_t SetVelocity(ZdAz v);
85 void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc);
86
87 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2);
88
89 void InitTracking();
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 void CheckForError();
102
103public:
104 MCosy(const char *dev, const int baud, ostream &out=cout);
105 ~MCosy();
106
107 void Start();
108 void Stop();
109
110 void *Proc(int msg, void *mp);
111
112 Bool_t HandleTimer(TTimer *t);
113
114 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);
115// static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0));
116
117};
118
119#endif
Note: See TracBrowser for help on using the repository browser.