LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
parser::AscParser Class Reference

Parses Vector CANalyzer ASC log files (.asc). More...

#include <AscParser.hpp>

Inheritance diagram for parser::AscParser:
Inheritance graph
Collaboration diagram for parser::AscParser:
Collaboration graph

Public Member Functions

 AscParser (std::filesystem::path dbcPath={})
 
 ~AscParser () override=default
 
void ParseData (const std::filesystem::path &filepath) override
 Parses data from a file path.
 
void ParseData (std::istream &input) override
 Parses data from an input stream.
 
uint32_t GetCurrentProgress () const override
 Gets the current parsing progress.
 
uint32_t GetTotalProgress () const override
 Gets the total expected progress value.
 
virtual std::vector< std::pair< std::string, std::string > > GetFileMetadata () const
 Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).
 
void RegisterObserver (IDataParserObserver *observer)
 Registers an observer to receive parsing notifications.
 
void UnregisterObserver (IDataParserObserver *observer)
 
void NotifyNewEvent (db::LogEvent &&event)
 
void NotifyProgressUpdated ()
 
void NotifyNewEventBatch (std::vector< std::pair< int, db::LogEvent::EventItems > > &&eventBatch)
 

Private Member Functions

util::Result< std::monostate, error::Error > LoadDbc ()
 Loads the DBC database from m_dbcPath.
 
void ParseStream (std::istream &input)
 

Private Attributes

std::filesystem::path m_dbcPath
 
dbc::DbcDatabase m_dbc
 
bool m_dbcLoaded {false}
 
uint32_t m_currentProgress {0}
 
uint32_t m_totalProgress {0}
 
int m_eventId {0}
 
std::vector< IDataParserObserver * > observers
 

Detailed Description

Parses Vector CANalyzer ASC log files (.asc).

Supports standard CAN frames (11-bit) and extended CAN frames (29-bit, 'X' suffix). An optional DBC database path may be supplied at construction time; when present, signal values decoded from the DBC are appended as "SIG:<name>" fields.

Parsed LogEvent fields: timestamp — float seconds from start of trace type — "Rx", "Tx", "TxRq", or "ErrorFrame" CAN_Channel — integer channel number CAN_ID — upper-case hex frame ID (e.g. "0B3") CAN_IDE — "Standard" or "Extended" CAN_DLC — data length code (0-8) CAN_Data — space-separated hex bytes (e.g. "F0 00 00 00 00 00 00 00") CAN_MsgName — message name from DBC (omitted when no DBC or unknown ID) SIG:<name> — decoded signal value with unit (omitted when no DBC) info — human-readable one-line summary

Constructor & Destructor Documentation

◆ AscParser()

parser::AscParser::AscParser ( std::filesystem::path  dbcPath = {})
explicit
Parameters
dbcPathOptional path to a DBC file for signal decoding. Leave empty (default) to skip DBC decoding.

◆ ~AscParser()

parser::AscParser::~AscParser ( )
overridedefault

Member Function Documentation

◆ GetCurrentProgress()

uint32_t parser::AscParser::GetCurrentProgress ( ) const
inlineoverridevirtual

Gets the current parsing progress.

Returns
uint32_t Current progress value (meaning depends on implementation)
Note
Progress values should be used with GetTotalProgress() for percentage calculations

Implements parser::IDataParser.

◆ GetFileMetadata()

virtual std::vector< std::pair< std::string, std::string > > parser::IDataParser::GetFileMetadata ( ) const
inlinevirtualinherited

Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).

Returns
Empty for formats without a header (the default).

Reimplemented in parser::SapiLogParser.

◆ GetTotalProgress()

uint32_t parser::AscParser::GetTotalProgress ( ) const
inlineoverridevirtual

Gets the total expected progress value.

Returns
uint32_t Maximum progress value when parsing is complete
Note
Return 0 if total progress cannot be determined in advance

Implements parser::IDataParser.

◆ LoadDbc()

util::Result< std::monostate, error::Error > parser::AscParser::LoadDbc ( )
private

Loads the DBC database from m_dbcPath.

Returns Ok(monostate) if no DBC path is configured or the DBC loaded successfully. Returns Err with FileNotFound/ParseError if the path is set but the file cannot be opened or parsed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NotifyNewEvent()

void parser::IDataParser::NotifyNewEvent ( db::LogEvent &&  event)
inlineinherited

◆ NotifyNewEventBatch()

void parser::IDataParser::NotifyNewEventBatch ( std::vector< std::pair< int, db::LogEvent::EventItems > > &&  eventBatch)
inlineinherited
Here is the caller graph for this function:

◆ NotifyProgressUpdated()

void parser::IDataParser::NotifyProgressUpdated ( )
inlineinherited
Here is the caller graph for this function:

◆ ParseData() [1/2]

void parser::AscParser::ParseData ( const std::filesystem::path &  filepath)
overridevirtual

Parses data from a file path.

Parameters
filepathThe path to the file to parse
Exceptions
std::runtime_errorif the file cannot be opened or parsed
Note
This method should be implemented by derived classes for file-based parsing

Implements parser::IDataParser.

Here is the call graph for this function:

◆ ParseData() [2/2]

void parser::AscParser::ParseData ( std::istream &  input)
overridevirtual

Parses data from an input stream.

Parameters
inputThe input stream to read data from
Exceptions
std::runtime_errorif the stream cannot be read or parsed
Note
This method enables parsing from various sources (files, network, memory)

Implements parser::IDataParser.

Here is the call graph for this function:

◆ ParseStream()

void parser::AscParser::ParseStream ( std::istream &  input)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterObserver()

void parser::IDataParser::RegisterObserver ( IDataParserObserver *  observer)
inlineinherited

Registers an observer to receive parsing notifications.

Parameters
observerPointer to the observer object
Note
The observer must remain valid until parsing completes or it's unregistered
Duplicate observers are automatically prevented

◆ UnregisterObserver()

void parser::IDataParser::UnregisterObserver ( IDataParserObserver *  observer)
inlineinherited

Member Data Documentation

◆ m_currentProgress

uint32_t parser::AscParser::m_currentProgress {0}
private

◆ m_dbc

dbc::DbcDatabase parser::AscParser::m_dbc
private

◆ m_dbcLoaded

bool parser::AscParser::m_dbcLoaded {false}
private

◆ m_dbcPath

std::filesystem::path parser::AscParser::m_dbcPath
private

◆ m_eventId

int parser::AscParser::m_eventId {0}
private

◆ m_totalProgress

uint32_t parser::AscParser::m_totalProgress {0}
private

◆ observers

std::vector<IDataParserObserver*> parser::IDataParser::observers
privateinherited

The documentation for this class was generated from the following files: