Telescope.hpp   Telescope.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _TELESCOPE_HPP_ #ifndef _TELESCOPE_HPP_
#define _TELESCOPE_HPP_ #define _TELESCOPE_HPP_
#include <QHostAddress>
#include <QHostInfo>
#include <QList> #include <QList>
#include <QString> #include <QString>
#include <QTcpSocket>
#if defined (_MSC_VER) #include <QObject>
#include <winsock2.h>
#endif
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
long long int GetNow(void); qint64 getNow(void);
#ifdef __MINGW32__
struct fd_set;
#endif
class Telescope : public StelObject class Telescope : public QObject, public StelObject
{ {
Q_OBJECT
public: public:
static Telescope *create(const QString &url); static Telescope *create(const QString &url);
virtual ~Telescope(void) {} virtual ~Telescope(void) {}
// Method inherited from StelObject // Method inherited from StelObject
QString getEnglishName(void) const {return name;} QString getEnglishName(void) const {return name;}
QString getNameI18n(void) const {return nameI18n;} QString getNameI18n(void) const {return nameI18n;}
//! Telescope supports the following InfoStringGroup flags: //! Telescope supports the following InfoStringGroup flags:
//! - Name //! - Name
//! - RaDecJ2000 //! - RaDecJ2000
skipping to change at line 68 skipping to change at line 65
virtual double getAngularSize(const StelCore* core) const {Q_ASSERT( 0); return 0;} // TODO virtual double getAngularSize(const StelCore* core) const {Q_ASSERT( 0); return 0;} // TODO
// Methods specific to telescope // Methods specific to telescope
virtual void telescopeGoto(const Vec3d &j2000Pos) = 0; virtual void telescopeGoto(const Vec3d &j2000Pos) = 0;
virtual bool isConnected(void) const = 0; virtual bool isConnected(void) const = 0;
virtual bool hasKnownPosition(void) const = 0; virtual bool hasKnownPosition(void) const = 0;
void addOcular(double fov) {if (fov>=0.0) oculars.push_back(fov);} void addOcular(double fov) {if (fov>=0.0) oculars.push_back(fov);}
const QList<double> &getOculars(void) const {return oculars;} const QList<double> &getOculars(void) const {return oculars;}
// all TCP (and all possible other style) communication shall be don e in these functions: // all TCP (and all possible other style) communication shall be don e in these functions:
virtual void prepareSelectFds(fd_set &read_fds,fd_set &write_fds, in virtual bool prepareCommunication() {return false;}
t &fdmax) = 0; virtual void performCommunication() {}
virtual void handleSelectFds(const fd_set &read_fds, const fd_set &w
rite_fds) {}
protected: protected:
Telescope(const QString &name); Telescope(const QString &name);
QString nameI18n; QString nameI18n;
const QString name; const QString name;
private: private:
bool isInitialized(void) const {return true;} bool isInitialized(void) const {return true;}
float getSelectPriority(const StelNavigator *nav) const {return -10. f;} float getSelectPriority(const StelNavigator *nav) const {return -10. f;}
private: private:
QList<double> oculars; // fov of the oculars QList<double> oculars; // fov of the oculars
}; };
//! This Telescope class can controll a telescope by communicating
//! to a server process ("telescope server") via
//! the "Stellarium telescope control protocol" over TCP/IP.
//! The "Stellarium telescope control protocol" is specified in a seperate
//! document along with the telescope server software.
class TelescopeTcp : public Telescope
{
Q_OBJECT
public:
TelescopeTcp(const QString &name,const QString &params);
~TelescopeTcp(void)
{
hangup();
}
private:
bool isConnected(void) const
{
//return (tcpSocket->isValid() && !wait_for_connection_estab
lishment);
return (tcpSocket->state() == QAbstractSocket::ConnectedStat
e);
}
Vec3d getJ2000EquatorialPos(const StelNavigator *nav=0) const;
bool prepareCommunication();
void performCommunication();
void telescopeGoto(const Vec3d &j2000Pos);
bool isInitialized(void) const
{
return (!address.isNull());
}
void performReading(void);
void performWriting(void);
private:
void hangup(void);
void resetPositions(void);
QHostAddress address;
unsigned int port;
QTcpSocket * tcpSocket;
bool wait_for_connection_establishment;
qint64 end_of_timeout;
char readBuffer[120];
char *readBufferEnd;
char writeBuffer[120];
char *writeBufferEnd;
int time_delay;
struct Position
{
qint64 server_micros;
qint64 client_micros;
Vec3d pos;
int status;
};
Position positions[16];
Position *position_pointer;
Position *const end_position;
virtual bool hasKnownPosition(void) const
{
return (position_pointer->client_micros != 0x7FFFFFFFFFFFFFF
FLL);
}
private slots:
void socketFailed(QAbstractSocket::SocketError socketError);
};
#endif // _TELESCOPE_HPP_ #endif // _TELESCOPE_HPP_
 End of changes. 7 change blocks. 
14 lines changed or deleted 73 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/