1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Merge branch 'next' into revo-next

This commit is contained in:
James Cotton 2012-05-28 15:17:13 -05:00
commit f64adcfa58
4 changed files with 27 additions and 17 deletions

View File

@ -50,15 +50,10 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
m_config->setupUi(this); m_config->setupUi(this);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
addUAVObject("ActuatorSettings");
UAVSettingsImportExportFactory * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>(); UAVSettingsImportExportFactory * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>();
connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests())); connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests()));
addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
addUAVObject("ActuatorSettings");
// NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10. // NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10.
// Register for ActuatorSettings changes: // Register for ActuatorSettings changes:
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++)
@ -73,23 +68,37 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool))); connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
refreshWidgetsValues();
firstUpdate = true; firstUpdate = true;
// Configure the task widget
// Connect the help button // Connect the help button
connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
// Add custom handling of displaying things
connect(this,SIGNAL(refreshWidgetsValuesRequested()), this, SLOT(refreshOutputWidgetsValues()));
addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
// Track the ActuatorSettings object
addUAVObject("ActuatorSettings");
// Associate the buttons with their UAVO fields
addWidget(m_config->cb_outputRate4); addWidget(m_config->cb_outputRate4);
addWidget(m_config->cb_outputRate3); addWidget(m_config->cb_outputRate3);
addWidget(m_config->cb_outputRate2); addWidget(m_config->cb_outputRate2);
addWidget(m_config->cb_outputRate1); addWidget(m_config->cb_outputRate1);
addWidget(m_config->spinningArmed); addWidget(m_config->spinningArmed);
disconnect(this, SLOT(refreshWidgetsValues(UAVObject*)));
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject* obj = objManager->getObject(QString("ActuatorCommand")); UAVObject* obj = objManager->getObject(QString("ActuatorCommand"));
if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE)
this->setEnabled(false); this->setEnabled(false);
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(disableIfNotMe(UAVObject*))); connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(disableIfNotMe(UAVObject*)));
refreshWidgetsValues();
} }
void ConfigOutputWidget::enableControls(bool enable) void ConfigOutputWidget::enableControls(bool enable)
{ {
@ -222,10 +231,8 @@ void ConfigOutputWidget::sendChannelTest(int index, int value)
/** /**
Request the current config from the board (RC Output) Request the current config from the board (RC Output)
*/ */
void ConfigOutputWidget::refreshWidgetsValues(UAVObject *) void ConfigOutputWidget::refreshOutputWidgetsValues(UAVObject *)
{ {
bool dirty=isDirty();
// Reset all channel assignements: // Reset all channel assignements:
QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>(); QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>();
foreach(OutputChannelForm *outputChannelForm, outputChannelForms) foreach(OutputChannelForm *outputChannelForm, outputChannelForms)
@ -318,8 +325,6 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *)
int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()]; int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()];
outputChannelForm->neutral(neutral); outputChannelForm->neutral(neutral);
} }
setDirty(dirty);
} }
/** /**

View File

@ -69,7 +69,7 @@ private:
private slots: private slots:
void stopTests(); void stopTests();
void disableIfNotMe(UAVObject *obj); void disableIfNotMe(UAVObject *obj);
virtual void refreshWidgetsValues(UAVObject * obj = NULL); void refreshOutputWidgetsValues(UAVObject * obj = NULL);
void updateObjectsFromWidgets(); void updateObjectsFromWidgets();
void runChannelTests(bool state); void runChannelTests(bool state);
void sendChannelTest(int index, int value); void sendChannelTest(int index, int value);

View File

@ -32,7 +32,7 @@
/** /**
* Constructor * Constructor
*/ */
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL) ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL),allowWidgetUpdates(true)
{ {
pm = ExtensionSystem::PluginManager::instance(); pm = ExtensionSystem::PluginManager::instance();
objManager = pm->getObject<UAVObjectManager>(); objManager = pm->getObject<UAVObjectManager>();
@ -127,7 +127,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
Q_ASSERT(obj); Q_ASSERT(obj);
objectUpdates.insert(obj,true); objectUpdates.insert(obj,true);
connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*))); connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*)));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*))); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection);
} }
if(!field.isEmpty() && obj) if(!field.isEmpty() && obj)
_field = obj->getField(QString(field)); _field = obj->getField(QString(field));
@ -258,6 +258,9 @@ void ConfigTaskWidget::populateWidgets()
*/ */
void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj) void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj)
{ {
if (!allowWidgetUpdates)
return;
bool dirtyBack=dirty; bool dirtyBack=dirty;
emit refreshWidgetsValuesRequested(); emit refreshWidgetsValuesRequested();
foreach(objectToWidget * ow,objOfInterest) foreach(objectToWidget * ow,objOfInterest)
@ -452,10 +455,10 @@ bool ConfigTaskWidget::isDirty()
*/ */
void ConfigTaskWidget::disableObjUpdates() void ConfigTaskWidget::disableObjUpdates()
{ {
allowWidgetUpdates = false;
foreach(objectToWidget * obj,objOfInterest) foreach(objectToWidget * obj,objOfInterest)
{ {
if(obj->object) if(obj->object)disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)));
disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
} }
} }
/** /**
@ -463,10 +466,11 @@ void ConfigTaskWidget::disableObjUpdates()
*/ */
void ConfigTaskWidget::enableObjUpdates() void ConfigTaskWidget::enableObjUpdates()
{ {
allowWidgetUpdates = true;
foreach(objectToWidget * obj,objOfInterest) foreach(objectToWidget * obj,objOfInterest)
{ {
if(obj->object) if(obj->object)
connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*))); connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection);
} }
} }
/** /**

View File

@ -145,6 +145,7 @@ private slots:
void reloadButtonClicked(); void reloadButtonClicked();
private: private:
bool isConnected; bool isConnected;
bool allowWidgetUpdates;
QStringList objectsList; QStringList objectsList;
QList <objectToWidget*> objOfInterest; QList <objectToWidget*> objOfInterest;
ExtensionSystem::PluginManager *pm; ExtensionSystem::PluginManager *pm;