Пример #1
0
void KStars::setINDIAction(const QString &action)
{
    INDI_D *dev;
    INDI_E *el;

    if (!indidriver || !indimenu)
    {
        kDebug() << "setINDIAction: establishINDI() failed.";
        return;
    }

    dev = indimenu->findDevice(indimenu->getCurrentDevice());
    if (!dev)
        dev = indimenu->findDeviceByLabel(indimenu->getCurrentDevice());
    if (!dev) {
        kDebug() << "Device " << indimenu->getCurrentDevice() << " not found!";
        return;
    }

    el = dev->findElem(action);
    if( !el )
        return;

    el->pp->activateSwitch(action);

}
Пример #2
0
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;

}