Commit c72fe46c authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Fix dust cap issues and attemp reconnection upon failure

parent 158754a1
......@@ -79,7 +79,7 @@ bool DustCap::park()
return currentDustCap->Park();
}
bool DustCap::unPark()
bool DustCap::unpark()
{
if (currentDustCap == NULL)
return false;
......@@ -87,6 +87,14 @@ bool DustCap::unPark()
return currentDustCap->UnPark();
}
bool DustCap::canPark()
{
if (currentDustCap == NULL)
return false;
return currentDustCap->canPark();
}
bool DustCap::hasLight()
{
if (currentDustCap == NULL)
......
......@@ -43,6 +43,12 @@ public:
/*@{*/
/** DBUS interface function.
* If dust cap can park/unpark or is it just a light source?
* @return True if park is supported, false otherwise
*/
Q_SCRIPTABLE bool canPark();
/** DBUS interface function.
* Park / Close dust cap
* @return True if operation started/successful, false otherwise
......@@ -53,7 +59,7 @@ public:
* UnPark / Open dust cap
* @return True if operation started/successful, false otherwise
*/
Q_SCRIPTABLE bool unPark();
Q_SCRIPTABLE bool unpark();
/** DBUS interface function.
* hasLight: Does the dust cap have a flat light source?
......
......@@ -57,6 +57,8 @@ Scheduler::Scheduler()
Dawn = -1;
Dusk = -1;
indiConnectFailureCount=0;
noWeatherCounter=0;
weatherStatus=IPS_IDLE;
......@@ -131,6 +133,13 @@ Scheduler::Scheduler()
connect(focusModuleCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(alignModuleCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(guideModuleCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(capCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(uncapCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(parkMountCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(unparkMountCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(parkDomeCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(unparkDomeCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
connect(warmCCDCheck, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
}
Scheduler::~Scheduler()
......@@ -616,12 +625,21 @@ void Scheduler::stop()
// Only reset startup state to idle if the startup procedure was interrupted before it had the chance to complete.
// Or if we're doing a soft shutdown
if (startupState != STARTUP_COMPLETE || preemptiveShutdown)
{
if (startupState == STARTUP_SCRIPT)
{
scriptProcess.disconnect();
scriptProcess.terminate();
}
startupState = STARTUP_IDLE;
}
shutdownState = SHUTDOWN_IDLE;
currentJob = NULL;
captureBatch =0;
indiConnectFailureCount=0;
jobEvaluationOnly=false;
// If soft shutdown, we return for now
......@@ -1546,11 +1564,15 @@ bool Scheduler::checkINDIState()
}
else if(isINDIConnected.value()== EkosManager::STATUS_ERROR)
{
appendLogText(i18n("INDI devices failed to connect. Check INDI control panel for details."));
if (indiConnectFailureCount++ < 3)
{
appendLogText(i18n("One or more INDI devices failed to connect. Retrying..."));
ekosInterface->call(QDBus::AutoDetect,"connectDevices");
return false;
}
appendLogText(i18n("INDI devices failed to connect. Check INDI control panel for details."));
stop();
// TODO deal with INDI connection error? Wait until user resolves it? stop scheduler?
return false;
}
else
......@@ -1592,11 +1614,11 @@ bool Scheduler::checkINDIState()
else
weatherCheck->setEnabled(false);
QDBusReply<int> capReply = capInterface->call(QDBus::AutoDetect, "hasLight");
QDBusReply<bool> capReply = capInterface->call(QDBus::AutoDetect, "canPark");
if (capReply.error().type() == QDBusError::NoError)
{
capCheck->setEnabled(true);
uncapCheck->setEnabled(true);
capCheck->setEnabled(capReply.value());
uncapCheck->setEnabled(capReply.value());
}
else
{
......@@ -2720,7 +2742,7 @@ bool Scheduler::saveScheduler(const QUrl &fileURL)
if (warmCCDCheck->isChecked())
outstream << "<Procedure>WarmCCD</Procedure>" << endl;
if (capCheck->isChecked())
outstream << "<Procedure>CapMount</Procedure>" << endl;
outstream << "<Procedure>ParkCap</Procedure>" << endl;
if (parkMountCheck->isChecked())
outstream << "<Procedure>ParkMount</Procedure>" << endl;
if (parkDomeCheck->isChecked())
......@@ -2956,11 +2978,12 @@ void Scheduler::setGOTOMode(Align::GotoMode mode)
void Scheduler::stopINDI()
{
ekosInterface->call(QDBus::AutoDetect,"disconnectDevices");
indiConnectFailureCount=0;
ekosInterface->call(QDBus::AutoDetect,"disconnectDevices");
startupState = STARTUP_IDLE;
shutdownState= SHUTDOWN_IDLE;
weatherStatus= IPS_IDLE;
startupState = STARTUP_IDLE;
shutdownState= SHUTDOWN_IDLE;
weatherStatus= IPS_IDLE;
}
void Scheduler::setDirty()
......@@ -3313,7 +3336,7 @@ void Scheduler::unParkCap()
if (status != DustCap::UNPARKING_OK)
{
startupState = STARTUP_UNPARKING_CAP;
domeInterface->call(QDBus::AutoDetect,"unpark");
capInterface->call(QDBus::AutoDetect,"unpark");
appendLogText(i18n("Unparking cap..."));
}
else if (status == DustCap::UNPARKING_OK)
......
......@@ -431,6 +431,7 @@ private:
QTimer weatherTimer; // Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device.
QTimer sleepTimer; // Timer to put the scheduler into sleep mode until a job is ready
uint8_t noWeatherCounter; // Keep track of how many times we didn't receive weather updates
uint8_t indiConnectFailureCount;// Keep track of how many times we didn't receive weather updates
bool preemptiveShutdown; // Are we shutting down until later?
bool jobEvaluationOnly; // Only run job evaluation
......
......@@ -38,28 +38,23 @@ void DustCap::processText(ITextVectorProperty *tvp)
}
bool DustCap::isParked()
bool DustCap::canPark()
{
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("DUST_COVER");
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("CAP_PARK");
if (parkSP == NULL)
return false;
ISwitch *parkSW = IUFindSwitch(parkSP, "DUST_COVER_CLOSE");
if (parkSW == NULL)
return false;
return ( (parkSW->s == ISS_ON) && parkSP->s == IPS_OK);
else
return true;
}
bool DustCap::Park()
{
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("DUST_COVER");
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("CAP_PARK");
if (parkSP == NULL)
return false;
ISwitch *parkSW = IUFindSwitch(parkSP, "DUST_COVER_CLOSE");
ISwitch *parkSW = IUFindSwitch(parkSP, "PARK");
if (parkSW == NULL)
return false;
......@@ -72,11 +67,11 @@ bool DustCap::Park()
bool DustCap::UnPark()
{
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("DUST_COVER");
ISwitchVectorProperty *parkSP = baseDevice->getSwitch("CAP_PARK");
if (parkSP == NULL)
return false;
ISwitch *parkSW = IUFindSwitch(parkSP, "DUST_COVER_OPEN");
ISwitch *parkSW = IUFindSwitch(parkSP, "UNPARK");
if (parkSW == NULL)
return false;
......
......@@ -37,7 +37,7 @@ public:
DeviceFamily getType() { return dType;}
bool hasLight();
bool isParked();
bool canPark();
public slots:
/**
......
......@@ -4,10 +4,13 @@
<method name="getParkingStatus">
<arg type="i" direction="out"/>
</method>
<method name="canPark">
<arg type="b" direction="out"/>
</method>
<method name="park">
<arg type="b" direction="out"/>
</method>
<method name="unPark">
<method name="unpark">
<arg type="b" direction="out"/>
</method>
<method name="hasLight">
......
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