8#include <QtDBus/qdbusmetatype.h>
10#include "indidustcap.h"
11#include "dustcapadaptor.h"
20DustCap::DustCap(GenericDevice *parent): ConcreteDevice(parent)
22 qRegisterMetaType<ISD::DustCap::Status>(
"ISD::DustCap::Status");
23 qDBusRegisterMetaType<ISD::DustCap::Status>();
25 new DustCapAdaptor(
this);
26 m_DBusObjectPath =
QString(
"/KStars/INDI/DustCap/%1").
arg(getID());
30void DustCap::processSwitch(INDI::Property prop)
32 auto svp = prop.getSwitch();
33 if (svp->isNameMatch(
"CAP_PARK"))
35 Status currentStatus = CAP_ERROR;
36 ParkStatus currentParkStatus = PARK_UNKNOWN;
38 switch (svp->getState())
41 if (svp->at(0)->getState() == ISS_ON)
43 currentStatus = CAP_PARKED;
44 currentParkStatus = PARK_PARKED;
46 else if (svp->at(1)->getState() == ISS_ON)
48 currentStatus = CAP_IDLE;
49 currentParkStatus = PARK_UNPARKED;
54 if (svp->at(0)->getState() == ISS_ON)
56 currentStatus = CAP_PARKED;
57 currentParkStatus = PARK_PARKED;
61 currentStatus = CAP_IDLE;
62 currentParkStatus = PARK_UNPARKED;
67 if (svp->at(0)->getState() == ISS_ON)
69 currentStatus = CAP_PARKING;
70 currentParkStatus = PARK_PARKING;
74 currentStatus = CAP_UNPARKING;
75 currentParkStatus = PARK_UNPARKING;
80 currentStatus = CAP_ERROR;
81 currentParkStatus = PARK_ERROR;
84 if (currentStatus != m_Status)
86 m_Status = currentStatus;
87 emit newStatus(m_Status);
90 if (currentParkStatus != m_ParkStatus)
92 m_ParkStatus = currentParkStatus;
93 emit newParkStatus(m_ParkStatus);
100bool DustCap::canPark()
102 auto parkSP = getSwitch(
"CAP_PARK");
109bool DustCap::isParked()
111 auto parkSP = getSwitch(
"CAP_PARK");
115 return ((parkSP->getState() == IPS_OK || parkSP->getState() == IPS_IDLE) && parkSP->at(0)->getState() == ISS_ON);
118bool DustCap::isUnParked()
120 auto parkSP = getSwitch(
"CAP_PARK");
124 return ( (parkSP->getState() == IPS_OK || parkSP->getState() == IPS_IDLE) && parkSP->at(1)->getState() == ISS_ON);
129 auto parkSP = getSwitch(
"CAP_PARK");
133 auto parkSW = parkSP->findWidgetByName(
"PARK");
138 parkSW->setState(ISS_ON);
139 sendNewProperty(parkSP);
144bool DustCap::unpark()
146 auto parkSP = getSwitch(
"CAP_PARK");
150 auto parkSW = parkSP->findWidgetByName(
"UNPARK");
155 parkSW->setState(ISS_ON);
156 sendNewProperty(parkSP);
161const QString DustCap::getStatusString(DustCap::Status status,
bool translated)
163 return translated ? capStates[status].toString() : capStates[status].untranslatedText();
171 argument << static_cast<int>(source);
182 dest =
static_cast<ISD::DustCap::Status
>(a);
KLocalizedString KI18N_EXPORT ki18n(const char *text)
ISD is a collection of INDI Standard Devices.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
QDBusConnection sessionBus()
QString arg(Args &&... args) const const