Ejemplo n.º 1
0
/*
   Saves every checked UAVObjet in the list to Flash
 */
void ImportSummaryDialog::doTheSaving()
{
    int itemCount = 0;
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    UAVObjectUtilManager *utilManager  = pm->getObject<UAVObjectUtilManager>();

    connect(utilManager, SIGNAL(saveCompleted(int, bool)), this, SLOT(updateSaveCompletion()));

    for (int i = 0; i < ui->importSummaryList->rowCount(); i++) {
        QCheckBox *box = dynamic_cast<QCheckBox *>(ui->importSummaryList->cellWidget(i, 0));
        if (box->isChecked()) {
            ++itemCount;
        }
    }
    if (itemCount == 0) {
        return;
    }
    ui->progressBar->setMaximum(itemCount + 1);
    ui->progressBar->setValue(1);
    for (int i = 0; i < ui->importSummaryList->rowCount(); i++) {
        QString uavObjectName = ui->importSummaryList->item(i, 1)->text();
        QCheckBox *box = dynamic_cast<QCheckBox *>(ui->importSummaryList->cellWidget(i, 0));
        if (box->isChecked()) {
            UAVObject *obj = objManager->getObject(uavObjectName);
            utilManager->saveObjectToSD(obj);
            this->repaint();
        }
    }

    ui->saveToFlash->setEnabled(false);
    ui->closeButton->setEnabled(false);
}
Ejemplo n.º 2
0
int CopterControl::queryMaxGyroRate()
{
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
    HwCopterControl *hwCopterControl = HwCopterControl::GetInstance(uavoManager);
    UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
    Q_ASSERT(hwCopterControl);
    Q_ASSERT(utilMngr);
    if (!hwCopterControl)
        return 0;
    HwCopterControl::DataFields settings = hwCopterControl->getData();

    int CC_Version = (utilMngr->getBoardModel() & 0x00FF);
    if(CC_Version == 1) return 500;

    switch(settings.GyroRange) {
    case HwCopterControl::GYRORANGE_250:
        return 250;
    case HwCopterControl::GYRORANGE_500:
        return 500;
    case HwCopterControl::GYRORANGE_1000:
        return 1000;
    case HwCopterControl::GYRORANGE_2000:
        return 2000;
    default:
        return 500;
    }
}
Ejemplo n.º 3
0
void ConfigTaskWidget::saveObjectToSD(UAVObject *obj)
{
    // saveObjectToSD is now handled by the UAVUtils plugin in one
    // central place (and one central queue)
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
    utilMngr->saveObjectToSD(obj);
}
void ConfigStabilizationWidget::onBoardConnected()
{
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectUtilManager *utilMngr     = pm->getObject<UAVObjectUtilManager>();

    Q_ASSERT(utilMngr);
    boardModel = utilMngr->getBoardModel();
    // If Revolution board enable Althold tab, otherwise disable it
    ui->AltitudeHold->setEnabled((boardModel & 0xff00) == 0x0900);
}
ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
    m_telemetry = new Ui_CC_HW_Widget();
    m_telemetry->setupUi(this);

    ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
    Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>();
    if(!settings->useExpertMode())
        m_telemetry->saveTelemetryToRAM->setVisible(false);


    UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
    int id = utilMngr->getBoardModel();

    switch (id) {
    case 0x0101:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0101.svg"));
        break;
    case 0x0301:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0301.svg"));
        break;
    case 0x0401:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    case 0x0402:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    case 0x0201:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0201.svg"));
        break;
    default:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    }
    addApplySaveButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD);
    addUAVObjectToWidgetRelation("HwCopterControl","FlexiPort",m_telemetry->cbFlexi);
    addUAVObjectToWidgetRelation("HwCopterControl","MainPort",m_telemetry->cbTele);
    addUAVObjectToWidgetRelation("HwCopterControl","RcvrPort",m_telemetry->cbRcvr);
    addUAVObjectToWidgetRelation("HwCopterControl","USB_HIDPort",m_telemetry->cbUsbHid);
    addUAVObjectToWidgetRelation("HwCopterControl","USB_VCPPort",m_telemetry->cbUsbVcp);
    addUAVObjectToWidgetRelation("ModuleSettings","TelemetrySpeed",m_telemetry->telemetrySpeed);
    addUAVObjectToWidgetRelation("ModuleSettings","GPSSpeed",m_telemetry->gpsSpeed);
    addUAVObjectToWidgetRelation("ModuleSettings","ComUsbBridgeSpeed",m_telemetry->comUsbBridgeSpeed);

    // Load UAVObjects to widget relations from UI file
    // using objrelation dynamic property
    autoLoadWidgets();

    connect(m_telemetry->cchwHelp,SIGNAL(clicked()),this,SLOT(openHelp()));
    enableControls(false);
    populateWidgets();
    refreshWidgetsValues();
    forceConnectedState();
}
Ejemplo n.º 6
0
void ConfigGadgetWidget::onAutopilotConnect()
{
    // qDebug() << "ConfigGadgetWidget::onAutopilotConnect";

    // Check what Board type we are talking to, and if necessary, remove/add tabs in the config gadget
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectUtilManager *utilMngr     = pm->getObject<UAVObjectUtilManager>();

    if (utilMngr) {
        int board = utilMngr->getBoardModel();
        if ((board & 0xff00) == 0x0400) {
            // CopterControl family
            ConfigTaskWidget *widget;
            widget = new ConfigCCAttitudeWidget(this);
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Sensors, widget);
            widget = new ConfigCCHWWidget(this);
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Hardware, widget);
        } else if ((board & 0xff00) == 0x0900) {
            // Revolution family
            ConfigTaskWidget *widget;
            widget = new ConfigRevoWidget(this);
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Sensors, widget);
            if (board == 0x0903 || board == 0x0904) {
                widget = new ConfigRevoHWWidget(this);
            } else if (board == 0x0905) {
                widget = new ConfigRevoNanoHWWidget(this);
            }
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Hardware, widget);
        } else if ((board & 0xff00) == 0x9200) {
            // Sparky2
            ConfigTaskWidget *widget;
            widget = new ConfigRevoWidget(this);
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Sensors, widget);
            widget = new ConfigSparky2HWWidget(this);
            widget->bind();
            stackWidget->replaceTab(ConfigGadgetWidget::Hardware, widget);
        } else {
            // Unknown board
            qWarning() << "Unknown board " << board;
        }
    }
}
Ejemplo n.º 7
0
SetupWizard::CONTROLLER_TYPE ControllerPage::getControllerType()
{
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
    int id = utilMngr->getBoardModel();

    switch (id) {
    case 0x0301:
        return SetupWizard::CONTROLLER_PIPX;
    case 0x0401:
        return SetupWizard::CONTROLLER_CC;
    case 0x0402:
        return SetupWizard::CONTROLLER_CC3D;
    case 0x0901:
        return SetupWizard::CONTROLLER_REVO;
    default:
        return SetupWizard::CONTROLLER_UNKNOWN;
    }
}
void ThermalCalibrationHelper::createDebugLog()
{
    if (m_debugFile.isOpen()) {
        closeDebugLog();
    }
    if (m_tempdir->isValid()) {
        QString filename = QStringLiteral("thcaldebug_%1.txt").arg(QDateTime::currentDateTime().toString("dd.MM.yyyy-hh.mm.ss.zzz"));
        QDir dir = QDir(m_tempdir->path());
        m_debugFile.setFileName(dir.filePath(filename));
        if (!m_debugFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
            m_debugStream.setDevice(0);
            return;
        }
        qDebug() << "Saving debug data for this session to " << dir.filePath(filename);

        m_debugStream.setDevice(&m_debugFile);

        ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
        UAVObjectUtilManager *utilMngr     = pm->getObject<UAVObjectUtilManager>();
        deviceDescriptorStruct board = utilMngr->getBoardDescriptionStruct();

        m_debugStream << "INFO::Hardware" << " type:" << QString().setNum(board.boardType, 16)
                      << " revision:" << QString().setNum(board.boardRevision, 16)
                      << " serial:" << QString(utilMngr->getBoardCPUSerial().toHex()) << endl;

        QString uavo = board.uavoHash.toHex();
        m_debugStream << "INFO::firmware tag:" << board.gitTag
                      << " date:" << board.gitDate
                      << " hash:" << board.gitHash
                      << " uavo:" << uavo.left(8) << endl;

        m_debugStream << "INFO::gcs tag:" << VersionInfo::tagOrBranch() + VersionInfo::dirty()
                      << " date:" << VersionInfo::dateTime()
                      << " hash:" << VersionInfo::hash().left(8)
                      << " uavo:" << VersionInfo::uavoHash().left(8) << endl;
    }
}
Ejemplo n.º 9
0
bool VehicleConfigurationHelper::saveChangesToController(bool save)
{
    qDebug() << "Saving modified objects to controller. " << m_modifiedObjects.count() << " objects in found.";
    const int OUTER_TIMEOUT = 3000 * 20; // 10 seconds timeout for saving all objects
    const int INNER_TIMEOUT = 2000; // 1 second timeout on every save attempt

    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    Q_ASSERT(pm);
    UAVObjectUtilManager *utilMngr     = pm->getObject<UAVObjectUtilManager>();
    Q_ASSERT(utilMngr);

    QTimer outerTimeoutTimer;
    outerTimeoutTimer.setSingleShot(true);

    QTimer innerTimeoutTimer;
    innerTimeoutTimer.setSingleShot(true);

    connect(utilMngr, SIGNAL(saveCompleted(int, bool)), this, SLOT(uAVOTransactionCompleted(int, bool)));
    connect(&innerTimeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
    connect(&outerTimeoutTimer, SIGNAL(timeout()), this, SLOT(saveChangesTimeout()));

    outerTimeoutTimer.start(OUTER_TIMEOUT);
    for (int i = 0; i < m_modifiedObjects.count(); i++) {
        QPair<UAVDataObject *, QString> *objPair = m_modifiedObjects.at(i);
        m_transactionOK = false;
        UAVDataObject *obj     = objPair->first;
        QString objDescription = objPair->second;
        if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettings()) {
            emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, objDescription);

            m_currentTransactionObjectID = obj->getObjID();

            connect(obj, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(uAVOTransactionCompleted(UAVObject *, bool)));
            while (!m_transactionOK && !m_transactionTimeout) {
                // Allow the transaction to take some time
                innerTimeoutTimer.start(INNER_TIMEOUT);

                // Set object updated
                obj->updated();
                if (!m_transactionOK) {
                    m_eventLoop.exec();
                }
                innerTimeoutTimer.stop();
            }
            disconnect(obj, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(uAVOTransactionCompleted(UAVObject *, bool)));
            if (m_transactionOK) {
                qDebug() << "Object " << obj->getName() << " was successfully updated.";
                if (save) {
                    m_transactionOK = false;
                    m_currentTransactionObjectID = obj->getObjID();
                    // Try to save until success or timeout
                    while (!m_transactionOK && !m_transactionTimeout) {
                        // Allow the transaction to take some time
                        innerTimeoutTimer.start(INNER_TIMEOUT);

                        // Persist object in controller
                        utilMngr->saveObjectToFlash(obj);
                        if (!m_transactionOK) {
                            m_eventLoop.exec();
                        }
                        innerTimeoutTimer.stop();
                    }
                    m_currentTransactionObjectID = -1;
                }
            }

            if (!m_transactionOK) {
                qDebug() << "Transaction timed out when trying to save: " << obj->getName();
            } else {
                qDebug() << "Object " << obj->getName() << " was successfully saved.";
            }
        } else {
ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
    m_telemetry = new Ui_CC_HW_Widget();
    m_telemetry->setupUi(this);

    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
    if (!settings->useExpertMode()) {
        m_telemetry->saveTelemetryToRAM->setVisible(false);
    }


    UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
    int id = utilMngr->getBoardModel();

    switch (id) {
    case 0x0101:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0101.svg"));
        break;
    case 0x0301:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0301.svg"));
        break;
    case 0x0401:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    case 0x0402:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    case 0x0201:
        m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0201.svg"));
        break;
    default:
        m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
        break;
    }
    addApplySaveButtons(m_telemetry->saveTelemetryToRAM, m_telemetry->saveTelemetryToSD);
    addWidgetBinding("HwSettings", "CC_FlexiPort", m_telemetry->cbFlexi);
    addWidgetBinding("HwSettings", "CC_MainPort", m_telemetry->cbTele);
    addWidgetBinding("HwSettings", "CC_RcvrPort", m_telemetry->cbRcvr);
    addWidgetBinding("HwSettings", "USB_HIDPort", m_telemetry->cbUsbHid);
    addWidgetBinding("HwSettings", "USB_VCPPort", m_telemetry->cbUsbVcp);
    addWidgetBinding("HwSettings", "TelemetrySpeed", m_telemetry->telemetrySpeed);
    addWidgetBinding("HwSettings", "GPSSpeed", m_telemetry->gpsSpeed);
    // Add Gps protocol configuration

    HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
    HwSettings::DataFields hwSettingsData = hwSettings->getData();

    if (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_GPS] != HwSettings::OPTIONALMODULES_ENABLED) {
        m_telemetry->gpsProtocol->setEnabled(false);
        m_telemetry->gpsProtocol->setToolTip(tr("Enable GPS module and reboot the board to be able to select GPS protocol"));
    } else {
        addWidgetBinding("GPSSettings", "DataProtocol", m_telemetry->gpsProtocol);
    }

    addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_telemetry->comUsbBridgeSpeed);
    connect(m_telemetry->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
    enableSaveButtons(false);
    populateWidgets();
    refreshWidgetsValues();
    forceConnectedState();
}
void UsageTrackerPlugin::collectUsageParameters(QMap<QString, QString> &parameters)
{
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectUtilManager *utilMngr     = pm->getObject<UAVObjectUtilManager>();

    QByteArray description = utilMngr->getBoardDescription();
    deviceDescriptorStruct devDesc;

    if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) {
        int boardModel = utilMngr->getBoardModel();
        parameters["board_type"]   = "0x" + QString::number(boardModel, 16).toLower();
        parameters["board_serial"] = utilMngr->getBoardCPUSerial().toHex();
        parameters["bl_version"]   = QString::number(utilMngr->getBootloaderRevision());
        parameters["fw_tag"] = devDesc.gitTag;
        parameters["fw_hash"] = devDesc.gitHash;
        parameters["os_version"]   = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture();
        parameters["os_threads"]   = QString::number(QThread::idealThreadCount());
        parameters["os_timezone"]  = QTimeZone::systemTimeZoneId();
        parameters["gcs_version"]  = VersionInfo::revision();

        // Configuration parameters
        ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
        UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();

        parameters["conf_receiver"] = getUAVFieldValue(objManager, "ManualControlSettings", "ChannelGroups", 0);
        parameters["conf_vehicle"]  = getUAVFieldValue(objManager, "SystemSettings", "AirframeType");

        if ((boardModel & 0xff00) == 0x0400) {
            // CopterControl family
            parameters["conf_rport"] = getUAVFieldValue(objManager, "HwSettings", "CC_RcvrPort");
            parameters["conf_mport"] = getUAVFieldValue(objManager, "HwSettings", "CC_MainPort");
            parameters["conf_fport"] = getUAVFieldValue(objManager, "HwSettings", "CC_FlexiPort");
        } else if ((boardModel & 0xff00) == 0x0900) {
            // Revolution family
            parameters["conf_rport"]  = getUAVFieldValue(objManager, "HwSettings", "RM_RcvrPort");
            parameters["conf_mport"]  = getUAVFieldValue(objManager, "HwSettings", "RM_MainPort");
            parameters["conf_fport"]  = getUAVFieldValue(objManager, "HwSettings", "RM_FlexiPort");
            parameters["conf_fusion"] = getUAVFieldValue(objManager, "RevoSettings", "FusionAlgorithm");
        }

        parameters["conf_uport"]    = getUAVFieldValue(objManager, "HwSettings", "USB_HIDPort");
        parameters["conf_vport"]    = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort");

        parameters["conf_rotation"] = QString("[%1:%2:%3]")
                                      .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0))
                                      .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1))
                                      .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2));
        parameters["conf_pidr"] = QString("[%1:%2:%3:%4][%5:%6:%7:%8][%9:%10:%11:%12]")
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 0))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 1))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 2))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 3))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 0))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 1))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 2))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 3))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 0))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 1))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 2))
                                  .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 3));
        parameters["conf_pia"] = QString("[%1:%2:%3][%4:%5:%6][%7:%8:%9]")
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 0))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 1))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 2))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 0))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 1))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 2))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 0))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 1))
                                 .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 2));

        parameters["conf_tps"]     = getUAVFieldValue(objManager, "StabilizationSettingsBank1", "EnableThrustPIDScaling");
        parameters["conf_piro"]    = getUAVFieldValue(objManager, "StabilizationSettingsBank1", "EnablePiroComp");

        parameters["conf_fmcount"] = getUAVFieldValue(objManager, "ManualControlSettings", "FlightModeNumber");
        parameters["conf_fmodes"]  = QString("[%1:%2:%3]").arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 0))
                                     .arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 1))
                                     .arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 2));
    }
}