diff --git a/kstars/indi/indicommon.h b/kstars/indi/indicommon.h index 3a6286281..2d47e213a 100644 --- a/kstars/indi/indicommon.h +++ b/kstars/indi/indicommon.h @@ -1,212 +1,213 @@ /* INDI Common Defs Copyright (C) 2012 Jasem Mutlaq This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #ifndef INDICOMMON_H #define INDICOMMON_H #include #include /*! \page INDI "INDI Overview" \tableofcontents \section Intro Introduction INDI is a simple XML-like communications protocol described for interactive and automated remote control of diverse instrumentation. INDI is small, easy to parse, and stateless. The main key concept in INDI is that devices have the ability to describe themselves. This is accomplished by using XML to describe a generic hierarchy that can represent both canonical and non-canonical devices. All devices may contain one or more properties. A property in the INDI paradigm describes a specific function of the driver. Any property may contain one or more elements. There are four types of INDI properties:
  • Text property: Property to transfer simple text information in ISO-8859-1. The text is not encoded or encrypted on transfer. If the text includes elements that can break XML syntax, a BLOB property should be used to make the transfer.
  • Number property: Property to transfer numeric information with configurable minimum, maximum, and step values. The supported number formats are decimal and sexigesmal. The property includes a GUI hint element in printf style format to enable clients to properly display numeric properties.
  • Switch property: Property to hold a group of options or selections (Represented in GUI by buttons and check boxes).
  • Light property: Property to hold a group of status indicators (Represented in GUI by colored LEDs).
  • BLOB property: BLOB is a Binary Large OBject used to transfer binary data to and from drivers.
For example, all INDI devices share the CONNECTION standard switch property. The CONNECTION property has two elements: CONNECT and DISCONNECT switches. GUI clients parse the generic XML description of properties and builds a GUI representation suitable for direct human interaction. KStars is a fully featured INDI client. INDI Data (i.e. devices and properties) and GUI (how they appear on the screen) are separated. INDI adopts is a server/client architecture where one or more servers communicate with one or more drivers, each driver can communicate with one or more actual hardware devices. Clients connect to the server, obtain a list of devices, and generate GUI to represent the devices for user interaction and control. The creation of GUI happens in run time via introspection. \section Structure Hierarchy The following is a description of some of the various classes that support INDI:
  • DriverManager: Manages local drivers as installed by INDI library. Enables users to start/stop local INDI servers (ServerManager) running one or more drivers (DriverInfo). Also enables connecting to local or remote INDI servers. For both local and remote connection, it creates a ClientManager to handle incoming data from each INDI server started, and creates a GUIManager to render the devices in INDI Control Panel. The user may also choose to only start an INDI server without a client manager and GUI.
  • ClientManager: Manages sending and receiving data from and to an INDI server. The ClientManager sends notifications (signals) when a new device or property is defined, updated, or deleted.
  • GUIManager: Handles creation of GUI interface for devices (INDI_D) and their properties and updates the interface in accord with any data emitted by the associated ClientManager. The GUI manager supports multiple ClientManagers and consolidate all devices from all the ClientManagers into a single INDI Control Panel where each device is created as a tab.
  • INDIListener: Once a ClientManager is created in DriverManager after successfully connecting to an INDI server, it is added to INDIListener where it monitors any new devices and if a new device is detected, it creates an ISD::GenericDevice to hold the data of the device. It also monitors new properties and registers them. If it detects an INDI standard property associated with a particular device family (e.g. Property EQUATORIAL_EOD_COORD is a standard property of a Telescope device), then it extends the ISD::GenericDevice to the particular specialized device type using the Decorator Pattern. All updated properties from INDI server are delegated to their respective devices.
  • ServerManager
  • Manages establishment and shutdown of local INDI servers.
  • DriverInfo
  • : Simple class that holds information on INDI drivers such as name, version, device type..etc.
  • ISD::GDInterface: Abstract class where the ISD::DeviceDecorator and ISD::GenericDevice are derived.
  • ISD::DeviceDecorator: Base class of all specialized decorators such as ISD::Telescope, ISD::Filter, and ISD::CCD devices.
  • ISD::GenericDevice: Base class for all INDI devices. It implements processes shared across all INDI devices such as handling connection/disconnection, setting of configuration..etc.. When a specialized decorator is created (e.g. ISD::Telescope), the decorator is passed an ISD::GenericDevice pointer. Since ISD::Telescope is a child of ISD::DeviceDecorator, it can override some or all the device specific functions as defined in ISD::GDInterface (e.g. ProcessNumber(INumberVectorProperty *nvp)). For any function that is not overridden, the parent ISD::DeviceDecorator will invoke the function in ISD::GenericDevice instead. Moreover, The specialized decorator device can explicitly call DeviceDecorator::ProcessNumber(INumberVectorProperty *nvp) for example to cause the ISD::DeviceDecorator to invoke the same function but as defined in ISD::GenericDevice.
\section Example Example Suppose the user wishes to control an EQMod mount with \e indi_eqmod_telescope driver. From the DriverManager GUI, the user selects the driver and \e starts INDI services. The DriverManager will create a ServerManager instance to run an INDI server with the EQMod driver executable. After establishing the server, the DriverManager will create an instance of ClientManager and set its INDI server address as the host and port of the server created in ServerManager. For local servers, the host name is \e localhost and the default INDI port is 7624. If connection to the INDI server is successful, DriverManager then adds the ClientManager to both INDIListener (to handle data), and GUIManager (to handle GUI). Since the ClientManager emits signals whenever a new, updated, or deleted device/property is received from INDI server, it affects both the data handling part as well as GUI rendering. INDIListener holds a list of all INDI devices in KStars regardless of their origin. Once INDIListener receives a new device from the ClientManager, it creates a new ISD::GenericDevice. At the GUIManager side, it creates INDI Control Panel and adds a new tab with the device name. It also creates a separate tab for each property group received. The user is presented with a basic GUI to set the connection port of EQMod and to connect/disconnect to/from the telescope. If the user clicks connect, the status of the connection property is updated, and INDI_P sends the new switch status (CONNECT=ON) to INDI server via the ClientManager. If the connection is successful at the driver side, it will start defining new properties to cover the complete functionality of the EQMod driver, one of the standard properties is EQUATORIAL_EOD_COORD which will be detected in INDIListener. Upon detection of this key signature property, INDIListener creates a new ISD::Telescope device while passing to it the ISD::GenericDevice instance created earlier. Now suppose an updated Number property arrives from INDI server, the ClientManager emits a signal indicating a number property has a new updated value and INDIListener delegates the INDI Number property to the device, which is now of type ISD::Telescope. The ISD::Telescope overridden the processNumber(INumberVectorProperty *nvp) function in ISD::DeviceDecorator because it wants to handle some telescope specific numbers such as EQUATORIAL_EOD_COORD in order to move the telescope marker on the sky map as it changes. If the received property was indeed EQUATORIAL_EOD_COORD or any property handled by the ISD::Telescope ProcessNumber() function, then there is no further action needed. But what if the property is not processed in ISD::Telescope ProcessNumber() function? In this case, the ProcessNumber() function simply calls DeviceDecorator::ProcessNumber() and it will delgate the call to ISD::GenericDevice ProcessNumber() to process. This is how the Decorator pattern work, the decorator classes implements extended functionality, but the basic class is still responsible for handling all of the basic functions. */ #define INDIVERSION 1.7 /* we support this or less */ typedef enum { PRIMARY_XML, THIRD_PARTY_XML, EM_XML, HOST_SOURCE, CUSTOM_SOURCE, GENERATED_SOURCE } DriverSource; typedef enum { SERVER_CLIENT, SERVER_ONLY } ServerMode; typedef enum { DATA_FITS, DATA_VIDEO, DATA_CCDPREVIEW, DATA_ASCII, DATA_OTHER } INDIDataTypes; typedef enum { LOAD_LAST_CONFIG, SAVE_CONFIG, LOAD_DEFAULT_CONFIG, PURGE_CONFIG } INDIConfig; typedef enum { NO_DIR = 0, RA_INC_DIR, RA_DEC_DIR, DEC_INC_DIR, DEC_DEC_DIR } GuideDirection; /* GUI layout */ #define PROPERTY_LABEL_WIDTH 100 +#define PROPERTY_LABEL_HEIGHT 30 #define ELEMENT_LABEL_WIDTH 175 -#define ELEMENT_LABEL_HEIGHT 25 +#define ELEMENT_LABEL_HEIGHT 30 #define ELEMENT_READ_WIDTH 175 #define ELEMENT_WRITE_WIDTH 175 #define ELEMENT_FULL_WIDTH 340 #define MIN_SET_WIDTH 50 #define MAX_SET_WIDTH 110 #define MED_INDI_FONT 2 #define MAX_LABEL_LENGTH 20 typedef enum { PG_NONE = 0, PG_TEXT, PG_NUMERIC, PG_BUTTONS, PG_RADIO, PG_MENU, PG_LIGHTS, PG_BLOB } PGui; /* new versions of glibc define TIME_UTC as a macro */ #undef TIME_UTC /* INDI std properties */ enum stdProperties { CONNECTION, DEVICE_PORT, TIME_UTC, TIME_LST, TIME_UTC_OFFSET, GEOGRAPHIC_COORD, /* General */ EQUATORIAL_COORD, EQUATORIAL_EOD_COORD, EQUATORIAL_EOD_COORD_REQUEST, HORIZONTAL_COORD, /* Telescope */ TELESCOPE_ABORT_MOTION, ON_COORD_SET, SOLAR_SYSTEM, TELESCOPE_MOTION_NS, /* Telescope */ TELESCOPE_MOTION_WE, TELESCOPE_PARK, /* Telescope */ CCD_EXPOSURE, CCD_TEMPERATURE_REQUEST, CCD_FRAME, /* CCD */ CCD_FRAME_TYPE, CCD_BINNING, CCD_INFO, CCD_VIDEO_STREAM, /* Video */ FOCUS_SPEED, FOCUS_MOTION, FOCUS_TIMER, /* Focuser */ FILTER_SLOT, /* Filter */ WATCHDOG_HEARTBEAT }; /* Watchdog */ /* Devices families that we explicitly support (i.e. with std properties) */ typedef enum { KSTARS_ADAPTIVE_OPTICS, KSTARS_AGENT, KSTARS_AUXILIARY, KSTARS_CCD, KSTARS_DETECTORS, KSTARS_DOME, KSTARS_FILTER, KSTARS_FOCUSER, KSTARS_ROTATOR, KSTARS_SPECTROGRAPHS, KSTARS_TELESCOPE, KSTARS_WEATHER, KSTARS_UNKNOWN } DeviceFamily; const QMap DeviceFamilyLabels = { {KSTARS_ADAPTIVE_OPTICS, "Adaptive Optics"}, {KSTARS_AGENT, "Agent"}, {KSTARS_AUXILIARY, "Auxiliary"}, {KSTARS_CCD, "CCDs"}, {KSTARS_DETECTORS, "Detectors"}, {KSTARS_DOME, "Domes"}, {KSTARS_FILTER, "Filter Wheels"}, {KSTARS_FOCUSER, "Focusers"}, {KSTARS_ROTATOR, "Rotators"}, {KSTARS_SPECTROGRAPHS, "Spectrographs"}, {KSTARS_TELESCOPE, "Telescopes"}, {KSTARS_WEATHER, "Weather"}, {KSTARS_UNKNOWN, "Unknown"}, }; typedef enum { FRAME_LIGHT, FRAME_BIAS, FRAME_DARK, FRAME_FLAT } CCDFrameType; typedef enum { SINGLE_BIN, DOUBLE_BIN, TRIPLE_BIN, QUADRAPLE_BIN } CCDBinType; typedef enum { INDI_SEND_COORDS, INDI_FIND_TELESCOPE, INDI_CENTER_LOCK, INDI_CENTER_UNLOCK, INDI_CUSTOM_PARKING, INDI_SET_PORT, INDI_CONNECT, INDI_DISCONNECT, INDI_SET_FILTER, INDI_CONFIRM_FILTER, INDI_SET_ROTATOR_TICKS, INDI_SET_ROTATOR_ANGLE } DeviceCommand; typedef enum { SOURCE_MANUAL, SOURCE_FLATCAP, SOURCE_WALL, SOURCE_DAWN_DUSK, SOURCE_DARKCAP } FlatFieldSource; typedef enum { DURATION_MANUAL, DURATION_ADU } FlatFieldDuration; #endif // INDICOMMON_H diff --git a/kstars/indi/indiproperty.cpp b/kstars/indi/indiproperty.cpp index e1cbd5086..4c6d40e29 100644 --- a/kstars/indi/indiproperty.cpp +++ b/kstars/indi/indiproperty.cpp @@ -1,682 +1,680 @@ /* INDI Property Copyright (C) 2003 Jasem Mutlaq (mutlaqja@ikarustech.com) This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include "indiproperty.h" #include "clientmanager.h" #include "indidevice.h" #include "indielement.h" #include "indigroup.h" #include "kstars.h" #include "Options.h" #include "skymap.h" #include "dialogs/timedialog.h" #include #include #include #include #include #include #include #include #include #include extern const char *libindi_strings_context; /******************************************************************* ** INDI Property: contains widgets, labels, and their status *******************************************************************/ INDI_P::INDI_P(INDI_G *ipg, INDI::Property *prop) { pg = ipg; dataProp = prop; name = QString(prop->getName()); PHBox.reset(new QHBoxLayout()); PHBox->setContentsMargins(0, 0, 0, 0); PVBox = new QVBoxLayout(); PVBox->setContentsMargins(0, 0, 0, 0); initGUI(); } INDI_P::~INDI_P() { qDeleteAll(elementList); elementList.clear(); } void INDI_P::updateStateLED() { /* set state light */ switch (dataProp->getState()) { case IPS_IDLE: ledStatus->setColor(Qt::gray); break; case IPS_OK: ledStatus->setColor(Qt::green); break; case IPS_BUSY: ledStatus->setColor(Qt::yellow); break; case IPS_ALERT: ledStatus->setColor(Qt::red); break; - - default: - break; } } /* build widgets for property pp using info in root. */ void INDI_P::initGUI() { QString label = i18nc(libindi_strings_context, dataProp->getLabel()); if (label == "(I18N_EMPTY_MESSAGE)") label = dataProp->getLabel(); /* add to GUI group */ ledStatus.reset(new KLed(pg->getContainer())); ledStatus->setMaximumSize(16, 16); ledStatus->setLook(KLed::Sunken); updateStateLED(); /* Create a horizontally layout widget around light and label */ QWidget *labelWidget = new QWidget(); QHBoxLayout *labelLayout = new QHBoxLayout(); labelLayout->setContentsMargins(0, 0, 0, 0); labelWidget->setLayout(labelLayout); /* #1 First widget is the LED status indicator */ labelLayout->addWidget(ledStatus.get()); if (label.isEmpty()) { label = i18nc(libindi_strings_context, name.toUtf8()); if (label == "(I18N_EMPTY_MESSAGE)") label = name.toUtf8(); labelW.reset(new QLabel(label, pg->getContainer())); } else labelW.reset(new QLabel(label, pg->getContainer())); //labelW->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); labelW->setFrameShape(QFrame::Box); labelW->setFrameShadow(QFrame::Sunken); labelW->setMargin(2); labelW->setFixedWidth(PROPERTY_LABEL_WIDTH * KStars::Instance()->devicePixelRatio()); + labelW->setMinimumHeight(PROPERTY_LABEL_HEIGHT * KStars::Instance()->devicePixelRatio()); labelW->setTextFormat(Qt::RichText); labelW->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); labelW->setWordWrap(true); labelLayout->addWidget(labelW.get()); PHBox->addWidget(labelWidget, 0, Qt::AlignTop | Qt::AlignLeft); ledStatus->show(); labelW->show(); // #3 Add the Vertical layout which may contain several elements PHBox->addLayout(PVBox); switch (dataProp->getType()) { case INDI_SWITCH: if (dataProp->getSwitch()->r == ISR_NOFMANY) guiType = PG_RADIO; else if (dataProp->getSwitch()->nsp > 4) guiType = PG_MENU; else guiType = PG_BUTTONS; if (guiType == PG_MENU) buildMenuGUI(); else buildSwitchGUI(); break; case INDI_TEXT: buildTextGUI(); break; case INDI_NUMBER: buildNumberGUI(); break; case INDI_LIGHT: buildLightGUI(); break; case INDI_BLOB: buildBLOBGUI(); break; default: break; } } void INDI_P::buildSwitchGUI() { INDI_E *lp = nullptr; ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; groupB.reset(new QButtonGroup()); if (guiType == PG_BUTTONS) { if (svp->r == ISR_1OFMANY) groupB->setExclusive(true); else groupB->setExclusive(false); } else if (guiType == PG_RADIO) groupB->setExclusive(false); if (svp->p != IP_RO) QObject::connect(groupB.get(), SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(newSwitch(QAbstractButton*))); for (int i = 0; i < svp->nsp; i++) { ISwitch *sp = &(svp->sp[i]); lp = new INDI_E(this, dataProp); lp->buildSwitch(groupB.get(), sp); elementList.append(lp); } horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addItem(horSpacer); } void INDI_P::buildTextGUI() { INDI_E *lp = nullptr; ITextVectorProperty *tvp = dataProp->getText(); if (tvp == nullptr) return; for (int i = 0; i < tvp->ntp; i++) { IText *tp = &(tvp->tp[i]); lp = new INDI_E(this, dataProp); lp->buildText(tp); elementList.append(lp); } horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addItem(horSpacer); if (tvp->p == IP_RO) return; // INDI STD, but we use our own controls if (name == "TIME_UTC") setupSetButton(i18n("Time")); else setupSetButton(i18n("Set")); } void INDI_P::buildNumberGUI() { INDI_E *lp = nullptr; INumberVectorProperty *nvp = dataProp->getNumber(); if (nvp == nullptr) return; for (int i = 0; i < nvp->nnp; i++) { INumber *np = &(nvp->np[i]); lp = new INDI_E(this, dataProp); lp->buildNumber(np); elementList.append(lp); } horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addItem(horSpacer); if (nvp->p == IP_RO) return; setupSetButton(i18n("Set")); } void INDI_P::buildLightGUI() { INDI_E *ep = nullptr; ILightVectorProperty *lvp = dataProp->getLight(); if (lvp == nullptr) return; for (int i = 0; i < lvp->nlp; i++) { ILight *lp = &(lvp->lp[i]); ep = new INDI_E(this, dataProp); ep->buildLight(lp); elementList.append(ep); } horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addItem(horSpacer); } void INDI_P::buildBLOBGUI() { INDI_E *lp = nullptr; IBLOBVectorProperty *bvp = dataProp->getBLOB(); if (bvp == nullptr) return; for (int i = 0; i < bvp->nbp; i++) { IBLOB *bp = &(bvp->bp[i]); lp = new INDI_E(this, dataProp); lp->buildBLOB(bp); elementList.append(lp); } horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addItem(horSpacer); enableBLOBC = new QCheckBox(); enableBLOBC->setIcon(QIcon::fromTheme("network-modem")); enableBLOBC->setChecked(true); enableBLOBC->setToolTip(i18n("Enable binary data transfer from this property to KStars and vice-versa.")); PHBox->addWidget(enableBLOBC); connect(enableBLOBC, SIGNAL(stateChanged(int)), this, SLOT(setBLOBOption(int))); if (dataProp->getPermission() != IP_RO) setupSetButton(i18n("Upload")); } void INDI_P::setBLOBOption(int state) { pg->getDevice()->getClientManager()->setBLOBEnabled(state == Qt::Checked, dataProp->getDeviceName(), dataProp->getName()); } void INDI_P::newSwitch(QAbstractButton *button) { ISwitchVectorProperty *svp = dataProp->getSwitch(); QString buttonText = button->text(); if (svp == nullptr) return; buttonText.remove('&'); foreach (INDI_E *el, elementList) { if (el->getLabel() == buttonText) { newSwitch(el->getName()); return; } } } void INDI_P::resetSwitch() { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; if (menuC.get() != nullptr) { menuC->setCurrentIndex(IUFindOnSwitchIndex(svp)); } } void INDI_P::newSwitch(int index) { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; if (index >= svp->nsp) return; ISwitch *sp = &(svp->sp[index]); IUResetSwitch(svp); sp->s = ISS_ON; sendSwitch(); } void INDI_P::newSwitch(const QString &name) { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; ISwitch *sp = IUFindSwitch(svp, name.toLatin1().constData()); if (sp == nullptr) return; if (svp->r == ISR_1OFMANY) { IUResetSwitch(svp); sp->s = ISS_ON; } else { if (svp->r == ISR_ATMOST1) { ISState prev_state = sp->s; IUResetSwitch(svp); sp->s = prev_state; } sp->s = (sp->s == ISS_ON) ? ISS_OFF : ISS_ON; } sendSwitch(); } void INDI_P::sendSwitch() { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; svp->s = IPS_BUSY; foreach (INDI_E *el, elementList) el->syncSwitch(); updateStateLED(); // Send it to server pg->getDevice()->getClientManager()->sendNewSwitch(svp); } void INDI_P::sendText() { ITextVectorProperty *tvp = nullptr; INumberVectorProperty *nvp = nullptr; switch (dataProp->getType()) { case INDI_TEXT: tvp = dataProp->getText(); if (tvp == nullptr) return; tvp->s = IPS_BUSY; foreach (INDI_E *el, elementList) el->updateTP(); pg->getDevice()->getClientManager()->sendNewText(tvp); break; case INDI_NUMBER: nvp = dataProp->getNumber(); if (nvp == nullptr) return; nvp->s = IPS_BUSY; foreach (INDI_E *el, elementList) el->updateNP(); pg->getDevice()->getClientManager()->sendNewNumber(nvp); break; default: break; } updateStateLED(); } void INDI_P::buildMenuGUI() { QStringList menuOptions; QString oneOption; int onItem = -1; INDI_E *lp = nullptr; ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; menuC.reset(new QComboBox(pg->getContainer())); if (svp->p == IP_RO) connect(menuC.get(), SIGNAL(activated(int)), this, SLOT(resetSwitch())); else connect(menuC.get(), SIGNAL(activated(int)), this, SLOT(newSwitch(int))); for (int i = 0; i < svp->nsp; i++) { ISwitch *tp = &(svp->sp[i]); if (tp->s == ISS_ON) onItem = i; lp = new INDI_E(this, dataProp); lp->buildMenuItem(tp); oneOption = i18nc(libindi_strings_context, lp->getLabel().toUtf8()); if (oneOption == "(I18N_EMPTY_MESSAGE)") oneOption = lp->getLabel().toUtf8(); menuOptions.append(oneOption); elementList.append(lp); } menuC->addItems(menuOptions); menuC->setCurrentIndex(onItem); horSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); PHBox->addWidget(menuC.get()); PHBox->addItem(horSpacer); } void INDI_P::setupSetButton(const QString &caption) { setB.reset(new QPushButton(caption, pg->getContainer())); setB->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setB->setMinimumWidth(MIN_SET_WIDTH * KStars::Instance()->devicePixelRatio()); setB->setMaximumWidth(MAX_SET_WIDTH * KStars::Instance()->devicePixelRatio()); connect(setB.get(), SIGNAL(clicked()), this, SLOT(processSetButton())); PHBox->addWidget(setB.get()); } void INDI_P::addWidget(QWidget *w) { PHBox->addWidget(w); } void INDI_P::addLayout(QHBoxLayout *layout) { PVBox->addLayout(layout); } void INDI_P::updateMenuGUI() { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == nullptr) return; int currentIndex = IUFindOnSwitchIndex(svp); menuC->setCurrentIndex(currentIndex); } void INDI_P::processSetButton() { switch (dataProp->getType()) { case INDI_TEXT: if (!strcmp(dataProp->getName(), "TIME_UTC")) newTime(); else sendText(); break; case INDI_NUMBER: sendText(); break; case INDI_BLOB: sendBlob(); break; default: break; } } void INDI_P::sendBlob() { //int index=0; //bool openingTag=false; IBLOBVectorProperty *bvp = dataProp->getBLOB(); if (bvp == nullptr) return; bvp->s = IPS_BUSY; pg->getDevice()->getClientManager()->startBlob(bvp->device, bvp->name, timestamp()); for (int i = 0; i < elementList.count(); i++) { IBLOB *bp = &(bvp->bp[i]); #if (INDI_VERSION_MINOR >= 4 && INDI_VERSION_RELEASE >= 2) pg->getDevice()->getClientManager()->sendOneBlob(bp); #else pg->getDevice()->getClientManager()->sendOneBlob(bp->name, bp->size, bp->format, bp->blob); #endif } // JM: Why we need dirty here? We should be able to upload multiple time /*foreach(INDI_E *ep, elementList) { if (ep->getBLOBDirty() == true) { if (openingTag == false) { pg->getDevice()->getClientManager()->startBlob(bvp->device, bvp->name, timestamp()); openingTag = true; } IBLOB *bp = &(bvp->bp[index]); ep->setBLOBDirty(false); //qDebug() << "SENDING BLOB " << bp->name << " has size of " << bp->size << " and bloblen of " << bp->bloblen << endl; pg->getDevice()->getClientManager()->sendOneBlob(bp->name, bp->size, bp->format, bp->blob); } index++; }*/ //if (openingTag) pg->getDevice()->getClientManager()->finishBlob(); updateStateLED(); } void INDI_P::newTime() { INDI_E *timeEle; INDI_E *offsetEle; timeEle = getElement("UTC"); offsetEle = getElement("OFFSET"); if (!timeEle || !offsetEle) return; TimeDialog timedialog(KStars::Instance()->data()->ut(), KStars::Instance()->data()->geo(), KStars::Instance(), true); if (timedialog.exec() == QDialog::Accepted) { QTime newTime(timedialog.selectedTime()); QDate newDate(timedialog.selectedDate()); timeEle->setText(QString("%1-%2-%3T%4:%5:%6") .arg(newDate.year()) .arg(newDate.month()) .arg(newDate.day()) .arg(newTime.hour()) .arg(newTime.minute()) .arg(newTime.second())); offsetEle->setText(QString().setNum(KStars::Instance()->data()->geo()->TZ(), 'g', 2)); sendText(); } else return; } INDI_E *INDI_P::getElement(const QString &elementName) { foreach (INDI_E *ep, elementList) { if (ep->getName() == elementName) return ep; } return nullptr; }