QStringList ConfigGroundVehicleWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults QStringList channelDesc; for (int i = 0; i < (int)ConfigGroundVehicleWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } // get the gui config data GUIConfigDataUnion configData = getConfigData(); if (configData.ground.GroundVehicleSteering1 > 0) { channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1"); } if (configData.ground.GroundVehicleSteering2 > 0) { channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2"); } if (configData.ground.GroundVehicleThrottle1 > 0) { channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundMotor1"); } if (configData.ground.GroundVehicleThrottle2 > 0) { channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundMotor2"); } return channelDesc; }
QStringList ConfigFixedWingWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults QStringList channelDesc; for (int i = 0; i < (int)ConfigFixedWingWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } // get the gui config data GUIConfigDataUnion configData = getConfigData(); if (configData.fixedwing.FixedWingPitch1 > 0) { channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); } if (configData.fixedwing.FixedWingPitch2 > 0) { channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2"); } if (configData.fixedwing.FixedWingRoll1 > 0) { channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1"); } if (configData.fixedwing.FixedWingRoll2 > 0) { channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2"); } if (configData.fixedwing.FixedWingYaw1 > 0) { channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1"); } if (configData.fixedwing.FixedWingYaw2 > 0) { channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2"); } if (configData.fixedwing.FixedWingThrottle > 0) { channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle"); } return channelDesc; }
/** Virtual function to refresh the UI widget values */ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { setupUI(frameType); initMixerCurves(frameType); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); GUIConfigDataUnion config = getConfigData(); // THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1); setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2); setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1); setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2); if (frameType == "GroundVehicleDifferential") { // Find the channel number for Motor1 int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. m_aircraft->differentialSteeringSlider1->setValue( getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) / 1.27); } channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; if (channel > -1) { m_aircraft->differentialSteeringSlider2->setValue( -getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) / 1.27); } } }
QColor GeneralConfig::getWhiteSpaceColor() { /* -returns color of white space when visible in editor */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "whitespace-color"); //process and return value QColor c = getColorFromString(colorString); if ( c.isValid() ) return c; else return QColor(255,255,255); }
QColor GeneralConfig::getMarginsBackground() { /* -returns backgroung color for margins (line numbering etc.) */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "margins-background"); //process and return value QColor c = getColorFromString(colorString); if ( c.isValid() ) return c; else return QColor(200,200,200); }
QColor GeneralConfig::getMarginsForeground() { /* -returns foreground color for margins (line numbering etc.) */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "margins-foreground"); //process and return value QColor c = getColorFromString(colorString); //QColor c = getValueAsColor("editor_theme", "paper_color"); if ( c.isValid() ) return c; else return QColor(0,0,0); }
/** Setup steerable ground vehicle. Returns False if impossible to create the mixer. */ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) { // Check coherence: // Show any config errors in GUI if (throwConfigError(airframeType)) { return false; } // Now setup the channels: GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); setConfigData(config); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); int channel = m_aircraft->gvSteering1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); channel = m_aircraft->gvSteering2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); // Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); return true; }
/** Virtual function to refresh the UI widget values */ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) { Q_ASSERT(m_aircraft); setupUI(frameType); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); QList<double> curveValues; getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); // is at least one of the curve values != 0? if (isValidThrottleCurve(&curveValues)) { // yes, use the curve we just read from mixersettings m_aircraft->fixedWingThrottle->initCurve(&curveValues); } else { // no, init a straight curve m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); } GUIConfigDataUnion config = getConfigData(); fixedGUISettingsStruct fixed = config.fixedwing; // Then retrieve how channels are setup setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle); setComboCurrentIndex(m_aircraft->fwAileron1ChannelBox, fixed.FixedWingRoll1); setComboCurrentIndex(m_aircraft->fwAileron2ChannelBox, fixed.FixedWingRoll2); setComboCurrentIndex(m_aircraft->fwElevator1ChannelBox, fixed.FixedWingPitch1); setComboCurrentIndex(m_aircraft->fwElevator2ChannelBox, fixed.FixedWingPitch2); setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1); setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2); // Get mixing values for GUI sliders (values stored onboard) m_aircraft->elevonSlider3->setValue(getMixerValue(mixer, "RollDifferential")); if (frameType == "FixedWingElevon" || frameType == "Elevon") { m_aircraft->elevonSlider1->setValue(getMixerValue(mixer, "MixerValueRoll")); m_aircraft->elevonSlider2->setValue(getMixerValue(mixer, "MixerValuePitch")); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { m_aircraft->elevonSlider1->setValue(getMixerValue(mixer, "MixerValueYaw")); m_aircraft->elevonSlider2->setValue(getMixerValue(mixer, "MixerValuePitch")); } }
svn_client_ctx_t * ClientContext::getContext(CommitMessage *message, SVN::Pool &in_pool) { apr_pool_t *pool = in_pool.getPool(); svn_client_ctx_t *ctx = m_context; /* Make a temporary copy of ctx to restore at pool cleanup to avoid leaving references to dangling pointers. Note that this allows creating a stack of context changes if the function is invoked multiple times with different pools. */ clearctx_baton_t *bt = reinterpret_cast<clearctx_baton_t *>(apr_pcalloc(pool, sizeof(*bt))); bt->ctx = ctx; bt->backup = reinterpret_cast<svn_client_ctx_t*>(apr_pmemdup(pool, ctx, sizeof(*ctx))); apr_pool_cleanup_register(in_pool.getPool(), bt, clear_ctx_ptrs, clear_ctx_ptrs); if (!ctx->config) { apr_hash_t * configData = getConfigData(); ctx->config = configData; bt->backup->config = ctx->config; } ctx->auth_baton = getAuthBaton(in_pool); ctx->log_msg_baton3 = message; resetCancelRequest(); SVN_JNI_ERR(svn_wc_context_create(&ctx->wc_ctx, NULL, in_pool.getPool(), in_pool.getPool()), NULL); return ctx; }
TMHConfig* createTMHConfig( const char* const configDataFilePath, bool dumpConfig ) { return getConfigData(configDataFilePath,dumpConfig); }
/** Virtual function to refresh the UI widget values */ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { setupUI(frameType); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); QList<double> curveValues; getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); // is at least one of the curve values != 0? if (isValidThrottleCurve(&curveValues)) { // yes, use the curve we just read from mixersettings m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); } else { // no, init a straight curve m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); } // Setup all Throttle2 curves for all types of airframes getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); if (isValidThrottleCurve(&curveValues)) { m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); } else { m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); } GUIConfigDataUnion config = getConfigData(); // THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1); setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2); setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1); setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2); if (frameType == "GroundVehicleDifferential") { // CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE // If the vehicle type is "differential", restore the slider setting // Find the channel number for Motor1 // obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings"))); // Q_ASSERT(obj); int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. m_aircraft->differentialSteeringSlider1->setValue( getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100); m_aircraft->differentialSteeringSlider2->setValue( getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); } } else if (frameType == "GroundVehicleMotorcycle") { // CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE // obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings"))); // Q_ASSERT(obj); // int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; // if (chMixerNumber >=0) { // field = obj->getField(mixerVectors.at(chMixerNumber)); // int ti = field->getElementNames().indexOf("Yaw"); // m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); // // ti = field->getElementNames().indexOf("Pitch"); // m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100); // } } }
void NetworkConnectionClass::run() { client = server.available(); while (client.connected()) { switch (state) { case IDLE: state = SEND_DATA; return; case RECV_DATA: getConfigData(); for (LinkedList<SensorData*>::Iterator it = sensorData->begin(); it != sensorData->end(); it++) { if ((*it)->code == 12) { LightClass *temp = new LightClass(); temp->init((*it)->pin); (*it)->dev = (SensorClass*)temp; } else if ((*it)->code == 0) { LedClass *d1 = new LedClass(); d1->init((*it)->pin); (*it)->dev = (SensorClass*)d1; } else if ((*it)->code == 1) { MotorClass *d2 = new MotorClass(); d2->init((*it)->pin); (*it)->dev = (SensorClass*)d2; } else if ((*it)->code == 2) { Serial.println("Street created"); StreetLightClass *d3 = new StreetLightClass(); d3->init((*it)->pin); (*it)->dev = (SensorClass*)d3; } } state = SEND_DATA; break; case SEND_DATA: unsigned long currentMillis = millis(); if (currentMillis - previousMillis > interval) { previousMillis = currentMillis; for (LinkedList<SensorData*>::Iterator it = sensorData->begin(); it != sensorData->end(); it++) { // Check just sensors, not devices. Devices have code 0. if ((*it)->code != 0 && (*it)->code != 1 && (*it)->code != 2) { float dataValue; if ((*it)->code == 12) { dataValue = (*it)->dev->getValue(""); } float newValueMax = (*it)->oldValue + (*it)->treshold; float newValueMin = (*it)->oldValue - (*it)->treshold; // Check if the sensor has exceeded threshold, send data and update oldValue of sensor //if (dataValue <= newValueMin || dataValue >= newValueMax) { sendData((*it)->name, String((int)dataValue)); (*it)->oldValue = dataValue; //Serial.println((*it)->name); //Serial.println(dataValue); //} } } } checkForUpdate(); state = SEND_DATA; break; } } }
/** Setup VTail */ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) { // Check coherence: // Show any config errors in GUI if (throwConfigError(airframeType)) { return false; } GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); setConfigData(config); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); // Save the curve: // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel double pitch; double roll; double yaw; // motor int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); // ailerons setMixerValue(mixer, "FirstRollServo", m_aircraft->fwAileron1ChannelBox->currentIndex()); channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; if (channel > -1) { // Roll mixer value, currently no slider (should be added for Ailerons response ?) roll = 127; // Store Roll fixed and RollDifferential values onboard setMixerValue(mixer, "MixerValueRoll", 100); setMixerValue(mixer, "RollDifferential", m_aircraft->elevonSlider3->value()); // First Aileron (left) setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll); // Second Aileron (right) channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll); } // vtail (pitch / yaw mixing) channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; if (channel > -1) { // Compute mixer absolute values pitch = (double)(m_aircraft->elevonSlider2->value() * 1.27); yaw = (double)(m_aircraft->elevonSlider1->value() * 1.27); // Store sliders values onboard setMixerValue(mixer, "MixerValuePitch", m_aircraft->elevonSlider2->value()); setMixerValue(mixer, "MixerValueYaw", m_aircraft->elevonSlider1->value()); // First Vtail servo setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, -pitch); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yaw); // Second Vtail servo channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yaw); } m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; }
/** Setup Elevator/Aileron/Rudder airframe. If both Aileron channels are set to 'None' (EasyStar), do Pitch/Rudder mixing Returns False if impossible to create the mixer. */ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) { // Check coherence: // Show any config errors in GUI if (throwConfigError(airframeType)) { return false; } // Now setup the channels: GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); setConfigData(config); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel // motor int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); // rudder channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); // ailerons setMixerValue(mixer, "FirstRollServo", m_aircraft->fwAileron1ChannelBox->currentIndex()); channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; if (channel > -1) { // Store differential value onboard setMixerValue(mixer, "RollDifferential", m_aircraft->elevonSlider3->value()); setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); } // elevators channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; if (channel > -1) { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); } m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; }
/** Helper function to */ QString ConfigCustomWidget::updateConfigObjectsFromWidgets() { UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings"))); Q_ASSERT(system); QPointer<UAVObjectField> field = system->getField(QString("AirframeType")); // Do not allow changes until AirframeType == Custom // If user want to save custom mixer : first set AirframeType to 'Custom' without changes and next modify. if (field->getValue().toString() == "Custom") { UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); GUIConfigDataUnion configData = getConfigData(); resetActuators(&configData); // Update the table: for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) { QComboBox *q = (QComboBox *)m_aircraft->customMixerTable->cellWidget(0, channel); if (q->currentText() == "Disabled") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); } else if (q->currentText() == "Motor") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); if (configData.custom.Motor1 == 0) { configData.custom.Motor1 = channel + 1; } else if (configData.custom.Motor2 == 0) { configData.custom.Motor2 = channel + 1; } else if (configData.custom.Motor3 == 0) { configData.custom.Motor3 = channel + 1; } else if (configData.custom.Motor4 == 0) { configData.custom.Motor4 = channel + 1; } else if (configData.custom.Motor5 == 0) { configData.custom.Motor5 = channel + 1; } else if (configData.custom.Motor6 == 0) { configData.custom.Motor6 = channel + 1; } else if (configData.custom.Motor7 == 0) { configData.custom.Motor7 = channel + 1; } else if (configData.custom.Motor8 == 0) { configData.custom.Motor8 = channel + 1; } } else if (q->currentText() == "ReversableMotor") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR); if (configData.custom.RevMotor1 == 0) { configData.custom.RevMotor1 = channel + 1; } else if (configData.custom.RevMotor2 == 0) { configData.custom.RevMotor2 = channel + 1; } else if (configData.custom.RevMotor3 == 0) { configData.custom.RevMotor3 = channel + 1; } else if (configData.custom.RevMotor4 == 0) { configData.custom.RevMotor4 = channel + 1; } else if (configData.custom.RevMotor5 == 0) { configData.custom.RevMotor5 = channel + 1; } else if (configData.custom.RevMotor6 == 0) { configData.custom.RevMotor6 = channel; } else if (configData.custom.RevMotor7 == 0) { configData.custom.RevMotor7 = channel; } else if (configData.custom.RevMotor8 == 0) { configData.custom.RevMotor8 = channel; } } else if (q->currentText() == "Servo") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); if (configData.custom.Servo1 == 0) { configData.custom.Servo1 = channel + 1; } else if (configData.custom.Servo2 == 0) { configData.custom.Servo2 = channel + 1; } else if (configData.custom.Servo3 == 0) { configData.custom.Servo3 = channel + 1; } else if (configData.custom.Servo4 == 0) { configData.custom.Servo4 = channel + 1; } else if (configData.custom.Servo5 == 0) { configData.custom.Servo5 = channel + 1; } else if (configData.custom.Servo6 == 0) { configData.custom.Servo6 = channel + 1; } else if (configData.custom.Servo7 == 0) { configData.custom.Servo7 = channel + 1; } else if (configData.custom.Servo8 == 0) { configData.custom.Servo8 = channel + 1; } } else if (q->currentText() == "CameraRoll") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL); } else if (q->currentText() == "CameraPitch") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); } else if (q->currentText() == "CameraYaw") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); } else if (q->currentText() == "Accessory0") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); } else if (q->currentText() == "Accessory1") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); } else if (q->currentText() == "Accessory2") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); } else if (q->currentText() == "Accessory3") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); } else if (q->currentText() == "Accessory4") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); } else if (q->currentText() == "Accessory5") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); } setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); } setConfigData(configData); } return "Custom"; }
QStringList ConfigCustomWidget::getChannelDescriptions() { QStringList channelDesc; for (int i = 0; i < (int)VehicleConfig::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } // get the gui config data GUIConfigDataUnion configData = getConfigData(); customGUISettingsStruct custom = configData.custom; if (custom.Motor1 > 0 && custom.Motor1 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor1 - 1] = QString("Motor1"); } if (custom.Motor2 > 0 && custom.Motor2 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor2 - 1] = QString("Motor2"); } if (custom.Motor3 > 0 && custom.Motor3 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor3 - 1] = QString("Motor3"); } if (custom.Motor4 > 0 && custom.Motor4 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor4 - 1] = QString("Motor4"); } if (custom.Motor5 > 0 && custom.Motor5 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor5 - 1] = QString("Motor5"); } if (custom.Motor6 > 0 && custom.Motor6 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor6 - 1] = QString("Motor6"); } if (custom.Motor7 > 0 && custom.Motor7 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor7 - 1] = QString("Motor7"); } if (custom.Motor8 > 0 && custom.Motor8 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Motor8 - 1] = QString("Motor8"); } if (custom.RevMotor1 > 0 && custom.RevMotor1 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor1 - 1] = QString("RevMotor1"); } if (custom.RevMotor2 > 0 && custom.RevMotor2 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor2 - 1] = QString("RevMotor2"); } if (custom.RevMotor3 > 0 && custom.RevMotor3 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor3 - 1] = QString("RevMotor3"); } if (custom.RevMotor4 > 0 && custom.RevMotor4 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor4 - 1] = QString("RevMotor4"); } if (custom.RevMotor5 > 0 && custom.RevMotor5 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor5 - 1] = QString("RevMotor5"); } if (custom.RevMotor6 > 0 && custom.RevMotor6 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor6 - 1] = QString("RevMotor6"); } if (custom.RevMotor7 > 0 && custom.RevMotor7 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor7 - 1] = QString("RevMotor7"); } if (custom.RevMotor8 > 0 && custom.RevMotor8 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.RevMotor8 - 1] = QString("RevMotor8"); } if (custom.Servo1 > 0 && custom.Servo1 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo1 - 1] = QString("Servo1"); } if (custom.Servo2 > 0 && custom.Servo2 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo2 - 1] = QString("Servo2"); } if (custom.Servo3 > 0 && custom.Servo3 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo3 - 1] = QString("Servo3"); } if (custom.Servo4 > 0 && custom.Servo4 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo4 - 1] = QString("Servo4"); } if (custom.Servo5 > 0 && custom.Servo5 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo5 - 1] = QString("Servo5"); } if (custom.Servo6 > 0 && custom.Servo6 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo6 - 1] = QString("Servo6"); } if (custom.Servo7 > 0 && custom.Servo7 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo7 - 1] = QString("Servo7"); } if (custom.Servo8 > 0 && custom.Servo8 <= VehicleConfig::CHANNEL_NUMELEM) { channelDesc[custom.Servo8 - 1] = QString("Servo8"); } return channelDesc; }
svn_auth_baton_t * OperationContext::getAuthBaton(SVN::Pool &in_pool) { svn_auth_baton_t *ab; apr_pool_t *pool = in_pool.getPool(); apr_hash_t * configData = getConfigData(); if (configData == NULL) { return NULL; } svn_config_t *config = static_cast<svn_config_t *>(apr_hash_get(configData, SVN_CONFIG_CATEGORY_CONFIG, APR_HASH_KEY_STRING)); const bool use_native_store = GlobalConfig::useNativeCredentialsStore(); /* The whole list of registered providers */ apr_array_header_t *providers; svn_auth_provider_object_t *provider; if (use_native_store) { /* Populate the registered providers with the platform-specific providers */ SVN_JNI_ERR( svn_auth_get_platform_specific_client_providers( &providers, config, pool), NULL); /* Use the prompter (if available) to prompt for password and cert * caching. */ svn_auth_plaintext_prompt_func_t plaintext_prompt_func; void *plaintext_prompt_baton; svn_auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func; void *plaintext_passphrase_prompt_baton; if (m_prompter.get()) { plaintext_prompt_func = Prompter::plaintext_prompt; plaintext_prompt_baton = m_prompter.get(); plaintext_passphrase_prompt_func = Prompter::plaintext_passphrase_prompt; plaintext_passphrase_prompt_baton = m_prompter.get(); } else { plaintext_prompt_func = NULL; plaintext_prompt_baton = NULL; plaintext_passphrase_prompt_func = NULL; plaintext_passphrase_prompt_baton = NULL; } /* The main disk-caching auth providers, for both * 'username/password' creds and 'username' creds. */ svn_auth_get_simple_provider2(&provider, plaintext_prompt_func, plaintext_prompt_baton, pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; svn_auth_get_username_provider(&provider, pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; svn_auth_get_ssl_server_trust_file_provider(&provider, pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; svn_auth_get_ssl_client_cert_file_provider(&provider, pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; svn_auth_get_ssl_client_cert_pw_file_provider2( &provider, plaintext_passphrase_prompt_func, plaintext_passphrase_prompt_baton, pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; } else { // Not using hte native credentials store, start with an empty // providers array. providers = apr_array_make(pool, 0, sizeof(svn_auth_provider_object_t *)); } if (m_prompter.get()) { /* Two basic prompt providers: username/password, and just username.*/ provider = m_prompter->get_provider_simple(in_pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; provider = m_prompter->get_provider_username(in_pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; /* Three ssl prompt providers, for server-certs, client-certs, * and client-cert-passphrases. */ provider = m_prompter->get_provider_server_ssl_trust(in_pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; provider = m_prompter->get_provider_client_ssl(in_pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; provider = m_prompter->get_provider_client_ssl_password(in_pool); APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; } /* Build an authentication baton to give to libsvn_client. */ svn_auth_open(&ab, providers, pool); /* Place any default --username or --password credentials into the * auth_baton's run-time parameter hash. ### Same with --no-auth-cache? */ if (!m_userName.empty()) svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, apr_pstrdup(in_pool.getPool(), m_userName.c_str())); if (!m_passWord.empty()) svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, apr_pstrdup(in_pool.getPool(), m_passWord.c_str())); /* Store where to retrieve authentication data? */ if (!m_configDir.empty()) svn_auth_set_parameter(ab, SVN_AUTH_PARAM_CONFIG_DIR, apr_pstrdup(in_pool.getPool(), m_configDir.c_str())); return ab; }