TelescopeClient.cpp   TelescopeClient.cpp 
skipping to change at line 43 skipping to change at line 43
#include <cmath> #include <cmath>
#include <QDebug> #include <QDebug>
#include <QHostAddress> #include <QHostAddress>
#include <QHostInfo> #include <QHostInfo>
#include <QRegExp> #include <QRegExp>
#include <QString> #include <QString>
#include <QTcpSocket> #include <QTcpSocket>
#include <QTextStream> #include <QTextStream>
#ifdef WIN32 #ifdef Q_OS_WIN32
#include <windows.h> // GetSystemTimeAsFileTime() #include <windows.h> // GetSystemTimeAsFileTime()
#else #else
#include <sys/time.h> #include <sys/time.h>
#endif #endif
TelescopeClient *TelescopeClient::create(const QString &url) TelescopeClient *TelescopeClient::create(const QString &url)
{ {
// example url: My_first_telescope:TCP:localhost:10000:500000 // example url: My_first_telescope:TCP:localhost:10000:500000
// split to: // split to:
// name = My_first_telescope // name = My_first_telescope
skipping to change at line 132 skipping to change at line 132
oss << "<h2>" << nameI18n << "</h2>"; oss << "<h2>" << nameI18n << "</h2>";
} }
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
#ifndef COMPATIBILITY_001003 //Duplicate function definition causes errors
during static linking
//! returns the current system time in microseconds since the Epoch //! returns the current system time in microseconds since the Epoch
//! Prior to revision 6308, it was necessary to put put this method in an
//! #ifdef block, as duplicate function definition caused errors during sta
tic
//! linking.
qint64 getNow(void) qint64 getNow(void)
{ {
// At the moment this can't be done in a platform-independent way with Qt // At the moment this can't be done in a platform-independent way with Qt
// (QDateTime and QTime don't support microsecond precision) // (QDateTime and QTime don't support microsecond precision)
#ifdef WIN32 #ifdef Q_OS_WIN32
FILETIME file_time; FILETIME file_time;
GetSystemTimeAsFileTime(&file_time); GetSystemTimeAsFileTime(&file_time);
return (*((__int64*)(&file_time))/10) - 86400000000LL*134774; return (*((__int64*)(&file_time))/10) - 86400000000LL*134774;
#else #else
struct timeval tv; struct timeval tv;
gettimeofday(&tv,0); gettimeofday(&tv,0);
return tv.tv_sec * 1000000LL + tv.tv_usec; return tv.tv_sec * 1000000LL + tv.tv_usec;
#endif #endif
} }
#endif //COMPATIBILITY_001003
TelescopeTCP::TelescopeTCP(const QString &name, const QString &params) : TelescopeTCP::TelescopeTCP(const QString &name, const QString &params) :
TelescopeClient(name), TelescopeClient(name),
tcpSocket(new QTcpSocket()), tcpSocket(new QTcpSocket()),
end_position(positions+(sizeof(positions)/sizeof (positions[0]))) end_position(positions+(sizeof(positions)/sizeof (positions[0])))
{ {
hangup(); hangup();
// Example params: // Example params:
// localhost:10000:500000 // localhost:10000:500000
// split into: // split into:
skipping to change at line 266 skipping to change at line 265
//! queues a GOTO command with the specified position to the write buffer. //! queues a GOTO command with the specified position to the write buffer.
//! For the data format of the command see the //! For the data format of the command see the
//! "Stellarium telescope control protocol" text file //! "Stellarium telescope control protocol" text file
void TelescopeTCP::telescopeGoto(const Vec3d &j2000Pos) void TelescopeTCP::telescopeGoto(const Vec3d &j2000Pos)
{ {
if (isConnected()) if (isConnected())
{ {
if (writeBufferEnd - writeBuffer + 20 < (int)sizeof(writeBuf fer)) if (writeBufferEnd - writeBuffer + 20 < (int)sizeof(writeBuf fer))
{ {
const double ra = atan2(j2000Pos[1], j2000Pos[0]); const double ra_signed = atan2(j2000Pos[1], j2000Pos
[0]);
//Workaround for the discrepancy in precision betwee
n Windows/Linux/PPC Macs and Intel Macs:
const double ra = (ra_signed >= 0) ? ra_signed : (ra
_signed + 2.0 * M_PI);
const double dec = atan2(j2000Pos[2], sqrt(j2000Pos[ 0]*j2000Pos[0]+j2000Pos[1]*j2000Pos[1])); const double dec = atan2(j2000Pos[2], sqrt(j2000Pos[ 0]*j2000Pos[0]+j2000Pos[1]*j2000Pos[1]));
unsigned int ra_int = (unsigned int)floor(0.5 + ra*( ((unsigned int)0x80000000)/M_PI)); unsigned int ra_int = (unsigned int)floor(0.5 + ra*( ((unsigned int)0x80000000)/M_PI));
int dec_int = (int)floor(0.5 + dec*(((unsigned int)0 x80000000)/M_PI)); int dec_int = (int)floor(0.5 + dec*(((unsigned int)0 x80000000)/M_PI));
// length of packet: // length of packet:
*writeBufferEnd++ = 20; *writeBufferEnd++ = 20;
*writeBufferEnd++ = 0; *writeBufferEnd++ = 0;
// type of packet: // type of packet:
*writeBufferEnd++ = 0; *writeBufferEnd++ = 0;
*writeBufferEnd++ = 0; *writeBufferEnd++ = 0;
// client_micros: // client_micros:
skipping to change at line 542 skipping to change at line 543
if (tcpSocket->bytesAvailable() > 0) if (tcpSocket->bytesAvailable() > 0)
{ {
//If performReading() is called when there are no by tes to read, //If performReading() is called when there are no by tes to read,
//it closes the connection //it closes the connection
performReading(); performReading();
} }
} }
} }
//TODO: More informative error messages? //TODO: More informative error messages?
void TelescopeTCP::socketFailed(QAbstractSocket::SocketError socketError) void TelescopeTCP::socketFailed(QAbstractSocket::SocketError)
{ {
qDebug() << "TelescopeTCP(" << name << "): TCP socket error:\n" << t cpSocket->errorString(); qDebug() << "TelescopeTCP(" << name << "): TCP socket error:\n" << t cpSocket->errorString();
} }
 End of changes. 7 change blocks. 
9 lines changed or deleted 13 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/