Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/observatory/observatory.cpp
Show First 20 Lines • Show All 380 Lines • ▼ Show 20 Line(s) | 354 | { | |||
---|---|---|---|---|---|
381 | } | 381 | } | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | void Observatory::enableWeather(bool enable) | 384 | void Observatory::enableWeather(bool enable) | ||
385 | { | 385 | { | ||
386 | weatherBox->setEnabled(enable); | 386 | weatherBox->setEnabled(enable); | ||
387 | clearGraphHistory->setVisible(enable); | 387 | clearGraphHistory->setVisible(enable); | ||
388 | clearGraphHistory->setEnabled(enable); | 388 | clearGraphHistory->setEnabled(enable); | ||
389 | autoscaleValuesCB->setVisible(enable); | ||||
389 | sensorGraphs->setVisible(enable); | 390 | sensorGraphs->setVisible(enable); | ||
390 | } | 391 | } | ||
391 | 392 | | |||
392 | void Observatory::clearSensorDataHistory() | 393 | void Observatory::clearSensorDataHistory() | ||
393 | { | 394 | { | ||
394 | std::map<QString, QVector<QCPGraphData>*>::iterator it; | 395 | std::map<QString, QVector<QCPGraphData>*>::iterator it; | ||
395 | 396 | | |||
396 | for (it=sensorGraphData.begin(); it != sensorGraphData.end(); ++it) | 397 | for (it=sensorGraphData.begin(); it != sensorGraphData.end(); ++it) | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 497 | { | |||
502 | initSensorGraphs(); | 503 | initSensorGraphs(); | ||
503 | 504 | | |||
504 | connect(weatherWarningBox, &QGroupBox::clicked, getWeatherModel(), &ObservatoryWeatherModel::setWarningActionsActive); | 505 | connect(weatherWarningBox, &QGroupBox::clicked, getWeatherModel(), &ObservatoryWeatherModel::setWarningActionsActive); | ||
505 | connect(weatherAlertBox, &QGroupBox::clicked, getWeatherModel(), &ObservatoryWeatherModel::setAlertActionsActive); | 506 | connect(weatherAlertBox, &QGroupBox::clicked, getWeatherModel(), &ObservatoryWeatherModel::setAlertActionsActive); | ||
506 | 507 | | |||
507 | connect(getWeatherModel(), &Ekos::ObservatoryWeatherModel::newStatus, this, &Ekos::Observatory::setWeatherStatus); | 508 | connect(getWeatherModel(), &Ekos::ObservatoryWeatherModel::newStatus, this, &Ekos::Observatory::setWeatherStatus); | ||
508 | connect(getWeatherModel(), &Ekos::ObservatoryWeatherModel::disconnected, this, &Ekos::Observatory::shutdownWeather); | 509 | connect(getWeatherModel(), &Ekos::ObservatoryWeatherModel::disconnected, this, &Ekos::Observatory::shutdownWeather); | ||
509 | connect(clearGraphHistory, &QPushButton::clicked, this, &Observatory::clearSensorDataHistory); | 510 | connect(clearGraphHistory, &QPushButton::clicked, this, &Observatory::clearSensorDataHistory); | ||
511 | connect(autoscaleValuesCB, &QCheckBox::clicked, [this](bool checked) | ||||
512 | { | ||||
513 | getWeatherModel()->setAutoScaleValues(checked); | ||||
514 | this->refreshSensorGraph(); | ||||
515 | }); | ||||
510 | connect(&weatherStatusTimer, &QTimer::timeout, [this]() | 516 | connect(&weatherStatusTimer, &QTimer::timeout, [this]() | ||
511 | { | 517 | { | ||
512 | weatherWarningStatusLabel->setText(getWeatherModel()->getWarningActionsStatus()); | 518 | weatherWarningStatusLabel->setText(getWeatherModel()->getWarningActionsStatus()); | ||
513 | weatherAlertStatusLabel->setText(getWeatherModel()->getAlertActionsStatus()); | 519 | weatherAlertStatusLabel->setText(getWeatherModel()->getAlertActionsStatus()); | ||
514 | }); | 520 | }); | ||
515 | 521 | | |||
516 | weatherBox->setEnabled(true); | 522 | weatherBox->setEnabled(true); | ||
523 | autoscaleValuesCB->setChecked(getWeatherModel()->autoScaleValues()); | ||||
517 | weatherActionsBox->setVisible(true); | 524 | weatherActionsBox->setVisible(true); | ||
518 | weatherActionsBox->setEnabled(true); | 525 | weatherActionsBox->setEnabled(true); | ||
519 | weatherWarningBox->setChecked(getWeatherModel()->getWarningActionsActive()); | 526 | weatherWarningBox->setChecked(getWeatherModel()->getWarningActionsActive()); | ||
520 | weatherAlertBox->setChecked(getWeatherModel()->getAlertActionsActive()); | 527 | weatherAlertBox->setChecked(getWeatherModel()->getAlertActionsActive()); | ||
521 | setWeatherStatus(getWeatherModel()->status()); | 528 | setWeatherStatus(getWeatherModel()->status()); | ||
522 | setWarningActions(getWeatherModel()->getWarningActions()); | 529 | setWarningActions(getWeatherModel()->getWarningActions()); | ||
523 | setAlertActions(getWeatherModel()->getAlertActions()); | 530 | setAlertActions(getWeatherModel()->getAlertActions()); | ||
524 | weatherStatusTimer.start(1000); | 531 | weatherStatusTimer.start(1000); | ||
525 | if (getWeatherModel()->refresh() == false) | 532 | if (getWeatherModel()->refresh() == false) | ||
526 | appendLogText(i18n("Refreshing weather data failed.")); | 533 | appendLogText(i18n("Refreshing weather data failed.")); | ||
534 | // avoid double init | ||||
535 | disconnect(getWeatherModel(), &Ekos::ObservatoryWeatherModel::ready, this, &Ekos::Observatory::initWeather); | ||||
527 | } | 536 | } | ||
528 | 537 | | |||
529 | void Observatory::shutdownWeather() | 538 | void Observatory::shutdownWeather() | ||
530 | { | 539 | { | ||
531 | weatherStatusTimer.stop(); | 540 | weatherStatusTimer.stop(); | ||
532 | setWeatherStatus(ISD::Weather::WEATHER_IDLE); | 541 | setWeatherStatus(ISD::Weather::WEATHER_IDLE); | ||
533 | enableWeather(false); | 542 | enableWeather(false); | ||
534 | } | 543 | } | ||
Show All 20 Lines | 563 | { | |||
555 | // display first point in scattered style | 564 | // display first point in scattered style | ||
556 | if (sensorGraphData[id]->size() == 1) | 565 | if (sensorGraphData[id]->size() == 1) | ||
557 | sensorGraphs->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 0), QBrush(Qt::green), 5)); | 566 | sensorGraphs->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 0), QBrush(Qt::green), 5)); | ||
558 | else | 567 | else | ||
559 | sensorGraphs->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone)); | 568 | sensorGraphs->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone)); | ||
560 | 569 | | |||
561 | // display data point | 570 | // display data point | ||
562 | sensorGraphs->graph()->addData(sensorGraphData[id]->last().key, sensorGraphData[id]->last().value); | 571 | sensorGraphs->graph()->addData(sensorGraphData[id]->last().key, sensorGraphData[id]->last().value); | ||
563 | sensorGraphs->rescaleAxes(); | 572 | | ||
564 | // ensure that the 0-line is visible | 573 | // determine where the x axis is relatively to the value ranges | ||
565 | if ((sensorRanges[id] > 0 && value < 0) || (sensorRanges[id] < 0 && value > 0)) | 574 | if ((sensorRanges[id] > 0 && value < 0) || (sensorRanges[id] < 0 && value > 0)) | ||
566 | sensorRanges[id] = 0; | 575 | sensorRanges[id] = 0; | ||
567 | 576 | | |||
568 | // ensure visibility of the 0-line on the y-axis | 577 | refreshSensorGraph(); | ||
569 | if (sensorRanges[id] > 0) | | |||
570 | sensorGraphs->yAxis->setRangeLower(0); | | |||
571 | else if (sensorRanges[id] < 0) | | |||
572 | sensorGraphs->yAxis->setRangeUpper(0); | | |||
573 | sensorGraphs->replot(); | | |||
574 | } | 578 | } | ||
575 | } | 579 | } | ||
576 | 580 | | |||
577 | void Observatory::updateSensorData(std::vector<ISD::Weather::WeatherData> weatherData) | 581 | void Observatory::updateSensorData(std::vector<ISD::Weather::WeatherData> weatherData) | ||
578 | { | 582 | { | ||
579 | std::vector<ISD::Weather::WeatherData>::iterator it; | 583 | std::vector<ISD::Weather::WeatherData>::iterator it; | ||
580 | QDateTime now = KStarsData::Instance()->lt(); | 584 | QDateTime now = KStarsData::Instance()->lt(); | ||
581 | 585 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 642 | QToolTip::showText( | |||
640 | i18n("%1 = %2 @ %3", selectedSensorID, value, when.toString("hh:mm"))); | 644 | i18n("%1 = %2 @ %3", selectedSensorID, value, when.toString("hh:mm"))); | ||
641 | } | 645 | } | ||
642 | else { | 646 | else { | ||
643 | QToolTip::hideText(); | 647 | QToolTip::hideText(); | ||
644 | } | 648 | } | ||
645 | } | 649 | } | ||
646 | 650 | | |||
647 | 651 | | |||
652 | void Observatory::refreshSensorGraph() | ||||
653 | { | ||||
654 | | ||||
655 | sensorGraphs->rescaleAxes(); | ||||
656 | | ||||
657 | // restrict the y-Axis to the values range | ||||
658 | if (getWeatherModel()->autoScaleValues() == false) | ||||
659 | { | ||||
660 | if (sensorRanges[selectedSensorID] > 0) | ||||
661 | sensorGraphs->yAxis->setRangeLower(0); | ||||
662 | else if (sensorRanges[selectedSensorID] < 0) | ||||
663 | sensorGraphs->yAxis->setRangeUpper(0); | ||||
664 | } | ||||
665 | | ||||
666 | sensorGraphs->replot(); | ||||
667 | } | ||||
668 | | ||||
648 | void Observatory::selectedSensorChanged(QString id) | 669 | void Observatory::selectedSensorChanged(QString id) | ||
649 | { | 670 | { | ||
650 | QVector<QCPGraphData> *data = sensorGraphData[id]; | 671 | QVector<QCPGraphData> *data = sensorGraphData[id]; | ||
651 | 672 | | |||
652 | if (data != nullptr) | 673 | if (data != nullptr) | ||
653 | { | 674 | { | ||
654 | // copy the graph data to the graph container | 675 | // copy the graph data to the graph container | ||
655 | QCPGraphDataContainer *container = new QCPGraphDataContainer(); | 676 | QCPGraphDataContainer *container = new QCPGraphDataContainer(); | ||
656 | for (QVector<QCPGraphData>::iterator it = data->begin(); it != data->end(); ++it) | 677 | for (QVector<QCPGraphData>::iterator it = data->begin(); it != data->end(); ++it) | ||
657 | container->add(QCPGraphData(it->key, it->value)); | 678 | container->add(QCPGraphData(it->key, it->value)); | ||
658 | 679 | | |||
659 | sensorGraphs->graph()->setData(QSharedPointer<QCPGraphDataContainer>(container)); | 680 | sensorGraphs->graph()->setData(QSharedPointer<QCPGraphDataContainer>(container)); | ||
660 | sensorGraphs->rescaleAxes(); | | |||
661 | sensorGraphs->replot(); | | |||
662 | selectedSensorID = id; | 681 | selectedSensorID = id; | ||
682 | refreshSensorGraph(); | ||||
663 | } | 683 | } | ||
664 | } | 684 | } | ||
665 | 685 | | |||
666 | 686 | | |||
667 | 687 | | |||
668 | void Observatory::setWeatherStatus(ISD::Weather::Status status) | 688 | void Observatory::setWeatherStatus(ISD::Weather::Status status) | ||
669 | { | 689 | { | ||
670 | std::string label; | 690 | std::string label; | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
760 | } | 780 | } | ||
761 | 781 | | |||
762 | 782 | | |||
763 | void Observatory::weatherWarningSettingsChanged() | 783 | void Observatory::weatherWarningSettingsChanged() | ||
764 | { | 784 | { | ||
765 | struct WeatherActions actions; | 785 | struct WeatherActions actions; | ||
766 | actions.parkDome = weatherWarningDomeCB->isChecked(); | 786 | actions.parkDome = weatherWarningDomeCB->isChecked(); | ||
767 | actions.closeShutter = weatherWarningShutterCB->isChecked(); | 787 | actions.closeShutter = weatherWarningShutterCB->isChecked(); | ||
788 | // Fixme: not implemented yet | ||||
789 | actions.stopScheduler = false; | ||||
768 | actions.delay = static_cast<unsigned int>(weatherWarningDelaySB->value()); | 790 | actions.delay = static_cast<unsigned int>(weatherWarningDelaySB->value()); | ||
769 | 791 | | |||
770 | getWeatherModel()->setWarningActions(actions); | 792 | getWeatherModel()->setWarningActions(actions); | ||
771 | } | 793 | } | ||
772 | 794 | | |||
773 | void Observatory::weatherAlertSettingsChanged() | 795 | void Observatory::weatherAlertSettingsChanged() | ||
774 | { | 796 | { | ||
775 | struct WeatherActions actions; | 797 | struct WeatherActions actions; | ||
776 | actions.parkDome = weatherAlertDomeCB->isChecked(); | 798 | actions.parkDome = weatherAlertDomeCB->isChecked(); | ||
777 | actions.closeShutter = weatherAlertShutterCB->isChecked(); | 799 | actions.closeShutter = weatherAlertShutterCB->isChecked(); | ||
800 | // Fixme: not implemented yet | ||||
801 | actions.stopScheduler = false; | ||||
778 | actions.delay = static_cast<unsigned int>(weatherAlertDelaySB->value()); | 802 | actions.delay = static_cast<unsigned int>(weatherAlertDelaySB->value()); | ||
779 | 803 | | |||
780 | getWeatherModel()->setAlertActions(actions); | 804 | getWeatherModel()->setAlertActions(actions); | ||
781 | } | 805 | } | ||
782 | 806 | | |||
783 | void Observatory::observatoryStatusChanged(bool ready) | 807 | void Observatory::observatoryStatusChanged(bool ready) | ||
784 | { | 808 | { | ||
785 | // statusReadyButton->setEnabled(!ready); | 809 | // statusReadyButton->setEnabled(!ready); | ||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |