DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
LivetimeCounter counts the total time in milliseconds spent in each of the available states. More...
#include <LivetimeCounter.hpp>
Public Types | |
enum class | State { kLive , kDead , kPaused } |
using | state_time_t = uint64_t |
A type to store a time duration in milliseconds. | |
Public Member Functions | |
LivetimeCounter (State state) | |
Construct a LivetimeCounter in the given state. | |
~LivetimeCounter () | |
void | set_state (State state) |
Set the current state to state. | |
std::map< State, state_time_t > | get_time_map () |
Get a map of accumulated time in milliseconds in each state. | |
state_time_t | get_time (State state) |
Get the accumulated time in milliseconds spent in a particular state. | |
std::string | get_report_string () |
Get a nicely-formatted string of the time spent in each state. | |
std::string | get_state_name (State state) const |
Private Member Functions | |
state_time_t | now () const |
void | update_map () |
Private Attributes | |
std::mutex | m_mutex |
State | m_state |
std::map< State, state_time_t > | m_state_times |
state_time_t | m_last_state_change_time |
LivetimeCounter counts the total time in milliseconds spent in each of the available states.
The current state is set at construction, and can be changed with set_state(). The accumulated time in a particular state can be retrieved with get_time(State), and the times spent in all the states with get_time_map()
Definition at line 18 of file LivetimeCounter.hpp.
using dunedaq::trigger::LivetimeCounter::state_time_t = uint64_t |
A type to store a time duration in milliseconds.
Definition at line 30 of file LivetimeCounter.hpp.
|
strong |
dunedaq::trigger::LivetimeCounter::LivetimeCounter | ( | LivetimeCounter::State | state | ) |
Construct a LivetimeCounter in the given state.
Counting the time in the initial state begins immediately
Definition at line 9 of file LivetimeCounter.cpp.
dunedaq::trigger::LivetimeCounter::~LivetimeCounter | ( | ) |
Definition at line 19 of file LivetimeCounter.cpp.
std::string dunedaq::trigger::LivetimeCounter::get_report_string | ( | ) |
Get a nicely-formatted string of the time spent in each state.
Definition at line 69 of file LivetimeCounter.cpp.
std::string dunedaq::trigger::LivetimeCounter::get_state_name | ( | LivetimeCounter::State | state | ) | const |
Definition at line 82 of file LivetimeCounter.cpp.
LivetimeCounter::state_time_t dunedaq::trigger::LivetimeCounter::get_time | ( | LivetimeCounter::State | state | ) |
Get the accumulated time in milliseconds spent in a particular state.
Definition at line 54 of file LivetimeCounter.cpp.
std::map< LivetimeCounter::State, LivetimeCounter::state_time_t > dunedaq::trigger::LivetimeCounter::get_time_map | ( | ) |
Get a map of accumulated time in milliseconds in each state.
Definition at line 46 of file LivetimeCounter.cpp.
|
private |
Definition at line 62 of file LivetimeCounter.cpp.
void dunedaq::trigger::LivetimeCounter::set_state | ( | LivetimeCounter::State | state | ) |
Set the current state to state.
Updates the accumulated time in the previous state and switches the state
Definition at line 37 of file LivetimeCounter.cpp.
|
private |
Definition at line 26 of file LivetimeCounter.cpp.
|
private |
Definition at line 75 of file LivetimeCounter.hpp.
|
private |
Definition at line 72 of file LivetimeCounter.hpp.
|
private |
Definition at line 73 of file LivetimeCounter.hpp.
|
private |
Definition at line 74 of file LivetimeCounter.hpp.