Commit a412dfef authored by pixhawk's avatar pixhawk

Merged

parents 49a778ed a11ca3da
......@@ -356,3 +356,38 @@ QProgressBar::chunk#speedBar {
QProgressBar::chunk#thrustBar {
background-color: orange;
}
QDialog {
border: 1px solid #62676B;
border-radius: 2px;
}
QTabWidget::pane { /* The tab widget frame */
border: 1px solid #62676B;
border-radius: 2px;
position: absolute;
top: -0.5em;
}
QTabWidget::tab-bar {
alignment: center;
}
/* Style the tab using the tab sub-control. Note that
it reads QTabBar _not_ QTabWidget */
QTabBar::tab {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #090909, stop: 1 #353535);
border: 2px solid #62676B;
border-radius: 4px;
min-width: 8ex;
padding: 2px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #090909, stop: 1 #353535);
border: 2px solid #379AC3;
}
QTabBar::tab:selected {
border: 2px solid #379AC3;
}
......@@ -63,10 +63,10 @@ namespace qmapcontrol
void MapNetwork::requestFinished(int id, bool error)
{
// sleep(1);
// qDebug() << "MapNetwork::requestFinished" << http->state() << ", id: " << id;
qDebug() << "QMapControl: MapNetwork::requestFinished" << http->state() << ", id: " << id;
if (error)
{
qDebug() << "network error: " << http->errorString();
qDebug() << "QMapControl: network error: " << http->errorString();
//restart query
}
......@@ -79,7 +79,7 @@ namespace qmapcontrol
QString url = loadingMap[id];
loadingMap.remove(id);
vectorMutex.unlock();
// qDebug() << "request finished for id: " << id << ", belongs to: " << notifier.url << endl;
//qDebug() << "QMapControl: request finished for id: " << id << ", belongs to: " << notifier.url << endl;
QByteArray ax;
if (http->bytesAvailable()>0)
......@@ -87,17 +87,20 @@ namespace qmapcontrol
QPixmap pm;
ax = http->readAll();
qDebug() << "QMapControl: Request consisted of " << ax.size() << "bytes";
if (pm.loadFromData(ax))
{
loaded += pm.size().width()*pm.size().height()*pm.depth()/8/1024;
// qDebug() << "Network loaded: " << (loaded);
qDebug() << "QMapControl: Network loaded: " << (loaded);
parent->receivedImage(pm, url);
}
else if (pm.width() == 0 || pm.height() == 0)
{
// Silently ignore map request for a
// 0xn pixel map
qDebug() << "QMapControl: IGNORED 0x0 pixel map request, widthxheight:" << pm.width() << "x" << pm.height();
qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
}
else
{
......@@ -105,7 +108,7 @@ namespace qmapcontrol
// TODO Error is currently undetected
//qDebug() << "NETWORK_PIXMAP_ERROR: " << ax;
qDebug() << "QMapControl external library: ERROR loading map:" << "width:" << pm.width() << "heigh:" << pm.height() << "at " << __FILE__ << __LINE__;
//qDebug() << "HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
}
}
......
......@@ -157,7 +157,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCWaypointListMulti.ui \
src/ui/mission/QGCCustomWaypointAction.ui \
src/ui/QGCUDPLinkConfiguration.ui
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/QGCSettingsWidget.ui
INCLUDEPATH += src \
src/ui \
......@@ -268,7 +269,8 @@ HEADERS += src/MG.h \
src/comm/MAVLinkSimulationMAV.h \
src/uas/QGCMAVLinkUASFactory.h \
src/ui/QGCWaypointListMulti.h \
src/ui/QGCUDPLinkConfiguration.h
src/ui/QGCUDPLinkConfiguration.h \
src/ui/QGCSettingsWidget.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008: {
......@@ -394,7 +396,8 @@ SOURCES += src/main.cc \
src/comm/MAVLinkSimulationMAV.cc \
src/uas/QGCMAVLinkUASFactory.cc \
src/ui/QGCWaypointListMulti.cc \
src/ui/QGCUDPLinkConfiguration.cc
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/QGCSettingsWidget.cc
macx|win32-msvc2008: {
SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -151,10 +151,14 @@ GAudioOutput::~GAudioOutput()
void GAudioOutput::mute(bool mute)
{
this->muted = mute;
QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY+"muted", this->muted);
settings.sync();
if (mute != muted)
{
this->muted = mute;
QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY+"muted", this->muted);
settings.sync();
emit mutedChanged(muted);
}
}
bool GAudioOutput::isMuted()
......
......@@ -80,6 +80,9 @@ public:
VOICE_FEMALE
} QGVoice;
/** @brief Get the mute state */
bool isMuted();
public slots:
/** @brief Say this text if current output priority matches */
bool say(QString text, int severity=1);
......@@ -101,8 +104,9 @@ public slots:
void notifyNegative();
/** @brief Mute/unmute sound */
void mute(bool mute);
/** @brief Get the mute state */
bool isMuted();
signals:
void mutedChanged(bool);
protected:
#ifdef Q_OS_MAC
......
......@@ -62,6 +62,9 @@ public:
/** @brief Get a list of all links */
const QList<LinkInterface*> getLinks();
/** @brief Get a list of all protocols */
const QList<ProtocolInterface*> getProtocols() { return protocolLinks.uniqueKeys(); }
public slots:
void add(LinkInterface* link);
......
......@@ -44,6 +44,11 @@ MAVLinkProtocol::MAVLinkProtocol() :
m_loggingEnabled(false),
m_logfile(NULL),
m_enable_version_check(true),
m_paramRetransmissionTimeout(350),
m_paramRewriteTimeout(500),
m_paramGuardEnabled(true),
m_actionGuardEnabled(false),
m_actionRetransmissionTimeout(100),
versionMismatchIgnore(false),
systemId(QGC::defaultSystemId)
{
......@@ -95,6 +100,14 @@ void MAVLinkProtocol::loadSettings()
{
systemId = temp;
}
// Parameter interface settings
bool ok;
temp = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", m_paramRetransmissionTimeout).toInt(&ok);
if (ok) m_paramRetransmissionTimeout = temp;
temp = settings.value("PARAMETER_REWRITE_TIMEOUT", m_paramRewriteTimeout).toInt(&ok);
if (ok) m_paramRewriteTimeout = temp;
m_paramGuardEnabled = settings.value("PARAMETER_TRANSMISSION_GUARD_ENABLED", m_paramGuardEnabled).toBool();
settings.endGroup();
}
......@@ -113,6 +126,10 @@ void MAVLinkProtocol::storeSettings()
// Logfile exists, store the name
settings.setValue("LOGFILE_NAME", m_logfile->fileName());
}
// Parameter interface settings
settings.setValue("PARAMETER_RETRANSMISSION_TIMEOUT", m_paramRetransmissionTimeout);
settings.setValue("PARAMETER_REWRITE_TIMEOUT", m_paramRewriteTimeout);
settings.setValue("PARAMETER_TRANSMISSION_GUARD_ENABLED", m_paramGuardEnabled);
settings.endGroup();
settings.sync();
//qDebug() << "Storing settings!";
......@@ -418,6 +435,51 @@ void MAVLinkProtocol::enableMultiplexing(bool enabled)
if (changed) emit multiplexingChanged(m_multiplexingEnabled);
}
void MAVLinkProtocol::enableParamGuard(bool enabled)
{
if (enabled != m_paramGuardEnabled)
{
m_paramGuardEnabled = enabled;
emit paramGuardChanged(m_paramGuardEnabled);
}
}
void MAVLinkProtocol::enableActionGuard(bool enabled)
{
if (enabled != m_actionGuardEnabled)
{
m_actionGuardEnabled = enabled;
emit actionGuardChanged(m_actionGuardEnabled);
}
}
void MAVLinkProtocol::setParamRetransmissionTimeout(int ms)
{
if (ms != m_paramRetransmissionTimeout)
{
m_paramRetransmissionTimeout = ms;
emit paramRetransmissionTimeoutChanged(m_paramRetransmissionTimeout);
}
}
void MAVLinkProtocol::setParamRewriteTimeout(int ms)
{
if (ms != m_paramRewriteTimeout)
{
m_paramRewriteTimeout = ms;
emit paramRewriteTimeoutChanged(m_paramRewriteTimeout);
}
}
void MAVLinkProtocol::setActionRetransmissionTimeout(int ms)
{
if (ms != m_actionRetransmissionTimeout)
{
m_actionRetransmissionTimeout = ms;
emit actionRetransmissionTimeoutChanged(m_actionRetransmissionTimeout);
}
}
void MAVLinkProtocol::enableLogging(bool enabled)
{
bool changed = false;
......
......@@ -77,6 +77,16 @@ public:
int getVersion() { return MAVLINK_VERSION; }
/** @brief Get the name of the packet log file */
QString getLogfileName();
/** @brief Get state of parameter retransmission */
bool paramGuardEnabled() { return m_paramGuardEnabled; }
/** @brief Get parameter read timeout */
int getParamRetransmissionTimeout() { return m_paramRetransmissionTimeout; }
/** @brief Get parameter write timeout */
int getParamRewriteTimeout() { return m_paramRewriteTimeout; }
/** @brief Get state of action retransmission */
bool actionGuardEnabled() { return m_actionGuardEnabled; }
/** @brief Get parameter read timeout */
int getActionRetransmissionTimeout() { return m_actionRetransmissionTimeout; }
public slots:
/** @brief Receive bytes from a communication interface */
......@@ -99,6 +109,21 @@ public slots:
/** @brief Enabled/disable packet multiplexing */
void enableMultiplexing(bool enabled);
/** @brief Enable / disable parameter retransmission */
void enableParamGuard(bool enabled);
/** @brief Enable / disable action retransmission */
void enableActionGuard(bool enabled);
/** @brief Set parameter read timeout */
void setParamRetransmissionTimeout(int ms);
/** @brief Set parameter write timeout */
void setParamRewriteTimeout(int ms);
/** @brief Set parameter read timeout */
void setActionRetransmissionTimeout(int ms);
/** @brief Set log file name */
void setLogfileName(const QString& filename);
......@@ -121,6 +146,11 @@ protected:
bool m_multiplexingEnabled; ///< Enable/disable packet multiplexing
QFile* m_logfile; ///< Logfile
bool m_enable_version_check; ///< Enable checking of version match of MAV and QGC
int m_paramRetransmissionTimeout; ///< Timeout for parameter retransmission
int m_paramRewriteTimeout; ///< Timeout for sending re-write request
bool m_paramGuardEnabled; ///< Parameter retransmission/rewrite enabled
bool m_actionGuardEnabled; ///< Action request retransmission enabled
int m_actionRetransmissionTimeout; ///< Timeout for parameter retransmission
QMutex receiveMutex; ///< Mutex to protect receiveBytes function
int lastIndex[256][256];
int totalReceiveCounter;
......@@ -143,6 +173,18 @@ signals:
void versionCheckChanged(bool enabled);
/** @brief Emitted if a message from the protocol should reach the user */
void protocolStatusMessage(const QString& title, const QString& message);
/** @brief Emitted if a new system ID was set */
void systemIdChanged(int systemId);
/** @brief Emitted if param guard status changed */
void paramGuardChanged(bool enabled);
/** @brief Emitted if param read timeout changed */
void paramRetransmissionTimeoutChanged(int ms);
/** @brief Emitted if param write timeout changed */
void paramRewriteTimeoutChanged(int ms);
/** @brief Emitted if action guard status changed */
void actionGuardChanged(bool enabled);
/** @brief Emitted if actiion request timeout changed */
void actionRetransmissionTimeoutChanged(int ms);
};
#endif // MAVLINKPROTOCOL_H_
......@@ -817,8 +817,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
qDebug() << "GCS REQUESTED PARAM LIST FROM SIMULATION";
mavlink_param_request_list_t read;
mavlink_msg_param_request_list_decode(&msg, &read);
if (read.target_system == systemId)
{
// if (read.target_system == systemId)
// {
// Output all params
// Iterate through all components, through all parameters and emit them
QMap<QString, float>::iterator i;
......@@ -826,18 +826,21 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
int j = 0;
for (i = onboardParams.begin(); i != onboardParams.end(); ++i)
{
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)i.key().toStdString().c_str(), i.value(), onboardParams.size(), j);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
if (j != 5)
{
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(read.target_system, componentId, &msg, (int8_t*)i.key().toStdString().c_str(), i.value(), onboardParams.size(), j);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
j++;
}
qDebug() << "SIMULATION SENT PARAMETERS TO GCS";
}
// }
}
break;
case MAVLINK_MSG_ID_PARAM_SET:
......@@ -845,8 +848,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
qDebug() << "SIMULATION RECEIVED COMMAND TO SET PARAMETER";
mavlink_param_set_t set;
mavlink_msg_param_set_decode(&msg, &set);
if (set.target_system == systemId)
{
// if (set.target_system == systemId)
// {
QString key = QString((char*)set.param_id);
if (onboardParams.contains(key))
{
......@@ -854,13 +857,46 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
onboardParams.insert(key, set.param_value);
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), set.param_value, onboardParams.size(), 0);
mavlink_msg_param_value_pack(set.target_system, componentId, &msg, (int8_t*)key.toStdString().c_str(), set.param_value, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
// }
}
case MAVLINK_MSG_ID_PARAM_REQUEST_READ:
{
qDebug() << "SIMULATION RECEIVED COMMAND TO SEND PARAMETER";
mavlink_param_request_read_t read;
mavlink_msg_param_request_read_decode(&msg, &read);
QByteArray bytes((char*)read.param_id, MAVLINK_MSG_PARAM_REQUEST_READ_FIELD_PARAM_ID_LEN);
QString key = QString(bytes);
if (onboardParams.contains(key))
{
float paramValue = onboardParams.value(key);
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(read.target_system, componentId, &msg, (int8_t*)key.toStdString().c_str(), paramValue, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
else if (read.param_index < onboardParams.size())
{
key = onboardParams.keys().at(read.param_index);
float paramValue = onboardParams.value(key);
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), paramValue, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
}
break;
......@@ -868,10 +904,10 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
}
//unsigned char v=data[i];
//fprintf(stderr,"%02x ", v);
unsigned char v=data[i];
fprintf(stderr,"%02x ", v);
}
//fprintf(stderr,"\n");
fprintf(stderr,"\n");
readyBufferMutex.lock();
for (int i = 0; i < streampointer; i++)
......@@ -903,22 +939,22 @@ void MAVLinkSimulationLink::readBytes() {
readyBufferMutex.unlock();
// if (len > 0)
// {
// qDebug() << "Simulation sent " << len << " bytes to groundstation: ";
//
// /* Increase write counter */
// //bitsSentTotal += size * 8;
//
// //Output all bytes as hex digits
// int i;
// for (i=0; i<len; i++)
// {
// unsigned int v=data[i];
// fprintf(stderr,"%02x ", v);
// }
// fprintf(stderr,"\n");
// }
// if (len > 0)
// {
// qDebug() << "Simulation sent " << len << " bytes to groundstation: ";
// /* Increase write counter */
// //bitsSentTotal += size * 8;
// //Output all bytes as hex digits
// int i;
// for (i=0; i<len; i++)
// {
// unsigned int v=data[i];
// fprintf(stderr,"%02x ", v);
// }
// fprintf(stderr,"\n");
// }
}
/**
......@@ -957,8 +993,9 @@ bool MAVLinkSimulationLink::connect()
start(LowPriority);
MAVLinkSimulationMAV* mav1 = new MAVLinkSimulationMAV(this, 1, 47.376, 8.548);
//MAVLinkSimulationMAV* mav2 = new MAVLinkSimulationMAV(this, 2);
Q_UNUSED(mav1);
//MAVLinkSimulationMAV* mav2 = new MAVLinkSimulationMAV(this, 2);
//
//Q_UNUSED(mav2);
// timer->start(rate);
return true;
......
......@@ -96,7 +96,7 @@ void MAVLinkSimulationMAV::mainloop()
{
//float trueyaw = atan2f(xm, ym);
float newYaw = atan2f(xm, ym);
float newYaw = atan2f(ym, xm);
if (fabs(yaw - newYaw) < 90)
{
......@@ -112,8 +112,8 @@ void MAVLinkSimulationMAV::mainloop()
//if (sqrt(xm*xm+ym*ym) > 0.0000001)
if (flying)
{
x += sin(yaw)*radPer100ms;
y += cos(yaw)*radPer100ms;
x += cos(yaw)*radPer100ms;
y += sin(yaw)*radPer100ms;
z += altPer100ms*zsign;
}
......@@ -135,7 +135,7 @@ void MAVLinkSimulationMAV::mainloop()
pos.alt = z*1000.0;
pos.lat = x*1E7;
pos.lon = y*1E7;
pos.vx = 10.0f*100.0f;
pos.vx = sin(yaw)*10.0f*100.0f;
pos.vy = 0;
pos.vz = altPer100ms*10.0f*100.0f*zsign*-1.0f;
mavlink_msg_global_position_int_encode(systemid, MAV_COMP_ID_IMU, &msg, &pos);
......@@ -147,7 +147,7 @@ void MAVLinkSimulationMAV::mainloop()
attitude.usec = 0;
attitude.roll = 0.0f;
attitude.pitch = 0.0f;
attitude.yaw = yaw-(M_PI/2.0);
attitude.yaw = yaw;
attitude.rollspeed = 0.0f;
attitude.pitchspeed = 0.0f;
attitude.yawspeed = 0.0f;
......@@ -170,11 +170,11 @@ void MAVLinkSimulationMAV::mainloop()
// VFR HUD
mavlink_vfr_hud_t hud;
hud.airspeed = pos.vx;
hud.groundspeed = pos.vx;
hud.alt = pos.alt;
hud.airspeed = pos.vx/100.0f;
hud.groundspeed = pos.vx/100.0f;
hud.alt = z;
hud.heading = static_cast<int>((yaw/M_PI)*180.0f+180.0f) % 360;
hud.climb = pos.vz;
hud.climb = pos.vz/100.0f;
hud.throttle = 90;
mavlink_msg_vfr_hud_encode(systemid, MAV_COMP_ID_IMU, &msg, &hud);
link->sendMAVLinkMessage(&msg);
......@@ -323,6 +323,7 @@ void MAVLinkSimulationMAV::handleMessage(const mavlink_message_t& msg)
{
case MAV_ACTION_TAKEOFF:
flying = true;
nav_mode = MAV_NAV_LIFTOFF;
ack.result = 1;
break;
default:
......@@ -345,6 +346,7 @@ void MAVLinkSimulationMAV::handleMessage(const mavlink_message_t& msg)
mavlink_msg_local_position_setpoint_set_decode(&msg, &sp);
if (sp.target_system == this->systemid)
{
nav_mode = MAV_NAV_WAYPOINT;
previousSPX = nextSPX;
previousSPY = nextSPY;
previousSPZ = nextSPZ;
......
......@@ -575,9 +575,9 @@ void MAVLinkSimulationWaypointPlanner::mavlink_handler (const mavlink_message_t*
float x = static_cast<double>(pos.lat)/1E7;
float y = static_cast<double>(pos.lon)/1E7;
float z = static_cast<double>(pos.alt)/1000;
//float z = static_cast<double>(pos.alt)/1000;
qDebug() << "Received new position: x:" << x << "| y:" << y << "| z:" << z;
//qDebug() << "Received new position: x:" << x << "| y:" << y << "| z:" << z;
posReached = false;
yawReached = true;
......
......@@ -143,7 +143,7 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit errCountChanged(uasId, "IMU", "SPI0", status.spi0_err_count);
emit errCountChanged(uasId, "IMU", "SPI1", status.spi1_err_count);
emit errCountChanged(uasId, "IMU", "UART", status.uart_total_err_count);
emit valueChanged(uasId, "Load", "%", ((float)status.load)/1000.0f, MG::TIME::getGroundTimeNow());
emit valueChanged(uasId, "Load", "%", ((float)status.load)/10.0f, getUnixTime());
}
break;
default:
......
This diff is collapsed.
......@@ -130,8 +130,9 @@ protected: //COMMENTS FOR TEST UNIT
bool batteryRemainingEstimateEnabled; ///< If the estimate is enabled, QGC will try to estimate the remaining battery life
float chargeLevel; ///< Charge level of battery, in percent
int timeRemaining; ///< Remaining time calculated based on previous and current
unsigned int mode; ///< The current mode of the MAV
int mode; ///< The current mode of the MAV
int status; ///< The current status of the MAV
int navMode; ///< The current navigation mode of the MAV
quint64 onboardTimeOffset;
bool controlRollManual; ///< status flag, true if roll is controlled manually
......@@ -173,6 +174,8 @@ public:
float getChargeLevel();
/** @brief Get the human-readable status message for this code */
void getStatusForCode(int statusCode, QString& uasState, QString& stateDescription);
/** @brief Get the human-readable navigation mode translation for this mode */
QString getNavModeText(int mode);
/** @brief Check if vehicle is in autonomous mode */
bool isAuto();
......@@ -259,6 +262,9 @@ public slots:
/** @brief Request all parameters */
void requestParameters();
/** @brief Request a single parameter by index */
void requestParameter(int component, int parameter);
/** @brief Set a system parameter */
void setParameter(const int component, const QString& id, const float value);
......
......@@ -226,6 +226,8 @@ public slots:
virtual void setLocalOriginAtCurrentGPSPosition() = 0;
/** @brief Request all onboard parameters of all components */
virtual void requestParameters() = 0;
/** @brief Request one specific onboard parameter */
virtual void requestParameter(int component, int parameter) = 0;
/** @brief Write parameter to permanent storage */
virtual void writeParametersToStorage() = 0;
/** @brief Read parameter from permanent storage */
......@@ -304,7 +306,11 @@ signals:
void poiFound(UASInterface* uas, int type, int colorIndex, QString message, float x, float y, float z);
void poiConnectionFound(UASInterface* uas, int type, int colorIndex, QString message, float x1, float y1, float z1, float x2, float y2, float z2);
/** @brief A text message from the system has been received */
void textMessageReceived(int uasid, int componentid, int severity, QString text);
void navModeChanged(int uasid, int mode, const QString& text);
/**
* @brief Update the error count of a device
*
......
......@@ -236,6 +236,7 @@ void UASWaypointManager::handleWaypointCurrent(quint8 systemId, quint8 compId, m
{
if (systemId == uas.getUASID() && compId == MAV_COMP_ID_WAYPOINTPLANNER)
{
// FIXME Petri
if (current_state == WP_SETCURRENT)
{
protocol_timer.stop();
......@@ -257,11 +258,12 @@ void UASWaypointManager::handleWaypointCurrent(quint8 systemId, quint8 compId, m
}
}
emit updateStatusString(QString("New current waypoint %1").arg(wpc->seq));
//emit update to UI widgets
emit currentWaypointChanged(wpc->seq);
//qDebug() << "Updated waypoints list";
}
qDebug() << "new current waypoint" << wpc->seq;
emit updateStatusString(QString("New current waypoint %1").arg(wpc->seq));
//emit update to UI widgets
emit currentWaypointChanged(wpc->seq);
//qDebug() << "new current waypoint" << wpc->seq;
}
}
......
......@@ -67,7 +67,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Hide sent text field - it is only useful after send has been hit
m_ui->sentText->setVisible(false);
// Hide auto-send checkbox
m_ui->specialCheckBox->setVisible(false);
//m_ui->specialCheckBox->setVisible(false);
// Make text area not editable
m_ui->receiveText->setReadOnly(true);
// Limit to 500 lines
......@@ -85,10 +85,10 @@ DebugConsole::DebugConsole(QWidget *parent) :
snapShotTimer.setInterval(snapShotInterval);
snapShotTimer.start();
// Set hex checkbox checked
m_ui->hexCheckBox->setChecked(!convertToAscii);
m_ui->mavlinkCheckBox->setChecked(filterMAVLINK);
m_ui->holdCheckBox->setChecked(autoHold);
// // Set hex checkbox checked
// m_ui->hexCheckBox->setChecked(!convertToAscii);
// m_ui->mavlinkCheckBox->setChecked(filterMAVLINK);
// m_ui->holdCheckBox->setChecked(autoHold);
// Get a list of all existing links
links = QList<LinkInterface*>();
......@@ -116,12 +116,10 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Connect Checkbox
connect(m_ui->specialComboBox, SIGNAL(highlighted(QString)), this, SLOT(specialSymbolSelected(QString)));
// Set add button invisible if auto add checkbox is checked
connect(m_ui->specialCheckBox, SIGNAL(clicked(bool)), m_ui->addSymbolButton, SLOT(setHidden(bool)));
//connect(m_ui->specialCheckBox, SIGNAL(clicked(bool)), m_ui->addSymbolButton, SLOT(setHidden(bool)));
// Allow to send via return
connect(m_ui->sendText, SIGNAL(returnPressed()), this, SLOT(sendBytes()));
hold(false);
loadSettings();
// Warn user about not activated hold
......@@ -131,6 +129,12 @@ DebugConsole::DebugConsole(QWidget *parent) :
}
}
void DebugConsole::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
storeSettings();
}
DebugConsole::~DebugConsole()
{
storeSettings();
......@@ -146,16 +150,16 @@ void DebugConsole::loadSettings()
m_ui->specialComboBox->setCurrentIndex(settings.value("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex()).toInt());
m_ui->specialCheckBox->setChecked(settings.value("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked()).toBool());
hexModeEnabled(settings.value("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked()).toBool());
MAVLINKfilterEnabled(settings.value("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked()).toBool());
setAutoHold(settings.value("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked()).toBool());
MAVLINKfilterEnabled(settings.value("MAVLINK_FILTER_ENABLED", filterMAVLINK).toBool());
setAutoHold(settings.value("AUTO_HOLD_ENABLED", autoHold).toBool());
settings.endGroup();
// Update visibility settings
if (m_ui->specialCheckBox->isChecked())
{
m_ui->specialCheckBox->setVisible(true);
m_ui->addSymbolButton->setVisible(false);
}
// // Update visibility settings
// if (m_ui->specialCheckBox->isChecked())
// {
// m_ui->specialCheckBox->setVisible(true);
// m_ui->addSymbolButton->setVisible(false);
// }
}
void DebugConsole::storeSettings()
......@@ -166,8 +170,8 @@ void DebugConsole::storeSettings()
settings.setValue("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex());
settings.setValue("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked());
settings.setValue("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked());
settings.setValue("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked());
settings.setValue("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked());
settings.setValue("MAVLINK_FILTER_ENABLED", filterMAVLINK);
settings.setValue("AUTO_HOLD_ENABLED", autoHold);
settings.endGroup();
settings.sync();
//qDebug() << "Storing settings!";
......@@ -242,6 +246,11 @@ void DebugConsole::setAutoHold(bool hold)
this->hold(false);
m_ui->holdButton->setChecked(false);
}
// Set auto hold checkbox
if (m_ui->holdCheckBox->isChecked() != hold)
{
m_ui->holdCheckBox->setChecked(hold);
}
// Set new state
autoHold = hold;
}
......@@ -516,7 +525,7 @@ QString DebugConsole::bytesToSymbolNames(const QByteArray& b)
void DebugConsole::specialSymbolSelected(const QString& text)
{
Q_UNUSED(text);
m_ui->specialCheckBox->setVisible(true);
//m_ui->specialCheckBox->setVisible(true);
}
void DebugConsole::appendSpecialSymbol(const QString& text)
......
......@@ -101,6 +101,7 @@ public slots:
protected:
void changeEvent(QEvent *e);
void hideEvent(QHideEvent* event);
/** @brief Convert a symbol name to the byte representation */
QByteArray symbolNameToBytes(const QString& symbol);
/** @brief Convert a symbol byte to the name */
......
......@@ -50,6 +50,9 @@
<property name="toolTip">
<string>Ignore MAVLINK protocol messages in display</string>
</property>
<property name="statusTip">
<string>Ignore MAVLINK protocol messages in display</string>
</property>
<property name="text">
<string>Hide MAVLink</string>
</property>
......@@ -58,7 +61,10 @@
<item>
<widget class="QCheckBox" name="hexCheckBox">
<property name="toolTip">
<string>Display and send bytes in HEX representation</string>
<string>Display and enter bytes in HEX representation (e.g. 0xAA)</string>
</property>
<property name="statusTip">
<string>Display and enter bytes in HEX representation (e.g. 0xAA)</string>
</property>
<property name="text">
<string>HEX</string>
......
......@@ -221,12 +221,14 @@ void HSIDisplay::renderOverlay()
// Draw orientation labels
// Translate and rotate coordinate frame
painter.translate((xCenterPos)*scalingFactor, (yCenterPos)*scalingFactor);
painter.rotate((yaw/(M_PI))*180.0f);
const float yawDeg = ((yaw/M_PI)*180.0f);
int yawRotate = static_cast<int>(yawDeg) % 360;
painter.rotate(-yawRotate);
paintText(tr("N"), ringColor, 3.5f, - 1.0f, - baseRadius - 5.5f, &painter);
paintText(tr("S"), ringColor, 3.5f, - 1.0f, + baseRadius + 1.5f, &painter);
paintText(tr("E"), ringColor, 3.5f, + baseRadius + 2.0f, - 1.25f, &painter);
paintText(tr("E"), ringColor, 3.5f, + baseRadius + 3.0f, - 1.25f, &painter);
paintText(tr("W"), ringColor, 3.5f, - baseRadius - 5.5f, - 1.75f, &painter);
painter.rotate((-yaw/(M_PI))*180.0f);
painter.rotate(+yawRotate);
painter.translate(-(xCenterPos)*scalingFactor, -(yCenterPos)*scalingFactor);
// Draw center indicator
......@@ -323,7 +325,7 @@ void HSIDisplay::renderOverlay()
{
// Position
QString str;
str.sprintf("%05.2f lat %06.2f lon %06.2f alt", lat, lon, alt);
str.sprintf("lat: %05.2f lon: %06.2f alt: %06.2f", lat, lon, alt);
paintText(tr("GPS"), QGC::colorCyan, 2.6f, 2, vheight- 5.0f, &painter);
paintText(str, Qt::white, 2.6f, 10, vheight - 5.0f, &painter);
}
......
......@@ -1309,7 +1309,7 @@ void HUD::drawChangeRateStrip(float xRef, float yRef, float height, float minRat
// Text
QString label;
label.sprintf("< %06.2f", value);
label.sprintf("< %+06.2f", value);
paintText(label, defaultColor, 3.0f, xRef+width/2.0f, yRef+height-((scaledValue - minRate)/(maxRate-minRate))*height - 1.6f, painter);
}
......
......@@ -51,16 +51,44 @@ MAVLinkSettingsWidget::MAVLinkSettingsWidget(MAVLinkProtocol* protocol, QWidget
m_ui->multiplexingCheckBox->setChecked(protocol->multiplexingEnabled());
m_ui->systemIdSpinBox->setValue(protocol->getSystemId());
m_ui->paramGuardCheckBox->setChecked(protocol->paramGuardEnabled());
m_ui->paramRetransmissionSpinBox->setValue(protocol->getParamRetransmissionTimeout());
m_ui->paramRewriteSpinBox->setValue(protocol->getParamRewriteTimeout());
m_ui->actionGuardCheckBox->setChecked(protocol->actionGuardEnabled());
m_ui->actionRetransmissionSpinBox->setValue(protocol->getActionRetransmissionTimeout());
// Connect actions
// Heartbeat
connect(protocol, SIGNAL(heartbeatChanged(bool)), m_ui->heartbeatCheckBox, SLOT(setChecked(bool)));
connect(m_ui->heartbeatCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableHeartbeats(bool)));
// Logging
connect(protocol, SIGNAL(loggingChanged(bool)), m_ui->loggingCheckBox, SLOT(setChecked(bool)));
connect(m_ui->loggingCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableLogging(bool)));
// Version check
connect(protocol, SIGNAL(versionCheckChanged(bool)), m_ui->versionCheckBox, SLOT(setChecked(bool)));
connect(m_ui->versionCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableVersionCheck(bool)));
// Logfile
connect(m_ui->logFileButton, SIGNAL(clicked()), this, SLOT(chooseLogfileName()));
// System ID
connect(protocol, SIGNAL(systemIdChanged(int)), m_ui->systemIdSpinBox, SLOT(setValue(int)));
connect(m_ui->systemIdSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setSystemId(int)));
// Multiplexing
connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingCheckBox, SLOT(setChecked(bool)));
connect(m_ui->multiplexingCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableMultiplexing(bool)));
// Parameter guard
connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramGuardCheckBox, SLOT(setChecked(bool)));
connect(m_ui->paramGuardCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableParamGuard(bool)));
connect(protocol, SIGNAL(paramRetransmissionTimeoutChanged(int)), m_ui->paramRetransmissionSpinBox, SLOT(setValue(int)));
connect(m_ui->paramRetransmissionSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setParamRetransmissionTimeout(int)));
connect(protocol, SIGNAL(paramRewriteTimeoutChanged(int)), m_ui->paramRewriteSpinBox, SLOT(setValue(int)));
connect(m_ui->paramRewriteSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setParamRewriteTimeout(int)));
// Action guard
connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionGuardCheckBox, SLOT(setChecked(bool)));
connect(m_ui->actionGuardCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableActionGuard(bool)));
connect(protocol, SIGNAL(actionRetransmissionTimeoutChanged(int)), m_ui->actionRetransmissionSpinBox, SLOT(setValue(int)));
connect(m_ui->actionRetransmissionSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setActionRetransmissionTimeout(int)));
// Update values
m_ui->versionLabel->setText(tr("MAVLINK_VERSION: %1").arg(protocol->getVersion()));
......@@ -69,26 +97,40 @@ MAVLinkSettingsWidget::MAVLinkSettingsWidget(MAVLinkProtocol* protocol, QWidget
// Connect visibility updates
connect(protocol, SIGNAL(versionCheckChanged(bool)), m_ui->versionLabel, SLOT(setVisible(bool)));
m_ui->versionLabel->setVisible(protocol->versionCheckEnabled());
//connect(m_ui->versionCheckBox, SIGNAL(toggled(bool)), m_ui->versionSpacer, SLOT(setVisible(bool)));
//connect(m_ui->loggingCheckBox, SIGNAL(toggled(bool)), m_ui->logFileSpacer, SLOT(setVisible(bool)));
// Logging visibility
connect(protocol, SIGNAL(loggingChanged(bool)), m_ui->logFileLabel, SLOT(setVisible(bool)));
m_ui->logFileLabel->setVisible(protocol->loggingEnabled());
connect(protocol, SIGNAL(loggingChanged(bool)), m_ui->logFileButton, SLOT(setVisible(bool)));
m_ui->logFileButton->setVisible(protocol->loggingEnabled());
connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterCheckBox, SLOT(setVisible(bool)));
m_ui->multiplexingFilterCheckBox->setVisible(protocol->multiplexingEnabled());
connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterLineEdit, SLOT(setVisible(bool)));
m_ui->multiplexingFilterLineEdit->setVisible(protocol->multiplexingEnabled());
// // Multiplexing visibility
// connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterCheckBox, SLOT(setVisible(bool)));
// m_ui->multiplexingFilterCheckBox->setVisible(protocol->multiplexingEnabled());
// connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterLineEdit, SLOT(setVisible(bool)));
// m_ui->multiplexingFilterLineEdit->setVisible(protocol->multiplexingEnabled());
// Param guard visibility
connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRetransmissionSpinBox, SLOT(setVisible(bool)));
m_ui->paramRetransmissionSpinBox->setVisible(protocol->paramGuardEnabled());
connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRetransmissionLabel, SLOT(setVisible(bool)));
m_ui->paramRetransmissionLabel->setVisible(protocol->paramGuardEnabled());
connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRewriteSpinBox, SLOT(setVisible(bool)));
m_ui->paramRewriteSpinBox->setVisible(protocol->paramGuardEnabled());
connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRewriteLabel, SLOT(setVisible(bool)));
m_ui->paramRewriteLabel->setVisible(protocol->paramGuardEnabled());
// Action guard visibility
connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionRetransmissionSpinBox, SLOT(setVisible(bool)));
m_ui->actionRetransmissionSpinBox->setVisible(protocol->actionGuardEnabled());
connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionRetransmissionLabel, SLOT(setVisible(bool)));
m_ui->actionRetransmissionLabel->setVisible(protocol->actionGuardEnabled());
// TODO implement filtering
// and then remove these two lines
m_ui->multiplexingFilterCheckBox->setVisible(false);
m_ui->multiplexingFilterLineEdit->setVisible(false);
// Update settings
m_ui->loggingCheckBox->setChecked(protocol->loggingEnabled());
m_ui->heartbeatCheckBox->setChecked(protocol->heartbeatsEnabled());
m_ui->versionCheckBox->setChecked(protocol->versionCheckEnabled());
// // Update settings
// m_ui->loggingCheckBox->setChecked(protocol->loggingEnabled());
// m_ui->heartbeatCheckBox->setChecked(protocol->heartbeatsEnabled());
// m_ui->versionCheckBox->setChecked(protocol->versionCheckEnabled());
}
void MAVLinkSettingsWidget::updateLogfileName(const QString& fileName)
......@@ -132,7 +174,8 @@ MAVLinkSettingsWidget::~MAVLinkSettingsWidget()
void MAVLinkSettingsWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
switch (e->type())
{
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
......@@ -140,3 +183,9 @@ void MAVLinkSettingsWidget::changeEvent(QEvent *e)
break;
}
}
void MAVLinkSettingsWidget::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
protocol->storeSettings();
}
......@@ -24,6 +24,7 @@ public slots:
protected:
MAVLinkProtocol* protocol;
void changeEvent(QEvent *e);
void hideEvent(QHideEvent* event);
private:
Ui::MAVLinkSettingsWidget *m_ui;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>431</width>
<height>256</height>
<height>387</height>
</rect>
</property>
<property name="windowTitle">
......@@ -151,6 +151,143 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="3">
<widget class="QCheckBox" name="paramGuardCheckBox">
<property name="text">
<string>Enable retransmission of parameter read/write requests</string>
</property>
</widget>
</item>
<item row="12" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="1">
<widget class="QLabel" name="paramRetransmissionLabel">
<property name="text">
<string>Read request retransmission timeout</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="paramRewriteLabel">
<property name="text">
<string>Write request retransmission timeout</string>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QSpinBox" name="paramRetransmissionSpinBox">
<property name="toolTip">
<string>Time in milliseconds after which a not acknowledged read request is sent again.</string>
</property>
<property name="statusTip">
<string>Time in milliseconds after which a not acknowledged read request is sent again.</string>
</property>
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>60000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="QSpinBox" name="paramRewriteSpinBox">
<property name="toolTip">
<string>Time in milliseconds after which a not acknowledged write request is sent again.</string>
</property>
<property name="statusTip">
<string>Time in milliseconds after which a not acknowledged write request is sent again.</string>
</property>
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>60000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
</widget>
</item>
<item row="14" column="0" colspan="3">
<widget class="QCheckBox" name="actionGuardCheckBox">
<property name="text">
<string>Enable retransmission of actions / commands</string>
</property>
</widget>
</item>
<item row="15" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="15" column="1">
<widget class="QLabel" name="actionRetransmissionLabel">
<property name="text">
<string>Action request retransmission timeout</string>
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QSpinBox" name="actionRetransmissionSpinBox">
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -28,6 +28,7 @@
#include "GAudioOutput.h"
#include "QGCToolWidget.h"
#include "QGCMAVLinkLogPlayer.h"
#include "QGCSettingsWidget.h"
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
......@@ -261,7 +262,8 @@ QString MainWindow::getWindowStateKey()
QString MainWindow::getWindowGeometryKey()
{
return QString::number(currentView)+"_geometry";
//return QString::number(currentView)+"_geometry";
return "_geometry";
}
void MainWindow::buildCustomWidget()
......@@ -389,7 +391,7 @@ void MainWindow::buildCommonWidgets()
if (!dataplotWidget)
{
dataplotWidget = new QGCDataPlot2D(this);
addToCentralWidgetsMenu (dataplotWidget, "Data Plot", SLOT(showCentralWidget()),CENTRAL_DATA_PLOT);
addToCentralWidgetsMenu (dataplotWidget, "Logfile Plot", SLOT(showCentralWidget()),CENTRAL_DATA_PLOT);
}
}
......@@ -429,27 +431,27 @@ void MainWindow::buildPxWidgets()
{
// Center widgets
linechartWidget = new Linecharts(this);
addToCentralWidgetsMenu(linechartWidget, "Line Plots", SLOT(showCentralWidget()), CENTRAL_LINECHART);
addToCentralWidgetsMenu(linechartWidget, tr("Realtime Plot"), SLOT(showCentralWidget()), CENTRAL_LINECHART);
}
if (!hudWidget)
{
hudWidget = new HUD(320, 240, this);
addToCentralWidgetsMenu(hudWidget, "HUD", SLOT(showCentralWidget()), CENTRAL_HUD);
addToCentralWidgetsMenu(hudWidget, tr("Head Up Display"), SLOT(showCentralWidget()), CENTRAL_HUD);
}
if (!dataplotWidget)
{
dataplotWidget = new QGCDataPlot2D(this);
addToCentralWidgetsMenu(dataplotWidget, "Data Plots", SLOT(showCentralWidget()), CENTRAL_DATA_PLOT);
addToCentralWidgetsMenu(dataplotWidget, "Logfile Plot", SLOT(showCentralWidget()), CENTRAL_DATA_PLOT);
}
#ifdef QGC_OSG_ENABLED
if (!_3DWidget)
{
_3DWidget = Q3DWidgetFactory::get("PIXHAWK");
addToCentralWidgetsMenu(_3DWidget, "Local 3D", SLOT(showCentralWidget()), CENTRAL_3D_LOCAL);
addToCentralWidgetsMenu(_3DWidget, tr("Local 3D"), SLOT(showCentralWidget()), CENTRAL_3D_LOCAL);
}
#endif
......@@ -457,7 +459,7 @@ void MainWindow::buildPxWidgets()
if (!_3DMapWidget)
{
_3DMapWidget = Q3DWidgetFactory::get("MAP3D");
addToCentralWidgetsMenu(_3DMapWidget, "OSG Earth 3D", SLOT(showCentralWidget()), CENTRAL_OSGEARTH);
addToCentralWidgetsMenu(_3DMapWidget, tr("OSG Earth 3D"), SLOT(showCentralWidget()), CENTRAL_OSGEARTH);
}
#endif
......@@ -465,7 +467,7 @@ void MainWindow::buildPxWidgets()
if (!gEarthWidget)
{
gEarthWidget = new QGCGoogleEarthView(this);
addToCentralWidgetsMenu(gEarthWidget, "Google Earth", SLOT(showCentralWidget()), CENTRAL_GOOGLE_EARTH);
addToCentralWidgetsMenu(gEarthWidget, tr("Google Earth"), SLOT(showCentralWidget()), CENTRAL_GOOGLE_EARTH);
}
#endif
......@@ -501,7 +503,7 @@ void MainWindow::buildPxWidgets()
hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
hsiDockWidget->setWidget( new HSIDisplay(this) );
hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET");
addToToolsMenu (hsiDockWidget, tr("HSI"), SLOT(showToolWidget(bool)), MENU_HSI, Qt::BottomDockWidgetArea);
addToToolsMenu (hsiDockWidget, tr("Horizontal Situation"), SLOT(showToolWidget(bool)), MENU_HSI, Qt::BottomDockWidgetArea);
}
if (!headDown1DockWidget)
......@@ -570,6 +572,7 @@ void MainWindow::buildSlugsWidgets()
{
// Center widgets
linechartWidget = new Linecharts(this);
addToCentralWidgetsMenu(linechartWidget, tr("Realtime Plot"), SLOT(showCentralWidget()), CENTRAL_LINECHART);
}
if (!headUpDockWidget)
......@@ -578,7 +581,7 @@ void MainWindow::buildSlugsWidgets()
headUpDockWidget = new QDockWidget(tr("Control Indicator"), this);
headUpDockWidget->setWidget( new HUD(320, 240, this));
headUpDockWidget->setObjectName("HEAD_UP_DISPLAY_DOCK_WIDGET");
addToToolsMenu (headUpDockWidget, tr("HUD"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea);
addToToolsMenu (headUpDockWidget, tr("Head Up Display"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea);
}
if (!rcViewDockWidget)
......@@ -1336,6 +1339,7 @@ void MainWindow::connectCommonActions()
// Audio output
ui.actionMuteAudioOutput->setChecked(GAudioOutput::instance()->isMuted());
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui.actionMuteAudioOutput, SLOT(setChecked(bool)));
connect(ui.actionMuteAudioOutput, SIGNAL(triggered(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
// User interaction
......@@ -1344,8 +1348,12 @@ void MainWindow::connectCommonActions()
// unless it is actually used
// so no ressources spend on this.
ui.actionJoystickSettings->setVisible(true);
// Joystick configuration
// Configuration
// Joystick
connect(ui.actionJoystickSettings, SIGNAL(triggered()), this, SLOT(configure()));
// Application Settings
connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
}
void MainWindow::connectPxActions()
......@@ -1414,6 +1422,12 @@ void MainWindow::configure()
joystickWidget->show();
}
void MainWindow::showSettings()
{
QGCSettingsWidget* settings = new QGCSettingsWidget(this);
settings->show();
}
void MainWindow::addLink()
{
SerialLink* link = new SerialLink();
......
......@@ -101,6 +101,9 @@ public slots:
/** @brief Shows an info message as popup or as widget */
void showInfoMessage(const QString& title, const QString& message);
/** @brief Show the application settings */
void showSettings();
/** @brief Add a communication link */
void addLink();
void addLink(LinkInterface* link);
void configure();
......
......@@ -60,17 +60,17 @@
</property>
<widget class="QMenu" name="menuPreferences">
<property name="title">
<string>Preferences</string>
<string>Display</string>
</property>
<addaction name="actionSelectStylesheet"/>
<addaction name="actionReloadStylesheet"/>
<addaction name="actionSettings"/>
</widget>
<addaction name="actionJoystick_Settings"/>
<addaction name="actionSimulate"/>
<addaction name="separator"/>
<addaction name="actionMuteAudioOutput"/>
<addaction name="actionJoystickSettings"/>
<addaction name="actionSettings"/>
<addaction name="menuPreferences"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
......
......@@ -339,9 +339,11 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1");
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
overlay->setVisible(false);
// yahooActionOverlay->setEnabled(true);
}
else if (action == googleActionMap)
......@@ -865,8 +867,8 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
qmapcontrol::Point* p;
QPointF coordinate;
coordinate.setX(lat);
coordinate.setY(lon);
coordinate.setX(lon);
coordinate.setY(lat);
if (!uasIcons.contains(uas->getUASID()))
{
......@@ -901,7 +903,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
// if (p)
// {
p = uasIcons.value(uas->getUASID());
p->setCoordinate(QPointF(lat, lon));
p->setCoordinate(QPointF(lon, lat));
//p->setYaw(uas->getYaw());
// }
// Extend trail
......@@ -922,7 +924,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
// Sets the view to the interesting area
if (followgps->isChecked())
{
updatePosition(0, lat, lon);
updatePosition(0, lon, lat);
}
else
{
......
......@@ -44,12 +44,6 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
m_ui(new Ui::parameterWidget)
{
m_ui->setupUi(this);
// Make sure the combo box is empty
// because else indices get messed up
//m_ui->vehicleComboBox->clear();
// Setup UI connections
//connect(m_ui->vehicleComboBox, SIGNAL(activated(int)), this, SLOT(selectUAS(int)));
// Get current MAV list
QList<UASInterface*> systems = UASManager::instance()->getUASList();
......@@ -84,8 +78,6 @@ void ParameterInterface::selectUAS(int index)
*/
void ParameterInterface::addUAS(UASInterface* uas)
{
//m_ui->vehicleComboBox->addItem(uas->getUASName());
QGCParamWidget* param = new QGCParamWidget(uas, this);
paramWidgets->insert(uas->getUASID(), param);
m_ui->stackedWidget->addWidget(param);
......
......@@ -30,6 +30,8 @@ This file is part of the QGROUNDCONTROL project
#include <QPushButton>
#include <QFileDialog>
#include <QFile>
#include <QList>
#include <QSettings>
#include "QGCParamWidget.h"
#include "UASInterface.h"
......@@ -50,8 +52,13 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
parameters(),
transmissionListMode(false),
transmissionActive(false),
transmissionStarted(0)
transmissionStarted(0),
retransmissionTimeout(350),
rewriteTimeout(500)
{
// Load settings
loadSettings();
// Create tree widget
tree = new QTreeWidget(this);
statusLabel = new QLabel();
......@@ -127,6 +134,22 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
// New parameters from UAS
connect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,float)), this, SLOT(addParameter(int,int,int,int,QString,float)));
// Connect retransmission guard
connect(this, SIGNAL(requestParameter(int,int)), uas, SLOT(requestParameter(int,int)));
connect(&retransmissionTimer, SIGNAL(timeout()), this, SLOT(retransmissionGuardTick()));
}
void QGCParamWidget::loadSettings()
{
QSettings settings;
settings.beginGroup("QGC_MAVLINK_PROTOCOL");
bool ok;
int temp = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", retransmissionTimeout).toInt(&ok);
if (ok) retransmissionTimeout = temp;
temp = settings.value("PARAMETER_REWRITE_TIMEOUT", rewriteTimeout).toInt(&ok);
if (ok) rewriteTimeout = temp;
settings.endGroup();
}
/**
......@@ -202,6 +225,7 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa
transmissionMissingPackets.insert(component, new QList<int>());
}
// Mark all parameters as missing
for (int i = 0; i < paramCount; ++i)
{
if (!transmissionMissingPackets.value(component)->contains(i))
......@@ -209,8 +233,14 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa
transmissionMissingPackets.value(component)->append(i);
}
}
// Mark list size as known
transmissionListSizeKnown.insert(component, true);
}
// Start retransmission guard
// or reset timer
setRetransmissionGuardEnabled(true);
}
// Mark this parameter as received
......@@ -368,6 +398,13 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
*/
void QGCParamWidget::requestParameterList()
{
// FIXME This call does not belong here
// Once the comm handling is moved to a new
// Param manager class the settings can be directly
// loaded from MAVLink protocol
loadSettings();
// End of FIXME
// Clear view and request param list
clear();
parameters.clear();
......@@ -532,6 +569,68 @@ void QGCParamWidget::loadParameters()
}
/**
* Enabling the retransmission guard enables the parameter widget to track
* dropped parameters and to re-request them. This works for both individual
* parameter reads as well for whole list requests.
*
* @param enabled True if retransmission checking should be enabled, false else
*/
void QGCParamWidget::setRetransmissionGuardEnabled(bool enabled)
{
if (enabled)
{
retransmissionTimer.start(retransmissionTimeout);
}
else
{
retransmissionTimer.stop();
}
}
void QGCParamWidget::retransmissionGuardTick()
{
if (transmissionActive)
{
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE, CHECKING FOR DROPS..";
// Re-request at maximum five parameters at once
// to prevent link flooding
QMap<int, QMap<QString, float>*>::iterator i;
for (i = parameters.begin(); i != parameters.end(); ++i)
{
// Iterate through the parameters of the component
int component = i.key();
// Request five parameters from this component (at maximum)
QList<int> * paramList = transmissionMissingPackets.value(component, NULL);
if (paramList)
{
int count = 0;
int maxCount = 1;
foreach (int id, *paramList)
{
if (count < maxCount)
{
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD REQUESTS RETRANSMISSION OF PARAM #" << id << "FROM COMPONENT #" << component;
emit requestParameter(component, id);
statusLabel->setText(tr("Requ. retransmission of #%1").arg(id));
count++;
}
else
{
break;
}
}
}
}
}
else
{
qDebug() << __FILE__ << __LINE__ << "STOPPING RETRANSMISSION GUARD GRACEFULLY";
setRetransmissionGuardEnabled(false);
}
}
/**
* @param component the subsystem which has the parameter
......@@ -541,7 +640,23 @@ void QGCParamWidget::loadParameters()
void QGCParamWidget::setParameter(int component, QString parameterName, float value)
{
emit parameterChanged(component, parameterName, value);
// // Wait for parameter to be written back
// // mark it therefore as missing
// if (!transmissionMissingPackets.contains(component))
// {
// transmissionMissingPackets.insert(component, new QList<int>());
// }
// for (int i = 0; i < paramCount; ++i)
// {
// if (!transmissionMissingPackets.value(component)->contains(i))
// {
// transmissionMissingPackets.value(component)->append(i);
// }
// }
// transmissionActive = true;
// transmissionStarted = QGC::groundTimeUsecs();
// setRetransmissionGuardEnabled(true);
}
/**
......
......@@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project
#include <QTreeWidgetItem>
#include <QMap>
#include <QLabel>
#include <QTimer>
#include "UASInterface.h"
......@@ -51,6 +52,8 @@ public:
signals:
/** @brief A parameter was changed in the widget, NOT onboard */
void parameterChanged(int component, QString parametername, float value);
/** @brief Request a single parameter */
void requestParameter(int component, int parameter);
public slots:
/** @brief Add a component to the list */
void addComponent(int uas, int component, QString componentName);
......@@ -77,6 +80,10 @@ public slots:
void saveParameters();
/** @brief Load parameters from a file */
void loadParameters();
/** @brief Check for missing parameters */
void retransmissionGuardTick();
protected:
UASInterface* mav; ///< The MAV this widget is controlling
QTreeWidget* tree; ///< The parameter tree
......@@ -87,10 +94,19 @@ protected:
QMap<int, QMap<QString, float>* > parameters; ///< All parameters
QVector<bool> received; ///< Successfully received parameters
QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
QMap<int, QList<float>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
quint64 transmissionStarted; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
int rewriteTimeout; ///< Write request timeout, in milliseconds
/** @brief Activate / deactivate parameter retransmission */
void setRetransmissionGuardEnabled(bool enabled);
/** @brief Load settings */
void loadSettings();
};
#endif // QGCPARAMWIDGET_H
......@@ -37,6 +37,7 @@ QGCSensorSettingsWidget::QGCSensorSettingsWidget(UASInterface* uas, QWidget *par
ui(new Ui::QGCSensorSettingsWidget)
{
ui->setupUi(this);
// FIXME James Goppert
// XXX: This might be a bad idea sending a message every time the value changes
connect(ui->spinBox_rawSensor, SIGNAL(valueChanged(int)), mav, SLOT(enableRawSensorDataTransmission(int)));
connect(ui->spinBox_controller, SIGNAL(valueChanged(int)), mav, SLOT(enableRawControllerDataTransmission(int)));
......
#include "QGCSettingsWidget.h"
#include "ui_QGCSettingsWidget.h"
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "MAVLinkSettingsWidget.h"
#include "GAudioOutput.h"
//, Qt::WindowFlags flags
QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags),
ui(new Ui::QGCSettingsWidget)
{
ui->setupUi(this);
// Add all protocols
QList<ProtocolInterface*> protocols = LinkManager::instance()->getProtocols();
foreach (ProtocolInterface* protocol, protocols)
{
MAVLinkProtocol* mavlink = dynamic_cast<MAVLinkProtocol*>(protocol);
if (mavlink)
{
MAVLinkSettingsWidget* msettings = new MAVLinkSettingsWidget(mavlink, this);
ui->tabWidget->addTab(msettings, "MAVLink");
}
}
this->window()->setWindowTitle(tr("QGroundControl Settings"));
// Audio preferences
ui->audioMuteCheckBox->setChecked(GAudioOutput::instance()->isMuted());
connect(ui->audioMuteCheckBox, SIGNAL(toggled(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui->audioMuteCheckBox, SLOT(setChecked(bool)));
// Close / destroy
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(deleteLater()));
// Set layout options
ui->generalPaneGridLayout->setAlignment(Qt::AlignTop);
}
QGCSettingsWidget::~QGCSettingsWidget()
{
delete ui;
}
#ifndef QGCSETTINGSWIDGET_H
#define QGCSETTINGSWIDGET_H
#include <QDialog>
namespace Ui {
class QGCSettingsWidget;
}
class QGCSettingsWidget : public QDialog
{
Q_OBJECT
public:
QGCSettingsWidget(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet);
~QGCSettingsWidget();
private:
Ui::QGCSettingsWidget *ui;
};
#endif // QGCSETTINGSWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCSettingsWidget</class>
<widget class="QDialog" name="QGCSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>535</width>
<height>427</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<widget class="QWidget" name="general">
<attribute name="title">
<string>General</string>
</attribute>
<attribute name="toolTip">
<string>General Settings</string>
</attribute>
<layout class="QGridLayout" name="generalPaneGridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="audioMuteCheckBox">
<property name="text">
<string>Mute all audio output</string>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/audio-volume-muted.svg</normaloff>:/images/status/audio-volume-muted.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../mavground.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QGCSettingsWidget</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QGCSettingsWidget</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<height>111</height>
<width>360</width>
<height>119</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -56,10 +56,11 @@ QLabel#modeLabel {
QLabel#stateLabel {
font: 12px;
color: #3C7B9E;
}
QLabel#gpsLabel {
font: 8px;
QLabel#navLabel {
font: 12px;
}
QLabel#positionLabel {
......@@ -255,7 +256,7 @@ QMenu::separator {
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="10,10,1,10,10,10,100,100">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,1,10,10,10,10,80">
<property name="horizontalSpacing">
<number>4</number>
</property>
......@@ -306,23 +307,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="0" column="2" rowspan="8">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>88</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3" colspan="3">
<item row="0" column="2" colspan="3">
<widget class="QLabel" name="nameLabel">
<property name="maximumSize">
<size>
......@@ -349,7 +334,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="0" column="6" colspan="2">
<item row="0" column="5" colspan="2">
<widget class="QLabel" name="modeLabel">
<property name="maximumSize">
<size>
......@@ -366,11 +351,11 @@ QMenu::separator {
</font>
</property>
<property name="text">
<string/>
<string>MODE</string>
</property>
</widget>
</item>
<item row="1" column="3" rowspan="3">
<item row="1" column="2" rowspan="3">
<widget class="QLabel" name="timeRemainingLabel">
<property name="font">
<font>
......@@ -391,7 +376,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="1" column="4" rowspan="3" colspan="2">
<item row="1" column="3" rowspan="3" colspan="2">
<widget class="QLabel" name="timeElapsedLabel">
<property name="font">
<font>
......@@ -412,7 +397,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="3" column="6" rowspan="2" colspan="2">
<item row="3" column="5" rowspan="2" colspan="2">
<widget class="QProgressBar" name="thrustBar">
<property name="font">
<font>
......@@ -430,7 +415,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="4" column="3">
<item row="4" column="2">
<widget class="QLabel" name="groundDistanceLabel">
<property name="font">
<font>
......@@ -451,7 +436,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="4" column="4" colspan="2">
<item row="4" column="3" colspan="2">
<widget class="QLabel" name="speedLabel">
<property name="font">
<font>
......@@ -536,22 +521,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="5" column="3" rowspan="2" colspan="2">
<widget class="QLabel" name="stateLabel">
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="3" colspan="2">
<item row="7" column="2">
<widget class="QLabel" name="waypointLabel">
<property name="font">
<font>
......@@ -575,7 +545,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="2" column="6" colspan="2">
<item row="2" column="5" colspan="2">
<widget class="QLabel" name="positionLabel">
<property name="minimumSize">
<size>
......@@ -608,25 +578,7 @@ QMenu::separator {
</property>
</widget>
</item>
<item row="5" column="6" colspan="2">
<widget class="QLabel" name="statusTextLabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>12</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="5" rowspan="2" colspan="3">
<item row="7" column="3" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
......@@ -791,6 +743,49 @@ QMenu::separator {
</item>
</layout>
</item>
<item row="5" column="2" rowspan="2" colspan="2">
<widget class="QLabel" name="navLabel">
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>NAV</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="7">
<widget class="QLabel" name="statusTextLabel">
<property name="text">
<string>Waiting for first status update..</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QLabel" name="stateLabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>12</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>STATE</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -276,49 +276,113 @@ void WaypointList::waypointListChanged()
{
// Prevent updates to prevent visual flicker
this->setUpdatesEnabled(false);
// Get all waypoints
const QVector<Waypoint *> &waypoints = uas->getWaypointManager()->getWaypointList();
// Store the current state, then check which widgets to update
// and which ones to delete
QList<Waypoint*> oldWaypoints = wpViews.keys();
foreach (Waypoint* wp, waypoints)
{
// Create any new waypoint
if (!wpViews.contains(wp))
if (!wpViews.empty())
{
WaypointView* wpview = new WaypointView(wp, this);
wpViews.insert(wp, wpview);
connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
QMapIterator<Waypoint*,WaypointView*> viewIt(wpViews);
viewIt.toFront();
while(viewIt.hasNext())
{
viewIt.next();
Waypoint *cur = viewIt.key();
int i;
for (i = 0; i < waypoints.size(); i++)
{
if (waypoints[i] == cur)
{
break;
}
}
if (i == waypoints.size())
{
WaypointView* widget = wpViews.find(cur).value();
widget->hide();
listLayout->removeWidget(widget);
wpViews.remove(cur);
}
}
}
else
// then add/update the views for each waypoint in the list
for(int i = 0; i < waypoints.size(); i++)
{
// Update existing waypoints
Waypoint *wp = waypoints[i];
if (!wpViews.contains(wp))
{
WaypointView* wpview = new WaypointView(wp, this);
wpViews.insert(wp, wpview);
connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
}
WaypointView *wpv = wpViews.value(wp);
wpv->updateValues(); // update the values of the ui elements in the view
listLayout->addWidget(wpv);
// Mark as updated by removing from old list
oldWaypoints.removeAt(oldWaypoints.indexOf(wp));
}
WaypointView *wpv = wpViews.value(wp);
wpv->updateValues(); // update the values of the ui elements in the view
listLayout->addWidget(wpv);
this->setUpdatesEnabled(true);
}
// The old list now contains all wps to be deleted
foreach (Waypoint* wp, oldWaypoints)
{
// Delete waypoint view and entry in list
WaypointView* wpv = wpViews.value(wp);
if (wpv)
{
wpv->deleteLater();
}
wpViews.remove(wp);
}
loadFileGlobalWP = false;
}
//void WaypointList::waypointListChanged()
//{
// if (uas)
// {
// // Prevent updates to prevent visual flicker
// this->setUpdatesEnabled(false);
// // Get all waypoints
// const QVector<Waypoint *> &waypoints = uas->getWaypointManager()->getWaypointList();
//// // Store the current state, then check which widgets to update
//// // and which ones to delete
//// QList<Waypoint*> oldWaypoints = wpViews.keys();
//// foreach (Waypoint* wp, waypoints)
//// {
//// WaypointView* wpview;
//// // Create any new waypoint
//// if (!wpViews.contains(wp))
//// {
//// wpview = new WaypointView(wp, this);
//// wpViews.insert(wp, wpview);
//// connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
//// connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
//// connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
//// connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
//// connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
//// listLayout->addWidget(wpview);
//// }
//// else
//// {
//// // Update existing waypoints
//// wpview = wpViews.value(wp);
//// }
//// // Mark as updated by removing from old list
//// oldWaypoints.removeAt(oldWaypoints.indexOf(wp));
//// wpview->updateValues(); // update the values of the ui elements in the view
//// }
//// // The old list now contains all wps to be deleted
//// foreach (Waypoint* wp, oldWaypoints)
//// {
//// // Delete waypoint view and entry in list
//// WaypointView* wpv = wpViews.value(wp);
//// if (wpv)
//// {
//// listLayout->removeWidget(wpv);
//// delete wpv;
//// }
//// wpViews.remove(wp);
//// }
// if (!wpViews.empty())
// {
......@@ -339,8 +403,11 @@ void WaypointList::waypointListChanged()
// if (i == waypoints.size())
// {
// WaypointView* widget = wpViews.find(cur).value();
// widget->hide();
// listLayout->removeWidget(widget);
// if (widget)
// {
// widget->hide();
// listLayout->removeWidget(widget);
// }
// wpViews.remove(cur);
// }
// }
......@@ -365,10 +432,10 @@ void WaypointList::waypointListChanged()
// listLayout->addWidget(wpv);
// }
this->setUpdatesEnabled(true);
}
loadFileGlobalWP = false;
}
// this->setUpdatesEnabled(true);
// }
//// loadFileGlobalWP = false;
//}
void WaypointList::moveUp(Waypoint* wp)
{
......
......@@ -334,10 +334,10 @@ void WaypointView::updateFrameView(int frame)
void WaypointView::deleted(QObject* waypoint)
{
if (waypoint == this->wp)
{
deleteLater();
}
// if (waypoint == this->wp)
// {
// deleteLater();
// }
}
void WaypointView::changedFrame(int index)
......@@ -528,14 +528,9 @@ void WaypointView::updateValues()
void WaypointView::setCurrent(bool state)
{
if (state)
{
m_ui->selectedBox->setCheckState(Qt::Checked);
}
else
{
m_ui->selectedBox->setCheckState(Qt::Unchecked);
}
m_ui->selectedBox->blockSignals(true);
m_ui->selectedBox->setChecked(state);;
m_ui->selectedBox->blockSignals(false);
}
WaypointView::~WaypointView()
......
......@@ -107,7 +107,9 @@ updateTimer(new QTimer())
int labelRow = curvesWidgetLayout->rowCount();
curvesWidgetLayout->addWidget(new QLabel(tr("On")), labelRow, 0, 1, 2);
selectAllCheckBox = new QCheckBox("", this);
connect(selectAllCheckBox, SIGNAL(clicked(bool)), this, SLOT(selectAllCurves(bool)));
curvesWidgetLayout->addWidget(selectAllCheckBox, labelRow, 0, 1, 2);
label = new QLabel(this);
label->setText("Name");
......@@ -153,6 +155,15 @@ LinechartWidget::~LinechartWidget()
listedCurves = NULL;
}
void LinechartWidget::selectAllCurves(bool all)
{
QMap<QString, QLabel*>::iterator i;
for (i = curveLabels->begin(); i != curveLabels->end(); ++i)
{
activePlot->setVisible(i.key(), all);
}
}
void LinechartWidget::writeSettings()
{
QSettings settings;
......@@ -299,7 +310,7 @@ void LinechartWidget::appendData(int uasId, QString curve, double value, quint64
// Log data
if (logging)
{
if (activePlot->isVisible(curve))
if (activePlot->isVisible(curve+unit))
{
if (logStartTime == 0) logStartTime = usec;
qint64 time = usec - logStartTime;
......@@ -365,7 +376,7 @@ void LinechartWidget::appendData(int uasId, const QString& curve, const QString&
// Log data
if (logging)
{
if (activePlot->isVisible(curve))
if (activePlot->isVisible(curve+unit))
{
if (logStartTime == 0) logStartTime = usec;
qint64 time = usec - logStartTime;
......@@ -660,6 +671,7 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
// TODO
// Connect actions
connect(selectAllCheckBox, SIGNAL(clicked(bool)), checkBox, SLOT(setChecked(bool)));
QObject::connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(takeButtonClick(bool)));
QObject::connect(this, SIGNAL(curveVisible(QString, bool)), plot, SLOT(setVisible(QString, bool)));
......
......@@ -99,6 +99,8 @@ public slots:
void writeSettings();
/** @brief Read the current configuration from disk */
void readSettings();
/** @brief Select all curves */
void selectAllCurves(bool all);
protected:
void addCurveToList(QString curve);
......@@ -145,6 +147,7 @@ protected:
quint64 logStartTime;
QTimer* updateTimer;
LogCompressor* compressor;
QCheckBox* selectAllCheckBox;
static const int updateInterval = 400; ///< Time between number updates, in milliseconds
static const int MAX_CURVE_MENUITEM_NUMBER = 8;
......
......@@ -3,6 +3,8 @@
#include <qmath.h>
#include "QGC.h"
MAV2DIcon::MAV2DIcon(UASInterface* uas, int radius, int type, const QColor& color, QString name, Alignment alignment, QPen* pen)
: Point(uas->getLatitude(), uas->getLongitude(), name, alignment),
yaw(0.0f),
......@@ -112,7 +114,10 @@ void MAV2DIcon::drawAirframePolygon(int airframe, QPainter& painter, int radius,
// DRAW AIRPLANE
// Rotate 180 degs more since the icon is oriented downwards
float yawRotate = (yaw/(float)M_PI)*180.0f + 180.0f+180.0f;
//float yawRotate = (yaw/(float)M_PI)*180.0f + 180.0f+180.0f;
const float yawDeg = ((yaw/M_PI)*180.0f)+180.0f+180.0f;
int yawRotate = static_cast<int>(yawDeg) % 360;
painter.rotate(yawRotate);
......@@ -159,7 +164,8 @@ void MAV2DIcon::drawAirframePolygon(int airframe, QPainter& painter, int radius,
{
// QUADROTOR
float iconSize = radius*0.9f;
float yawRotate = (yaw/(float)M_PI)*180.0f + 180.0f;
const float yawDeg = ((yaw/M_PI)*180.0f)+180.0f;
int yawRotate = static_cast<int>(yawDeg) % 360;
painter.rotate(yawRotate);
......@@ -201,8 +207,8 @@ void MAV2DIcon::drawAirframePolygon(int airframe, QPainter& painter, int radius,
{
// DRAW AIRPLANE
float yawRotate = (yaw/(float)M_PI)*180.0f + 180.0f;
const float yawDeg = ((yaw/M_PI)*180.0f)+180.0f;
int yawRotate = static_cast<int>(yawDeg) % 360;
painter.rotate(yawRotate);
//qDebug() << "ICON SIZE:" << radius;
......
......@@ -211,10 +211,10 @@ void QGCGoogleEarthView::updateWaypointList(int uas)
}
}
void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lon, double lat, double alt, quint64 usec)
void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec)
{
Q_UNUSED(usec);
javaScript(QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
javaScript(QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 18).arg(lon, 0, 'f', 18).arg(alt, 0, 'f', 15));
//qDebug() << QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15);
}
......
......@@ -79,7 +79,7 @@ public slots:
/** @brief Set the currently selected UAS */
void setActiveUAS(UASInterface* uas);
/** @brief Update the global position */
void updateGlobalPosition(UASInterface* uas, double lon, double lat, double alt, quint64 usec);
void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
/** @brief Update a single waypoint */
void updateWaypoint(int uas, Waypoint* wp);
/** @brief Update the waypoint list */
......
......@@ -89,7 +89,9 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
connect(uas->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointUpdated(quint16)));
connect(uas, SIGNAL(systemTypeSet(UASInterface*,uint)), this, SLOT(setSystemType(UASInterface*,uint)));
connect(UASManager::instance(), SIGNAL(activeUASStatusChanged(UASInterface*,bool)), this, SLOT(updateActiveUAS(UASInterface*,bool)));
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(showStatusText(int, int, int, QString)));
connect(uas, SIGNAL(navModeChanged(int, int, QString)), this, SLOT(updateNavMode(int, int, QString)));
// Setup UAS selection
connect(m_ui->uasViewFrame, SIGNAL(clicked(bool)), this, SLOT(setUASasActive(bool)));
......@@ -151,6 +153,22 @@ void UASView::heartbeatTimeout()
timeout = true;
}
void UASView::updateNavMode(int uasid, int mode, const QString& text)
{
Q_UNUSED(uasid);
Q_UNUSED(mode);
m_ui->navLabel->setText(text);
}
void UASView::showStatusText(int uasid, int componentid, int severity, QString text)
{
Q_UNUSED(uasid);
Q_UNUSED(componentid);
Q_UNUSED(severity);
//m_ui->statusTextLabel->setText(text);
stateDesc = text;
}
/**
* Set the background color based on the MAV color. If the MAV is selected as the
* currently actively controlled system, the frame color is highlighted
......@@ -347,7 +365,7 @@ void UASView::updateGlobalPosition(UASInterface* uas, double lon, double lat, do
void UASView::updateSpeed(UASInterface*, double x, double y, double z, quint64 usec)
{
Q_UNUSED(usec);
totalSpeed = sqrt((pow(x, 2) + pow(y, 2) + pow(z, 2)));
totalSpeed = sqrt(x*x + y*y + z*z);
}
void UASView::currentWaypointUpdated(quint16 waypoint)
......
......@@ -86,6 +86,10 @@ public slots:
void selectAirframe();
/** @brief Select the battery type */
void setBatterySpecs();
/** @brief Show a status text message */
void showStatusText(int uasid, int componentid, int severity, QString text);
/** @brief Update the navigation mode state */
void updateNavMode(int uasid, int mode, const QString& text);
protected:
void changeEvent(QEvent *e);
......
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