Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,13 @@ cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --
'''

[tasks.newline-terminator]
env = { EXCLUSION_PATTERNS = [".png", "docs", "resources/images"] }
private = true
script_runner = "python"
script_extension = "py"
script = '''
import os
import re
import sys
import subprocess
def raises_exc(func):
Expand All @@ -900,6 +902,9 @@ try_open_text = lambda fn: lambda: (open(fn, "ta"), open(fn, "tr").read(4096))
valid_file = lambda fn: os.path.getsize(fn) > 0 and not raises_exc(try_open_text(fn))
no_trailing_lf = lambda fn: valid_file(fn) and not has_newline(fn)
all_files = subprocess.check_output(["git", "ls-files"]).decode('utf8').splitlines()
exclusion_substrings = os.environ.get("EXCLUSION_PATTERNS")
exclusion_substrings = exclusion_substrings.split(";")
all_files = [x for x in all_files if not any([re.match(".*"+y, x) for y in exclusion_substrings])]
no_newline = list(map(append_newline, filter(no_trailing_lf, all_files)))
footer = "*********************************************\n"
err = "ERROR: " if dry_run else "Fixing "
Expand Down
29 changes: 1 addition & 28 deletions console_backend/src/main_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
time::{Duration, Instant},
};

use capnp::message::Builder;
use chrono::Local;
use log::error;
use sbp::Sbp;
Expand All @@ -15,7 +14,7 @@ use crate::constants::{
};
use crate::output::{CsvLogging, SbpLogger};
use crate::shared_state::{create_directory, SharedState};
use crate::utils::{bytes_to_human_readable, refresh_loggingbar, serialize_capnproto_builder};
use crate::utils::{refresh_loggingbar, refresh_loggingbar_recording};
use crate::{client_sender::BoxedClientSender, shared_state::ConnectionState};
use crate::{common_constants::SbpLogging, shared_state::SbpLoggingStatsState};

Expand Down Expand Up @@ -55,32 +54,6 @@ pub fn logging_stats_thread(
})
}

pub fn refresh_loggingbar_recording(
client_sender: &BoxedClientSender,
size: u64,
duration: u64,
filename: Option<String>,
) {
let mut builder = Builder::new_default();
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();

let mut logging_bar_status = msg.init_logging_bar_recording_status();
logging_bar_status.set_recording_duration_sec(duration);
logging_bar_status.set_recording_size(&bytes_to_human_readable(size as u128));
if let Some(filename_) = filename {
logging_bar_status
.reborrow()
.get_recording_filename()
.set_filename(&filename_);
} else {
logging_bar_status
.reborrow()
.get_recording_filename()
.set_none(());
}
client_sender.send_data(serialize_capnproto_builder(builder));
}

pub struct MainTab {
logging_directory: PathBuf,
last_csv_logging: CsvLogging,
Expand Down
26 changes: 26 additions & 0 deletions console_backend/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ pub fn refresh_loggingbar(client_sender: &BoxedClientSender, shared_state: &Shar
client_sender.send_data(serialize_capnproto_builder(builder));
}

pub fn refresh_loggingbar_recording(
client_sender: &BoxedClientSender,
size: u64,
duration: u64,
filename: Option<String>,
) {
let mut builder = Builder::new_default();
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();

let mut logging_bar_status = msg.init_logging_bar_recording_status();
logging_bar_status.set_recording_duration_sec(duration);
logging_bar_status.set_recording_size(size);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change here is sending the size parameter instead of passing it to bytes_to_human_readable before sending to frontend. Now frontend will do the calculation and produce the string.

if let Some(filename_) = filename {
logging_bar_status
.reborrow()
.get_recording_filename()
.set_filename(&filename_);
} else {
logging_bar_status
.reborrow()
.get_recording_filename()
.set_none(());
}
client_sender.send_data(serialize_capnproto_builder(builder));
}

pub fn signal_key_label(
key: (SignalCodes, i16),
extra: Option<&HashMap<i16, i16>>,
Expand Down
2 changes: 2 additions & 0 deletions resources/Constants/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ QtObject {
readonly property int pauseButtonPadding: 0
readonly property string pauseButtonTooltip: "Pause Log Panel"
readonly property string playButtonTooltip: "Resume Log Panel"
readonly property string clearButtonTooltip: "Clear Log Panel"
readonly property int logLevelMenuHeight: 100
readonly property int dropdownButtonPadding: 0
readonly property int dropdownButtonWidth: 20
Expand Down Expand Up @@ -628,6 +629,7 @@ QtObject {
readonly property string swiftLogoPath: "qrc:/images/icon.png"
readonly property string swiftLogoWidePath: "qrc:/images/swiftLogoWide.svg"
readonly property string folderPath: "qrc:/images/fontawesome/folder-regular.svg"
readonly property string xPath: "qrc:/images/iconic/x.svg"
}

insSettingsPopup: QtObject {
Expand Down
44 changes: 36 additions & 8 deletions resources/LogPanel.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./Constants"
import "BaseComponents"
import "Constants"
import Qt.labs.qmlmodels 1.0
import QtQuick 2.15
import QtQuick.Controls 2.15
Expand Down Expand Up @@ -48,13 +49,43 @@ Item {
anchors.rightMargin: Constants.logPanel.pauseButtonRightMargin
z: Constants.logPanel.zAboveTable

RoundButton {
id: baselinePauseButton
SwiftButton {
width: Constants.logPanel.pauseButtonWidth
height: Constants.logPanel.pauseButtonWidth
padding: Constants.logPanel.pauseButtonPadding
icon.width: Constants.logPanel.pauseButtonWidth / 3
icon.height: Constants.logPanel.pauseButtonWidth / 3
icon.source: Constants.icons.xPath
icon.color: Constants.materialGrey
anchors.right: parent.right
anchors.top: parent.top
ToolTip.visible: hovered
ToolTip.text: Constants.logPanel.clearButtonTooltip
onClicked: {
tableView.model.clear();
var new_row = {
};
new_row[Constants.logPanel.timestampHeader] = "";
new_row[Constants.logPanel.levelHeader] = "";
new_row[Constants.logPanel.msgHeader] = "";
logEntries = [new_row];
tableView.model.setRow(0, new_row);
tableView.forceLayout();
}
}

}

Item {
anchors.fill: parent
anchors.topMargin: Constants.genericTable.cellHeight * 2
anchors.rightMargin: Constants.logPanel.pauseButtonRightMargin
z: Constants.logPanel.zAboveTable

SwiftButton {
visible: !consolePaused
width: Constants.logPanel.pauseButtonWidth
height: Constants.logPanel.pauseButtonWidth
radius: Constants.logPanel.pauseButtonWidth / 3
padding: Constants.logPanel.pauseButtonPadding
icon.width: Constants.logPanel.pauseButtonWidth / 3
icon.height: Constants.logPanel.pauseButtonWidth / 3
Expand All @@ -69,13 +100,10 @@ Item {
}
}

RoundButton {
id: baselinePlayButton

SwiftButton {
visible: consolePaused
width: Constants.logPanel.pauseButtonWidth
height: Constants.logPanel.pauseButtonWidth
radius: Constants.logPanel.pauseButtonWidth / 3
padding: Constants.logPanel.pauseButtonPadding
icon.width: Constants.logPanel.pauseButtonWidth / 3
icon.height: Constants.logPanel.pauseButtonWidth / 3
Expand Down
6 changes: 3 additions & 3 deletions resources/LoggingBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Rectangle {
let hours = Math.floor(duration / 3600).toFixed(0).padStart(2, 0);
let minutes = Math.floor(duration / 60).toFixed(0).padStart(2, 0);
let seconds = (duration % 60).toFixed(0).padStart(2, 0);
return hours + ":" + minutes + ":" + seconds + " s";
return hours + ":" + minutes + ":" + seconds;
}

color: Constants.swiftControlBackground
Expand Down Expand Up @@ -275,8 +275,8 @@ Rectangle {
mockRecordingSize += 15.15;
recordingSize.text = bytesToString(mockRecordingSize);
} else {
if (loggingBarData.recording_size.length > 0)
recordingSize.text = loggingBarData.recording_size;
if (loggingBarData.recording_size > 0)
recordingSize.text = bytesToString(loggingBarData.recording_size);
else
recordingSize.text = "0.00 MiB";
}
Expand Down
1 change: 1 addition & 0 deletions resources/console_resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<file>images/fontawesome/file-import.svg</file>
<file>images/fontawesome/exclamation-triangle.svg</file>
<file>images/fontawesome/folder-regular.svg</file>
<file>images/iconic/x.svg</file>
<file>images/icon.png</file>
<file>images/icon.ico</file>
<file>TableComponents/SortableColumnHeading.qml</file>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/base/console_backend.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ struct LoggingBarStatus {
}
struct LoggingBarRecordingStatus {
recordingDurationSec @0 : UInt64;
recordingSize @1 :Text;
recordingSize @1 :UInt64;
recordingFilename :union {
filename @2 :Text;
none @3 :Void = void;
Expand Down
10 changes: 5 additions & 5 deletions swiftnav_console/logging_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Keys.SBP_LOGGING_FORMAT: SbpLogging.SBP_JSON,
Keys.SBP_LOGGING_LABELS: [SbpLogging.SBP_JSON, SbpLogging.SBP],
Keys.RECORDING_DURATION_SEC: int,
Keys.RECORDING_SIZE: str,
Keys.RECORDING_SIZE: int,
Keys.RECORDING_FILENAME: str,
}

Expand All @@ -27,7 +27,7 @@ class LoggingBarData(QObject): # pylint: disable=too-many-instance-attributes
_sbp_logging_labels: List[str] = []
_previous_folders: List[str] = []
_recording_duration_sec: int = 0
_recording_size: str
_recording_size: int = 0
_recording_filename: str = ""

def get_csv_logging(self) -> bool:
Expand Down Expand Up @@ -70,13 +70,13 @@ def set_previous_folders(self, previous_folders: List[str]) -> None:

previous_folders = Property(QTKeys.QVARIANTLIST, get_previous_folders, set_previous_folders) # type: ignore

def get_recording_size(self) -> str:
def get_recording_size(self) -> int:
return self._recording_size

def set_recording_size(self, recording_size: str) -> None:
def set_recording_size(self, recording_size: int) -> None:
self._recording_size = recording_size

recording_size = Property(str, get_recording_size, set_recording_size)
recording_size = Property(int, get_recording_size, set_recording_size)

def get_recording_duration_sec(self) -> int:
return self._recording_duration_sec
Expand Down