TelescopeControl.cpp   TelescopeControl.cpp 
skipping to change at line 75 skipping to change at line 75
return new TelescopeControl(); return new TelescopeControl();
} }
StelPluginInfo TelescopeControlStelPluginInterface::getPluginInfo() const StelPluginInfo TelescopeControlStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(TelescopeControl); Q_INIT_RESOURCE(TelescopeControl);
StelPluginInfo info; StelPluginInfo info;
info.id = "TelescopeControl"; info.id = "TelescopeControl";
info.displayedName = "Telescope Control"; info.displayedName = q_("Telescope Control");
info.authors = "Bogdan Marinov, Johannes Gajdosik"; info.authors = "Bogdan Marinov, Johannes Gajdosik";
info.contact = "http://stellarium.org"; info.contact = "http://stellarium.org";
info.description = "This plug-in allows Stellarium to send \"slew\" commands to a telescope on a computerized mount (a \"GoTo telescope\")."; info.description = q_("This plug-in allows Stellarium to send \"slew \" commands to a telescope on a computerized mount (a \"GoTo telescope\")." );
return info; return info;
} }
Q_EXPORT_PLUGIN2(TelescopeControl, TelescopeControlStelPluginInterface) Q_EXPORT_PLUGIN2(TelescopeControl, TelescopeControlStelPluginInterface)
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Constructor and destructor // Constructor and destructor
TelescopeControl::TelescopeControl() TelescopeControl::TelescopeControl()
{ {
setObjectName("TelescopeControl"); setObjectName("TelescopeControl");
skipping to change at line 143 skipping to change at line 143
because LandscapeMgr::getCallOrder() depended on the modul e's because LandscapeMgr::getCallOrder() depended on the modul e's
existence to return a value.*/ existence to return a value.*/
//Load and start all telescope clients //Load and start all telescope clients
loadTelescopes(); loadTelescopes();
//Load OpenGL textures //Load OpenGL textures
reticleTexture = StelApp::getInstance().getTextureManager(). createTexture(":/telescopeControl/telescope_reticle.png"); reticleTexture = StelApp::getInstance().getTextureManager(). createTexture(":/telescopeControl/telescope_reticle.png");
selectionTexture = StelApp::getInstance().getTextureManager( ).createTexture("textures/pointeur2.png"); selectionTexture = StelApp::getInstance().getTextureManager( ).createTexture("textures/pointeur2.png");
//Load the module's custom style sheets
QFile styleSheetFile;
styleSheetFile.setFileName(":/telescopeControl/normalStyle.c
ss");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
normalStyleSheet = new QByteArray(styleSheetFile.rea
dAll());
}
styleSheetFile.close();
styleSheetFile.setFileName(":/telescopeControl/nightStyle.cs
s");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
nightStyleSheet = new QByteArray(styleSheetFile.read
All());
}
styleSheetFile.close();
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
//Create telescope key bindings //Create telescope key bindings
/* QAction-s with these key bindings existed in Stellarium prior to /* QAction-s with these key bindings existed in Stellarium prior to
revision 6311. Any future backports should account f or that. */ revision 6311. Any future backports should account f or that. */
QString group = N_("Telescope Control"); QString group = N_("Telescope Control");
for (int i = MIN_SLOT_NUMBER; i <= MAX_SLOT_NUMBER; i++)
// "Slew to object" commands {
gui->addGuiActions("actionMove_Telescope_To_Selection_1", N_ // "Slew to object" commands
("Move telescope #1 to selected object"), "Ctrl+1", group, false, false); QString name = QString("actionMove_Telescope_To_Sele
gui->addGuiActions("actionMove_Telescope_To_Selection_2", N_ ction_%1").arg(i);
("Move telescope #2 to selected object"), "Ctrl+2", group, false, false); QString description = q_("Move telescope #%1 to sele
gui->addGuiActions("actionMove_Telescope_To_Selection_3", N_ cted object").arg(i);
("Move telescope #3 to selected object"), "Ctrl+3", group, false, false); QString shortcut = QString("Ctrl+%1").arg(i);
gui->addGuiActions("actionMove_Telescope_To_Selection_4", N_ gui->addGuiActions(name, description, shortcut, grou
("Move telescope #4 to selected object"), "Ctrl+4", group, false, false); p, false, false);
gui->addGuiActions("actionMove_Telescope_To_Selection_5", N_ connect(gui->getGuiActions(name), SIGNAL(triggered()
("Move telescope #5 to selected object"), "Ctrl+5", group, false, false); ), this, SLOT(slewTelescopeToSelectedObject()));
gui->addGuiActions("actionMove_Telescope_To_Selection_6", N_
("Move telescope #6 to selected object"), "Ctrl+6", group, false, false); // "Slew to the center of the screen" commands
gui->addGuiActions("actionMove_Telescope_To_Selection_7", N_ name = QString("actionSlew_Telescope_To_Direction_%1
("Move telescope #7 to selected object"), "Ctrl+7", group, false, false); ").arg(i);
gui->addGuiActions("actionMove_Telescope_To_Selection_8", N_ description = q_("Move telescope #%1 to the point cu
("Move telescope #8 to selected object"), "Ctrl+8", group, false, false); rrently in the center of the screen").arg(i);
gui->addGuiActions("actionMove_Telescope_To_Selection_9", N_ shortcut = QString("Alt+%1").arg(i);
("Move telescope #9 to selected object"), "Ctrl+9", group, false, false); gui->addGuiActions(name, description, shortcut, grou
p, false, false);
// "Slew to the center of the screen" commands connect(gui->getGuiActions(name), SIGNAL(triggered()
gui->addGuiActions("actionSlew_Telescope_To_Direction_1", N_ ), this, SLOT(slewTelescopeToViewDirection()));
("Move telescope #1 to the point currently in the center of the screen"), " }
Alt+1", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_2", N_
("Move telescope #2 to the point currently in the center of the screen"), "
Alt+2", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_3", N_
("Move telescope #3 to the point currently in the center of the screen"), "
Alt+3", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_4", N_
("Move telescope #4 to the point currently in the center of the screen"), "
Alt+4", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_5", N_
("Move telescope #5 to the point currently in the center of the screen"), "
Alt+5", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_6", N_
("Move telescope #6 to the point currently in the center of the screen"), "
Alt+6", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_7", N_
("Move telescope #7 to the point currently in the center of the screen"), "
Alt+7", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_8", N_
("Move telescope #8 to the point currently in the center of the screen"), "
Alt+8", group, false, false);
gui->addGuiActions("actionSlew_Telescope_To_Direction_9", N_
("Move telescope #9 to the point currently in the center of the screen"), "
Alt+9", group, false, false);
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_1"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_2"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_3"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_4"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_5"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_6"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_7"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_8"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionMove_Telescope_To_Selectio
n_9"), SIGNAL(triggered()), this, SLOT(slewTelescopeToSelectedObject()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_1"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_2"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_3"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_4"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_5"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_6"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_7"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_8"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
connect(gui->getGuiActions("actionSlew_Telescope_To_Directio
n_9"), SIGNAL(triggered()), this, SLOT(slewTelescopeToViewDirection()));
//Create and initialize dialog windows //Create and initialize dialog windows
telescopeDialog = new TelescopeDialog(); telescopeDialog = new TelescopeDialog();
slewDialog = new SlewDialog(); slewDialog = new SlewDialog();
//TODO: Think of a better keyboard shortcut //TODO: Think of a better keyboard shortcut
gui->addGuiActions("actionShow_Slew_Window", N_("Move a tele scope to a given set of coordinates"), "Ctrl+0", group, true, false); gui->addGuiActions("actionShow_Slew_Window", N_("Move a tele scope to a given set of coordinates"), "Ctrl+0", group, true, false);
connect(gui->getGuiActions("actionShow_Slew_Window"), SIGNAL (toggled(bool)), slewDialog, SLOT(setVisible(bool))); connect(gui->getGuiActions("actionShow_Slew_Window"), SIGNAL (toggled(bool)), slewDialog, SLOT(setVisible(bool)));
connect(slewDialog, SIGNAL(visibleChanged(bool)), gui->getGu iActions("actionShow_Slew_Window"), SLOT(setChecked(bool))); connect(slewDialog, SIGNAL(visibleChanged(bool)), gui->getGu iActions("actionShow_Slew_Window"), SLOT(setChecked(bool)));
skipping to change at line 338 skipping to change at line 297
setCircleColor(circleNightColor); setCircleColor(circleNightColor);
} }
else else
{ {
setLabelColor(labelNormalColor); setLabelColor(labelNormalColor);
setReticleColor(reticleNormalColor); setReticleColor(reticleNormalColor);
setCircleColor(circleNormalColor); setCircleColor(circleNormalColor);
} }
telescopeDialog->updateStyle(); telescopeDialog->updateStyle();
slewDialog->updateStyle();
} }
double TelescopeControl::getCallOrder(StelModuleActionName actionName) cons t double TelescopeControl::getCallOrder(StelModuleActionName actionName) cons t
{ {
//TODO: Remove magic number (call order offset) //TODO: Remove magic number (call order offset)
if (actionName == StelModule::ActionDraw) if (actionName == StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Mete orMgr")->getCallOrder(actionName) + 2.; return StelApp::getInstance().getModuleMgr().getModule("Mete orMgr")->getCallOrder(actionName) + 2.;
return 0.; return 0.;
} }
skipping to change at line 777 skipping to change at line 735
int slot = key.toInt(&ok); int slot = key.toInt(&ok);
if(!ok || !isValidSlotNumber(slot)) if(!ok || !isValidSlotNumber(slot))
{ {
qDebug() << "TelescopeControl::loadTelescope s(): Deleted node unrecogised as slot:" << key; qDebug() << "TelescopeControl::loadTelescope s(): Deleted node unrecogised as slot:" << key;
map.remove(key); map.remove(key);
continue; continue;
} }
QVariantMap telescope = node.value().toMap(); QVariantMap telescope = node.value().toMap();
//Essential parameters: Name and connection type //Essential parameters: Name, connection type, equin ox
//Validation: Name //Validation: Name
QString name = telescope.value("name").toString(); QString name = telescope.value("name").toString();
if(name.isEmpty()) if(name.isEmpty())
{ {
qDebug() << "TelescopeControl: Unable to loa d telescope: No name specified at slot" << key; qDebug() << "TelescopeControl: Unable to loa d telescope: No name specified at slot" << key;
map.remove(key); map.remove(key);
continue; continue;
} }
//Validation: Connection //Validation: Connection
QString connection = telescope.value("connection").t oString(); QString connection = telescope.value("connection").t oString();
if(connection.isEmpty() || !connectionTypeNames.valu es().contains(connection)) if(connection.isEmpty() || !connectionTypeNames.valu es().contains(connection))
{ {
qDebug() << "TelescopeControl: Unable to loa d telescope: No valid connection type at slot" << key; qDebug() << "TelescopeControl: Unable to loa d telescope: No valid connection type at slot" << key;
map.remove(key); map.remove(key);
continue; continue;
} }
ConnectionType connectionType = connectionTypeNames. key(connection); ConnectionType connectionType = connectionTypeNames. key(connection);
QString equinox = telescope.value("equinox", "J2000"
).toString();
if (equinox != "J2000" && equinox != "JNow")
{
qDebug() << "TelescopeControl: Unable to loa
d telescope: Invalid equinox value at slot" << key;
map.remove(key);
continue;
}
QString hostName("localhost"); QString hostName("localhost");
int portTCP = 0; int portTCP = 0;
int delay = 0; int delay = 0;
QString deviceModelName; QString deviceModelName;
QString portSerial; QString portSerial;
if (connectionType == ConnectionInternal) if (connectionType == ConnectionInternal)
{ {
//Serial port and device model //Serial port and device model
deviceModelName = telescope.value("device_mo del").toString(); deviceModelName = telescope.value("device_mo del").toString();
skipping to change at line 902 skipping to change at line 868
//Initialize a telescope client for this slot //Initialize a telescope client for this slot
//TODO: Improve the flow of control //TODO: Improve the flow of control
if(connectAtStartup) if(connectAtStartup)
{ {
if (connectionType == ConnectionInternal) if (connectionType == ConnectionInternal)
{ {
//Use a sever if necessary //Use a sever if necessary
if(deviceModels[deviceModelName].use Executable) if(deviceModels[deviceModelName].use Executable)
{ {
if(startClientAtSlot(slot, c onnectionType, name, hostName, portTCP, delay, internalCircles)) if(startClientAtSlot(slot, c onnectionType, name, equinox, hostName, portTCP, delay, internalCircles))
{ {
if(!startServerAtSlo t(slot, deviceModelName, portTCP, portSerial)) if(!startServerAtSlo t(slot, deviceModelName, portTCP, portSerial))
{ {
stopClientAt Slot(slot); stopClientAt Slot(slot);
qDebug() << "TelescopeControl: Unable to launch a telescope server at slot" << slot; qDebug() << "TelescopeControl: Unable to launch a telescope server at slot" << slot;
} }
} }
else else
{ {
qDebug() << "Telesco peControl: Unable to create a telescope client at slot" << slot; qDebug() << "Telesco peControl: Unable to create a telescope client at slot" << slot;
continue; //Unnecessary due to
if-else construction;
//also, causes bug #
608533
//continue;
} }
} }
else else
{ {
addLogAtSlot(slot); addLogAtSlot(slot);
logAtSlot(slot); logAtSlot(slot);
if(!startClientAtSlot(slot, connectionType, name, QString(), 0, delay, internalCircles, deviceModelName , portSerial)) if(!startClientAtSlot(slot, connectionType, name, equinox, QString(), 0, delay, internalCircles, device ModelName, portSerial))
{ {
qDebug() << "Telesco peControl: Unable to create a telescope client at slot" << slot; qDebug() << "Telesco peControl: Unable to create a telescope client at slot" << slot;
continue; //Unnecessary due to
if-else construction;
//also, causes bug #
608533
//continue;
} }
} }
} }
else else
{ {
if(!startClientAtSlot(slot, connecti onType, name, hostName, portTCP, delay, internalCircles)) if(!startClientAtSlot(slot, connecti onType, name, equinox, hostName, portTCP, delay, internalCircles))
{ {
qDebug() << "TelescopeContro l: Unable to create a telescope client at slot" << slot; qDebug() << "TelescopeContro l: Unable to create a telescope client at slot" << slot;
continue; //Unnecessary due to if-else
construction;
//also, causes bug #608533
//continue;
} }
} }
} }
//If this line is reached, the telescope at this slo t has been loaded successfully //If this line is reached, the telescope at this slo t has been loaded successfully
telescopesCount++; telescopesCount++;
} }
if(telescopesCount > 0) if(telescopesCount > 0)
{ {
skipping to change at line 956 skipping to change at line 928
} }
} }
catch(std::runtime_error &e) catch(std::runtime_error &e)
{ {
qWarning() << "TelescopeControl: Error loading telescopes: " << e.what(); qWarning() << "TelescopeControl: Error loading telescopes: " << e.what();
} }
telescopeDescriptions = result; telescopeDescriptions = result;
} }
bool TelescopeControl::addTelescopeAtSlot(int slot, ConnectionType connecti onType, QString name, QString host, int portTCP, int delay, bool connectAtS tartup, QList<double> circles, QString deviceModelName, QString portSerial) bool TelescopeControl::addTelescopeAtSlot(int slot, ConnectionType connecti onType, QString name, QString equinox, QString host, int portTCP, int delay , bool connectAtStartup, QList<double> circles, QString deviceModelName, QS tring portSerial)
{ {
//Validation //Validation
if(!isValidSlotNumber(slot) || name.isEmpty() || connectionType <= C onnectionNA || connectionType >= ConnectionCount) if(!isValidSlotNumber(slot) || name.isEmpty() || equinox.isEmpty() | | connectionType <= ConnectionNA || connectionType >= ConnectionCount)
return false; return false;
//Create a new map node and fill it with parameters //Create a new map node and fill it with parameters
QVariantMap telescope; QVariantMap telescope;
telescope.insert("name", name); telescope.insert("name", name);
telescope.insert("connection", connectionTypeNames.value(connectionT ype)); telescope.insert("connection", connectionTypeNames.value(connectionT ype));
telescope.insert("equinox", equinox);//TODO: Validation!
if (connectionType == ConnectionRemote) if (connectionType == ConnectionRemote)
{ {
//TODO: Add more validation! //TODO: Add more validation!
if (host.isEmpty()) if (host.isEmpty())
return false; return false;
telescope.insert("host_name", host); telescope.insert("host_name", host);
} }
if(connectionType == ConnectionInternal) if(connectionType == ConnectionInternal)
skipping to change at line 1012 skipping to change at line 985
for(int i = 0; i < circles.size(); i++) for(int i = 0; i < circles.size(); i++)
circleList.append(circles[i]); circleList.append(circles[i]);
telescope.insert("circles", circleList); telescope.insert("circles", circleList);
} }
telescopeDescriptions.insert(QString::number(slot), telescope); telescopeDescriptions.insert(QString::number(slot), telescope);
return true; return true;
} }
bool TelescopeControl::getTelescopeAtSlot(int slot, ConnectionType& connect ionType, QString& name, QString& host, int& portTCP, int& delay, bool& conn ectAtStartup, QList<double>& circles, QString& deviceModelName, QString& po rtSerial) bool TelescopeControl::getTelescopeAtSlot(int slot, ConnectionType& connect ionType, QString& name, QString& equinox, QString& host, int& portTCP, int& delay, bool& connectAtStartup, QList<double>& circles, QString& deviceMode lName, QString& portSerial)
{ {
//Validation //Validation
if(!isValidSlotNumber(slot)) if(!isValidSlotNumber(slot))
return false; return false;
//Read the node at that slot //Read the node at that slot
QVariantMap telescope = telescopeDescriptions.value(QString::number( slot)).toMap(); QVariantMap telescope = telescopeDescriptions.value(QString::number( slot)).toMap();
if(telescope.isEmpty()) if(telescope.isEmpty())
{ {
telescopeDescriptions.remove(QString::number(slot)); telescopeDescriptions.remove(QString::number(slot));
return false; return false;
} }
//Read the parameters //Read the parameters
name = telescope.value("name").toString(); name = telescope.value("name").toString();
equinox = telescope.value("equinox", "J2000").toString();
host = telescope.value("host_name").toString(); host = telescope.value("host_name").toString();
portTCP = telescope.value("tcp_port").toInt(); portTCP = telescope.value("tcp_port").toInt();
delay = telescope.value("delay", DEFAULT_DELAY).toInt(); delay = telescope.value("delay", DEFAULT_DELAY).toInt();
connectAtStartup = telescope.value("connect_at_startup", false).toBo ol(); connectAtStartup = telescope.value("connect_at_startup", false).toBo ol();
QVariantList circleList = telescope.value("circles").toList(); QVariantList circleList = telescope.value("circles").toList();
if(!circleList.isEmpty() && circleList.size() <= MAX_CIRCLE_COUNT) if(!circleList.isEmpty() && circleList.size() <= MAX_CIRCLE_COUNT)
{ {
for(int i = 0; i < circleList.size(); i++) for(int i = 0; i < circleList.size(); i++)
circles.append(circleList.value(i, -1.0).toDouble()) ; circles.append(circleList.value(i, -1.0).toDouble()) ;
skipping to change at line 1068 skipping to change at line 1042
} }
bool TelescopeControl::startTelescopeAtSlot(int slot) bool TelescopeControl::startTelescopeAtSlot(int slot)
{ {
//Validation //Validation
if(!isValidSlotNumber(slot)) if(!isValidSlotNumber(slot))
return false; return false;
//Read the telescope properties //Read the telescope properties
QString name; QString name;
QString equinox;
QString host; QString host;
ConnectionType connectionType; ConnectionType connectionType;
int portTCP; int portTCP;
int delay; int delay;
bool connectAtStartup; bool connectAtStartup;
QList<double> circles; QList<double> circles;
QString deviceModelName; QString deviceModelName;
QString portSerial; QString portSerial;
if(!getTelescopeAtSlot(slot, connectionType, name, host, portTCP, de lay, connectAtStartup, circles, deviceModelName, portSerial)) if(!getTelescopeAtSlot(slot, connectionType, name, equinox, host, po rtTCP, delay, connectAtStartup, circles, deviceModelName, portSerial))
{ {
//TODO: Add debug //TODO: Add debug
return false; return false;
} }
if(connectionType == ConnectionInternal && !deviceModelName.isEmpty( )) if(connectionType == ConnectionInternal && !deviceModelName.isEmpty( ))
{ {
if(deviceModels[deviceModelName].useExecutable) if(deviceModels[deviceModelName].useExecutable)
{ {
if (startClientAtSlot(slot, connectionType, name, ho st, portTCP, delay, circles)) if (startClientAtSlot(slot, connectionType, name, eq uinox, host, portTCP, delay, circles))
{ {
if(!startServerAtSlot(slot, deviceModelName, portTCP, portSerial)) if(!startServerAtSlot(slot, deviceModelName, portTCP, portSerial))
{ {
//If a server can't be started, remo ve the client too //If a server can't be started, remo ve the client too
stopClientAtSlot(slot); stopClientAtSlot(slot);
return false; return false;
} }
emit clientConnected(slot, name); emit clientConnected(slot, name);
return true; return true;
} }
} }
else else
{ {
addLogAtSlot(slot); addLogAtSlot(slot);
logAtSlot(slot); logAtSlot(slot);
if (startClientAtSlot(slot, connectionType, name, QS tring(), 0, delay, circles, deviceModelName, portSerial)) if (startClientAtSlot(slot, connectionType, name, eq uinox, QString(), 0, delay, circles, deviceModelName, portSerial))
{ {
emit clientConnected(slot, name); emit clientConnected(slot, name);
return true; return true;
} }
} }
} }
else else
{ {
if (startClientAtSlot(slot, connectionType, name, host, port TCP, delay, circles)) if (startClientAtSlot(slot, connectionType, name, equinox, h ost, portTCP, delay, circles))
{ {
emit clientConnected(slot, name); emit clientConnected(slot, name);
return true; return true;
} }
} }
return false; return false;
} }
bool TelescopeControl::stopTelescopeAtSlot(int slot) bool TelescopeControl::stopTelescopeAtSlot(int slot)
skipping to change at line 1207 skipping to change at line 1182
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qDebug() << "TelescopeControl: Error starting telesc ope server: Can't find executable:" << serverExecutablePath; qDebug() << "TelescopeControl: Error starting telesc ope server: Can't find executable:" << serverExecutablePath;
return false; return false;
} }
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
QString serialPortName; QString serialPortName;
if(portSerial.right(portSerial.size() - SERIAL_PORT_PREFIX.s ize()).toInt() > 9) if(portSerial.right(portSerial.size() - SERIAL_PORT_PREFIX.s ize()).toInt() > 9)
serialPortName = "\\\\.\\" + portSerial + ":";//"\\. \COMxx", not sure if it will work serialPortName = "\\\\.\\" + portSerial;//"\\.\COMxx ", not sure if it will work
else else
serialPortName = portSerial + ":"; serialPortName = portSerial;
#else #else
QString serialPortName = portSerial; QString serialPortName = portSerial;
#endif //Q_OS_WIN32 #endif //Q_OS_WIN32
QStringList serverArguments; QStringList serverArguments;
serverArguments << QString::number(portTCP) << serialPortNam e; serverArguments << QString::number(portTCP) << serialPortNam e;
if(useTelescopeServerLogs) if(useTelescopeServerLogs)
serverArguments << QString(StelFileMgr::getUserDir() + "/log_TelescopeServer" + slotName + ".txt"); serverArguments << QString(StelFileMgr::getUserDir() + "/log_TelescopeServer" + slotName + ".txt");
qDebug() << "TelescopeControl: Starting tellescope server at slot" << slotName << "with path" << serverExecutablePath << "and arguments " << serverArguments.join(" "); qDebug() << "TelescopeControl: Starting tellescope server at slot" << slotName << "with path" << serverExecutablePath << "and arguments " << serverArguments.join(" ");
skipping to change at line 1255 skipping to change at line 1230
telescopeServerProcess[slotNumber]->terminate(); telescopeServerProcess[slotNumber]->terminate();
#endif //Q_OS_WIN32 #endif //Q_OS_WIN32
telescopeServerProcess[slotNumber]->waitForFinished(); telescopeServerProcess[slotNumber]->waitForFinished();
delete telescopeServerProcess[slotNumber]; delete telescopeServerProcess[slotNumber];
telescopeServerProcess.remove(slotNumber); telescopeServerProcess.remove(slotNumber);
return true; return true;
} }
bool TelescopeControl::startClientAtSlot(int slotNumber, ConnectionType con nectionType, QString name, QString host, int portTCP, int delay, QList<doub le> circles, QString deviceModelName, QString portSerial) bool TelescopeControl::startClientAtSlot(int slotNumber, ConnectionType con nectionType, QString name, QString equinox, QString host, int portTCP, int delay, QList<double> circles, QString deviceModelName, QString portSerial)
{ {
//Validation //Validation
if(!isValidSlotNumber(slotNumber)) if(!isValidSlotNumber(slotNumber))
return false; return false;
//Check if it's not already running //Check if it's not already running
//Should it return, or should it remove the old one and proceed? //Should it return, or should it remove the old one and proceed?
if(telescopeClients.contains(slotNumber)) if(telescopeClients.contains(slotNumber))
{ {
//TODO: Add debug. Update logic? //TODO: Add debug. Update logic?
return false; return false;
} }
QString initString; QString initString;
switch (connectionType) switch (connectionType)
{ {
case ConnectionVirtual: case ConnectionVirtual:
initString = QString("%1:%2").arg(name, "TelescopeServerDumm y"); initString = QString("%1:%2:%3").arg(name, "TelescopeServerD ummy", "J2000");
break; break;
case ConnectionInternal: case ConnectionInternal:
if(!deviceModelName.isEmpty() && !portSerial.isEmpty()) if(!deviceModelName.isEmpty() && !portSerial.isEmpty())
initString = QString("%1:%2:%3:%4").arg(name, device Models[deviceModelName].server, portSerial, QString::number(delay)); initString = QString("%1:%2:%3:%4:%5").arg(name, dev iceModels[deviceModelName].server, equinox, portSerial, QString::number(del ay));
break; break;
case ConnectionLocal: case ConnectionLocal:
if (isValidPort(portTCP)) if (isValidPort(portTCP))
initString = QString("%1:TCP:%2:%3:%4").arg(name, "l ocalhost", QString::number(portTCP), QString::number(delay)); initString = QString("%1:TCP:%2:%3:%4:%5").arg(name, equinox, "localhost", QString::number(portTCP), QString::number(delay));
break; break;
case ConnectionRemote: case ConnectionRemote:
default: default:
if (isValidPort(portTCP) && !host.isEmpty()) if (isValidPort(portTCP) && !host.isEmpty())
initString = QString("%1:TCP:%2:%3:%4").arg(name, ho st, QString::number(portTCP), QString::number(delay)); initString = QString("%1:TCP:%2:%3:%4:%5").arg(name, equinox, host, QString::number(portTCP), QString::number(delay));
} }
qDebug() << "initString:" << initString; //qDebug() << "initString:" << initString;
TelescopeClient* newTelescope = TelescopeClient::create(initString); TelescopeClient* newTelescope = TelescopeClient::create(initString);
if (newTelescope) if (newTelescope)
{ {
//Add FOV circles to the client if there are any specified //Add FOV circles to the client if there are any specified
if(!circles.isEmpty() && circles.size() <= MAX_CIRCLE_COUNT) if(!circles.isEmpty() && circles.size() <= MAX_CIRCLE_COUNT)
for (int i = 0; i < circles.size(); ++i) for (int i = 0; i < circles.size(); ++i)
newTelescope->addOcular(circles[i]); newTelescope->addOcular(circles[i]);
telescopeClients.insert(slotNumber, TelescopeClientP(newTele scope)); telescopeClients.insert(slotNumber, TelescopeClientP(newTele scope));
skipping to change at line 1524 skipping to change at line 1499
qWarning() << "TelescopeControl: Unable to copy the default device models list to" << deviceModelsListPath; qWarning() << "TelescopeControl: Unable to copy the default device models list to" << deviceModelsListPath;
return false; return false;
} }
QFile newCopy(deviceModelsListPath); QFile newCopy(deviceModelsListPath);
newCopy.setPermissions(newCopy.permissions() | QFile::WriteOwner); newCopy.setPermissions(newCopy.permissions() | QFile::WriteOwner);
qDebug() << "TelescopeControl: The default device models list has be en copied to" << deviceModelsListPath; qDebug() << "TelescopeControl: The default device models list has be en copied to" << deviceModelsListPath;
return true; return true;
} }
const StelStyle TelescopeControl::getModuleStyleSheet(const StelStyle& styl
e)
{
StelStyle pluginStyle(style);
if (style.confSectionName == "color")
{
pluginStyle.qtStyleSheet.append(*normalStyleSheet);
}
else
{
pluginStyle.qtStyleSheet.append(*nightStyleSheet);
}
return pluginStyle;
}
const QString& TelescopeControl::getServerExecutablesDirectoryPath() const QString& TelescopeControl::getServerExecutablesDirectoryPath()
{ {
return serverExecutablesDirectoryPath; return serverExecutablesDirectoryPath;
} }
bool TelescopeControl::setServerExecutablesDirectoryPath(const QString& new Path) bool TelescopeControl::setServerExecutablesDirectoryPath(const QString& new Path)
{ {
//TODO: Reuse code. //TODO: Reuse code.
QDir newServerDirectory(newPath); QDir newServerDirectory(newPath);
if(!newServerDirectory.exists()) if(!newServerDirectory.exists())
 End of changes. 32 change blocks. 
146 lines changed or deleted 72 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/