7#include "indiweather.h"
8#include "weatheradaptor.h"
10#include <basedevice.h>
12#include <QtDBus/qdbusmetatype.h>
17Weather::Weather(GenericDevice *parent) : ConcreteDevice(parent)
19 qRegisterMetaType<ISD::Weather::Status>(
"ISD::Weather::Status");
20 qDBusRegisterMetaType<ISD::Weather::Status>();
22 new WeatherAdaptor(
this);
23 m_DBusObjectPath =
QString(
"/KStars/INDI/Weather/%1").
arg(getID());
27void Weather::processLight(INDI::Property prop)
29 auto lvp = prop.getLight();
30 if (lvp->isNameMatch(
"WEATHER_STATUS"))
32 Status currentStatus =
static_cast<Status
>(lvp->s);
33 if (currentStatus != m_WeatherStatus)
35 m_WeatherStatus = currentStatus;
36 emit newStatus(m_WeatherStatus);
41void Weather::processNumber(INDI::Property prop)
43 auto nvp = prop.getNumber();
45 if (nvp->isNameMatch(
"WEATHER_PARAMETERS"))
50 for (
int i = 0; i < nvp->nnp; i++)
55 {
"name",
number->getName()},
56 {
"label",
number->getLabel()},
57 {
"value",
number->getValue()}
59 m_Data.push_back(sensor);
66Weather::Status Weather::status()
68 auto weatherLP = getLight(
"WEATHER_STATUS");
73 m_WeatherStatus =
static_cast<Status
>(weatherLP->getState());
75 return static_cast<Status
>(weatherLP->getState());
78int Weather::refreshPeriod()
80 auto updateNP = getNumber(
"WEATHER_UPDATE");
85 return static_cast<int>(updateNP->at(0)->getValue());
88void Weather::setRefreshPeriod(
int value)
90 auto updateNP = getNumber(
"WEATHER_UPDATE");
95 updateNP->at(0)->setValue(value);
96 sendNewProperty(updateNP);
99bool Weather::refresh()
101 auto refreshSP = getSwitch(
"WEATHER_REFRESH");
103 if (refreshSP ==
nullptr)
106 auto refreshSW = refreshSP->findWidgetByName(
"REFRESH");
108 if (refreshSW ==
nullptr)
112 refreshSW->setState(ISS_ON);
113 sendNewProperty(refreshSP);
124 argument << static_cast<int>(source);
135 dest =
static_cast<ISD::Weather::Status
>(a);
ISD is a collection of INDI Standard Devices.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
KIOCORE_EXPORT QString number(KIO::filesize_t size)
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
QDBusConnection sessionBus()
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const