diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index ba2116c9da029a912a99824f590041b6c224ac4e..3a3dd070b7199b22b31c2c14fb3748dd04052e53 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -222,6 +222,7 @@
src/Vehicle/TemperatureFact.json
src/Vehicle/SubmarineFact.json
src/Settings/BrandImage.SettingsGroup.json
+ src/Vehicle/ClockFact.json
src/comm/APMArduCopterMockLink.params
diff --git a/src/FactSystem/FactGroup.h b/src/FactSystem/FactGroup.h
index a051699645c687f0b8d2fc145f6040261f81ff3f..605844abcd6a02666c793d10c176159824ac02c8 100644
--- a/src/FactSystem/FactGroup.h
+++ b/src/FactSystem/FactGroup.h
@@ -48,8 +48,8 @@ protected:
int _updateRateMSecs; ///< Update rate for Fact::valueChanged signals, 0: immediate update
-private slots:
- void _updateAllValues(void);
+protected slots:
+ virtual void _updateAllValues(void);
private:
void _setupTimer();
diff --git a/src/Vehicle/ClockFact.json b/src/Vehicle/ClockFact.json
new file mode 100644
index 0000000000000000000000000000000000000000..dc233f9ca1003d8285accc84a216f69d447671bd
--- /dev/null
+++ b/src/Vehicle/ClockFact.json
@@ -0,0 +1,12 @@
+[
+{
+ "name": "currentTime",
+ "shortDescription": "Time",
+ "type": "string"
+},
+{
+ "name": "currentDate",
+ "shortDescription": "Date",
+ "type": "string"
+}
+]
diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc
index 01289f2f692d48523052af6f289d61e22311aa7a..7aed3cdd836e6576de4bdf0f568f182fae0055cd 100644
--- a/src/Vehicle/Vehicle.cc
+++ b/src/Vehicle/Vehicle.cc
@@ -7,6 +7,9 @@
*
****************************************************************************/
+#include
+#include
+#include
#include "Vehicle.h"
#include "MAVLinkProtocol.h"
@@ -66,6 +69,7 @@ const char* Vehicle::_batteryFactGroupName = "battery";
const char* Vehicle::_windFactGroupName = "wind";
const char* Vehicle::_vibrationFactGroupName = "vibration";
const char* Vehicle::_temperatureFactGroupName = "temperature";
+const char* Vehicle::_clockFactGroupName = "clock";
Vehicle::Vehicle(LinkInterface* link,
int vehicleId,
@@ -174,6 +178,7 @@ Vehicle::Vehicle(LinkInterface* link,
, _windFactGroup(this)
, _vibrationFactGroup(this)
, _temperatureFactGroup(this)
+ , _clockFactGroup(this)
{
_addLink(link);
@@ -348,6 +353,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _batteryFactGroup(this)
, _windFactGroup(this)
, _vibrationFactGroup(this)
+ , _clockFactGroup(this)
{
_commonInit();
_firmwarePlugin->initializeVehicle(this);
@@ -411,6 +417,7 @@ void Vehicle::_commonInit(void)
_addFactGroup(&_windFactGroup, _windFactGroupName);
_addFactGroup(&_vibrationFactGroup, _vibrationFactGroupName);
_addFactGroup(&_temperatureFactGroup, _temperatureFactGroupName);
+ _addFactGroup(&_clockFactGroup, _clockFactGroupName);
// Add firmware-specific fact groups, if provided
QMap* fwFactGroups = _firmwarePlugin->factGroups();
@@ -3046,3 +3053,27 @@ VehicleTemperatureFactGroup::VehicleTemperatureFactGroup(QObject* parent)
_temperature2Fact.setRawValue (std::numeric_limits::quiet_NaN());
_temperature3Fact.setRawValue (std::numeric_limits::quiet_NaN());
}
+
+const char* VehicleClockFactGroup::_currentTimeFactName = "currentTime";
+const char* VehicleClockFactGroup::_currentDateFactName = "currentDate";
+
+VehicleClockFactGroup::VehicleClockFactGroup(QObject* parent)
+ : FactGroup(1000, ":/json/Vehicle/ClockFact.json", parent)
+ , _currentTimeFact (0, _currentTimeFactName, FactMetaData::valueTypeString)
+ , _currentDateFact (0, _currentDateFactName, FactMetaData::valueTypeString)
+{
+ _addFact(&_currentTimeFact, _currentTimeFactName);
+ _addFact(&_currentDateFact, _currentDateFactName);
+
+ // Start out as not available "--.--"
+ _currentTimeFact.setRawValue (std::numeric_limits::quiet_NaN());
+ _currentDateFact.setRawValue (std::numeric_limits::quiet_NaN());
+}
+
+void VehicleClockFactGroup::_updateAllValues(void)
+{
+ _currentTimeFact.setRawValue(QTime::currentTime().toString());
+ _currentDateFact.setRawValue(QDateTime::currentDateTime().toString(QLocale::system().dateFormat(QLocale::ShortFormat)));
+
+ FactGroup::_updateAllValues();
+}
diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h
index 4f116f9b7c51b6d69aafefa6eccb6556a1dfedea..5c68214cb92d658a3be543c3cdaf61a848ac3746 100644
--- a/src/Vehicle/Vehicle.h
+++ b/src/Vehicle/Vehicle.h
@@ -224,6 +224,32 @@ private:
Fact _temperature3Fact;
};
+class VehicleClockFactGroup : public FactGroup
+{
+ Q_OBJECT
+
+public:
+ VehicleClockFactGroup(QObject* parent = NULL);
+
+ Q_PROPERTY(Fact* currentTime READ currentTime CONSTANT)
+ Q_PROPERTY(Fact* currentDate READ currentDate CONSTANT)
+
+ Fact* currentTime (void) { return &_currentTimeFact; }
+ Fact* currentDate (void) { return &_currentDateFact; }
+
+ static const char* _currentTimeFactName;
+ static const char* _currentDateFactName;
+
+ static const char* _settingsGroup;
+
+private slots:
+ void _updateAllValues(void) override;
+
+private:
+ Fact _currentTimeFact;
+ Fact _currentDateFact;
+};
+
class Vehicle : public FactGroup
{
Q_OBJECT
@@ -356,6 +382,7 @@ public:
Q_PROPERTY(FactGroup* wind READ windFactGroup CONSTANT)
Q_PROPERTY(FactGroup* vibration READ vibrationFactGroup CONSTANT)
Q_PROPERTY(FactGroup* temperature READ temperatureFactGroup CONSTANT)
+ Q_PROPERTY(FactGroup* clock READ clockFactGroup CONSTANT)
Q_PROPERTY(int firmwareMajorVersion READ firmwareMajorVersion NOTIFY firmwareVersionChanged)
Q_PROPERTY(int firmwareMinorVersion READ firmwareMinorVersion NOTIFY firmwareVersionChanged)
@@ -627,6 +654,7 @@ public:
FactGroup* windFactGroup (void) { return &_windFactGroup; }
FactGroup* vibrationFactGroup (void) { return &_vibrationFactGroup; }
FactGroup* temperatureFactGroup (void) { return &_temperatureFactGroup; }
+ FactGroup* clockFactGroup (void) { return &_clockFactGroup; }
void setConnectionLostEnabled(bool connectionLostEnabled);
@@ -1076,6 +1104,7 @@ private:
VehicleWindFactGroup _windFactGroup;
VehicleVibrationFactGroup _vibrationFactGroup;
VehicleTemperatureFactGroup _temperatureFactGroup;
+ VehicleClockFactGroup _clockFactGroup;
static const char* _rollFactName;
static const char* _pitchFactName;
@@ -1095,6 +1124,7 @@ private:
static const char* _windFactGroupName;
static const char* _vibrationFactGroupName;
static const char* _temperatureFactGroupName;
+ static const char* _clockFactGroupName;
static const int _vehicleUIUpdateRateMSecs = 100;