diff --git a/kstars/ekos/observatory/observatory.cpp b/kstars/ekos/observatory/observatory.cpp --- a/kstars/ekos/observatory/observatory.cpp +++ b/kstars/ekos/observatory/observatory.cpp @@ -402,7 +402,7 @@ QCPGraphData last = graphDataVector->last(); graphDataVector->clear(); QDateTime when = QDateTime(); - when.setSecsSinceEpoch(static_cast(last.key)); + when.setTime_t(static_cast(last.key)); updateSensorGraph(it->first, when, last.value); } } @@ -545,7 +545,7 @@ } // store the data - sensorGraphData[id]->append(QCPGraphData(static_cast(now.toSecsSinceEpoch()), value)); + sensorGraphData[id]->append(QCPGraphData(static_cast(now.toTime_t()), value)); // add data for the graphs we display if (selectedSensorID == id) @@ -624,11 +624,12 @@ if (graph) { int index = sensorGraphs->graph(0)->findBegin(key); - double value = sensorGraphs->graph(0)->dataMainValue(index); + double value = sensorGraphs->graph(0)->dataMainValue(index); + QDateTime when = QDateTime::fromTime_t(sensorGraphs->graph(0)->dataMainKey(index)); QToolTip::showText( event->globalPos(), - i18n("%1 = %2", selectedSensorID, value)); + i18n("%1 = %2 @ %3", selectedSensorID, value, when.toString("hh:mm"))); } else { QToolTip::hideText(); @@ -732,8 +733,7 @@ // create the universal graph QCPGraph *graph = sensorGraphs->addGraph(); - graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 0), QBrush(Qt::green), 5)); - graph->setPen(QPen(Qt::darkGreen)); + graph->setPen(QPen(Qt::darkGreen, 2)); graph->setBrush(QColor(10, 100, 50, 70)); // ensure that the 0-line is visible @@ -787,16 +787,32 @@ void Observatory::setWarningActions(WeatherActions actions) { - weatherWarningDomeCB->setChecked(actions.parkDome); - weatherWarningShutterCB->setChecked(actions.closeShutter); + if (getDomeModel() != nullptr) + weatherWarningDomeCB->setChecked(actions.parkDome); + else + weatherWarningDomeCB->setChecked(actions.parkDome); + + if (getDomeModel() != nullptr && getDomeModel()->hasShutter()) + weatherWarningShutterCB->setChecked(actions.closeShutter); + else + weatherWarningShutterCB->setChecked(actions.closeShutter); + weatherWarningDelaySB->setValue(static_cast(actions.delay)); } void Observatory::setAlertActions(WeatherActions actions) { - weatherAlertDomeCB->setChecked(actions.parkDome); - weatherAlertShutterCB->setChecked(actions.closeShutter); + if (getDomeModel() != nullptr) + weatherAlertDomeCB->setChecked(actions.parkDome); + else + weatherAlertDomeCB->setChecked(false); + + if (getDomeModel() != nullptr && getDomeModel()->hasShutter()) + weatherAlertShutterCB->setChecked(actions.closeShutter); + else + weatherAlertShutterCB->setChecked(false); + weatherAlertDelaySB->setValue(static_cast(actions.delay)); } diff --git a/kstars/ekos/observatory/observatoryweathermodel.h b/kstars/ekos/observatory/observatoryweathermodel.h --- a/kstars/ekos/observatory/observatoryweathermodel.h +++ b/kstars/ekos/observatory/observatoryweathermodel.h @@ -83,13 +83,16 @@ struct WeatherActions warningActions, alertActions; bool warningActionsActive, alertActionsActive; + void startAlertTimer(); + void startWarningTimer(); + // hold all sensor data received from the weather station std::vector m_WeatherData; // update the stored values void updateWeatherData(std::vector entries); unsigned long findWeatherData(QString name); - private slots: +private slots: void weatherChanged(ISD::Weather::Status status); void updateWeatherStatus(); diff --git a/kstars/ekos/observatory/observatoryweathermodel.cpp b/kstars/ekos/observatory/observatoryweathermodel.cpp --- a/kstars/ekos/observatory/observatoryweathermodel.cpp +++ b/kstars/ekos/observatory/observatoryweathermodel.cpp @@ -31,13 +31,15 @@ warningActions.parkDome = Options::weatherWarningCloseDome(); warningActions.closeShutter = Options::weatherWarningCloseShutter(); warningActions.delay = Options::weatherWarningDelay(); - warningActions.stopScheduler = Options::weatherAlertStopScheduler(); alertActionsActive = Options::alertActionsActive(); alertActions.parkDome = Options::weatherAlertCloseDome(); alertActions.closeShutter = Options::weatherAlertCloseShutter(); - alertActions.stopScheduler = Options::weatherAlertStopScheduler(); alertActions.delay = Options::weatherAlertDelay(); + // not implemented yet + warningActions.stopScheduler = false; + alertActions.stopScheduler = false; + warningTimer.setInterval(static_cast(warningActions.delay * 1000)); warningTimer.setSingleShot(true); alertTimer.setInterval(static_cast(alertActions.delay * 1000)); @@ -73,8 +75,19 @@ if (!active && warningTimer.isActive()) warningTimer.stop(); // start warning timer if activated - else if (active && !warningTimer.isActive() && weatherInterface->status() == ISD::Weather::WEATHER_WARNING) - warningTimer.start(); + else if (weatherInterface->status() == ISD::Weather::WEATHER_WARNING) + startWarningTimer(); +} + +void ObservatoryWeatherModel::startWarningTimer() +{ + if (warningActionsActive && (warningActions.parkDome || warningActions.closeShutter || warningActions.stopScheduler)) + { + if (!warningTimer.isActive()) + warningTimer.start(); + } + else if (warningTimer.isActive()) + warningTimer.stop(); } void ObservatoryWeatherModel::setAlertActionsActive(bool active) @@ -86,17 +99,32 @@ if (!active && alertTimer.isActive()) alertTimer.stop(); // start alert timer if activated - else if (active && !alertTimer.isActive() && weatherInterface->status() == ISD::Weather::WEATHER_ALERT) - alertTimer.start(); + else if (weatherInterface->status() == ISD::Weather::WEATHER_ALERT) + startAlertTimer(); +} + +void ObservatoryWeatherModel::startAlertTimer() +{ + if (alertActionsActive && (alertActions.parkDome || alertActions.closeShutter || alertActions.stopScheduler)) + { + if (!alertTimer.isActive()) + alertTimer.start(); + } + else if (alertTimer.isActive()) + alertTimer.stop(); } void ObservatoryWeatherModel::setWarningActions(WeatherActions actions) { warningActions = actions; Options::setWeatherWarningCloseDome(actions.parkDome); Options::setWeatherWarningCloseShutter(actions.closeShutter); Options::setWeatherWarningDelay(actions.delay); - warningTimer.setInterval(static_cast(actions.delay * 1000)); + if (!warningTimer.isActive()) + warningTimer.setInterval(static_cast(actions.delay * 1000)); + + if (weatherInterface->status() == ISD::Weather::WEATHER_WARNING) + startWarningTimer(); } @@ -117,7 +145,11 @@ Options::setWeatherAlertCloseDome(actions.parkDome); Options::setWeatherAlertCloseShutter(actions.closeShutter); Options::setWeatherAlertDelay(actions.delay); - alertTimer.setInterval(static_cast(actions.delay * 1000)); + if (!alertTimer.isActive()) + alertTimer.setInterval(static_cast(actions.delay * 1000)); + + if (weatherInterface->status() == ISD::Weather::WEATHER_ALERT) + startAlertTimer(); } QString ObservatoryWeatherModel::getAlertActionsStatus() @@ -147,14 +179,12 @@ alertTimer.stop(); break; case ISD::Weather::WEATHER_WARNING: - if (warningActionsActive) - warningTimer.start(); alertTimer.stop(); + startWarningTimer(); break; case ISD::Weather::WEATHER_ALERT: warningTimer.stop(); - if (alertActionsActive) - alertTimer.start(); + startAlertTimer(); break; default: break;