void KStars::switchINDI(bool turnOn) { INDI_D *dev; INDI_P *prop; if (!indidriver || !indimenu) { kDebug() << "switchINDI: establishINDI() failed."; return; } dev = indimenu->findDevice(indimenu->getCurrentDevice()); if (!dev) dev = indimenu->findDeviceByLabel(indimenu->getCurrentDevice()); if (!dev) { kDebug() << "Device " << indimenu->getCurrentDevice() << " not found!"; return; } if (turnOn && dev->isOn() || (!turnOn && !dev->isOn())) return; prop = dev->findProp("CONNECTION"); if (!prop) return; if (turnOn) prop->newSwitch(0); else prop->newSwitch(1); }
void imagesequence::checkCCD(int ccdNum) { INDI_D *idevice = NULL; QString targetCCD = CCDCombo->text(ccdNum); INDIMenu *imenu = ksw->getINDIMenu(); if (!imenu) { KMessageBox::error(this, i18n("INDI Menu has not been initialized properly. Restart KStars.")); return; } idevice = imenu->findDeviceByLabel(targetCCD); if (!idevice) { KMessageBox::error(this, i18n("INDI device %1 no longer exists.").arg(targetCCD)); CCDCombo->removeItem(ccdNum); lastCCD = CCDCombo->currentItem(); if (lastCCD != -1) checkCCD(lastCCD); return; } if (!idevice->isOn()) { KMessageBox::error(this, i18n("%1 is disconnected. Establish a connection to the device using the INDI Control Panel.").arg(targetCCD)); CCDCombo->setCurrentItem(lastCCD); return; } currentCCD = targetCCD; }
bool imagesequence::verifyCCDIntegrity() { QString targetCCD; INDI_D *idevice = NULL; INDI_P *exposeProp; INDI_E *exposeElem; stdDevCCD = NULL; INDIMenu *imenu = ksw->getINDIMenu(); if (!imenu) { KMessageBox::error(this, i18n("INDI Menu has not been initialized properly. Restart KStars.")); return false; } targetCCD = CCDCombo->currentText(); if (targetCCD.isEmpty()) return false; // #2 Check if the device exists idevice = imenu->findDeviceByLabel(targetCCD); if (!idevice) { KMessageBox::error(this, i18n("INDI device %1 no longer exists.").arg(targetCCD)); CCDCombo->removeItem(CCDCombo->currentItem()); lastCCD = CCDCombo->currentItem(); return false; } if (!idevice->isOn()) { KMessageBox::error(this, i18n("%1 is disconnected. Establish a connection to the device using the INDI Control Panel.").arg(currentCCD)); return false; } stdDevCCD = idevice->stdDev; exposeProp = stdDevCCD->dp->findProp("CCD_EXPOSE_DURATION"); if (!exposeProp) { KMessageBox::error(this, i18n("Device does not support CCD_EXPOSE_DURATION property.")); return false; } exposeElem = exposeProp->findElement("EXPOSE_DURATION"); if (!exposeElem) { KMessageBox::error(this, i18n("CCD_EXPOSE_DURATION property is missing DURATION element.")); return false; } return true; }
bool imagesequence::verifyFilterIntegrity() { QString targetFilter; INDIMenu *devMenu = ksw->getINDIMenu(); INDI_D *filterDevice (NULL); INDI_E *filterElem(NULL); if (devMenu == NULL) return false; targetFilter = filterCombo->currentText(); if (targetFilter.isEmpty() || targetFilter == i18n("None")) { filterPosCombo->clear(); return false; } // #1 Check the device exists filterDevice = devMenu->findDeviceByLabel(targetFilter); if (filterDevice == NULL) { KMessageBox::error(this, i18n("INDI device %1 no longer exists.").arg(targetFilter)); filterCombo->removeItem(filterCombo->currentItem()); filterCombo->setCurrentItem(0); currentFilter = filterCombo->currentText(); filterPosCombo->clear(); stdDevFilter = NULL; return false; } // #2 Make sure it's connected if (!filterDevice->isOn()) { KMessageBox::error(this, i18n("%1 is disconnected. Establish a connection to the device using the INDI Control Panel.").arg(targetFilter)); filterCombo->setCurrentItem(0); currentFilter = filterCombo->currentText(); filterPosCombo->clear(); stdDevFilter = NULL; return false; } // #3 Make sure it has FILTER_SLOT std property by searching for its SLOT element filterElem = filterDevice->findElem("SLOT"); if (filterElem == NULL) { KMessageBox::error(this, i18n("Device does not support FILTER_SLOT property.")); filterCombo->setCurrentItem(0); currentFilter = filterCombo->currentText(); filterPosCombo->clear(); stdDevFilter = NULL; return false; } stdDevFilter = filterDevice->stdDev; lastFilter = filterCombo->currentItem(); currentFilter = targetFilter; // We're good return true; }