source: BAORadio/libindi/libindi/libs/indibase/inditelescope.h @ 642

Last change on this file since 642 was 642, checked in by frichard, 12 years ago

-Alignement des antennes
-Version 0.0.9 de libindi

File size: 8.0 KB
Line 
1/*******************************************************************************
2  Copyright(c) 2011 Gerry Rozema, Jasem Mutlaq. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB.  If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#ifndef INDI_TELESCOPE_H
20#define INDI_TELESCOPE_H
21
22#include "defaultdriver.h"
23
24/**
25 * \class INDI::Telescope
26   \brief Class to provide general functionality of a telescope device.
27
28   Developers need to subclass INDI::Telescope to implement any driver for telescopes within INDI.
29
30   Implementing a basic telescope driver involves the child class performing the following steps:
31   <ul>
32   <li>If the telescope has additional properties, the child class should override initProperties and initilize the respective additional properties.</li>
33   <li>Once the parent class calls Connect(), the child class attempts to connect to the telescope and return either success of failure</li>
34   <li>INDI::Telescope calls updateProperties() to enable the child class to define which properties to send to the client upon connection</li>
35   <li>INDI::Telescope calls ReadScopeStatus() to check the link to the telescope and update its state and position. The child class should call newRaDec() whenever
36   a new value is read from the telescope.</li>
37   <li>The child class should implmenet Goto() and Sync(), and Park() if applicable.</li>
38   <li>INDI::Telescope calls disconnect() when the client request a disconnection. The child class should remove any additional properties it defined in updateProperties() if applicable</li>
39   </ul>
40
41\author Gerry Rozema, Jasem Mutlaq
42\see TelescopeSimulator and SynScan drivers for examples of implementations of INDI::Telescope.
43*/
44class INDI::Telescope : public INDI::DefaultDriver
45{
46    private:
47
48    public:
49        Telescope();
50        virtual ~Telescope();
51
52        enum TelescopeStatus { SCOPE_IDLE, SCOPE_SLEWING, SCOPE_TRACKING, SCOPE_PARKING, SCOPE_PARKED };
53        enum TelescopeMotionNS { MOTION_NORTH, MOTION_SOUTH };
54        enum TelescopeMotionWE { MOTION_WEST, MOTION_EAST };
55
56        virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
57        virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
58        virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
59        virtual void ISGetProperties (const char *dev);
60
61        /** \brief Called to initialize basic properties required all the time */
62        virtual bool initProperties();
63        /** \brief Called when connected state changes, to add/remove properties */
64        virtual bool updateProperties();
65
66        /** \brief Called when setTimer() time is up */
67        virtual void TimerHit();
68
69        /** \brief Connect to the telescope.
70          \return True if connection is successful, false otherwise
71        */
72        virtual bool Connect();
73
74        /** \brief Disconnect from telescope
75            \return True if successful, false otherwise */
76        virtual bool Disconnect();
77
78        /** \brief INDI::Telescope implementation of Connect() assumes 9600 baud, 8 bit word, even parity, and no stop bit. Override function if communication paramaters
79          are different
80          \param port Port to connect to
81          \return True if connection is successful, false otherwise
82          \warning Do not call this function directly, it is called by INDI::Telescope Connect() function.
83        */
84        virtual bool Connect(const char *port);
85
86        protected:
87
88        virtual bool saveConfigItems(FILE *fp);
89
90        /** \brief The child class calls this function when it has updates */
91        void NewRaDec(double ra,double dec);
92
93        /** \brief Read telescope status.
94         This function checks the following:
95         <ol>
96           <li>Check if the link to the telescope is alive.</li>
97           <li>Update telescope status: Idle, Slewing, Parking..etc.</li>
98           <li>Read coordinates</li>
99         </ol>
100          \return True if reading scope status is OK, false if an error is encounterd.
101          \note This function is not implemented in INDI::Telescope, it must be implemented in the child class */
102        virtual bool ReadScopeStatus();
103
104        /** \brief Move the scope to the supplied RA and DEC coordinates
105            \return True if successful, false otherewise
106            \note This function is not implemented in INDI::Telescope, it must be implemented in the child class
107        */
108        virtual bool Goto(double ra,double dec);
109
110        /** \brief Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates
111            \return True if successful, false otherewise
112            \note This function is not implemented in INDI::Telescope, it must be implemented in the child class
113        */
114        virtual bool Sync(double ra,double dec);
115
116        /** \brief Move the telescope in the direction dir.
117            \return True if successful, false otherewise
118            \note This function is not implemented in INDI::Telescope, it must be implemented in the child class
119        */
120        virtual bool MoveNS(TelescopeMotionNS dir);
121
122        /** \brief Move the telescope in the direction dir.
123            \return True if successful, false otherewise
124            \note This function is not implemented in INDI::Telescope, it must be implemented in the child class
125        */
126        virtual bool MoveWE(TelescopeMotionWE dir);
127
128        /** \brief Part the telescope to its home position.
129            \return True if successful, false otherewise
130            \note This function is not implemented in INDI::Telescope, it must be implemented in the child class
131        */
132        virtual bool Park();
133
134
135        //  Since every mount I know of actually uses a serial port for control
136        //  We put the serial helper into the base telescope class
137        //  One less piece to worry about in the hardware specific
138        //  low level stuff
139        int PortFD;
140
141        //  This is a variable filled in by the ReadStatus telescope
142        //  low level code, used to report current state
143        //  are we slewing, tracking, or parked.
144        TelescopeStatus TrackState;
145
146        //  All telescopes should produce equatorial co-ordinates
147        INumberVectorProperty *EqNV;
148        INumber EqN[2];
149
150        //  And we need a vector to store requests, ie, where are we asked to go
151        INumberVectorProperty *EqReqNV;
152        INumber EqReqN[2];
153
154        ISwitchVectorProperty *CoordSV; //  A switch vector that stores how we should readct
155        ISwitch CoordS[3];              //  On a coord_set message, sync, or slew
156
157        ISwitchVectorProperty *ConfigSV; //  A switch vector that stores how we should readct
158        ISwitch ConfigS[3];              //  On a coord_set message, sync, or slew
159
160        INumberVectorProperty *LocationNV;   //  A number vector that stores lattitude and longitude
161        INumber LocationN[2];
162
163        ISwitchVectorProperty *ParkSV; //  A Switch in the client interface to park the scope
164        ISwitch ParkS[1];
165
166        ITextVectorProperty *PortTV; //  A text vector that stores out physical port name
167        IText PortT[1];
168
169        ISwitch MovementNSS[2];     // A switch for North/South motion
170        ISwitchVectorProperty *MovementNSSP;
171
172        ISwitch MovementWES[2];     // A switch for West/East motion
173        ISwitchVectorProperty *MovementWESP;
174
175
176};
177
178#endif // INDI::Telescope_H
Note: See TracBrowser for help on using the repository browser.