Class PowerInfo#

Class Documentation#

class PowerInfo#

holds the most recently published powerd telemetry

Keeps only the plugs the sequencer makes decisions about. Written by the subscriber thread, read by the sequence threads; the caller serializes all access under Sequence::powerd_mtx.

Public Functions

inline PowerInfo()#
inline void init()#

initialize all class member variables to “non-values”

inline void store(const nlohmann::json &jmessage)#

store a received powerd telemetry message

powerd publishes a plug as true when it is on. That reduces to a tri-state here so a plug missing from the message is distinguishable from one that is off.

Parameters:

jmessage[in] subscribed-received JSON message

inline bool is_valid() const#

is there cached telemetry to act on?

Not an age check, same reason as CalibInfo::is_valid()

Returns:

true|false

inline void invalidate()#

discard the cache, e.g. when powerd is known to have restarted

inline int plug_state(const std::string &name) const#

cached state of the named plug

Parameters:

name[in] plug name

Returns:

1=on 0=off -1=undefined or unknown plug

Public Members

std::map<std::string, int> plug#

1=on 0=off -1=undefined, indexed by plug name