Skip to content

Commit

Permalink
document
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 26, 2023
1 parent 339808a commit 03af4e2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 32 deletions.
16 changes: 16 additions & 0 deletions app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void MavlinkTelemetry::start()
QSettings settings;
// By default, we always use UDP / localhost mode.
enable_udp();
m_heartbeat_thread_run=true;
m_heartbeat_thread=std::make_unique<std::thread>(&MavlinkTelemetry::send_heartbeat_loop,this);
}

bool MavlinkTelemetry::sendMessage(mavlink_message_t msg){
Expand Down Expand Up @@ -206,6 +208,7 @@ void MavlinkTelemetry::process_message_timesync(const mavlink_message_t &msg)
}
}


void MavlinkTelemetry::add_tcp_connection_handler(QString ip)
{
qDebug()<<"MavlinkTelemetry::add_tcp_connection_handler"<<ip;
Expand Down Expand Up @@ -259,3 +262,16 @@ void MavlinkTelemetry::re_apply_rates()
{
FCMsgIntervalHandler::instance().restart();
}

void MavlinkTelemetry::send_heartbeat_loop()
{
mavlink_message_t msg;
mavlink_heartbeat_t heartbeat{};
heartbeat.type=MAV_TYPE_GCS;
heartbeat.autopilot=MAV_AUTOPILOT_INVALID;
while(m_heartbeat_thread_run){
std::this_thread::sleep_for(std::chrono::milliseconds(500));
mavlink_msg_heartbeat_encode(QOpenHDMavlinkHelper::get_own_sys_id(),QOpenHDMavlinkHelper::get_own_comp_id(),&msg,&heartbeat);
sendMessage(msg);
}
}
3 changes: 3 additions & 0 deletions app/telemetry/MavlinkTelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class MavlinkTelemetry : public QObject
int64_t m_tele_received_packets=0;
BitrateCalculator2 m_tele_bitrate_in;
PacketsPerSecondCalculator m_tele_pps_in;
std::unique_ptr<std::thread> m_heartbeat_thread;
std::atomic_bool m_heartbeat_thread_run;
void send_heartbeat_loop();
};

#endif // OHDMAVLINKCONNECTION_H
18 changes: 9 additions & 9 deletions app/telemetry/models/camerastreammodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air(const mavlink_o
set_curr_recommended_bitrate_from_message(curr_recommended_bitrate_kbits);
set_curr_video_measured_encoder_bitrate(Telemetryutil::bitrate_bps_to_qstring(msg.curr_measured_encoder_bitrate));
set_curr_video_injected_bitrate(Telemetryutil::bitrate_bps_to_qstring(msg.curr_injected_bitrate));
set_curr_video0_injected_pps(Telemetryutil::pps_to_string(msg.curr_injected_pps));
set_curr_video_injected_pps(Telemetryutil::pps_to_string(msg.curr_injected_pps));
set_total_n_tx_dropped_frames(msg.curr_dropped_frames);
if(m_last_tx_frame_drop_calculation_count<0){
m_last_tx_frame_drop_calculation_count=msg.curr_dropped_frames;
Expand Down Expand Up @@ -140,27 +140,27 @@ void CameraStreamModel::update_mavlink_openhd_camera_status_air(const mavlink_op

void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air_fec_performance(const mavlink_openhd_stats_wb_video_air_fec_performance_t &msg)
{
set_curr_video0_fec_encode_time_avg_min_max(
set_curr_fec_encode_time_avg_min_max(
Telemetryutil::us_min_max_avg_to_string(msg.curr_fec_encode_time_min_us,msg.curr_fec_encode_time_max_us,msg.curr_fec_encode_time_avg_us));
set_curr_video0_fec_block_length_min_max_avg(
set_curr_fec_block_length_min_max_avg(
Telemetryutil::min_max_avg_to_string(msg.curr_fec_block_size_min,msg.curr_fec_block_size_max,msg.curr_fec_block_size_avg));
set_curr_time_until_tx_min_max_avg(
Telemetryutil::us_min_max_avg_to_string(msg.curr_tx_delay_min_us,msg.curr_tx_delay_max_us,msg.curr_tx_delay_avg_us));
}

void CameraStreamModel::update_mavlink_openhd_stats_wb_video_ground(const mavlink_openhd_stats_wb_video_ground_t &msg)
{
set_curr_video0_received_bitrate_with_fec(Telemetryutil::bitrate_bps_to_qstring(msg.curr_incoming_bitrate));
set_video0_count_blocks_lost(msg.count_blocks_lost);
set_video0_count_blocks_recovered(msg.count_blocks_recovered);
set_video0_count_fragments_recovered(msg.count_fragments_recovered);
set_video0_count_blocks_total(msg.count_blocks_total);
set_curr_received_bitrate_with_fec(Telemetryutil::bitrate_bps_to_qstring(msg.curr_incoming_bitrate));
set_count_blocks_lost(msg.count_blocks_lost);
set_count_blocks_recovered(msg.count_blocks_recovered);
set_count_fragments_recovered(msg.count_fragments_recovered);
set_count_blocks_total(msg.count_blocks_total);
//set_gnd_rx_packets_per_second_and_bits_per_second(StringHelper::bitrate_and_pps_to_string(msg.curr_incoming_bitrate,msg.cur_).c_str());
}

void CameraStreamModel::update_mavlink_openhd_stats_wb_video_ground_fec_performance(const mavlink_openhd_stats_wb_video_ground_fec_performance_t &msg)
{
set_curr_video0_fec_decode_time_avg_min_max(
set_curr_fec_decode_time_avg_min_max(
Telemetryutil::us_min_max_avg_to_string(msg.curr_fec_decode_time_min_us,msg.curr_fec_decode_time_max_us,msg.curr_fec_decode_time_avg_us));
}

Expand Down
18 changes: 9 additions & 9 deletions app/telemetry/models/camerastreammodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class CameraStreamModel : public QObject
L_RO_PROP(int,curr_recomended_video_bitrate_kbits,set_curr_recomended_video_bitrate_kbits,0)
L_RO_PROP(QString,curr_video_measured_encoder_bitrate,set_curr_video_measured_encoder_bitrate,"N/A")
L_RO_PROP(QString,curr_video_injected_bitrate,set_curr_video_injected_bitrate,"N/A") //includes FEC overhead
L_RO_PROP(QString,curr_video0_injected_pps,set_curr_video0_injected_pps,"-1pps") //includes FEC overhead
L_RO_PROP(QString,curr_video_injected_pps,set_curr_video_injected_pps,"-1pps") //includes FEC overhead
// total n of frames that were dropped on the tx (hints at too high bitrate)
L_RO_PROP(int,total_n_tx_dropped_frames,set_total_n_tx_dropped_frames,0)
// calculated in fixed X second interval(s) - n of tx frames dropped during this interval
L_RO_PROP(int,curr_delta_tx_dropped_frames,set_curr_delta_tx_dropped_frames,0)
// DEV stats
L_RO_PROP(QString,curr_video0_fec_encode_time_avg_min_max,set_curr_video0_fec_encode_time_avg_min_max,"avg na, min na, max na")
L_RO_PROP(QString,curr_video0_fec_block_length_min_max_avg,set_curr_video0_fec_block_length_min_max_avg,"avg na, min na, max na")
L_RO_PROP(QString,curr_fec_encode_time_avg_min_max,set_curr_fec_encode_time_avg_min_max,"avg na, min na, max na")
L_RO_PROP(QString,curr_fec_block_length_min_max_avg,set_curr_fec_block_length_min_max_avg,"avg na, min na, max na")
L_RO_PROP(QString,curr_time_until_tx_min_max_avg,set_curr_time_until_tx_min_max_avg,"avg na, min na, max na")
// Used to show the user a visual indication that the set and measured encoder bitrate are far apart
// 0 - all okay, 1= bitrate is too low (yellow), 2= bitrate is too high (red)
Expand All @@ -58,12 +58,12 @@ class CameraStreamModel : public QObject
//
// These are generated by the OpenHD ground unit
//
L_RO_PROP(QString,curr_video0_received_bitrate_with_fec,set_curr_video0_received_bitrate_with_fec,"N/A")
L_RO_PROP(qint64,video0_count_blocks_total,set_video0_count_blocks_total,-1)
L_RO_PROP(qint64,video0_count_blocks_lost,set_video0_count_blocks_lost,-1)
L_RO_PROP(qint64,video0_count_blocks_recovered,set_video0_count_blocks_recovered,-1)
L_RO_PROP(qint64,video0_count_fragments_recovered,set_video0_count_fragments_recovered,-1)
L_RO_PROP(QString,curr_video0_fec_decode_time_avg_min_max,set_curr_video0_fec_decode_time_avg_min_max,"avg na, min na, max na")
L_RO_PROP(QString,curr_received_bitrate_with_fec,set_curr_received_bitrate_with_fec,"N/A")
L_RO_PROP(qint64,count_blocks_total,set_count_blocks_total,-1)
L_RO_PROP(qint64,count_blocks_lost,set_count_blocks_lost,-1)
L_RO_PROP(qint64,count_blocks_recovered,set_count_blocks_recovered,-1)
L_RO_PROP(qint64,count_fragments_recovered,set_count_fragments_recovered,-1)
L_RO_PROP(QString,curr_fec_decode_time_avg_min_max,set_curr_fec_decode_time_avg_min_max,"avg na, min na, max na")
//
public:
// generated by wb / link
Expand Down
6 changes: 3 additions & 3 deletions qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ Rectangle {
// air
Text {
id: test2
text: qsTr("video0 FEC encode: "+_cameraStreamModelPrimary.curr_video0_fec_encode_time_avg_min_max)
text: qsTr("video0 FEC encode: "+_cameraStreamModelPrimary.curr_fec_encode_time_avg_min_max)
}
Text {
id: testX
text: qsTr("video0 TX delay: "+_cameraStreamModelPrimary.curr_time_until_tx_min_max_avg)
}
Text {
id: test4
text: qsTr("video0 FEC block length: "+_cameraStreamModelPrimary.curr_video0_fec_block_length_min_max_avg)
text: qsTr("video0 FEC block length: "+_cameraStreamModelPrimary.curr_fec_block_length_min_max_avg)
}
// ground
Text {
id: test3
text: qsTr("video0 FEC decode: "+_cameraStreamModelPrimary.curr_video0_fec_decode_time_avg_min_max)
text: qsTr("video0 FEC decode: "+_cameraStreamModelPrimary.curr_fec_decode_time_avg_min_max)
}
Text {
id: test5
Expand Down
17 changes: 12 additions & 5 deletions qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import OpenHD 1.0
import "../../../ui" as Ui
import "../../elements"

import QtCharts 2.0
//simport QtCharts 2.0

// This is an extra screen for changing the frequency / channel width -
// They both need to match !
Expand Down Expand Up @@ -97,11 +97,18 @@ Rectangle{
console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models);
if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return
create_list_model_supported();
//update_pollution_graph();
}

/*property BarCategoryAxis m_bar_category_axis;
function update_pollution_graph(){

}
const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies();
m_bar_category_axis.categories.clear();
for(var i=0;i<supported_frequencies.length;i++){
m_bar_category_axis.categories.append(""+supported_frequencies.at(i));
}
hm_bar_series.axisX = m_bar_category_axis
}*/

//
Component.onCompleted: {
Expand Down Expand Up @@ -635,7 +642,7 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur
text: _wbLinkSettingsHelper.text_for_qml
}
}
ChartView {
/*ChartView {
title: "Bar series"
width: parent.width
height: rowHeight * 3
Expand All @@ -649,7 +656,7 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur
BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
}
}
}*/
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions qml/ui/widgets/LinkDownRSSIWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ BaseWidget {
}
Text {
//Layout.alignment: left
text: "Blocks lost: "+_cameraStreamModelPrimary.video0_count_blocks_lost
text: "Blocks lost: "+_cameraStreamModelPrimary.count_blocks_lost
color: "white"
font.bold: true
height: parent.height
Expand All @@ -311,7 +311,7 @@ BaseWidget {
}
Text {
//Layout.alignment: left
text: "Blocks recovered: "+_cameraStreamModelPrimary.video0_count_blocks_recovered;
text: "Blocks recovered: "+_cameraStreamModelPrimary.count_blocks_recovered;
color: "white"
font.bold: true
height: parent.height
Expand All @@ -320,7 +320,7 @@ BaseWidget {
}
Text {
//Layout.alignment: left
text: "Fragments recovered: "+_cameraStreamModelPrimary.video0_count_fragments_recovered;
text: "Fragments recovered: "+_cameraStreamModelPrimary.count_fragments_recovered;
color: "white"
font.bold: true
height: parent.height
Expand Down
11 changes: 8 additions & 3 deletions qml/ui/widgets/VideoBitrateWidgetGeneric.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ BaseWidget {
_wbLinkSettingsHelper.set_param_video_resolution_framerate_async(false,resolution_str)
}
}
function get_drop_str_tx_rx(){
//return _cameraStreamModelPrimary.total_n_tx_dropped_frames+":"+_cameraStreamModelPrimary.count_blocks_lost;
//return m_camera_stream_model.curr_delta_tx_dropped_frames+":"+m_camera_stream_model.total_n_tx_dropped_frames
return m_camera_stream_model.total_n_tx_dropped_frames+":"+m_camera_stream_model.count_blocks_lost;
}


//----------------------------- DETAIL BELOW ----------------------------------
Expand Down Expand Up @@ -169,7 +174,7 @@ BaseWidget {
width: parent.width
height: 32
Text {
text: qsTr("TX drop (tot/curr):")
text: qsTr("TX Dropped/RX lost:")
color: "white"
font.bold: true
height: parent.height
Expand All @@ -178,7 +183,7 @@ BaseWidget {
verticalAlignment: Text.AlignVCenter
}
Text {
text: m_camera_stream_model.curr_delta_tx_dropped_frames+":"+m_camera_stream_model.total_n_tx_dropped_frames
text: get_drop_str_tx_rx()
color: "white";
font.bold: true;
height: parent.height
Expand Down Expand Up @@ -280,7 +285,7 @@ BaseWidget {
width: 84
height: 32
color: bitrate_color(m_camera_stream_model.curr_set_and_measured_bitrate_mismatch)
text: m_camera_stream_model.curr_video0_received_bitrate_with_fec
text: m_camera_stream_model.curr_received_bitrate_with_fec
anchors.verticalCenterOffset: 0
anchors.left: camera_icon.right
anchors.leftMargin: 6
Expand Down

0 comments on commit 03af4e2

Please sign in to comment.