6 #ifndef SYSFSIOGROUP_HPP_INCLUDE
7 #define SYSFSIOGROUP_HPP_INCLUDE
30 std::shared_ptr<SaveControl> control_saver,
31 std::shared_ptr<IOUring> batch_reader,
32 std::shared_ptr<IOUring> batch_writer);
42 int push_signal(
const std::string &signal_name,
int domain_type,
int domain_idx)
override;
43 int push_control(
const std::string &control_name,
int domain_type,
int domain_idx)
override;
46 double sample(
int batch_idx)
override;
47 void adjust(
int batch_idx,
double setting)
override;
48 double read_signal(
const std::string &signal_name,
int domain_type,
int domain_idx)
override;
49 void write_control(
const std::string &control_name,
int domain_type,
int domain_idx,
double setting)
override;
51 void save_control(
const std::string &save_path)
override;
54 std::function<double(
const std::vector<double> &)>
agg_function(
const std::string &signal_name)
const override;
55 std::function<std::string(
double)>
format_function(
const std::string &signal_name)
const override;
59 std::string
name(
void)
const override;
61 std::string canonical_name(
const std::string &
name)
const;
62 std::string check_request(
const std::string &method_name,
63 const std::string &signal_name,
64 const std::string &control_name,
66 int domain_idx)
const;
67 std::shared_ptr<SysfsDriver> m_driver;
71 bool m_do_batch_write;
74 bool m_is_batch_write;
75 std::vector<double> m_control_value;
76 const std::map<std::string, SysfsDriver::properties_s> m_properties;
77 std::map<std::string, std::reference_wrapper<const SysfsDriver::properties_s> > m_signals;
78 std::map<std::string, std::reference_wrapper<const SysfsDriver::properties_s> > m_controls;
81 struct m_pushed_info_s {
88 std::shared_ptr<int> last_io_return;
89 std::array<char, SysfsDriver::M_IO_BUFFER_SIZE> buf;
90 std::function<double(
const std::string&)> parse;
91 std::function<std::string(
double)> gen;
95 std::vector<m_pushed_info_s> m_pushed_info_signal;
96 std::vector<m_pushed_info_s> m_pushed_info_control;
97 std::shared_ptr<SaveControl> m_control_saver;
98 std::shared_ptr<IOUring> m_batch_reader;
99 std::shared_ptr<IOUring> m_batch_writer;
100 std::set<std::string> m_unsaved_controls;
Definition: IOGroup.hpp:21
Definition: SysfsIOGroup.hpp:24
double sample(int batch_idx) override
Retrieve signal value from data read by last call to read_batch() for a particular signal previously ...
Definition: SysfsIOGroup.cpp:394
void write_batch(void) override
Write all of the pushed controls so that values previously given to adjust() are written to the platf...
Definition: SysfsIOGroup.cpp:360
bool is_valid_control(const std::string &control_name) const override
Test if control_name refers to a control supported by the group.
Definition: SysfsIOGroup.cpp:200
void adjust(int batch_idx, double setting) override
Adjust a setting for a particular control that was previously pushed with push_control()....
Definition: SysfsIOGroup.cpp:408
int push_control(const std::string &control_name, int domain_type, int domain_idx) override
Add a control to the list of controls that is written by write_batch() and configured with adjust().
Definition: SysfsIOGroup.cpp:288
bool is_valid_signal_domain(const std::string &signal_name, int domain_idx) const
Definition: SysfsIOGroup.cpp:184
void restore_control(void) override
Restore all controls to values recorded in previous call to the save() method.
Definition: SysfsIOGroup.cpp:458
std::set< std::string > signal_names(void) const override
Returns the names of all signals provided by the IOGroup.
Definition: SysfsIOGroup.cpp:142
std::function< std::string(double)> format_function(const std::string &signal_name) const override
Returns a function that can be used to convert a signal of the given name into a printable string....
Definition: SysfsIOGroup.cpp:489
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
Return a function that should be used when aggregating the given signal.
Definition: SysfsIOGroup.cpp:477
std::string control_description(const std::string &control_name) const override
Returns a description of the control. This string can be used by tools to generate help text for user...
Definition: SysfsIOGroup.cpp:520
int control_domain_type(const std::string &control_name) const override
Query the domain for a named control.
Definition: SysfsIOGroup.cpp:233
void read_batch(void) override
Read all pushed signals from the platform so that the next call to sample() will reflect the updated ...
Definition: SysfsIOGroup.cpp:331
bool is_valid_control_domain(const std::string &control_name, int domain_idx) const
Definition: SysfsIOGroup.cpp:205
std::string name(void) const override
Get the IOGroup name.
Definition: SysfsIOGroup.cpp:541
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Add a signal to the list of signals that is read by read_batch() and sampled by sample().
Definition: SysfsIOGroup.cpp:244
bool is_valid_signal(const std::string &signal_name) const override
Test if signal_name refers to a signal supported by the group.
Definition: SysfsIOGroup.cpp:179
void save_control(void) override
Save the state of all controls so that any subsequent changes made through the IOGroup can be undone ...
Definition: SysfsIOGroup.cpp:437
int signal_domain_type(const std::string &signal_name) const override
Query the domain for a named signal.
Definition: SysfsIOGroup.cpp:222
int signal_behavior(const std::string &signal_name) const override
Returns a hint about how a signal will change as a function of time.
Definition: SysfsIOGroup.cpp:530
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Read from platform and interpret into SI units a signal given its name and domain....
Definition: SysfsIOGroup.cpp:421
virtual ~SysfsIOGroup()
Definition: SysfsIOGroup.cpp:137
std::string signal_description(const std::string &signal_name) const override
Returns a description of the signal. This string can be used by tools to generate help text for users...
Definition: SysfsIOGroup.cpp:501
void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override
Interpret the setting and write setting to the platform. Does not modify the values stored by calling...
Definition: SysfsIOGroup.cpp:430
std::set< std::string > control_names(void) const override
Returns the names of all controls provided by the IOGroup.
Definition: SysfsIOGroup.cpp:161
A wrapper to close a file descriptor when the descriptor goes out of scope.
Definition: UniqueFd.hpp:13