2
The stellarium telescope library helps building
3
telescope server programs, that can communicate with stellarium
4
by means of the stellarium TCP telescope protocol.
5
It also contains smaple server classes (dummy, Meade LX200).
7
Author and Copyright of this file and of the stellarium telescope library:
8
Johannes Gajdosik, 2006
10
This library is free software; you can redistribute it and/or
11
modify it under the terms of the GNU Lesser General Public
12
License as published by the Free Software Foundation; either
13
version 2.1 of the License, or (at your option) any later version.
15
This library is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Lesser General Public License for more details.
20
You should have received a copy of the GNU Lesser General Public
21
License along with this library; if not, write to the Free Software
22
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
#ifndef _LX200_COMMAND_HPP_
26
#define _LX200_COMMAND_HPP_
28
#include <QTextStream>
32
class TelescopeClientDirectLx200;
34
//! Abstract base class for Meade LX200 (and compatible) commands.
38
virtual ~Lx200Command(void) {}
39
virtual bool writeCommandToBuffer(char *&buff, char *end) = 0;
40
bool hasBeenWrittenToBuffer(void) const {return has_been_written_to_buffer;}
41
virtual int readAnswerFromBuffer(const char *&buff, const char *end) = 0;
42
virtual bool needsNoAnswer(void) const {return false;}
43
virtual void print(QTextStream &o) const = 0;
44
virtual bool isCommandGotoSelected(void) const {return false;}
45
virtual bool shortAnswerReceived(void) const {return false;}
46
//returns true when reading is finished
49
Lx200Command(Server &server);
50
TelescopeClientDirectLx200 &server;
51
bool has_been_written_to_buffer;
54
inline QTextStream &operator<<(QTextStream &o, const Lx200Command &c)
60
//! Meade LX200 command: Toggle long or short format.
61
//! Does not require an answer from the telescope.
62
class Lx200CommandToggleFormat : public Lx200Command
65
Lx200CommandToggleFormat(Server &server) : Lx200Command(server) {}
68
bool writeCommandToBuffer(char *&buff, char *end);
69
int readAnswerFromBuffer(const char*&, const char*) {return 1;}
70
bool needsNoAnswer(void) const {return true;}
71
void print(QTextStream &o) const;
74
//! Meade LX200 command: Stop the current slew.
75
//! Does not require an answer from the telescope.
76
class Lx200CommandStopSlew : public Lx200Command
79
Lx200CommandStopSlew(Server &server) : Lx200Command(server) {}
82
bool writeCommandToBuffer(char *&buff, char *end);
83
int readAnswerFromBuffer(const char*&, const char*) {return 1;}
84
bool needsNoAnswer(void) const {return true;}
85
void print(QTextStream &o) const;
88
//! Meade LX200 command: Set right ascension.
89
class Lx200CommandSetSelectedRa : public Lx200Command
92
Lx200CommandSetSelectedRa(Server &server, int ra)
93
: Lx200Command(server), ra(ra) {}
94
bool writeCommandToBuffer(char *&buff, char *end);
95
int readAnswerFromBuffer(const char *&buff, const char *end);
96
void print(QTextStream &o) const;
102
//! Meade LX200 command: Set declination.
103
class Lx200CommandSetSelectedDec : public Lx200Command
106
Lx200CommandSetSelectedDec(Server &server,int dec)
107
: Lx200Command(server), dec(dec) {}
108
bool writeCommandToBuffer(char *&buff, char *end);
109
int readAnswerFromBuffer(const char *&buff, const char *end);
110
void print(QTextStream &o) const;
116
//! Meade LX200 command: Slew to the coordinates set before.
117
class Lx200CommandGotoSelected : public Lx200Command
120
Lx200CommandGotoSelected(Server &server)
121
: Lx200Command(server), first_byte(256) {}
122
bool writeCommandToBuffer(char *&buff, char *end);
123
int readAnswerFromBuffer(const char *&buff, const char *end);
124
void print(QTextStream &o) const;
125
bool isCommandGotoSelected(void) const {return true;}
126
bool shortAnswerReceived(void) const {return (first_byte != 256);}
132
//! Meade LX200 command: Get the current right ascension.
133
class Lx200CommandGetRa : public Lx200Command
136
Lx200CommandGetRa(Server &server) : Lx200Command(server) {}
137
bool writeCommandToBuffer(char *&buff, char *end);
138
int readAnswerFromBuffer(const char *&buff, const char *end);
139
void print(QTextStream &o) const;
142
//! Meade LX200 command: Get the current declination.
143
class Lx200CommandGetDec : public Lx200Command
146
Lx200CommandGetDec(Server &server) : Lx200Command(server) {}
147
bool writeCommandToBuffer(char *&buff, char *end);
148
int readAnswerFromBuffer(const char *&buff, const char *end);
149
void print(QTextStream &o) const;
152
#endif //_LX200_COMMAND_HPP_