From 56647f5409a9f7e47be205eb5fabafda239c49cf Mon Sep 17 00:00:00 2001 From: "Richard Flay (Hyper)" Date: Tue, 31 Jul 2012 11:07:07 +0930 Subject: [PATCH 1/6] Fix for OP-661: error messages in GCS log due to obsolete AHRSComms and SDCard related alarms. Change also disables obsolete SDCard support on the flight side of CC and PipX --- flight/CopterControl/System/inc/pios_config_posix.h | 1 - flight/PipXtreme/System/inc/pios_config_posix.h | 1 - flight/SimPosix/System/inc/pios_config.h | 1 - flight/UAVObjects/inc/uavobjectmanager.h | 9 ++------- flight/UAVObjects/uavobjectmanager.c | 10 ++++------ shared/uavobjectdefinition/systemalarms.xml | 2 +- 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/flight/CopterControl/System/inc/pios_config_posix.h b/flight/CopterControl/System/inc/pios_config_posix.h index f7dd4aa2e..ed2351ea6 100644 --- a/flight/CopterControl/System/inc/pios_config_posix.h +++ b/flight/CopterControl/System/inc/pios_config_posix.h @@ -33,7 +33,6 @@ #define PIOS_INCLUDE_SYS #define PIOS_INCLUDE_DELAY #define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SDCARD #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_COM #define PIOS_INCLUDE_UDP diff --git a/flight/PipXtreme/System/inc/pios_config_posix.h b/flight/PipXtreme/System/inc/pios_config_posix.h index ddf7ee5d4..9d589d634 100755 --- a/flight/PipXtreme/System/inc/pios_config_posix.h +++ b/flight/PipXtreme/System/inc/pios_config_posix.h @@ -33,7 +33,6 @@ #define PIOS_INCLUDE_SYS #define PIOS_INCLUDE_DELAY #define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SDCARD #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_COM #define PIOS_INCLUDE_UDP diff --git a/flight/SimPosix/System/inc/pios_config.h b/flight/SimPosix/System/inc/pios_config.h index d4add3666..84d857f19 100644 --- a/flight/SimPosix/System/inc/pios_config.h +++ b/flight/SimPosix/System/inc/pios_config.h @@ -44,7 +44,6 @@ //#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SDCARD //#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_SERVO #define PIOS_INCLUDE_SPI diff --git a/flight/UAVObjects/inc/uavobjectmanager.h b/flight/UAVObjects/inc/uavobjectmanager.h index 62aff543d..7d774d5ae 100644 --- a/flight/UAVObjects/inc/uavobjectmanager.h +++ b/flight/UAVObjects/inc/uavobjectmanager.h @@ -46,13 +46,6 @@ #define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT 6 #define UAVOBJ_UPDATE_MODE_MASK 0x3 - -// FIXME: All this typedef for SDCARD needs to be abstracted away -#if !defined(PIOS_INCLUDE_SDCARD) -typedef struct {} FILEINFO; -#endif - - typedef void* UAVObjHandle; /** @@ -164,8 +157,10 @@ int32_t UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t* dataOut); int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId); int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId); int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId); +#if defined(PIOS_INCLUDE_SDCARD) int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, FILEINFO* file); UAVObjHandle UAVObjLoadFromFile(FILEINFO* file); +#endif int32_t UAVObjSaveSettings(); int32_t UAVObjLoadSettings(); int32_t UAVObjDeleteSettings(); diff --git a/flight/UAVObjects/uavobjectmanager.c b/flight/UAVObjects/uavobjectmanager.c index 2b2b69018..c339af0fe 100644 --- a/flight/UAVObjects/uavobjectmanager.c +++ b/flight/UAVObjects/uavobjectmanager.c @@ -668,6 +668,7 @@ unlock_exit: return rc; } +#if defined(PIOS_INCLUDE_SDCARD) /** * Save the data of the specified object instance to the file system (SD card). * The object will be appended and the file will not be closed. @@ -682,7 +683,6 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, { PIOS_Assert(obj_handle); -#if defined(PIOS_INCLUDE_SDCARD) uint32_t bytesWritten; // Check for file system availability if (PIOS_SDCARD_IsMounted() == 0) { @@ -741,9 +741,9 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, } // Done xSemaphoreGiveRecursive(mutex); -#endif /* PIOS_INCLUDE_SDCARD */ return 0; } +#endif /* PIOS_INCLUDE_SDCARD */ /** * Save the data of the specified object to the file system (SD card). @@ -811,6 +811,7 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId) return 0; } +#if defined(PIOS_INCLUDE_SDCARD) /** * Load an object from the file system (SD card). * @param[in] file File to read from @@ -818,7 +819,6 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId) */ UAVObjHandle UAVObjLoadFromFile(FILEINFO * file) { -#if defined(PIOS_INCLUDE_SDCARD) uint32_t bytesRead; struct UAVOBase *objEntry; InstanceHandle instEntry; @@ -898,10 +898,8 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO * file) // Unlock xSemaphoreGiveRecursive(mutex); return obj_handle; -#else /* PIOS_INCLUDE_SDCARD */ - return NULL; -#endif } +#endif /* PIOS_INCLUDE_SDCARD */ /** * Load an object from the file system (SD card). diff --git a/shared/uavobjectdefinition/systemalarms.xml b/shared/uavobjectdefinition/systemalarms.xml index cc20045b6..dd185cfa3 100644 --- a/shared/uavobjectdefinition/systemalarms.xml +++ b/shared/uavobjectdefinition/systemalarms.xml @@ -2,7 +2,7 @@ Alarms from OpenPilot to indicate failure conditions or warnings. Set by various modules. + elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,Telemetry,ManualControl,Actuator,Attitude,Sensors,Stabilization,Guidance,Battery,FlightTime,I2C,GPS,BootFault" defaultvalue="Uninitialised"/> From 6d347954941e718c374c10402f1f86c5072e0683 Mon Sep 17 00:00:00 2001 From: "Richard Flay (Hyper)" Date: Wed, 1 Aug 2012 19:53:59 +0930 Subject: [PATCH 2/6] Re-enabled simposix SDCard support, and removed obsolete SDCard alarm usage from System module --- flight/Modules/System/systemmod.c | 9 --------- flight/SimPosix/System/inc/pios_config.h | 1 + .../diagrams/default/system-health.svg | 20 ------------------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/flight/Modules/System/systemmod.c b/flight/Modules/System/systemmod.c index 33bf462fb..715c26d72 100644 --- a/flight/Modules/System/systemmod.c +++ b/flight/Modules/System/systemmod.c @@ -463,15 +463,6 @@ static void updateSystemAlarms() AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW); } -#if defined(PIOS_INCLUDE_SDCARD) - // Check for SD card - if (PIOS_SDCARD_IsMounted() == 0) { - AlarmsSet(SYSTEMALARMS_ALARM_SDCARD, SYSTEMALARMS_ALARM_ERROR); - } else { - AlarmsClear(SYSTEMALARMS_ALARM_SDCARD); - } -#endif - // Check for event errors UAVObjGetStats(&objStats); EventGetStats(&evStats); diff --git a/flight/SimPosix/System/inc/pios_config.h b/flight/SimPosix/System/inc/pios_config.h index 84d857f19..d4add3666 100644 --- a/flight/SimPosix/System/inc/pios_config.h +++ b/flight/SimPosix/System/inc/pios_config.h @@ -44,6 +44,7 @@ //#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_SDCARD //#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_SERVO #define PIOS_INCLUDE_SPI diff --git a/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg b/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg index 2ec58bd37..fb82a980c 100644 --- a/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg +++ b/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg @@ -1385,26 +1385,6 @@ id="Telemetry-Critical" style="fill:#cf0e0e;fill-opacity:1;stroke:#ffffff;stroke-width:0.29055119;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" /> - - - - Date: Wed, 1 Aug 2012 14:42:21 +0100 Subject: [PATCH 3/6] GCS-Made the UI limits board specific --- .../src/plugins/config/configinputwidget.cpp | 12 +++---- .../src/plugins/uavobjects/uavobjectfield.cpp | 28 +++++++++++++--- .../src/plugins/uavobjects/uavobjectfield.h | 7 ++-- .../uavobjectwidgetutils/configtaskwidget.cpp | 33 +++++++++++-------- .../uavobjectwidgetutils/configtaskwidget.h | 2 ++ .../manualcontrolsettings.xml | 2 +- 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 7952b3d70..e0425d963 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -82,12 +82,12 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) connect(m_config->wzBack,SIGNAL(clicked()),this,SLOT(wzBack())); m_config->stackedWidget->setCurrentIndex(0); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos1,0); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos2,1); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos3,2); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos4,3); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos5,4); - addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos6,5); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos1,0,1,true); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos2,1,1,true); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos3,2,1,true); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos4,3,1,true); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos5,4,1,true); + addUAVObjectToWidgetRelation("ManualControlSettings","FlightModePosition",m_config->fmsModePos6,5,1,true); addUAVObjectToWidgetRelation("ManualControlSettings","FlightModeNumber",m_config->fmsPosNum); addUAVObjectToWidgetRelation("ManualControlSettings","Stabilization1Settings",m_config->fmsSsPos1Roll,"Roll"); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp index 5ccd7371f..71e4b27a6 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp @@ -113,12 +113,22 @@ void UAVObjectField::limitsInitialize(const QString &limits) quint32 index=0; foreach (QString str, stringPerElement) { QString _str=str.trimmed(); + if(_str.isEmpty()) + continue; QStringList valuesPerElement=_str.split(":"); LimitStruct lstruc; bool b1=valuesPerElement.at(0).startsWith("%"); bool b2=(int)(index)<(int)numElements; - if(b1 && b2) + bool b3=valuesPerElement.at(0).size()==3; + bool auxb; + valuesPerElement.at(0).mid(1,4).toInt(&auxb,16); + bool b4=((valuesPerElement.at(0).size())==7 && auxb); + if(b1 && b2 && (b3 || b4)) { + if(b4) + lstruc.board=valuesPerElement.at(0).mid(1,4).toInt(&auxb,16); + else + lstruc.board=0; if(valuesPerElement.at(0).right(2)=="EQ") lstruc.type=EQUAL; else if(valuesPerElement.at(0).right(2)=="NE") @@ -140,7 +150,7 @@ void UAVObjectField::limitsInitialize(const QString &limits) case UINT8: case UINT16: case UINT32: - case BITFIELD: + case BITFIELD: lstruc.values.append((quint32)value.toULong()); break; case INT8: @@ -170,14 +180,18 @@ void UAVObjectField::limitsInitialize(const QString &limits) qDebug()<<"limits parsing failed (property doesn't start with %) on UAVObjectField"<numelements) on UAVObjectField"< values; + int board; } LimitStruct; UAVObjectField(const QString& name, const QString& units, FieldType type, quint32 numElements, const QStringList& options,const QString& limits=QString()); @@ -74,9 +75,9 @@ public: bool isText(); QString toString(); - bool isWithinLimits(QVariant var, quint32 index); - QVariant getMaxLimit(quint32 index); - QVariant getMinLimit(quint32 index); + bool isWithinLimits(QVariant var, quint32 index, int board=0); + QVariant getMaxLimit(quint32 index, int board=0); + QVariant getMinLimit(quint32 index, int board=0); signals: void fieldUpdated(UAVObjectField* field); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 7fb8d70c7..594063358 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -37,6 +37,7 @@ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnecte pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); TelemetryManager* telMngr = pm->getObject(); + utilMngr = pm->getObject(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); connect(telMngr, SIGNAL(connected()), this, SIGNAL(autoPilotConnected())); @@ -226,9 +227,15 @@ void ConfigTaskWidget::onAutopilotDisconnect() void ConfigTaskWidget::onAutopilotConnect() { + if (utilMngr) + currentBoard = utilMngr->getBoardModel();//TODO REMEMBER TO ADD THIS TO FORCE CONNECTED FUNC ON CC3D_RELEASE invalidateObjects(); dirty=false; isConnected=true; + foreach(objectToWidget * ow,objOfInterest) + { + loadWidgetLimits(ow->widget,ow->field,ow->index,ow->isLimited,ow->scale); + } enableControls(true); refreshWidgetsValues(); } @@ -1057,7 +1064,7 @@ void ConfigTaskWidget::checkWidgetsLimits(QWidget * widget,UAVObjectField * fiel { if(!hasLimits) return; - if(!field->isWithinLimits(value,index)) + if(!field->isWithinLimits(value,index,currentBoard)) { if(!widget->property("styleBackup").isValid()) widget->setProperty("styleBackup",widget->styleSheet()); @@ -1131,7 +1138,7 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field, { foreach(QString str,option) { - if(field->isWithinLimits(str,index)) + if(field->isWithinLimits(str,index,currentBoard)) cb->addItem(str); } } @@ -1144,33 +1151,33 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field, { if(field->getMaxLimit(index).isValid()) { - cb->setMaximum((double)(field->getMaxLimit(index).toDouble()/scale)); + cb->setMaximum((double)(field->getMaxLimit(index,currentBoard).toDouble()/scale)); } - if(field->getMinLimit(index).isValid()) + if(field->getMinLimit(index,currentBoard).isValid()) { - cb->setMinimum((double)(field->getMinLimit(index).toDouble()/scale)); + cb->setMinimum((double)(field->getMinLimit(index,currentBoard).toDouble()/scale)); } } else if(QSpinBox * cb=qobject_cast(widget)) { - if(field->getMaxLimit(index).isValid()) + if(field->getMaxLimit(index,currentBoard).isValid()) { - cb->setMaximum((int)qRound(field->getMaxLimit(index).toDouble()/scale)); + cb->setMaximum((int)qRound(field->getMaxLimit(index,currentBoard).toDouble()/scale)); } - if(field->getMinLimit(index).isValid()) + if(field->getMinLimit(index,currentBoard).isValid()) { - cb->setMinimum((int)qRound(field->getMinLimit(index).toDouble()/scale)); + cb->setMinimum((int)qRound(field->getMinLimit(index,currentBoard).toDouble()/scale)); } } else if(QSlider * cb=qobject_cast(widget)) { - if(field->getMaxLimit(index).isValid()) + if(field->getMaxLimit(index,currentBoard).isValid()) { - cb->setMaximum((int)qRound(field->getMaxLimit(index).toDouble()/scale)); + cb->setMaximum((int)qRound(field->getMaxLimit(index,currentBoard).toDouble()/scale)); } - if(field->getMinLimit(index).isValid()) + if(field->getMinLimit(index,currentBoard).isValid()) { - cb->setMinimum((int)(field->getMinLimit(index).toDouble()/scale)); + cb->setMinimum((int)(field->getMinLimit(index,currentBoard).toDouble()/scale)); } } } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 3cac0abc0..0a17aa544 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -144,12 +144,14 @@ private slots: void defaultButtonClicked(); void reloadButtonClicked(); private: + int currentBoard; bool isConnected; bool allowWidgetUpdates; QStringList objectsList; QList objOfInterest; ExtensionSystem::PluginManager *pm; UAVObjectManager *objManager; + UAVObjectUtilManager* utilMngr; smartSaveButton *smartsave; QMap objectUpdates; QMap *> defaultReloadGroups; diff --git a/shared/uavobjectdefinition/manualcontrolsettings.xml b/shared/uavobjectdefinition/manualcontrolsettings.xml index 09d4ca618..87924a065 100644 --- a/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -24,7 +24,7 @@ - + From cb26100d65f1c95beeeaed22d7afc31d4def0660 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Thu, 2 Aug 2012 16:48:37 +0100 Subject: [PATCH 4/6] GCS - Dummy commit to see if crucible notices this branch --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 594063358..b08fea191 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -230,6 +230,7 @@ void ConfigTaskWidget::onAutopilotConnect() if (utilMngr) currentBoard = utilMngr->getBoardModel();//TODO REMEMBER TO ADD THIS TO FORCE CONNECTED FUNC ON CC3D_RELEASE invalidateObjects(); + dirty=false; isConnected=true; foreach(objectToWidget * ow,objOfInterest) From 352f18bec0597d90cb7b3dcad2bf0f7530ac63fc Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Thu, 2 Aug 2012 23:56:02 +0100 Subject: [PATCH 5/6] GCS-Allow for more than 1 limit per index --- .../src/plugins/uavobjects/uavobjectfield.cpp | 613 +++++++++--------- .../src/plugins/uavobjects/uavobjectfield.h | 2 +- 2 files changed, 320 insertions(+), 295 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp index 71e4b27a6..fcd108155 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp @@ -112,76 +112,94 @@ void UAVObjectField::limitsInitialize(const QString &limits) QStringList stringPerElement=limits.split(","); quint32 index=0; foreach (QString str, stringPerElement) { - QString _str=str.trimmed(); - if(_str.isEmpty()) - continue; - QStringList valuesPerElement=_str.split(":"); - LimitStruct lstruc; - bool b1=valuesPerElement.at(0).startsWith("%"); - bool b2=(int)(index)<(int)numElements; - bool b3=valuesPerElement.at(0).size()==3; - bool auxb; - valuesPerElement.at(0).mid(1,4).toInt(&auxb,16); - bool b4=((valuesPerElement.at(0).size())==7 && auxb); - if(b1 && b2 && (b3 || b4)) + QStringList ruleList=str.split(";"); + QList limitList; + foreach(QString rule,ruleList) { - if(b4) - lstruc.board=valuesPerElement.at(0).mid(1,4).toInt(&auxb,16); - else - lstruc.board=0; - if(valuesPerElement.at(0).right(2)=="EQ") - lstruc.type=EQUAL; - else if(valuesPerElement.at(0).right(2)=="NE") - lstruc.type=NOT_EQUAL; - else if(valuesPerElement.at(0).right(2)=="BE") - lstruc.type=BETWEEN; - else if(valuesPerElement.at(0).right(2)=="BI") - lstruc.type=BIGGER; - else if(valuesPerElement.at(0).right(2)=="SM") - lstruc.type=SMALLER; - else - qDebug()<<"limits parsing failed (invalid property) on UAVObjectField"<numelements) on UAVObjectField"< limitList,elementLimits) + { + foreach(LimitStruct limit,limitList) { - if(!valuesPerElement.at(0).isEmpty() && !b1) - qDebug()<<"limits parsing failed (property doesn't start with %) on UAVObjectField"<numelements) on UAVObjectField"<2) + qDebug()<<__FUNCTION__<<"between limit with more than 1 pair, using first; field"<=struc.values.at(0).toInt() && var.toInt()<=struc.values.at(1).toInt())) + return false; + return true; + break; + case UINT8: + case UINT16: + case UINT32: + case BITFIELD: + if(!(var.toUInt()>=struc.values.at(0).toUInt() && var.toUInt()<=struc.values.at(1).toUInt())) + return false; + return true; + break; + case ENUM: + if(!(options.indexOf(var.toString())>=options.indexOf(struc.values.at(0).toString()) && options.indexOf(var.toString())<=options.indexOf(struc.values.at(1).toString()))) + return false; + return true; + break; + case STRING: + return true; + break; + case FLOAT32: + if(!(var.toFloat()>=struc.values.at(0).toFloat() && var.toFloat()<=struc.values.at(1).toFloat())) + return false; + return true; + break; + default: + return true; } - return false; break; - default: - return true; - } - break; - case NOT_EQUAL: - switch (type) - { - case INT8: - case INT16: - case INT32: - foreach (QVariant vars, struc.values) { - if(var.toInt()==vars.toInt()) - return false; + case BIGGER: + if(struc.values.length()<1) + { + qDebug()<<__FUNCTION__<<"BIGGER limit with less than 1 value, aborting; field:"<1) + qDebug()<<__FUNCTION__<<"BIGGER limit with more than 1 value, using first; field"<=struc.values.at(0).toInt())) + return false; + return true; + break; + case UINT8: + case UINT16: + case UINT32: + case BITFIELD: + if(!(var.toUInt()>=struc.values.at(0).toUInt())) + return false; + return true; + break; + case ENUM: + if(!(options.indexOf(var.toString())>=options.indexOf(struc.values.at(0).toString()))) + return false; + return true; + break; + case STRING: + return true; + break; + case FLOAT32: + if(!(var.toFloat()>=struc.values.at(0).toFloat())) + return false; + return true; + break; + default: + return true; } - return true; break; - case ENUM: - case STRING: - foreach (QVariant vars, struc.values) { - if(var.toString()==vars.toString()) - return false; + case SMALLER: + switch (type) + { + case INT8: + case INT16: + case INT32: + if(!(var.toInt()<=struc.values.at(0).toInt())) + return false; + return true; + break; + case UINT8: + case UINT16: + case UINT32: + case BITFIELD: + if(!(var.toUInt()<=struc.values.at(0).toUInt())) + return false; + return true; + break; + case ENUM: + if(!(options.indexOf(var.toString())<=options.indexOf(struc.values.at(0).toString()))) + return false; + return true; + break; + case STRING: + return true; + break; + case FLOAT32: + if(!(var.toFloat()<=struc.values.at(0).toFloat())) + return false; + return true; + break; + default: + return true; } - return true; - break; - case FLOAT32: - foreach (QVariant vars, struc.values) { - if(var.toFloat()==vars.toFloat()) - return false; - } - return true; - break; - default: - return true; - } - break; - case BETWEEN: - if(struc.values.length()<2) - { - qDebug()<<__FUNCTION__<<"between limit with less than 1 pair, aborting; field:"<2) - qDebug()<<__FUNCTION__<<"between limit with more than 1 pair, using first; field"<=struc.values.at(0).toInt() && var.toInt()<=struc.values.at(1).toInt())) - return false; - return true; - break; - case UINT8: - case UINT16: - case UINT32: - case BITFIELD: - if(!(var.toUInt()>=struc.values.at(0).toUInt() && var.toUInt()<=struc.values.at(1).toUInt())) - return false; - return true; - break; - case ENUM: - if(!(options.indexOf(var.toString())>=options.indexOf(struc.values.at(0).toString()) && options.indexOf(var.toString())<=options.indexOf(struc.values.at(1).toString()))) - return false; - return true; - break; - case STRING: - return true; - break; - case FLOAT32: - if(!(var.toFloat()>=struc.values.at(0).toFloat() && var.toFloat()<=struc.values.at(1).toFloat())) - return false; - return true; - break; - default: - return true; - } - break; - case BIGGER: - if(struc.values.length()<1) - { - qDebug()<<__FUNCTION__<<"BIGGER limit with less than 1 value, aborting; field:"<1) - qDebug()<<__FUNCTION__<<"BIGGER limit with more than 1 value, using first; field"<=struc.values.at(0).toInt())) - return false; - return true; - break; - case UINT8: - case UINT16: - case UINT32: - case BITFIELD: - if(!(var.toUInt()>=struc.values.at(0).toUInt())) - return false; - return true; - break; - case ENUM: - if(!(options.indexOf(var.toString())>=options.indexOf(struc.values.at(0).toString()))) - return false; - return true; - break; - case STRING: - return true; - break; - case FLOAT32: - if(!(var.toFloat()>=struc.values.at(0).toFloat())) - return false; - return true; - break; - default: - return true; - } - break; - case SMALLER: - switch (type) - { - case INT8: - case INT16: - case INT32: - if(!(var.toInt()<=struc.values.at(0).toInt())) - return false; - return true; - break; - case UINT8: - case UINT16: - case UINT32: - case BITFIELD: - if(!(var.toUInt()<=struc.values.at(0).toUInt())) - return false; - return true; - break; - case ENUM: - if(!(options.indexOf(var.toString())<=options.indexOf(struc.values.at(0).toString()))) - return false; - return true; - break; - case STRING: - return true; - break; - case FLOAT32: - if(!(var.toFloat()<=struc.values.at(0).toFloat())) - return false; - return true; - break; - default: - return true; } } return true; @@ -402,55 +423,59 @@ QVariant UAVObjectField::getMaxLimit(quint32 index,int board) { if(!elementLimits.keys().contains(index)) return QVariant(); - LimitStruct struc=elementLimits.value(index); - if((struc.board!=board) && board!=0 && struc.board!=0) - return QVariant(); - switch(struc.type) + foreach(LimitStruct struc,elementLimits.value(index)) { - case EQUAL: - case NOT_EQUAL: - case BIGGER: - return QVariant(); - break; - break; - case BETWEEN: - return struc.values.at(1); - break; - case SMALLER: - return struc.values.at(0); - break; - default: - return QVariant(); - break; + if((struc.board!=board) && board!=0 && struc.board!=0) + continue; + switch(struc.type) + { + case EQUAL: + case NOT_EQUAL: + case BIGGER: + return QVariant(); + break; + break; + case BETWEEN: + return struc.values.at(1); + break; + case SMALLER: + return struc.values.at(0); + break; + default: + return QVariant(); + break; + } } - return QVariant(); + return QVariant(); } QVariant UAVObjectField::getMinLimit(quint32 index, int board) { if(!elementLimits.keys().contains(index)) return QVariant(); - LimitStruct struc=elementLimits.value(index); - if((struc.board!=board) && board!=0 && struc.board!=0) - return QVariant(); - switch(struc.type) + foreach(LimitStruct struc,elementLimits.value(index)) { - case EQUAL: - case NOT_EQUAL: - case SMALLER: - return QVariant(); - break; - break; - case BETWEEN: - return struc.values.at(0); - break; - case BIGGER: - return struc.values.at(0); - break; - default: - return QVariant(); - break; + if((struc.board!=board) && board!=0 && struc.board!=0) + return QVariant(); + switch(struc.type) + { + case EQUAL: + case NOT_EQUAL: + case SMALLER: + return QVariant(); + break; + break; + case BETWEEN: + return struc.values.at(0); + break; + case BIGGER: + return struc.values.at(0); + break; + default: + return QVariant(); + break; + } } - return QVariant(); + return QVariant(); } void UAVObjectField::initialize(quint8* data, quint32 dataOffset, UAVObject* obj) { diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.h index d570efe6d..48d927797 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.h @@ -92,7 +92,7 @@ protected: quint32 offset; quint8* data; UAVObject* obj; - QMap elementLimits; + QMap > elementLimits; void clear(); void constructorInitialize(const QString& name, const QString& units, FieldType type, const QStringList& elementNames, const QStringList& options, const QString &limits); void limitsInitialize(const QString &limits); From df61d33f669851883a48eed618e83f1f9355a083 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Fri, 3 Aug 2012 18:57:24 +0100 Subject: [PATCH 6/6] GCS- Added the ability to have more than 1 ui limit per index --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 1 - shared/uavobjectdefinition/manualcontrolsettings.xml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index b08fea191..594063358 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -230,7 +230,6 @@ void ConfigTaskWidget::onAutopilotConnect() if (utilMngr) currentBoard = utilMngr->getBoardModel();//TODO REMEMBER TO ADD THIS TO FORCE CONNECTED FUNC ON CC3D_RELEASE invalidateObjects(); - dirty=false; isConnected=true; foreach(objectToWidget * ow,objOfInterest) diff --git a/shared/uavobjectdefinition/manualcontrolsettings.xml b/shared/uavobjectdefinition/manualcontrolsettings.xml index 87924a065..d9c5af7a5 100644 --- a/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -24,7 +24,7 @@ - +