ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject<UAVObjectManager>(); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); }
void Simulator::onAutopilotDisconnect() { autopilotConnectionStatus = false; emit autopilotDisconnected(); }
void Exporter::onAutopilotDisconnect() { autopilotConnectionStatus = false; emit autopilotDisconnected(); }
void HITLWidget::startButtonClicked() { QThread *mainThread = QThread::currentThread(); qDebug() << "Main Thread: " << mainThread; // Allow only one instance per simulator if (Simulator::Instances().indexOf(settings.simulatorId) != -1) { widget->textBrowser->append(settings.simulatorId + " alreary started!"); return; } if (!HITLPlugin::typeSimulators.size()) { qxtLog->info("There is no registered simulators, add through HITLPlugin::addSimulator"); return; } // Stop running process if one is active if (simulator) { QMetaObject::invokeMethod(simulator, "onDeleteSimulator", Qt::QueuedConnection); simulator = NULL; } if (settings.hostAddress == "" || settings.inPort == 0) { widget->textBrowser->append("Before start, set UDP parameters in options page!"); return; } SimulatorCreator *creator = HITLPlugin::getSimulatorCreator(settings.simulatorId); simulator = creator->createSimulator(settings); // move to thread <--[BCH] simulator->setName(creator->Description()); simulator->setSimulatorId(creator->ClassId()); connect(simulator, SIGNAL(processOutput(QString)), this, SLOT(onProcessOutput(QString))); // Setup process widget->textBrowser->append(QString("[%1] Starting %2... ").arg(QTime::currentTime().toString("hh:mm:ss")).arg(creator->Description())); qxtLog->info("HITL: Starting " + creator->Description()); // Start bridge bool ret = QMetaObject::invokeMethod(simulator, "setupProcess", Qt::QueuedConnection); if (ret) { Simulator::setInstance(settings.simulatorId); connect(this, SIGNAL(deleteSimulator()), simulator, SLOT(onDeleteSimulator()), Qt::QueuedConnection); widget->startButton->setEnabled(false); widget->stopButton->setEnabled(true); qxtLog->info("HITL: Starting bridge, initializing flight simulator and Autopilot connections"); connect(simulator, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect()), Qt::QueuedConnection); connect(simulator, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()), Qt::QueuedConnection); connect(simulator, SIGNAL(simulatorConnected()), this, SLOT(onSimulatorConnect()), Qt::QueuedConnection); connect(simulator, SIGNAL(simulatorDisconnected()), this, SLOT(onSimulatorDisconnect()), Qt::QueuedConnection); // Initialize connection status if (simulator->isAutopilotConnected()) { onAutopilotConnect(); } else { onAutopilotDisconnect(); } if (simulator->isSimulatorConnected()) { onSimulatorConnect(); } else { onSimulatorDisconnect(); } } }
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_config = new Ui_InputWidget(); m_config->setupUi(this); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); // First of all, put all the channel widgets into lists, so that we can // manipulate those: inMaxLabels << m_config->ch0Max << m_config->ch1Max << m_config->ch2Max << m_config->ch3Max << m_config->ch4Max << m_config->ch5Max << m_config->ch6Max << m_config->ch7Max; inMinLabels << m_config->ch0Min << m_config->ch1Min << m_config->ch2Min << m_config->ch3Min << m_config->ch4Min << m_config->ch5Min << m_config->ch6Min << m_config->ch7Min; inSliders << m_config->inSlider0 << m_config->inSlider1 << m_config->inSlider2 << m_config->inSlider3 << m_config->inSlider4 << m_config->inSlider5 << m_config->inSlider6 << m_config->inSlider7; inRevCheckboxes << m_config->ch0Rev << m_config->ch1Rev << m_config->ch2Rev << m_config->ch3Rev << m_config->ch4Rev << m_config->ch5Rev << m_config->ch6Rev << m_config->ch7Rev; inChannelAssign << m_config->ch0Assign << m_config->ch1Assign << m_config->ch2Assign << m_config->ch3Assign << m_config->ch4Assign << m_config->ch5Assign << m_config->ch6Assign << m_config->ch7Assign; // Now connect the widget to the ManualControlCommand / Channel UAVObject UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlCommand"))); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateChannels(UAVObject*))); // Register for ManualControlSettings changes: obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlSettings"))); connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); // Get the receiver types supported by OpenPilot and fill the corresponding // dropdown menu: obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlSettings"))); UAVObjectField * field; // Fill in the dropdown menus for the channel RC Input assignement. QStringList channelsList; channelsList << "None"; QList<UAVObjectField*> fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { if (field->getUnits().contains("channel")) { channelsList.append(field->getName()); } } m_config->ch0Assign->addItems(channelsList); m_config->ch1Assign->addItems(channelsList); m_config->ch2Assign->addItems(channelsList); m_config->ch3Assign->addItems(channelsList); m_config->ch4Assign->addItems(channelsList); m_config->ch5Assign->addItems(channelsList); m_config->ch6Assign->addItems(channelsList); m_config->ch7Assign->addItems(channelsList); // And the flight mode settings: field = obj->getField(QString("FlightModePosition")); m_config->fmsModePos1->addItems(field->getOptions()); m_config->fmsModePos2->addItems(field->getOptions()); m_config->fmsModePos3->addItems(field->getOptions()); field = obj->getField(QString("Stabilization1Settings")); channelsList.clear(); channelsList.append(field->getOptions()); m_config->fmsSsPos1Roll->addItems(channelsList); m_config->fmsSsPos1Pitch->addItems(channelsList); m_config->fmsSsPos1Yaw->addItems(channelsList); m_config->fmsSsPos2Roll->addItems(channelsList); m_config->fmsSsPos2Pitch->addItems(channelsList); m_config->fmsSsPos2Yaw->addItems(channelsList); m_config->fmsSsPos3Roll->addItems(channelsList); m_config->fmsSsPos3Pitch->addItems(channelsList); m_config->fmsSsPos3Yaw->addItems(channelsList); // And the Armin configurations: field = obj->getField(QString("Arming")); m_config->armControl->clear(); m_config->armControl->addItems(field->getOptions()); connect(m_config->saveRCInputToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); connect(m_config->saveRCInputToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); enableControls(false); refreshValues(); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); connect(m_config->ch0Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch1Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch2Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch3Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch4Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch5Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch6Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->ch7Rev, SIGNAL(toggled(bool)), this, SLOT(reverseCheckboxClicked(bool))); connect(m_config->doRCInputCalibration,SIGNAL(stateChanged(int)),this,SLOT(updateTips(int))); firstUpdate = true; // Connect the help button connect(m_config->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); updateTips(Qt::Unchecked); }
void MoCapWidget::startButtonClicked() { QThread* mainThread = QThread::currentThread(); qDebug() << "Main Thread: "<< mainThread; //Allow only one instance per exporter if(Exporter::Instances().indexOf(settings.exporterId) != -1) { widget->textBrowser->append(settings.exporterId + " alreary started!"); return; } if(!MoCapPlugin::typeMocaps.size()) { qxtLog->info("There is no registered exporters, add through MoCapPlugin::addExporter"); return; } // Stop running process if one is active if(exporter) { QMetaObject::invokeMethod(exporter, "onDeleteExporter",Qt::QueuedConnection); exporter = NULL; } if(settings.hostAddress == "" || settings.inPort == 0) { widget->textBrowser->append("Before start, set UDP parameters in options page!"); return; } MocapCreator* creator = MoCapPlugin::getMocapCreator(settings.exporterId); exporter = creator->createExporter(settings, widget); // move to thread <--[BCH] exporter->setName(creator->Description()); exporter->setExporterId(creator->ClassId()); connect(exporter, SIGNAL(processOutput(QString)), this, SLOT(onProcessOutput(QString))); // Setup process widget->textBrowser->append(QString("[%1] Starting %2... ").arg(QTime::currentTime().toString("hh:mm:ss")).arg(creator->Description())); qxtLog->info("MoCap: Starting " + creator->Description()); // Start bridge bool ret = QMetaObject::invokeMethod(exporter, "setupProcess",Qt::QueuedConnection); if(ret) { Exporter::setInstance(settings.exporterId); connect(this,SIGNAL(deleteExporter()),exporter, SLOT(onDeleteExporter()),Qt::QueuedConnection); widget->startButton->setEnabled(false); widget->stopButton->setEnabled(true); qxtLog->info("MoCap: Starting bridge, initializing flight exporter and Autopilot connections"); connect(exporter, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect()),Qt::QueuedConnection); connect(exporter, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()),Qt::QueuedConnection); connect(exporter, SIGNAL(exporterConnected()), this, SLOT(onExporterConnect()),Qt::QueuedConnection); connect(exporter, SIGNAL(exporterDisconnected()), this, SLOT(onExporterDisconnect()),Qt::QueuedConnection); connect(widget->trackablesComboBox, SIGNAL( currentIndexChanged(int)), this, SLOT(ontrackablesComboBox_changed())); // Initialize connection status if ( exporter->isAutopilotConnected() ) { onAutopilotConnect(); } else { onAutopilotDisconnect(); } if ( exporter->isExporterConnected() ) { onExporterConnect(); } else { onExporterDisconnect(); } } }