Commit 83c38c22 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

The telescope cursor should correspond to the device label not name.

svn path=/trunk/kdeedu/kstars/; revision=287350
parent a6cdff84
......@@ -300,19 +300,16 @@ INDI_D * DeviceManager::addDevice (XMLEle *dep, char errmsg[])
if (!ap)
return NULL;
// FIXME change the mechanism by which naming is assiged.
// Make a list (QStristList or something) that holds active devices
// And each new device should be checked against this list.
if (parent->currentLabel.isEmpty())
parent->setCustomLabel(valuXMLAtt(ap));
//fprintf(stderr, "\n\n\n ***************** Adding a device %s with label %s *************** \n\n\n", valuXMLAtt(ap), label);
dp = new INDI_D(parent, this, QString(valuXMLAtt(ap)), parent->currentLabel);
parent->currentLabel = "";
indi_dev.append(dp);
// Reset label
parent->currentLabel = "";
/* ok */
return dp;
}
......
......@@ -179,13 +179,21 @@ close(fd);
int testTelescope()
{
int i=0;
char ack[1] = { (char) 0x06 };
char MountAlign[64];
fprintf(stderr, "Testing telescope's connection...\n");
write(fd, ack, 1);
for (i=0; i < 2; i++)
{
write(fd, ack, 1);
read_ret = portRead(MountAlign, 1, LX200_TIMEOUT);
if (read_ret == 1)
return 0;
usleep(50000);
}
return (portRead(MountAlign, 1, LX200_TIMEOUT) == 1 ? 0 : -1);
return -1;
}
/**********************************************************************
......
......@@ -290,6 +290,7 @@ LX200Generic::LX200Generic()
currentSubCatalog = 0;
trackingMode = LX200_TRACK_DEFAULT;
fault = false;
targetRA = 0;
targetDEC = 0;
currentRA = 0;
......@@ -746,6 +747,8 @@ void LX200Generic::ISNewSwitch (const char *dev, const char *name, ISState *stat
return;
lastSet = getOnSwitch(states, n);
OnCoordSetSw.s = IPS_OK;
IDSetSwitch(&OnCoordSetSw, NULL);
/*handleCoordSet();*/
}
......@@ -1088,11 +1091,13 @@ void LX200Generic::handleError(ISwitchVectorProperty *svp, int err, const char *
if (err == -2)
{
svp->s = IPS_ALERT;
IDSetSwitch(svp, "Device timed out. Current device may be busy or does not support %s.", msg);
IDSetSwitch(svp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
}
else
/* Changing property failed, user should retry. */
IDSetSwitch( svp , "%s failed.", msg);
fault = true;
}
void LX200Generic::handleError(INumberVectorProperty *nvp, int err, const char *msg)
......@@ -1119,11 +1124,13 @@ void LX200Generic::handleError(INumberVectorProperty *nvp, int err, const char *
if (err == -2)
{
nvp->s = IPS_ALERT;
IDSetNumber(nvp, "Device timed out. Current device may be busy or does not support %s.", msg);
IDSetNumber(nvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
}
else
/* Changing property failed, user should retry. */
IDSetNumber( nvp , "%s failed.", msg);
fault = true;
}
void LX200Generic::handleError(ITextVectorProperty *tvp, int err, const char *msg)
......@@ -1150,14 +1157,24 @@ void LX200Generic::handleError(ITextVectorProperty *tvp, int err, const char *ms
if (err == -2)
{
tvp->s = IPS_ALERT;
IDSetText(tvp, "Device timed out. Current device may be busy or does not support %s.", msg);
IDSetText(tvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
}
else
/* Changing property failed, user should retry. */
IDSetText( tvp , "%s failed.", msg);
fault = true;
}
void LX200Generic::correctFault()
{
fault = false;
IDMessage(thisDevice, "Telescope is online.");
}
bool LX200Generic::isTelescopeOn(void)
{
return (PowerSw.sp[0].s == ISS_ON);
......@@ -1193,13 +1210,6 @@ void LX200Generic::ISPoll()
switch (eqNum.s)
{
case IPS_IDLE:
/*if ( (err = getLX200RA(&currentRA)) < 0 || (err = getLX200DEC(&currentDEC)) < 0)
{
handleError(&eqNum, err, "Getting RA/DEC");
return;
}
*/
getLX200RA(&currentRA);
getLX200DEC(&currentDEC);
......@@ -1286,6 +1296,9 @@ void LX200Generic::ISPoll()
handleError(&eqNum, err, "Getting RA/DEC");
return;
}
if (fault)
correctFault();
if ( fabs (currentRA - lastRA) > 0.01 || fabs (currentDEC - lastDEC) > 0.01)
{
......
......@@ -53,6 +53,7 @@ class LX200Generic
int handleCoordSet();
int getOnSwitch(ISState * states, int n);
void setCurrectDeviceName(const char * devName);
void correctFault();
protected:
......@@ -69,6 +70,7 @@ class LX200Generic
double targetDEC;
double lastRA;
double lastDEC;
bool fault;
struct tm *localTM;
......
......@@ -166,7 +166,7 @@ void SkyMap::drawTelescopeSymbols(QPainter &psky) {
psky.drawEllipse( x2, y2, s2, s2 );
//FIXME the label is not displayed optimally (needs to be somewhat centered vertically)
psky.drawText( x0+s2 + 2 , y0, QString(devMenu->mgr.at(i)->indi_dev.at(j)->name) );
psky.drawText( x0+s2 + 2 , y0, QString(devMenu->mgr.at(i)->indi_dev.at(j)->label) );
}
}
......
......@@ -80,8 +80,11 @@ telescopeWizardProcess::telescopeWizardProcess( QWidget* parent, const char* nam
if (indidriver->devices[i]->deviceType == KSTARS_TELESCOPE)
telescopeCombo->insertItem(indidriver->devices[i]->label);
portList << "/dev/ttyS0" << "/dev/ttyS1" << "/dev/ttyS2" << "/dev/ttyS3" << "/dev/ttyS4"
<< "/dev/ttyUSB0" << "/dev/ttyUSB1" << "/dev/ttyUSB2" << "/dev/ttyUSB3";// << "/dev/ttyUSB4";
if (!ksw->options()->indiPortName.isEmpty())
portList << ksw->options()->indiPortName;
portList << "/dev/ttyS0" << "/dev/ttyS1" << "/dev/ttyS2" << "/dev/ttyS3" << "/dev/ttyS4"
<< "/dev/ttyUSB0" << "/dev/ttyUSB1" << "/dev/ttyUSB2" << "/dev/ttyUSB3";// << "/dev/ttyUSB4";
connect(helpB, SIGNAL(clicked()), parent, SLOT(appHelpActivated()));
connect(nextB, SIGNAL(clicked()), this, SLOT(processNext()));
......@@ -231,7 +234,6 @@ int telescopeWizardProcess::establishLink()
indimenu->setCustomLabel(telescopeCombo->currentText());
currentDevice = indimenu->currentLabel;
//indimenu->currentLabel = "";
if (driverItem)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment