Commit 22658273 authored by Bryan Godbolt's avatar Bryan Godbolt

addressed fixmes and some issues from cppcheck

parent 6a5c6d98
...@@ -61,8 +61,8 @@ namespace OpalRT ...@@ -61,8 +61,8 @@ namespace OpalRT
const QGCParamID& getParamID() const {return *paramID;} const QGCParamID& getParamID() const {return *paramID;}
void setOpalID(unsigned short opalID) {this->opalID = opalID;} void setOpalID(unsigned short opalID) {this->opalID = opalID;}
const QString& getSimulinkPath() {return *simulinkPath;} const QString& getSimulinkPath() const {return *simulinkPath;}
const QString& getSimulinkName() {return *simulinkName;} const QString& getSimulinkName() const {return *simulinkName;}
uint8_t getComponentID() const {return componentID;} uint8_t getComponentID() const {return componentID;}
float getValue(); float getValue();
void setValue(float value); void setValue(float value);
......
...@@ -53,11 +53,11 @@ namespace OpalRT ...@@ -53,11 +53,11 @@ namespace OpalRT
const_iterator(const const_iterator& other); const_iterator(const const_iterator& other);
const_iterator& operator+=(int i) {index += i; return *this;} const_iterator& operator+=(int i) {index += i; return *this;}
bool operator<(const const_iterator& other) {return (this->paramList == other.paramList) bool operator<(const const_iterator& other) const {return (this->paramList == other.paramList)
&&(this->index<other.index);} &&(this->index<other.index);}
bool operator==(const const_iterator& other) {return (this->paramList == other.paramList) bool operator==(const const_iterator& other) const {return (this->paramList == other.paramList)
&&(this->index==other.index);} &&(this->index==other.index);}
bool operator!=(const const_iterator& other) {return !((*this) == other);} bool operator!=(const const_iterator& other) const {return !((*this) == other);}
const Parameter& operator*() const {return paramList[index];} const Parameter& operator*() const {return paramList[index];}
const Parameter* operator->() const {return &paramList[index];} const Parameter* operator->() const {return &paramList[index];}
......
...@@ -48,18 +48,14 @@ const float* RadioCalibrationData::operator [](int i) const ...@@ -48,18 +48,14 @@ const float* RadioCalibrationData::operator [](int i) const
return NULL; return NULL;
} }
const QVector<float>& RadioCalibrationData::operator ()(int i) const const QVector<float>& RadioCalibrationData::operator ()(const int i) const throw(std::out_of_range)
{ {
if (i < data->size()) if ((i < data->size()) && (i >=0))
{ {
return (*data)[i]; return (*data)[i];
} }
// FIXME Bryan throw std::out_of_range("Invalid channel index");
// FIXME James
// This is not good. If it is ever used after being returned it will cause a crash
// return QVector<float>();
} }
QString RadioCalibrationData::toString(RadioElement element) const QString RadioCalibrationData::toString(RadioElement element) const
......
...@@ -34,6 +34,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -34,6 +34,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug> #include <QDebug>
#include <QVector> #include <QVector>
#include <QString> #include <QString>
#include <stdexcept>
/** /**
...@@ -66,7 +67,7 @@ public: ...@@ -66,7 +67,7 @@ public:
}; };
const float* operator[](int i) const; const float* operator[](int i) const;
const QVector<float>& operator()(int i) const; const QVector<float>& operator()(int i) const throw(std::out_of_range);
void set(int element, int index, float value) {(*data)[element][index] = value;} void set(int element, int index, float value) {(*data)[element][index] = value;}
public slots: public slots:
......
...@@ -52,38 +52,38 @@ RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) : ...@@ -52,38 +52,38 @@ RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) :
setUASId(0); setUASId(0);
} }
void RadioCalibrationWindow::setChannelRaw(int ch, float raw) //void RadioCalibrationWindow::setChannelRaw(int ch, float raw)
{ //{
/** this expects a particular channel to function mapping // /** this expects a particular channel to function mapping
\todo allow run-time channel mapping // \todo allow run-time channel mapping
*/ // */
switch (ch) // switch (ch)
{ // {
case 0: // case 0:
aileron->channelChanged(raw); // aileron->channelChanged(raw);
break; // break;
case 1: // case 1:
elevator->channelChanged(raw); // elevator->channelChanged(raw);
break; // break;
case 2: // case 2:
throttle->channelChanged(raw); // throttle->channelChanged(raw);
break; // break;
case 3: // case 3:
rudder->channelChanged(raw); // rudder->channelChanged(raw);
break; // break;
case 4: // case 4:
gyro->channelChanged(raw); // gyro->channelChanged(raw);
break; // break;
case 5: // case 5:
pitch->channelChanged(raw); // pitch->channelChanged(raw);
break; // break;
} // }
} //}
void RadioCalibrationWindow::setChannelScaled(int ch, float normalized) //void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
{ //{
// FIXME James // FIXME James
// FIXME Bryan // FIXME Bryan
...@@ -113,9 +113,9 @@ void RadioCalibrationWindow::setChannelScaled(int ch, float normalized) ...@@ -113,9 +113,9 @@ void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
// } // }
} //}
void RadioCalibrationWindow::setChannel(int ch, float raw, float normalized) void RadioCalibrationWindow::setChannel(int ch, float raw)
{ {
/** this expects a particular channel to function mapping /** this expects a particular channel to function mapping
\todo allow run-time channel mapping \todo allow run-time channel mapping
......
...@@ -66,9 +66,10 @@ public: ...@@ -66,9 +66,10 @@ public:
explicit RadioCalibrationWindow(QWidget *parent = 0); explicit RadioCalibrationWindow(QWidget *parent = 0);
public slots: public slots:
void setChannel(int ch, float raw, float normalized); void setChannel(int ch, float raw);
void setChannelRaw(int ch, float raw); // @todo remove these functions if they are not needed - were added by lm on dec 14, 2010
void setChannelScaled(int ch, float normalized); // void setChannelRaw(int ch, float raw);
// void setChannelScaled(int ch, float normalized);
void loadFile(); void loadFile();
void saveFile(); void saveFile();
void send(); void send();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment