AstraLog-HPC
Loading...
Searching...
No Matches
OutputManager Class Reference

Manages the writing of results to files, separating valid data from alarms. More...

#include <OutputManager.hpp>

Collaboration diagram for OutputManager:
Collaboration graph

Public Member Functions

 OutputManager (const std::string &valid_data_path, const std::string &alarms_path, std::string stateful_path, std::string step_diff_path)
 Constructs a new OutputManager and opens the target output files.
 
 ~OutputManager ()
 Destructor of the class.
 
void writeNominal (const Batch &data_for_timestamp)
 Writes a single aggregated line for a timestamp without anomalies.
 
void writeAlarms (const std::vector< std::string > &alarms)
 Writes the alarm lines for non-nominal timestamps.
 
void writeStatefulString (const std::string &state)
 Writes the state of stateful rules to a file for use in the next batch.
 
void writeStepDiffString (const std::string &state)
 Writes the state of step difference rules to a file for use in the next batch.
 
void writeStateful (const EvaluationPipeline &pipeline)
 Writes stateful-rule state by introspecting the pipeline (single-process path / unit tests).
 
void writeStepDifference (const EvaluationPipeline &pipeline)
 Writes step-difference-rule state by introspecting the pipeline (single-process path / unit tests).
 
void readStateful (EvaluationPipeline &pipeline)
 Reads the state of stateful rules from a file to update the evaluation pipeline for the current batch.
 
void readStepDifference (EvaluationPipeline &pipeline)
 Reads the state of step difference rules from a file to update the evaluation pipeline for the current batch.
 

Private Attributes

std::ofstream valid_file
 output file stream for valid (nominal) data
 
std::ofstream alarms_file
 output file stream for alarms
 
std::string stateful_path
 path to the stateful rules state file
 
std::string step_diff_path
 path to the step difference rules state file
 

Detailed Description

Manages the writing of results to files, separating valid data from alarms.

Note
This class handles the file streams, keeping them open during execution and safely closing them upon destruction.

Constructor & Destructor Documentation

◆ OutputManager()

OutputManager::OutputManager ( const std::string &  valid_data_path,
const std::string &  alarms_path,
std::string  stateful_path,
std::string  step_diff_path 
)

Constructs a new OutputManager and opens the target output files.

Parameters
valid_data_pathThe file path where valid (nominal) data should be written.
alarms_pathThe file path where alarms should be written.
stateful_pathThe file path where the state of stateful rules should be written for the next batch.
step_diff_pathThe file path where the state of step difference rules should be written for the next batch.

◆ ~OutputManager()

OutputManager::~OutputManager ( )

Destructor of the class.

Note
Ensures that the output files are closed properly to prevent data loss.

Member Function Documentation

◆ readStateful()

void OutputManager::readStateful ( EvaluationPipeline &  pipeline)

Reads the state of stateful rules from a file to update the evaluation pipeline for the current batch.

Parameters
pipelineThe evaluation pipeline to be updated with the read stateful rules' states.

◆ readStepDifference()

void OutputManager::readStepDifference ( EvaluationPipeline &  pipeline)

Reads the state of step difference rules from a file to update the evaluation pipeline for the current batch.

Parameters
pipelineThe evaluation pipeline to be updated with the read step difference rules' states.

◆ writeAlarms()

void OutputManager::writeAlarms ( const std::vector< std::string > &  alarms)

Writes the alarm lines for non-nominal timestamps.

Note
The provided strings are expected to be already pre-formatted by the Evaluate component.
Parameters
alarmsA vector of strings, each representing a single alarm message to be written.

◆ writeNominal()

void OutputManager::writeNominal ( const Batch &  data_for_timestamp)

Writes a single aggregated line for a timestamp without anomalies.

Parameters
data_for_timestampThe batch of valid data collected for the given timestamp.

◆ writeStateful()

void OutputManager::writeStateful ( const EvaluationPipeline &  pipeline)

Writes stateful-rule state by introspecting the pipeline (single-process path / unit tests).

Parameters
pipelineThe evaluation pipeline whose stateful rules' counters are persisted.

◆ writeStatefulString()

void OutputManager::writeStatefulString ( const std::string &  state)

Writes the state of stateful rules to a file for use in the next batch.

Parameters
stateThe string representation of the stateful rules' states to be written to the file.

◆ writeStepDifference()

void OutputManager::writeStepDifference ( const EvaluationPipeline &  pipeline)

Writes step-difference-rule state by introspecting the pipeline (single-process path / unit tests).

Parameters
pipelineThe evaluation pipeline whose step-difference rules' last values are persisted.

◆ writeStepDiffString()

void OutputManager::writeStepDiffString ( const std::string &  state)

Writes the state of step difference rules to a file for use in the next batch.

Parameters
stateThe string representation of the step difference rules' states to be written to the file.

Member Data Documentation

◆ alarms_file

std::ofstream OutputManager::alarms_file
private

output file stream for alarms

◆ stateful_path

std::string OutputManager::stateful_path
private

path to the stateful rules state file

◆ step_diff_path

std::string OutputManager::step_diff_path
private

path to the step difference rules state file

◆ valid_file

std::ofstream OutputManager::valid_file
private

output file stream for valid (nominal) data


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