11 #include "clientmanager.h"
12 #include "driverinfo.h"
13 #include "deviceinfo.h"
14 #include "imageviewer.h"
15 #include "indi_debug.h"
17 #include "kstarsdata.h"
21 #include "indimount.h"
22 #include "indicamera.h"
23 #include "indiguider.h"
24 #include "indifocuser.h"
25 #include "indifilterwheel.h"
28 #include "indiweather.h"
29 #include "indiadaptiveoptics.h"
30 #include "indidustcap.h"
31 #include "indilightbox.h"
32 #include "indidetector.h"
33 #include "indirotator.h"
34 #include "indispectrograph.h"
35 #include "indicorrelator.h"
36 #include "indiauxiliary.h"
39 #include <QImageReader>
45 GDSetCommand::GDSetCommand(INDI_PROPERTY_TYPE inPropertyType,
const QString &inProperty,
const QString &inElement,
47 :
QObject(parent), propType(inPropertyType), indiProperty((inProperty)), indiElement(inElement), elementValue(qValue)
54 m_DriverInfo = idv.getDriverInfo();
55 m_BaseDevice = idv.getBaseDevice();
58 Q_ASSERT_X(m_BaseDevice, __FUNCTION__,
"Base device is invalid.");
59 Q_ASSERT_X(m_ClientManager, __FUNCTION__,
"Client manager is invalid.");
61 m_Name = m_BaseDevice->getDeviceName();
68 if (Options::useTimeUpdate() && Options::useKStarsSource())
70 if (m_BaseDevice !=
nullptr && isConnected())
72 auto tvp = m_BaseDevice->getText(
"TIME_UTC");
73 if (tvp && tvp->getPermission() != IP_RO)
79 m_ReadyTimer =
new QTimer(
this);
80 m_ReadyTimer->setInterval(250);
81 m_ReadyTimer->setSingleShot(
true);
83 connect(
this, &GenericDevice::ready,
this, [
this]()
86 m_ReadyTimer->disconnect(
this);
90 GenericDevice::~GenericDevice()
92 for (
auto &metadata : streamFileMetadata)
93 metadata.file->close();
96 void GenericDevice::registerDBusType()
99 static bool isRegistered =
false;
101 if (isRegistered ==
false)
103 qRegisterMetaType<ISD::ParkStatus>(
"ISD::ParkStatus");
104 qDBusRegisterMetaType<ISD::ParkStatus>();
110 const QString &GenericDevice::getDeviceName()
const
115 void GenericDevice::registerProperty(INDI::Property prop)
117 if (!prop->getRegistered())
120 m_ReadyTimer->start();
125 if (name ==
"CONNECTION")
127 auto svp = prop->getSwitch();
130 if (!svp || svp->getState() == IPS_BUSY)
133 auto conSP = svp->findWidgetByName(
"CONNECT");
138 if (m_Connected ==
false && svp->getState() == IPS_OK && conSP->getState() == ISS_ON)
144 else if (m_Connected && conSP->getState() == ISS_OFF)
150 else if (name ==
"DRIVER_INFO")
152 auto tvp = prop->getText();
155 auto tp = tvp->findWidgetByName(
"DRIVER_INTERFACE");
158 m_DriverInterface =
static_cast<uint32_t
>(atoi(tp->getText()));
159 emit interfaceDefined();
162 tp = tvp->findWidgetByName(
"DRIVER_VERSION");
165 m_DriverVersion =
QString(tp->getText());
169 else if (name ==
"SYSTEM_PORTS")
173 auto svp = prop->getSwitch();
174 auto port = m_BaseDevice->getText(
"DEVICE_PORT");
177 for (
const auto &it : *svp)
179 if (it.isNameMatch(port->at(0)->getText()))
181 emit systemPortDetected();
187 else if (name ==
"TIME_UTC" && Options::useTimeUpdate() && Options::useKStarsSource())
189 const auto &tvp = prop->getText();
190 if (tvp && tvp->getPermission() != IP_RO)
193 else if (name ==
"GEOGRAPHIC_COORD" && Options::useGeographicUpdate() && Options::useKStarsSource())
195 const auto &nvp = prop->getNumber();
196 if (nvp && nvp->getPermission() != IP_RO)
199 else if (name ==
"WATCHDOG_HEARTBEAT")
201 const auto &nvp = prop->getNumber();
204 if (watchDogTimer ==
nullptr)
206 watchDogTimer =
new QTimer(
this);
207 connect(watchDogTimer, SIGNAL(timeout()),
this, SLOT(resetWatchdog()));
210 if (m_Connected && nvp->at(0)->getValue() > 0)
213 m_ClientManager->sendNewNumber(nvp);
218 emit propertyDefined(prop);
221 void GenericDevice::removeProperty(
const QString &name)
223 emit propertyDeleted(name);
226 void GenericDevice::processSwitch(ISwitchVectorProperty *svp)
228 if (!strcmp(svp->name,
"CONNECTION"))
230 ISwitch *conSP = IUFindSwitch(svp,
"CONNECT");
232 if (conSP ==
nullptr)
236 if (svp->s == IPS_BUSY)
239 if (m_Connected ==
false && svp->s == IPS_OK && conSP->s == ISS_ON)
245 if (watchDogTimer !=
nullptr)
247 auto nvp = m_BaseDevice->getNumber(
"WATCHDOG_HEARTBEAT");
248 if (nvp && nvp->at(0)->getValue() > 0)
251 m_ClientManager->sendNewNumber(nvp);
255 else if (m_Connected && conSP->s == ISS_OFF)
262 emit switchUpdated(svp);
265 void GenericDevice::processNumber(INumberVectorProperty *nvp)
267 QString deviceName = getDeviceName();
271 if (!strcmp(nvp->name,
"GEOGRAPHIC_COORD") && nvp->s == IPS_OK &&
272 ( (Options::useMountSource() && (getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE)) ||
273 (Options::useGPSSource() && (getDriverInterface() & INDI::BaseDevice::GPS_INTERFACE))))
279 INumber *np = IUFindNumber(nvp,
"LONG");
287 lng.
setD(np->value - 360.0);
289 np = IUFindNumber(nvp,
"LAT");
298 qCWarning(KSTARS_INDI) <<
"Ignoring invalid device coordinates.";
302 np = IUFindNumber(nvp,
"ELEV");
307 std::unique_ptr<GeoLocation> tempGeo;
310 if (getDriverInterface() & INDI::BaseDevice::GPS_INTERFACE)
311 newLocationName =
i18n(
"GPS Location");
313 newLocationName =
i18n(
"Mount Location");
315 if (
geo->name() != newLocationName)
317 double TZ0 =
geo->TZ0();
319 tempGeo.reset(
new GeoLocation(lng, lat, newLocationName,
"",
"", TZ0,
rule, elev));
328 qCInfo(KSTARS_INDI) <<
"Setting location from device:" << deviceName <<
"Longitude:" << lng.
toDMSString() <<
"Latitude:" <<
333 else if (!strcmp(nvp->name,
"WATCHDOG_HEARTBEAT"))
335 if (watchDogTimer ==
nullptr)
337 watchDogTimer =
new QTimer(
this);
341 if (m_Connected && nvp->np[0].value > 0)
345 double nextMS = qMax(100.0, (nvp->np[0].value - 5) * 1000);
346 watchDogTimer->
start(nextMS);
348 else if (nvp->np[0].value == 0)
349 watchDogTimer->
stop();
352 emit numberUpdated(nvp);
355 void GenericDevice::processText(ITextVectorProperty *tvp)
358 if (!strcmp(tvp->name,
"TIME_UTC") && tvp->s == IPS_OK &&
359 ( (Options::useMountSource() && (getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE)) ||
360 (Options::useGPSSource() && (getDriverInterface() & INDI::BaseDevice::GPS_INTERFACE))))
362 int d, m, y, min, sec, hour;
367 IText *tp = IUFindText(tvp,
"UTC");
371 qCWarning(KSTARS_INDI) <<
"UTC property missing from TIME_UTC";
375 sscanf(tp->text,
"%d%*[^0-9]%d%*[^0-9]%dT%d%*[^0-9]%d%*[^0-9]%d", &y, &m, &d, &hour, &min, &sec);
377 indiTime.
setHMS(hour, min, sec);
381 tp = IUFindText(tvp,
"OFFSET");
385 qCWarning(KSTARS_INDI) <<
"Offset property missing from TIME_UTC";
389 sscanf(tp->text,
"%f", &utcOffset);
391 qCInfo(KSTARS_INDI) <<
"Setting UTC time from device:" << getDeviceName() << indiDateTime.toString();
398 utcOffset -=
geo->tzrule()->deltaTZ();
402 geo->setTZ0(utcOffset);
405 emit textUpdated(tvp);
408 void GenericDevice::processLight(ILightVectorProperty *lvp)
410 emit lightUpdated(lvp);
413 void GenericDevice::processMessage(
int messageID)
415 emit messageUpdated(messageID);
421 if (bp->bvp->p == IP_WO)
425 for (
auto oneConcreteDevice : m_ConcreteDevices)
427 if (oneConcreteDevice->processBLOB(bp))
431 INDIDataTypes dataType;
433 if (!strcmp(bp->format,
".ascii"))
434 dataType = DATA_ASCII;
436 dataType = DATA_OTHER;
438 QString currentDir = Options::fitsDir();
442 currentDir.
truncate(
sizeof(currentDir) - 1);
444 QString filename(currentDir +
'/');
454 if (dataType == DATA_ASCII)
458 auto it = std::find_if(streamFileMetadata.begin(), streamFileMetadata.end(), [bp](
const StreamFileMetadata & data)
460 return (bp->bvp->device == data.device && bp->bvp->name == data.property && bp->name == data.element);
463 QFile *streamDatafile =
nullptr;
466 if (it == streamFileMetadata.end())
468 StreamFileMetadata metadata;
469 metadata.device = bp->bvp->device;
471 metadata.element = bp->name;
475 streamDatafile =
new QFile(
this);
476 metadata.file = streamDatafile;
478 streamFileMetadata.append(metadata);
481 streamDatafile = (*it).file;
486 for (nr = 0; nr < bp->size; nr += n)
487 n = out.
writeRawData(
static_cast<char *
>(bp->blob) + nr, bp->size - nr);
490 streamDatafile->
flush();
495 QFile fits_temp_file(filename);
498 qCCritical(KSTARS_INDI) <<
"GenericDevice Error: Unable to open " << fits_temp_file.
fileName();
504 for (nr = 0; nr < (int)bp->size; nr += n)
505 n = out.
writeRawData(
static_cast<char *
>(bp->blob) + nr, bp->size - nr);
507 fits_temp_file.
flush();
508 fits_temp_file.
close();
521 if (dataType == DATA_OTHER)
524 emit BLOBUpdated(bp);
528 bool GenericDevice::setConfig(INDIConfig tConfig)
530 auto svp = m_BaseDevice->getSwitch(
"CONFIG_PROCESS");
535 const char *strConfig =
nullptr;
539 case LOAD_LAST_CONFIG:
540 strConfig =
"CONFIG_LOAD";
544 strConfig =
"CONFIG_SAVE";
547 case LOAD_DEFAULT_CONFIG:
548 strConfig =
"CONFIG_DEFAULT";
552 strConfig =
"CONFIG_PURGE";
559 auto sp = svp->findWidgetByName(strConfig);
562 sp->setState(ISS_ON);
565 m_ClientManager->sendNewSwitch(svp);
570 void GenericDevice::createDeviceInit()
572 if (Options::showINDIMessages())
581 void GenericDevice::updateTime()
595 auto timeUTC = m_BaseDevice->getText(
"TIME_UTC");
599 auto timeEle = timeUTC->findWidgetByName(
"UTC");
603 auto offsetEle = timeUTC->findWidgetByName(
"OFFSET");
607 if (timeEle && offsetEle)
608 m_ClientManager->sendNewText(timeUTC);
615 void GenericDevice::updateLocation()
620 if (
geo->lng()->Degrees() >= 0)
621 longNP =
geo->lng()->Degrees();
625 auto nvp = m_BaseDevice->getNumber(
"GEOGRAPHIC_COORD");
630 auto np = nvp->findWidgetByName(
"LONG");
635 np->setValue(longNP);
637 np = nvp->findWidgetByName(
"LAT");
641 np->setValue(
geo->lat()->Degrees());
643 np = nvp->findWidgetByName(
"ELEV");
647 np->setValue(
geo->elevation());
649 m_ClientManager->sendNewNumber(nvp);
652 bool GenericDevice::Connect()
658 bool GenericDevice::Disconnect()
664 bool GenericDevice::setProperty(
QObject *setPropCommand)
666 GDSetCommand *indiCommand =
static_cast<GDSetCommand *
>(setPropCommand);
670 auto pp = m_BaseDevice->getProperty(indiCommand->indiProperty.toLatin1().constData());
675 switch (indiCommand->propType)
679 auto svp = pp->getSwitch();
684 auto sp = svp->findWidgetByName(indiCommand->indiElement.toLatin1().constData());
689 if (svp->getRule() == ISR_1OFMANY || svp->getRule() == ISR_ATMOST1)
692 sp->setState(indiCommand->elementValue.toInt() == 0 ? ISS_OFF : ISS_ON);
695 m_ClientManager->sendNewSwitch(svp);
702 auto nvp = pp->getNumber();
707 auto np = nvp->findWidgetByName(indiCommand->indiElement.toLatin1().constData());
712 double value = indiCommand->elementValue.toDouble();
714 if (value == np->getValue())
720 m_ClientManager->sendNewNumber(nvp);
731 bool GenericDevice::getMinMaxStep(
const QString &propName,
const QString &elementName,
double *min,
double *max,
734 auto nvp = m_BaseDevice->getNumber(propName.
toLatin1());
739 auto np = nvp->findWidgetByName(elementName.
toLatin1());
746 *step = np->getStep();
751 IPState GenericDevice::getState(
const QString &propName)
756 IPerm GenericDevice::getPermission(
const QString &propName)
761 INDI::Property GenericDevice::getProperty(
const QString &propName)
766 bool GenericDevice::setJSONProperty(
const QString &propName,
const QJsonArray &propElements)
768 for (
auto &oneProp : * (m_BaseDevice->getProperties()))
770 if (propName ==
QString(oneProp->getName()))
772 switch (oneProp->getType())
776 auto svp = oneProp->getSwitch();
777 if (svp->getRule() == ISR_1OFMANY || svp->getRule() == ISR_ATMOST1)
780 for (
auto oneElement : propElements)
782 QJsonObject oneElementObject = oneElement.toObject();
783 auto sp = svp->findWidgetByName(oneElementObject[
"name"].
toString().toLatin1().constData());
786 sp->setState(
static_cast<ISState
>(oneElementObject[
"state"].toInt()));
790 m_ClientManager->sendNewSwitch(svp);
796 auto nvp = oneProp->getNumber();
797 for (
const auto &oneElement : propElements)
799 QJsonObject oneElementObject = oneElement.toObject();
800 auto np = nvp->findWidgetByName(oneElementObject[
"name"].
toString().toLatin1().constData());
803 double newValue = oneElementObject[
"value"].toDouble(std::numeric_limits<double>::quiet_NaN());
804 if (std::isnan(newValue))
806 f_scansexa(oneElementObject[
"value"].
toString().toLatin1().constData(), &newValue);
808 np->setValue(newValue);
812 m_ClientManager->sendNewNumber(nvp);
818 auto tvp = oneProp->getText();
819 for (
const auto &oneElement : propElements)
821 QJsonObject oneElementObject = oneElement.toObject();
822 auto tp = tvp->findWidgetByName(oneElementObject[
"name"].
toString().toLatin1().constData());
824 tp->setText(oneElementObject[
"text"].
toString().toLatin1().constData());
827 m_ClientManager->sendNewText(tvp);
844 bool GenericDevice::getJSONProperty(
const QString &propName,
QJsonObject &propObject,
bool compact)
846 for (
auto &oneProp : * (m_BaseDevice->getProperties()))
848 if (propName ==
QString(oneProp->getName()))
850 switch (oneProp->getType())
853 propertyToJson(oneProp->getSwitch(), propObject, compact);
857 propertyToJson(oneProp->getNumber(), propObject, compact);
861 propertyToJson(oneProp->getText(), propObject, compact);
865 propertyToJson(oneProp->getLight(), propObject, compact);
884 if (blobProperty ==
nullptr)
887 auto oneBLOB = blobProperty->getBLOB()->findWidgetByName(elementName.
toLatin1().
constData());
895 blobObject.
insert(
"property", propName);
896 blobObject.
insert(
"element", elementName);
898 blobObject.
insert(
"data", encoded);
903 void GenericDevice::resetWatchdog()
905 auto nvp = m_BaseDevice->getNumber(
"WATCHDOG_HEARTBEAT");
909 m_ClientManager->sendNewNumber(nvp);
912 ConcreteDevice *GenericDevice::getConcreteDevice(uint32_t interface)
914 if (m_ConcreteDevices.contains(interface))
915 return m_ConcreteDevices[interface].get();
919 void GenericDevice::generateDevices()
922 if (m_DriverInterface & INDI::BaseDevice::TELESCOPE_INTERFACE)
925 m_ConcreteDevices[INDI::BaseDevice::TELESCOPE_INTERFACE].reset(mount);
926 mount->registeProperties();
929 mount->processProperties();
930 emit newMount(mount);
934 connect(mount, &ISD::ConcreteDevice::ready,
this, [
this, mount]()
936 emit newMount(mount);
943 if (m_DriverInterface & INDI::BaseDevice::CCD_INTERFACE)
946 m_ConcreteDevices[INDI::BaseDevice::CCD_INTERFACE].reset(camera);
947 camera->registeProperties();
950 camera->processProperties();
951 emit newCamera(camera);
955 connect(camera, &ISD::ConcreteDevice::ready,
this, [
this, camera]()
957 emit newCamera(camera);
963 if (m_DriverInterface & INDI::BaseDevice::GUIDER_INTERFACE)
965 auto guider =
new ISD::Guider(
this);
966 m_ConcreteDevices[INDI::BaseDevice::GUIDER_INTERFACE].reset(guider);
967 guider->registeProperties();
970 guider->processProperties();
971 emit newGuider(guider);
975 connect(guider, &ISD::ConcreteDevice::ready,
this, [
this, guider]()
977 emit newGuider(guider);
983 if (m_DriverInterface & INDI::BaseDevice::FOCUSER_INTERFACE)
986 m_ConcreteDevices[INDI::BaseDevice::FOCUSER_INTERFACE].reset(focuser);
987 focuser->registeProperties();
990 focuser->processProperties();
991 emit newFocuser(focuser);
995 connect(focuser, &ISD::ConcreteDevice::ready,
this, [
this, focuser]()
997 emit newFocuser(focuser);
1003 if (m_DriverInterface & INDI::BaseDevice::FILTER_INTERFACE)
1005 auto filterWheel =
new ISD::FilterWheel(
this);
1006 m_ConcreteDevices[INDI::BaseDevice::FILTER_INTERFACE].reset(filterWheel);
1007 filterWheel->registeProperties();
1010 filterWheel->processProperties();
1011 emit newFilterWheel(filterWheel);
1015 connect(filterWheel, &ISD::ConcreteDevice::ready,
this, [
this, filterWheel]()
1017 emit newFilterWheel(filterWheel);
1023 if (m_DriverInterface & INDI::BaseDevice::DOME_INTERFACE)
1026 m_ConcreteDevices[INDI::BaseDevice::DOME_INTERFACE].reset(dome);
1027 dome->registeProperties();
1030 dome->processProperties();
1035 connect(dome, &ISD::ConcreteDevice::ready,
this, [
this, dome]()
1043 if (m_DriverInterface & INDI::BaseDevice::GPS_INTERFACE)
1045 auto gps =
new ISD::GPS(
this);
1046 m_ConcreteDevices[INDI::BaseDevice::DOME_INTERFACE].reset(gps);
1047 gps->registeProperties();
1050 gps->processProperties();
1055 connect(gps, &ISD::ConcreteDevice::ready,
this, [
this, gps]()
1063 if (m_DriverInterface & INDI::BaseDevice::WEATHER_INTERFACE)
1066 m_ConcreteDevices[INDI::BaseDevice::DOME_INTERFACE].reset(weather);
1067 weather->registeProperties();
1070 weather->processProperties();
1071 emit newWeather(weather);
1075 connect(weather, &ISD::ConcreteDevice::ready,
this, [
this, weather]()
1077 emit newWeather(weather);
1083 if (m_DriverInterface & INDI::BaseDevice::AO_INTERFACE)
1086 m_ConcreteDevices[INDI::BaseDevice::AO_INTERFACE].reset(ao);
1087 ao->registeProperties();
1090 ao->processProperties();
1091 emit newAdaptiveOptics(ao);
1095 connect(ao, &ISD::ConcreteDevice::ready,
this, [
this, ao]()
1097 emit newAdaptiveOptics(ao);
1103 if (m_DriverInterface & INDI::BaseDevice::DUSTCAP_INTERFACE)
1106 m_ConcreteDevices[INDI::BaseDevice::DUSTCAP_INTERFACE].reset(dustCap);
1107 dustCap->registeProperties();
1110 dustCap->processProperties();
1111 emit newDustCap(dustCap);
1115 connect(dustCap, &ISD::ConcreteDevice::ready,
this, [
this, dustCap]()
1117 emit newDustCap(dustCap);
1123 if (m_DriverInterface & INDI::BaseDevice::LIGHTBOX_INTERFACE)
1126 m_ConcreteDevices[INDI::BaseDevice::LIGHTBOX_INTERFACE].reset(lightBox);
1127 lightBox->registeProperties();
1130 lightBox->processProperties();
1131 emit newLightBox(lightBox);
1135 connect(lightBox, &ISD::ConcreteDevice::ready,
this, [
this, lightBox]()
1137 emit newLightBox(lightBox);
1143 if (m_DriverInterface & INDI::BaseDevice::ROTATOR_INTERFACE)
1146 m_ConcreteDevices[INDI::BaseDevice::ROTATOR_INTERFACE].reset(rotator);
1147 rotator->registeProperties();
1150 rotator->processProperties();
1151 emit newRotator(rotator);
1155 connect(rotator, &ISD::ConcreteDevice::ready,
this, [
this, rotator]()
1157 emit newRotator(rotator);
1163 if (m_DriverInterface & INDI::BaseDevice::DETECTOR_INTERFACE)
1166 m_ConcreteDevices[INDI::BaseDevice::DETECTOR_INTERFACE].reset(detector);
1167 detector->registeProperties();
1170 detector->processProperties();
1171 emit newDetector(detector);
1175 connect(detector, &ISD::ConcreteDevice::ready,
this, [
this, detector]()
1177 emit newDetector(detector);
1183 if (m_DriverInterface & INDI::BaseDevice::SPECTROGRAPH_INTERFACE)
1186 m_ConcreteDevices[INDI::BaseDevice::SPECTROGRAPH_INTERFACE].reset(spectrograph);
1187 spectrograph->registeProperties();
1190 spectrograph->processProperties();
1191 emit newSpectrograph(spectrograph);
1195 connect(spectrograph, &ISD::ConcreteDevice::ready,
this, [
this, spectrograph]()
1197 emit newSpectrograph(spectrograph);
1203 if (m_DriverInterface & INDI::BaseDevice::CORRELATOR_INTERFACE)
1206 m_ConcreteDevices[INDI::BaseDevice::CORRELATOR_INTERFACE].reset(correlator);
1207 correlator->registeProperties();
1210 correlator->processProperties();
1211 emit newCorrelator(correlator);
1215 connect(correlator, &ISD::ConcreteDevice::ready,
this, [
this, correlator]()
1217 emit newCorrelator(correlator);
1223 if (m_DriverInterface & INDI::BaseDevice::AUX_INTERFACE)
1226 m_ConcreteDevices[INDI::BaseDevice::AUX_INTERFACE].reset(aux);
1227 aux->registeProperties();
1230 aux->processProperties();
1231 emit newAuxiliary(aux);
1235 connect(aux, &ISD::ConcreteDevice::ready,
this, [
this, aux]()
1237 emit newAuxiliary(aux);
1243 void propertyToJson(ISwitchVectorProperty *svp,
QJsonObject &propObject,
bool compact)
1246 for (
int i = 0; i < svp->nsp; i++)
1248 QJsonObject oneSwitch = {{
"name", svp->sp[i].name}, {
"state", svp->sp[i].s}};
1250 oneSwitch.
insert(
"label", svp->sp[i].label);
1251 switches.
append(oneSwitch);
1254 propObject = {{
"device", svp->device}, {
"name", svp->name}, {
"state", svp->s}, {
"switches", switches}};
1257 propObject.
insert(
"label", svp->label);
1258 propObject.
insert(
"group", svp->group);
1259 propObject.
insert(
"perm", svp->p);
1260 propObject.
insert(
"rule", svp->r);
1264 void propertyToJson(INumberVectorProperty *nvp,
QJsonObject &propObject,
bool compact)
1267 for (
int i = 0; i < nvp->nnp; i++)
1269 QJsonObject oneNumber = {{
"name", nvp->np[i].name}, {
"value", nvp->np[i].
value}};
1272 oneNumber.
insert(
"label", nvp->np[i].label);
1273 oneNumber.
insert(
"min", nvp->np[i].min);
1274 oneNumber.
insert(
"max", nvp->np[i].max);
1275 oneNumber.
insert(
"step", nvp->np[i].step);
1276 oneNumber.
insert(
"format", nvp->np[i].format);
1278 numbers.
append(oneNumber);
1281 propObject = {{
"device", nvp->device}, {
"name", nvp->name}, {
"state", nvp->s}, {
"numbers", numbers}};
1284 propObject.
insert(
"label", nvp->label);
1285 propObject.
insert(
"group", nvp->group);
1286 propObject.
insert(
"perm", nvp->p);
1290 void propertyToJson(ITextVectorProperty *tvp,
QJsonObject &propObject,
bool compact)
1293 for (
int i = 0; i < tvp->ntp; i++)
1295 QJsonObject oneText = {{
"name", tvp->tp[i].name}, {
"text", tvp->tp[i].text}};
1298 oneText.
insert(
"label", tvp->tp[i].label);
1303 propObject = {{
"device", tvp->device}, {
"name", tvp->name}, {
"state", tvp->s}, {
"texts", Texts}};
1306 propObject.
insert(
"label", tvp->label);
1307 propObject.
insert(
"group", tvp->group);
1308 propObject.
insert(
"perm", tvp->p);
1312 void propertyToJson(ILightVectorProperty *lvp,
QJsonObject &propObject,
bool compact)
1315 for (
int i = 0; i < lvp->nlp; i++)
1317 QJsonObject oneLight = {{
"name", lvp->lp[i].name}, {
"state", lvp->lp[i].s}};
1320 oneLight.
insert(
"label", lvp->lp[i].label);
1325 propObject = {{
"device", lvp->device}, {
"name", lvp->name}, {
"state", lvp->s}, {
"lights", Lights}};
1328 propObject.
insert(
"label", lvp->label);
1329 propObject.
insert(
"group", lvp->group);
1333 void propertyToJson(INDI::Property prop,
QJsonObject &propObject,
bool compact)
1335 switch (prop->getType())
1338 propertyToJson(prop->getSwitch(), propObject, compact);
1341 propertyToJson(prop->getText(), propObject, compact);
1344 propertyToJson(prop->getNumber(), propObject, compact);
1347 propertyToJson(prop->getLight(), propObject, compact);
1359 argument << static_cast<int>(source);
1370 dest =
static_cast<ISD::ParkStatus
>(a);