Class StatusItem
Defined in File status_item.hpp
Class Documentation
-
class StatusItem
Helper class to hold, store DiagnosticStatus messages.
The StatusItem class is used by the Aggregator to store incoming DiagnosticStatus messages. Helper messages make it easy to calculate update intervals, and extract KeyValue pairs.
Public Functions
-
explicit DIAGNOSTIC_AGGREGATOR_PUBLIC StatusItem(const diagnostic_msgs::msg::DiagnosticStatus *status)
Constructed from const DiagnosticStatus*.
-
DIAGNOSTIC_AGGREGATOR_PUBLIC StatusItem(const std::string item_name, const std::string message = "Missing", const DiagnosticLevel level = Level_Stale)
Constructed from string of item name.
-
DIAGNOSTIC_AGGREGATOR_PUBLIC ~StatusItem()
- DIAGNOSTIC_AGGREGATOR_PUBLIC bool update (const diagnostic_msgs::msg::DiagnosticStatus *status)
Must have same name as original status or it won’t update.
- Returns:
True if update successful, false if error
- DIAGNOSTIC_AGGREGATOR_PUBLIC std::shared_ptr< diagnostic_msgs::msg::DiagnosticStatus > toStatusMsg (const std::string &path, const bool stale=false) const
Prepends “path/” to name, makes item stale if “stale” true.
Helper function to convert item back to diagnostic_msgs::msg::DiagnosticStatus pointer. Prepends path. Example: Item with name “Hokuyo” toStatusMsg(“Base Path/My Path”, false) gives “Base Path/My Path/Hokuyo”.
- Parameters:
path – : Prepended to name
stale – : If true, status level is 3
-
inline DiagnosticLevel getLevel() const
-
inline std::string getMessage() const
Get message field of DiagnosticStatus.
-
inline std::string getName() const
Returns name of DiagnosticStatus message.
-
inline std::string getHwId() const
Returns hardware ID field of DiagnosticStatus message.
-
inline const rclcpp::Time getLastUpdateTime() const
Returns the time since last update for this item.
-
inline bool hasKey(const std::string &key) const
Returns true if item has key in values KeyValues.
- Returns:
True if has key
-
inline std::string getValue(const std::string &key) const
Returns value for given key, “” if doens’t exist.
- Returns:
Value if key present, “” if not
-
explicit DIAGNOSTIC_AGGREGATOR_PUBLIC StatusItem(const diagnostic_msgs::msg::DiagnosticStatus *status)