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())); }
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) { m_config = new Ui_UploaderWidget(); m_config->setupUi(this); currentStep = IAP_STATE_READY; resetOnly=false; dfu = NULL; m_timer = 0; m_progress = 0; // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); getSerialPorts(); QIcon rbi; rbi.addFile(QString(":uploader/images/view-refresh.svg")); m_config->refreshPorts->setIcon(rbi); connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) onAutopilotConnect(); }
void Simulator::telStatsUpdated(UAVObject *obj) { Q_UNUSED(obj); GCSTelemetryStats::DataFields stats = telStats->getData(); if (!autopilotConnectionStatus && stats.Status == GCSTelemetryStats::STATUS_CONNECTED) { onAutopilotConnect(); } else if (autopilotConnectionStatus && stats.Status != GCSTelemetryStats::STATUS_CONNECTED) { onAutopilotDisconnect(); } }
/** * Constructor */ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);") { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject<UAVObjectManager>(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); connect(telMngr, SIGNAL(connected()), this, SIGNAL(autoPilotConnected())); connect(telMngr, SIGNAL(disconnected()), this, SIGNAL(autoPilotDisconnected())); UAVSettingsImportExportFactory * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>(); connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(invalidateObjects())); }
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) { m_config = new Ui_UploaderWidget(); m_config->setupUi(this); m_currentIAPStep = IAP_STATE_READY; m_resetOnly = false; m_dfu = NULL; m_autoUpdateClosing = false; // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager *telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onPhysicalHWConnect())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->safeBootButton, SIGNAL(clicked()), this, SLOT(systemSafeBoot())); connect(m_config->eraseBootButton, SIGNAL(clicked()), this, SLOT(systemEraseBoot())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); getSerialPorts(); connect(m_config->autoUpdateButton, SIGNAL(clicked()), this, SLOT(startAutoUpdate())); connect(m_config->autoUpdateEraseButton, SIGNAL(clicked()), this, SLOT(startAutoUpdateErase())); connect(m_config->autoUpdateOkButton, SIGNAL(clicked()), this, SLOT(closeAutoUpdate())); m_config->autoUpdateButton->setEnabled(autoUpdateCapable()); m_config->autoUpdateEraseButton->setEnabled(autoUpdateCapable()); m_config->autoUpdateGroupBox->setVisible(false); m_config->refreshPorts->setIcon(QIcon(":uploader/images/view-refresh.svg")); bootButtonsSetEnable(false); connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts())); connect(m_config->pbHelp, SIGNAL(clicked()), this, SLOT(openHelp())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) { onAutopilotConnect(); } }
bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); cf = new ConfigGadgetFactory(this); addAutoReleasedObject(cf); // Add Menu entry to erase all settings Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to erase all settings from the board cmd = am->registerAction(new QAction(this), "ConfigPlugin.EraseAll", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Erase all settings from board...")); ac->menu()->addSeparator(); ac->appendGroup("Utilities"); ac->addAction(cmd, "Utilities"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(eraseAllSettings())); // ********************* // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) onAutopilotConnect(); return true; }
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) { m_config = new Ui_UploaderWidget(); m_config->setupUi(this); currentStep = IAP_STATE_READY; rescueStep = RESCUE_STEP0; resetOnly=false; dfu = NULL; // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // Note: remove listening to the connection manager, it overlaps with // listening to the telemetry manager, we should only listen to one, not both. // Also listen to disconnect actions from the user: // Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); // connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onAutopilotDisconnect())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); getSerialPorts(); QIcon rbi; rbi.addFile(QString(":uploader/images/view-refresh.svg")); m_config->refreshPorts->setIcon(rbi); connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts())); }
void Simulator::onStart() { QMutexLocker locker(&lock); QThread* mainThread = QThread::currentThread(); qDebug() << "Simulator Thread: "<< mainThread; // Get required UAVObjects ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager* objManager = pm->getObject<UAVObjectManager>(); actDesired = ActuatorDesired::GetInstance(objManager); manCtrlCommand = ManualControlCommand::GetInstance(objManager); posHome = HomeLocation::GetInstance(objManager); velActual = VelocityActual::GetInstance(objManager); posActual = PositionActual::GetInstance(objManager); altActual = BaroAltitude::GetInstance(objManager); attActual = AttitudeActual::GetInstance(objManager); attRaw = AttitudeRaw::GetInstance(objManager); gpsPos = GPSPosition::GetInstance(objManager); telStats = GCSTelemetryStats::GetInstance(objManager); // Listen to autopilot connection events TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); //connect(telStats, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(telStatsUpdated(UAVObject*))); // If already connect setup autopilot GCSTelemetryStats::DataFields stats = telStats->getData(); if ( stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) onAutopilotConnect(); inSocket = new QUdpSocket(); outSocket = new QUdpSocket(); setupUdpPorts(settings.hostAddress,settings.inPort,settings.outPort); emit processOutput("\nLocal interface: " + settings.hostAddress + "\n" + \ "Remote interface: " + settings.remoteHostAddress + "\n" + \ "inputPort: " + QString::number(settings.inPort) + "\n" + \ "outputPort: " + QString::number(settings.outPort) + "\n"); qxtLog->info("\nLocal interface: " + settings.hostAddress + "\n" + \ "Remote interface: " + settings.remoteHostAddress + "\n" + \ "inputPort: " + QString::number(settings.inPort) + "\n" + \ "outputPort: " + QString::number(settings.outPort) + "\n"); // if(!inSocket->waitForConnected(5000)) // emit processOutput(QString("Can't connect to %1 on %2 port!").arg(settings.hostAddress).arg(settings.inPort)); // outSocket->connectToHost(settings.hostAddress,settings.outPort); // FG // if(!outSocket->waitForConnected(5000)) // emit processOutput(QString("Can't connect to %1 on %2 port!").arg(settings.hostAddress).arg(settings.outPort)); connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection); // Setup transmit timer txTimer = new QTimer(); connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection); txTimer->setInterval(updatePeriod); txTimer->start(); // Setup simulator connection timer simTimer = new QTimer(); connect(simTimer, SIGNAL(timeout()), this, SLOT(onSimulatorConnectionTimeout()),Qt::DirectConnection); simTimer->setInterval(simTimeout); simTimer->start(); // setup time time = new QTime(); time->start(); current.T=0; current.i=0; }
void Exporter::onStart() { QMutexLocker locker(&lock); QThread* mainThread = QThread::currentThread(); qDebug() << "Exporter Thread: "<< mainThread; // Get required UAVObjects ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager* objManager = pm->getObject<UAVObjectManager>(); actDesired = ActuatorDesired::GetInstance(objManager); actCommand = ActuatorCommand::GetInstance(objManager); manCtrlCommand = ManualControlCommand::GetInstance(objManager); gcsReceiver= GCSReceiver::GetInstance(objManager); flightStatus = FlightStatus::GetInstance(objManager); posHome = HomeLocation::GetInstance(objManager); velActual = VelocityActual::GetInstance(objManager); posActual = PositionActual::GetInstance(objManager); baroAlt = BaroAltitude::GetInstance(objManager); airspeedActual = AirspeedActual::GetInstance(objManager); attActual = AttitudeActual::GetInstance(objManager); attSettings = AttitudeSettings::GetInstance(objManager); accels = Accels::GetInstance(objManager); gyros = Gyros::GetInstance(objManager); gpsPos = GPSPosition::GetInstance(objManager); gpsVel = GPSVelocity::GetInstance(objManager); telStats = GCSTelemetryStats::GetInstance(objManager); // Listen to autopilot connection events TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); //connect(telStats, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(telStatsUpdated(UAVObject*))); // If already connect setup autopilot GCSTelemetryStats::DataFields stats = telStats->getData(); if ( stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) onAutopilotConnect(); inSocket = new QUdpSocket(); outSocket = new QUdpSocket(); setupUdpPorts(settings.hostAddress,settings.inPort,settings.outPort); emit processOutput("\nLocal interface: " + settings.hostAddress + "\n" + \ "Remote interface: " + settings.remoteAddress + "\n" + \ "inputPort: " + QString::number(settings.inPort) + "\n" + \ "outputPort: " + QString::number(settings.outPort) + "\n"); qxtLog->info("\nLocal interface: " + settings.hostAddress + "\n" + \ "Remote interface: " + settings.remoteAddress + "\n" + \ "inputPort: " + QString::number(settings.inPort) + "\n" + \ "outputPort: " + QString::number(settings.outPort) + "\n"); connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection); // Setup transmit timer txTimer = new QTimer(); connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection); txTimer->setInterval(updatePeriod); txTimer->start(); // Setup exporter connection timer exporterTimer = new QTimer(); connect(exporterTimer, SIGNAL(timeout()), this, SLOT(onExporterConnectionTimeout()),Qt::DirectConnection); exporterTimer->setInterval(exporterTimeout); exporterTimer->start(); // setup time time = new QTime(); time->start(); current.T=0; current.i=0; }
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(); } } }
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); stackWidget = new MyTabbedStackWidget(this, true, true); stackWidget->setIconSize(64); QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(stackWidget); setLayout(layout); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); QWidget *widget; QIcon *icon; icon = new QIcon(); icon->addFile(":/configgadget/images/hardware_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/hardware_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new DefaultConfigWidget(this, tr("Hardware")); stackWidget->insertTab(ConfigGadgetWidget::Hardware, widget, *icon, QString("Hardware")); icon = new QIcon(); icon->addFile(":/configgadget/images/vehicle_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/vehicle_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigVehicleTypeWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::Aircraft, widget, *icon, QString("Vehicle")); icon = new QIcon(); icon->addFile(":/configgadget/images/input_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/input_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigInputWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::Input, widget, *icon, QString("Input")); icon = new QIcon(); icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/output_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigOutputWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::Output, widget, *icon, QString("Output")); icon = new QIcon(); icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/ins_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new DefaultConfigWidget(this, tr("Attitude")); stackWidget->insertTab(ConfigGadgetWidget::Sensors, widget, *icon, QString("Attitude")); icon = new QIcon(); icon->addFile(":/configgadget/images/stabilization_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/stabilization_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigStabilizationWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::Stabilization, widget, *icon, QString("Stabilization")); icon = new QIcon(); icon->addFile(":/configgadget/images/camstab_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/camstab_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigCameraStabilizationWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::CameraStabilization, widget, *icon, QString("Gimbal")); icon = new QIcon(); icon->addFile(":/configgadget/images/txpid_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/txpid_selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new ConfigTxPIDWidget(this); static_cast<ConfigTaskWidget *>(widget)->bind(); stackWidget->insertTab(ConfigGadgetWidget::TxPid, widget, *icon, QString("TxPID")); icon = new QIcon(); icon->addFile(":/configgadget/images/pipx-normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/pipx-selected.png", QSize(), QIcon::Selected, QIcon::Off); widget = new DefaultConfigWidget(this, tr("OPLink Configuration")); stackWidget->insertTab(ConfigGadgetWidget::OPLink, widget, *icon, QString("OPLink")); stackWidget->setCurrentIndex(ConfigGadgetWidget::Hardware); // connect to autopilot connection events TelemetryManager *tm = pm->getObject<TelemetryManager>(); connect(tm, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(tm, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // check if we are already connected if (tm->isConnected()) { onAutopilotConnect(); } // connect to oplink manager OPLinkManager *om = pm->getObject<OPLinkManager>(); connect(om, SIGNAL(connected()), this, SLOT(onOPLinkConnect())); connect(om, SIGNAL(disconnected()), this, SLOT(onOPLinkDisconnect())); // check if we are already connected if (om->isConnected()) { onOPLinkConnect(); } help = 0; connect(stackWidget, SIGNAL(currentAboutToShow(int, bool *)), this, SLOT(tabAboutToChange(int, bool *))); }
void SoundNotifyPlugin::onTelemetryManagerAdded(QObject* obj) { telMngr = qobject_cast<TelemetryManager *>(obj); if (telMngr) connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); }
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); ftw = new MyTabbedStackWidget(this, true, true); ftw->setIconSize(64); QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(ftw); setLayout(layout); // ********************* QWidget *qwd; QIcon *icon = new QIcon(); icon->addFile(":/configgadget/images/hardware_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/hardware_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new DefaultHwSettingsWidget(this); ftw->insertTab(ConfigGadgetWidget::hardware, qwd, *icon, QString("Hardware")); icon = new QIcon(); icon->addFile(":/configgadget/images/vehicle_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/vehicle_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigVehicleTypeWidget(this); ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, *icon, QString("Vehicle")); icon = new QIcon(); icon->addFile(":/configgadget/images/input_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/input_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigInputWidget(this); ftw->insertTab(ConfigGadgetWidget::input, qwd, *icon, QString("Input")); icon = new QIcon(); icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/output_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigOutputWidget(this); ftw->insertTab(ConfigGadgetWidget::output, qwd, *icon, QString("Output")); icon = new QIcon(); icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/ins_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new DefaultAttitudeWidget(this); ftw->insertTab(ConfigGadgetWidget::sensors, qwd, *icon, QString("INS")); icon = new QIcon(); icon->addFile(":/configgadget/images/stabilization_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/stabilization_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigStabilizationWidget(this); ftw->insertTab(ConfigGadgetWidget::stabilization, qwd, *icon, QString("Stabilization")); icon = new QIcon(); icon->addFile(":/configgadget/images/autotune_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/autotune_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigAutotuneWidget(this); ftw->insertTab(ConfigGadgetWidget::autotune, qwd, *icon, QString("Autotune")); icon = new QIcon(); icon->addFile(":/configgadget/images/camstab_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/camstab_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigCameraStabilizationWidget(this); ftw->insertTab(ConfigGadgetWidget::camerastabilization, qwd, *icon, QString("Camera Stab")); icon = new QIcon(); icon->addFile(":/configgadget/images/txpid_normal.png", QSize(), QIcon::Normal, QIcon::Off); icon->addFile(":/configgadget/images/txpid_selected.png", QSize(), QIcon::Selected, QIcon::Off); qwd = new ConfigTxPIDWidget(this); ftw->insertTab(ConfigGadgetWidget::txpid, qwd, *icon, QString("TxPID")); ftw->setCurrentIndex(ConfigGadgetWidget::hardware); // ********************* // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) { onAutopilotConnect(); } help = 0; connect(ftw,SIGNAL(currentAboutToShow(int,bool*)),this,SLOT(tabAboutToChange(int,bool*)));//,Qt::BlockingQueuedConnection); // Connect to the PipXStatus object updates UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); pipxStatusObj = dynamic_cast<UAVDataObject*>(objManager->getObject("PipXStatus")); if (pipxStatusObj != NULL ) { connect(pipxStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updatePipXStatus(UAVObject*))); } else {
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(); } } }