Commit 2998176c authored by Gus Grubba's avatar Gus Grubba

Make Mock Link send battery info

parent 9ee95420
...@@ -104,6 +104,7 @@ MockLink::MockLink(SharedLinkConfigurationPointer& config) ...@@ -104,6 +104,7 @@ MockLink::MockLink(SharedLinkConfigurationPointer& config)
_adsbVehicleCoordinate = QGeoCoordinate(_vehicleLatitude, _vehicleLongitude).atDistanceAndAzimuth(1000, _adsbAngle); _adsbVehicleCoordinate = QGeoCoordinate(_vehicleLatitude, _vehicleLongitude).atDistanceAndAzimuth(1000, _adsbAngle);
_adsbVehicleCoordinate.setAltitude(100); _adsbVehicleCoordinate.setAltitude(100);
_runningTime.start();
} }
MockLink::~MockLink(void) MockLink::~MockLink(void)
...@@ -176,6 +177,7 @@ void MockLink::_run1HzTasks(void) ...@@ -176,6 +177,7 @@ void MockLink::_run1HzTasks(void)
_sendHighLatency2(); _sendHighLatency2();
} else { } else {
_sendVibration(); _sendVibration();
_sendSysStatus();
_sendADSBVehicles(); _sendADSBVehicles();
if (!qgcApp()->runningUnitTests()) { if (!qgcApp()->runningUnitTests()) {
// Sending RC Channels during unit test breaks RC tests which does it's own RC simulation // Sending RC Channels during unit test breaks RC tests which does it's own RC simulation
...@@ -357,6 +359,28 @@ void MockLink::_sendHighLatency2(void) ...@@ -357,6 +359,28 @@ void MockLink::_sendHighLatency2(void)
respondWithMavlinkMessage(msg); respondWithMavlinkMessage(msg);
} }
void MockLink::_sendSysStatus(void)
{
if(_batteryRemaining > 50) {
_batteryRemaining = static_cast<int8_t>(100 - (_runningTime.elapsed() / 1000));
}
mavlink_message_t msg;
mavlink_msg_sys_status_pack_chan(
_vehicleSystemId,
_vehicleComponentId,
static_cast<uint8_t>(_mavlinkChannel),
&msg,
0, // onboard_control_sensors_present
0, // onboard_control_sensors_enabled
0, // onboard_control_sensors_health
250, // load
4200 * 4, // voltage_battery
8000, // current_battery
_batteryRemaining, // battery_remaining
0,0,0,0,0,0);
respondWithMavlinkMessage(msg);
}
void MockLink::_sendVibration(void) void MockLink::_sendVibration(void)
{ {
mavlink_message_t msg; mavlink_message_t msg;
......
...@@ -196,6 +196,7 @@ private: ...@@ -196,6 +196,7 @@ private:
void _sendHomePosition(void); void _sendHomePosition(void);
void _sendGpsRawInt(void); void _sendGpsRawInt(void);
void _sendVibration(void); void _sendVibration(void);
void _sendSysStatus(void);
void _sendStatusTextMessages(void); void _sendStatusTextMessages(void);
void _respondWithAutopilotVersion(void); void _respondWithAutopilotVersion(void);
void _sendRCChannels(void); void _sendRCChannels(void);
...@@ -226,6 +227,9 @@ private: ...@@ -226,6 +227,9 @@ private:
uint32_t _mavCustomMode; uint32_t _mavCustomMode;
uint8_t _mavState; uint8_t _mavState;
QTime _runningTime;
int8_t _batteryRemaining = 100;
MAV_AUTOPILOT _firmwareType; MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType; MAV_TYPE _vehicleType;
double _vehicleLatitude; double _vehicleLatitude;
......
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