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
12 changes: 5 additions & 7 deletions console_backend/src/tabs/main_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

use std::{
path::PathBuf,
thread::JoinHandle,
time::{Duration, Instant},
};
use std::path::PathBuf;

use chrono::Local;
use log::error;
Expand All @@ -36,7 +32,7 @@ use crate::constants::{
use crate::output::{CsvLogging, SbpLogger};
use crate::shared_state::{create_directory, SharedState};
use crate::utils::{
refresh_log_recording_name, refresh_log_recording_size, refresh_loggingbar, OkOrLog,
refresh_log_recording_size, refresh_loggingbar, start_recording, stop_recording, OkOrLog,
};

pub struct MainTab {
Expand Down Expand Up @@ -151,7 +147,7 @@ impl MainTab {
self.shared_state.set_settings_refresh(true);
}
self.shared_state.set_sbp_logging_format(logging);
refresh_log_recording_name(&self.client_sender, filepath.display().to_string());
start_recording(&self.client_sender, filepath.display().to_string());
}

pub fn serialize_frame(&mut self, frame: &Frame) {
Expand Down Expand Up @@ -209,6 +205,8 @@ impl MainTab {
let bytes_size = frame.as_bytes().len() as u16;
refresh_log_recording_size(&self.client_sender, bytes_size);
}
} else {
stop_recording(&self.client_sender);
}
}

Expand Down
13 changes: 10 additions & 3 deletions console_backend/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,18 @@ pub fn refresh_log_recording_size(client_sender: &BoxedClientSender, size: u16)
client_sender.send_data(serialize_capnproto_builder(builder));
}

pub fn refresh_log_recording_name(client_sender: &BoxedClientSender, name: String) {
pub fn start_recording(client_sender: &BoxedClientSender, file_name: String) {
let mut builder = Builder::new_default();
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();
let mut log_name = msg.init_logging_bar_recording_name();
log_name.set_name(name.as_str());
let mut packet = msg.init_logging_bar_start_recording();
packet.set_name(file_name.as_str());
client_sender.send_data(serialize_capnproto_builder(builder));
}

pub fn stop_recording(client_sender: &BoxedClientSender) {
let mut builder = Builder::new_default();
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();
msg.init_logging_bar_stop_recording();
client_sender.send_data(serialize_capnproto_builder(builder));
}

Expand Down
13 changes: 6 additions & 7 deletions resources/LoggingBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,13 @@ Rectangle {
if (loggingBarData.recording_filename)
recordingFilenameText.editText = loggingBarData.recording_filename;

if (sbpLoggingButton.checked) {
if (mockTime) {
mockRecordingTime += interval;
recordingTime.text = loggingDurationFormat(mockRecordingTime / 1000);
} else {
recordingTime.text = loggingDurationFormat(loggingBarData.recording_duration_sec);
}
if (mockTime) {
mockRecordingTime += interval;
recordingTime.text = loggingDurationFormat(mockRecordingTime / 1000);
} else {
recordingTime.text = loggingDurationFormat(loggingBarData.recording_duration_sec);
}

if (mockSize) {
mockRecordingSize += 15.15;
recordingSize.text = bytesToString(mockRecordingSize);
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/base/console_backend.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,16 @@ struct TabChangeEvent {
currentTab @0 :Text;
}

struct LoggingBarRecordingName {
struct LoggingBarStartRecording {
name @0 :Text;
}

struct LoggingBarRecordingSize {
size @0 :UInt16;
}

struct LoggingBarStopRecording {}

struct Message {
union {
solutionVelocityStatus @0 :SolutionVelocityStatus;
Expand Down Expand Up @@ -512,7 +514,8 @@ struct Message {
settingsNotification @52 : SettingsNotification;
connectionDialogStatus @53 :ConnectionDialogStatus;
onTabChangeEvent @54 :TabChangeEvent;
loggingBarRecordingName @55 : LoggingBarRecordingName;
loggingBarStartRecording @55 : LoggingBarStartRecording;
loggingBarRecordingSize @56 : LoggingBarRecordingSize;
loggingBarStopRecording @57 : LoggingBarStopRecording;
}
}
9 changes: 7 additions & 2 deletions swiftnav_console/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,16 @@ def _process_message_buffer(self, buffer):
data[Keys.SBP_LOGGING] = m.loggingBarStatus.sbpLogging
data[Keys.SBP_LOGGING_FORMAT] = m.loggingBarStatus.sbpLoggingFormat
LoggingBarData.post_data_update(data)
elif m.which == Message.Union.LoggingBarRecordingName: # used as basically recording reset
elif m.which == Message.Union.LoggingBarStartRecording:
data = logging_bar_recording_update()
data[Keys.RECORDING_SIZE] = None # reset since name changed => new file
data[Keys.RECORDING_START_TIME] = time.time()
data[Keys.RECORDING_FILENAME] = m.loggingBarRecordingName.name
data[Keys.RECORDING_FILENAME] = m.loggingBarStartRecording.name
LoggingBarData.post_recording_data_update(data)
elif m.which == Message.Union.LoggingBarStopRecording:
data = logging_bar_recording_update()
data[Keys.RECORDING_SIZE] = None # reset since name changed => new file
data[Keys.RECORDING_START_TIME] = None
LoggingBarData.post_recording_data_update(data)
elif m.which == Message.Union.LoggingBarRecordingSize:
data = logging_bar_recording_update()
Expand Down