Stellarium  0.90.0
NexStarCommand.hpp
1 /*
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).
6 
7 Author and Copyright of this file and of the stellarium telescope library:
8 Johannes Gajdosik, 2006, modified for NexStar telescopes by Michael Heinz.
9 
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
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
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
23 */
24 
25 #ifndef _NEXSTAR_COMMAND_HPP_
26 #define _NEXSTAR_COMMAND_HPP_
27 
28 #include <QTextStream>
29 using namespace std;
30 
31 class Server;
33 
36 {
37 public:
38  virtual ~NexStarCommand(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) const = 0;
42  virtual bool needsNoAnswer(void) const { return false; }
43  virtual void print(QTextStream &o) const = 0;
44  // returns true when reading is finished
45 
46 protected:
47  NexStarCommand(Server &server);
49  bool has_been_written_to_buffer;
50 };
51 
52 inline QTextStream &operator<<(QTextStream &o, const NexStarCommand &c)
53 {
54  c.print(o);
55  return o;
56 }
57 
60 {
61 public:
62  NexStarCommandGotoPosition(Server &server, unsigned int ra_int, int dec_int);
63  bool writeCommandToBuffer(char *&buff, char *end);
64  int readAnswerFromBuffer(const char *&buff, const char *end) const;
65  void print(QTextStream &o) const;
66 
67 private:
68  int ra, dec;
69 };
70 
73 {
74 public:
75  NexStarCommandGetRaDec(Server &server) : NexStarCommand(server) {}
76  bool writeCommandToBuffer(char *&buff, char *end);
77  int readAnswerFromBuffer(const char *&buff, const char *end) const;
78  void print(QTextStream &o) const;
79 };
80 
81 #endif
Base class for telescope server classes.
Definition: Server.hpp:45
Telescope client that connects directly to a Celestron NexStar through a serial port.
STL namespace.
Celestron NexStar command: Get the current position.
QDataStream & operator<<(QDataStream &out, const SphericalRegionP &region)
Serialize the passed SphericalRegionP into a binary blob.
Abstract base class for Celestron NexStar (and compatible) commands.
Celestron NexStar command: Slew to a given position.