Skip to content
Open
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
3 changes: 3 additions & 0 deletions application/apps/indexer/gui/application/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ chrono.workspace = true
chrono-tz.workspace = true
dirs.workspace = true
serialport.workspace = true
dlt-core.workspace = true
lazy_static.workspace = true
Copy link
Member

Choose a reason for hiding this comment

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

We can remove the dependency for lazy_static as mentioned above

rustc-hash = "2.1"

#TODO: Replace env logger with log4rs
env_logger.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions application/apps/indexer/gui/application/src/host/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub enum HostCommand {
stream: StreamNames,
parser: ParserNames,
},
DltStatistics(Box<DltStatisticsParam>),
StartSession(Box<StartSessionParam>),
CloseSessionSetup(Uuid),
CloseMultiSetup(Uuid),
Expand All @@ -43,6 +44,12 @@ pub enum HostCommand {
},
}

#[derive(Debug, Clone)]
pub struct DltStatisticsParam {
pub session_setup_id: Uuid,
pub source_paths: Vec<PathBuf>,
}

#[derive(Debug, Clone)]
pub struct StartSessionParam {
pub parser: ParserConfig,
Expand Down
11 changes: 9 additions & 2 deletions application/apps/indexer/gui/application/src/host/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use uuid::Uuid;

use crate::{
host::ui::{multi_setup::state::MultiFileState, session_setup::state::SessionSetupState},
host::ui::{
multi_setup::state::MultiFileState,
session_setup::state::{SessionSetupState, parsers::dlt::statistics::DltStatistics},
},
session::InitSessionParams,
};

Expand All @@ -14,7 +17,11 @@ pub enum HostMessage {
SessionSetupClosed { id: Uuid },
/// Close multiple files setup with the provided id.
MultiSetupClose { id: Uuid },

/// The collected DLT statistics on a file for a SessionSetup
DltStatistics {
setup_session_id: Uuid,
statistics: Option<DltStatistics>,
Copy link
Member

Choose a reason for hiding this comment

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

I think we would need to wrap DltStatistics in a Box here to reduce the size of the enum

},
/// A new session has been successfully created.
SessionCreated {
session_params: InitSessionParams,
Expand Down
100 changes: 94 additions & 6 deletions application/apps/indexer/gui/application/src/host/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ use itertools::Itertools;
use tokio::runtime::Handle;
use uuid::Uuid;

use parsers::dlt::DltFilterConfig;
use stypes::{
DltParserSettings, FileFormat, ObserveOptions, ObserveOrigin, ParserType, SomeIpParserSettings,
Transport,
};

use crate::{
host::{
command::{HostCommand, StartSessionParam},
command::{DltStatisticsParam, HostCommand, StartSessionParam},
common::{parsers::ParserNames, sources::StreamNames},
communication::ServiceHandle,
error::HostError,
Expand All @@ -27,7 +28,9 @@ use crate::{
multi_setup::state::MultiFileState,
session_setup::state::{
SessionSetupState,
parsers::{DltParserConfig, ParserConfig, someip::SomeIpParserConfig},
parsers::{
DltParserConfig, ParserConfig, dlt::statistics, someip::SomeIpParserConfig,
},
sources::{
ByteSourceConfig, ProcessConfig, SerialConfig, SourceFileInfo, StreamConfig,
TcpConfig, UdpConfig,
Expand Down Expand Up @@ -110,6 +113,16 @@ impl HostService {
self.connection_session_setup(stream, parser).await
}

HostCommand::DltStatistics(statistics_param) => {
let DltStatisticsParam {
session_setup_id,
source_paths,
} = *statistics_param;

self.collect_statistics(session_setup_id, source_paths)
.await?;
}

HostCommand::StartSession(start_params) => {
let StartSessionParam {
parser,
Expand Down Expand Up @@ -154,7 +167,7 @@ impl HostService {
FileFormat::Text => ParserConfig::Text,
FileFormat::Binary => {
if Self::is_dlt_file(&file_path) {
ParserConfig::Dlt(DltParserConfig::new(true))
ParserConfig::Dlt(DltParserConfig::new(true, Some(vec![file_path.clone()])))
} else {
return Err(HostError::InitSessionError(InitSessionError::Other(
format!(
Expand Down Expand Up @@ -329,7 +342,7 @@ impl HostService {
}
_ => {}
}
ParserConfig::Dlt(DltParserConfig::new(true))
ParserConfig::Dlt(DltParserConfig::new(true, Some(files.clone())))
}
};

Expand Down Expand Up @@ -401,7 +414,7 @@ impl HostService {
};

let parser = match parser {
ParserNames::Dlt => ParserConfig::Dlt(DltParserConfig::new(false)),
ParserNames::Dlt => ParserConfig::Dlt(DltParserConfig::new(false, None)),
ParserNames::SomeIP => ParserConfig::SomeIP(SomeIpParserConfig::default()),
ParserNames::Text => ParserConfig::Text,
ParserNames::Plugins => todo!(),
Expand All @@ -415,6 +428,22 @@ impl HostService {
.await;
}

async fn collect_statistics(
&self,
setup_session_id: Uuid,
source_paths: Vec<PathBuf>,
) -> Result<(), HostError> {
self.communication
.senders
.send_message(HostMessage::DltStatistics {
setup_session_id,
statistics: statistics::collect(source_paths.clone()),
})
.await;

Ok(())
}

async fn start_session(
&self,
source: ByteSourceConfig,
Expand Down Expand Up @@ -450,6 +479,65 @@ impl HostService {

let parser = match parser {
ParserConfig::Dlt(config) => {
let (app_ids, app_id_count) =
if !config.dlt_tables.app_table.selected_ids.is_empty() {
(
Some(
config
.dlt_tables
.app_table
.selected_ids
.iter()
.cloned()
.collect::<Vec<String>>(),
),
config.dlt_tables.app_table.selected_ids.len() as i64,
)
} else {
(None, 0)
};

let (context_ids, context_id_count) =
if !config.dlt_tables.ctx_table.selected_ids.is_empty() {
(
Some(
config
.dlt_tables
.ctx_table
.selected_ids
.iter()
.cloned()
.collect::<Vec<String>>(),
),
config.dlt_tables.ctx_table.selected_ids.len() as i64,
)
} else {
(None, 0)
};

let ecu_ids = if !config.dlt_tables.ecu_table.selected_ids.is_empty() {
Some(
config
.dlt_tables
.ecu_table
.selected_ids
.iter()
.cloned()
.collect::<Vec<String>>(),
)
} else {
None
};

let filter_config = DltFilterConfig {
min_log_level: Some(config.log_level as u8),
app_ids,
ecu_ids,
context_ids,
app_id_count,
context_id_count,
};

let fibex_file_paths = config.fibex_files.is_empty().not().then(|| {
config
.fibex_files
Expand All @@ -459,7 +547,7 @@ impl HostService {
});

let dlt_config = DltParserSettings {
filter_config: None,
filter_config: Some(filter_config),
fibex_file_paths,
with_storage_header: config.with_storage_header,
tz: config.timezone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,4 @@ mod tests {
assert_eq!(paths[0], PathBuf::from("/tmp/test"));
assert!(handle.dialog_output.is_none());
}
}
}
11 changes: 11 additions & 0 deletions application/apps/indexer/gui/application/src/host/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ impl Host {
HostMessage::SessionSetupOpened(setup_state) => self
.state
.add_session_setup(setup_state, self.senders.cmd_tx.clone()),
HostMessage::DltStatistics {
setup_session_id,
statistics,
} => {
if let Some(setup) = self.state.session_setups.get_mut(&setup_session_id) {
if let ParserConfig::Dlt(config) = &mut setup.state.parser {
config.dlt_statistics = statistics;
config.update();
}
}
}
HostMessage::SessionCreated {
session_params,
session_setup_id,
Expand Down
Loading