Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(system_monitor/hdd_monitor): rename structs and functions #2144

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/system_monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ rclcpp_components_register_node(cpu_monitor_lib
)

rclcpp_components_register_node(hdd_monitor_lib
PLUGIN "HDDMonitor"
PLUGIN "HddMonitor"
EXECUTABLE hdd_monitor
)

Expand Down
10 changes: 5 additions & 5 deletions system/system_monitor/include/hdd_reader/hdd_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
/**
* @brief Enumeration of Request ID to hdd_reader
*/
enum HDDReaderRequestID {
GetHDDInfo,
enum HddReaderRequestId {
GetHddInfo,
UnmountDevice,
};

/**
* @brief HDD device
*/
struct HDDDevice
struct HddDevice
{
std::string name_; //!< @brief Device name
uint8_t temp_attribute_id_; //!< @brief S.M.A.R.T attribute ID of temperature
Expand Down Expand Up @@ -69,7 +69,7 @@ struct HDDDevice
/**
* @brief HDD information
*/
struct HDDInfo
struct HddInfo
{
int error_code_; //!< @brief error code, 0 on success, otherwise error
std::string model_; //!< @brief Model number
Expand Down Expand Up @@ -133,6 +133,6 @@ struct UnmountDeviceInfo
/**
* @brief HDD information list
*/
typedef std::map<std::string, HDDInfo> HDDInfoList;
typedef std::map<std::string, HddInfo> HddInfoList;

#endif // HDD_READER__HDD_READER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @brief error and warning temperature levels
*/
struct HDDParam
struct HddParam
{
std::string part_device_; //!< @brief partition device
std::string disk_device_; //!< @brief disk device
Expand All @@ -53,7 +53,7 @@ struct HDDParam
total_data_written_attribute_id_; //!< @brief S.M.A.R.T attribute ID of total data written
uint8_t recovered_error_attribute_id_; //!< @brief S.M.A.R.T attribute ID of recovered error

HDDParam()
HddParam()
: temp_warn_(55.0),
temp_error_(70.0),
power_on_hours_warn_(3000000),
Expand Down Expand Up @@ -90,25 +90,25 @@ struct SysfsDevStat
/**
* @brief statistics of HDD
*/
struct HDDStat
struct HddStat
{
std::string device_; //!< @brief device
std::string error_str_; //!< @brief error string
float read_data_rate_MBs_; //!< @brief data rate of read (MB/s)
float write_data_rate_MBs_; //!< @brief data rate of write (MB/s)
float read_iops_; //!< @brief IOPS of read
float write_iops_; //!< @brief IOPS of write
SysfsDevStat last_sfdevstat_; //!< @brief last statistics of sysfs device

HDDStat() : read_data_rate_MBs_(0.0), write_data_rate_MBs_(0.0), read_iops_(0.0), write_iops_(0.0)
std::string device_; //!< @brief device
std::string error_str_; //!< @brief error string
float read_data_rate_MBs_; //!< @brief data rate of read (MB/s)
float write_data_rate_MBs_; //!< @brief data rate of write (MB/s)
float read_iops_; //!< @brief IOPS of read
float write_iops_; //!< @brief IOPS of write
SysfsDevStat last_sysfs_dev_stat_; //!< @brief last statistics of sysfs device

HddStat() : read_data_rate_MBs_(0.0), write_data_rate_MBs_(0.0), read_iops_(0.0), write_iops_(0.0)
{
}
};

/**
* @brief SMART information items to check
*/
enum class HDDSMARTInfoItem : uint32_t {
enum class HddSmartInfoItem : uint32_t {
TEMPERATURE = 0,
POWER_ON_HOURS = 1,
TOTAL_DATA_WRITTEN = 2,
Expand All @@ -119,22 +119,22 @@ enum class HDDSMARTInfoItem : uint32_t {
/**
* @brief HDD statistics items to check
*/
enum class HDDStatItem : uint32_t {
enum class HddStatItem : uint32_t {
READ_DATA_RATE = 0,
WRITE_DATA_RATE = 1,
READ_IOPS = 2,
WRITE_IOPS = 3,
SIZE
};

class HDDMonitor : public rclcpp::Node
class HddMonitor : public rclcpp::Node
{
public:
/**
* @brief constructor
* @param [in] options Options associated with this node.
*/
explicit HDDMonitor(const rclcpp::NodeOptions & options);
explicit HddMonitor(const rclcpp::NodeOptions & options);

protected:
using DiagStatus = diagnostic_msgs::msg::DiagnosticStatus;
Expand All @@ -145,7 +145,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkSMARTTemperature(
void checkSmartTemperature(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -154,7 +154,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkSMARTPowerOnHours(
void checkSmartPowerOnHours(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -163,7 +163,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkSMARTTotalDataWritten(
void checkSmartTotalDataWritten(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -172,7 +172,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkSMARTRecoveredError(
void checkSmartRecoveredError(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -182,9 +182,9 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkSMART(
void checkSmart(
diagnostic_updater::DiagnosticStatusWrapper & stat,
HDDSMARTInfoItem item); // NOLINT(runtime/references)
HddSmartInfoItem item); // NOLINT(runtime/references)

/**
* @brief check HDD usage
Expand Down Expand Up @@ -219,7 +219,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkReadIOPS(
void checkReadIops(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -228,7 +228,7 @@ class HDDMonitor : public rclcpp::Node
* @note NOLINT syntax is needed since diagnostic_updater asks for a non-const reference
* to pass diagnostic message updated in this function to diagnostic publish calls.
*/
void checkWriteIOPS(
void checkWriteIops(
diagnostic_updater::DiagnosticStatusWrapper & stat); // NOLINT(runtime/references)

/**
Expand All @@ -240,7 +240,7 @@ class HDDMonitor : public rclcpp::Node
*/
void checkStatistics(
diagnostic_updater::DiagnosticStatusWrapper & stat,
HDDStatItem item); // NOLINT(runtime/references)
HddStatItem item); // NOLINT(runtime/references)

/**
* @brief check HDD connection
Expand All @@ -261,7 +261,7 @@ class HDDMonitor : public rclcpp::Node
/**
* @brief get HDD parameters
*/
void getHDDParams();
void getHddParams();

/**
* @brief get device name from mount point
Expand All @@ -278,17 +278,17 @@ class HDDMonitor : public rclcpp::Node
/**
* @brief update HDD information list
*/
void updateHDDInfoList();
void updateHddInfoList();

/**
* @brief start HDD transfer measurement
*/
void startHDDTransferMeasurement();
void startHddTransferMeasurement();

/**
* @brief update HDD statistics
*/
void updateHDDStatistics();
void updateHddStatistics();

/**
* @brief get increment value of sysfs device stats per second
Expand All @@ -303,15 +303,15 @@ class HDDMonitor : public rclcpp::Node
/**
* @brief read stats for current whole device using /sys/block/ directory
* @param [in] device device name
* @param [out] sfdevstat statistics of sysfs device
* @param [out] sysfs_dev_stat statistics of sysfs device
* @return result of success or failure
*/
int readSysfsDeviceStat(const std::string & device, SysfsDevStat & sfdevstat);
int readSysfsDeviceStat(const std::string & device, SysfsDevStat & sysfs_dev_stat);

/**
* @brief update HDD connections
*/
void updateHDDConnections();
void updateHddConnections();

/**
* @brief unmount device
Expand All @@ -321,26 +321,26 @@ class HDDMonitor : public rclcpp::Node
int unmountDevice(std::string & device);

diagnostic_updater::Updater updater_; //!< @brief Updater class which advertises to /diagnostics
rclcpp::TimerBase::SharedPtr timer_; //!< @brief timer to get HDD information from HDDReader
rclcpp::TimerBase::SharedPtr timer_; //!< @brief timer to get HDD information from HddReader

char hostname_[HOST_NAME_MAX + 1]; //!< @brief host name

int hdd_reader_port_; //!< @brief port number to connect to hdd_reader
std::map<std::string, HDDParam> hdd_params_; //!< @brief list of error and warning levels
std::map<std::string, HddParam> hdd_params_; //!< @brief list of error and warning levels
std::map<std::string, bool>
hdd_connected_flags_; //!< @brief list of flag whether HDD is connected
std::map<std::string, uint32_t>
initial_recovered_errors_; //!< @brief list of initial recovered error count
std::map<std::string, HDDStat> hdd_stats_; //!< @brief list of HDD statistics
std::map<std::string, HddStat> hdd_stats_; //!< @brief list of HDD statistics
//!< @brief diagnostic of connection
diagnostic_updater::DiagnosticStatusWrapper connect_diag_;
HDDInfoList hdd_info_list_; //!< @brief list of HDD information
HddInfoList hdd_info_list_; //!< @brief list of HDD information
rclcpp::Time last_hdd_stat_update_time_; //!< @brief last HDD statistics update time

/**
* @brief HDD SMART status messages
*/
const std::map<int, const char *> smart_dicts_[static_cast<uint32_t>(HDDSMARTInfoItem::SIZE)] = {
const std::map<int, const char *> smart_dicts_[static_cast<uint32_t>(HddSmartInfoItem::SIZE)] = {
// temperature
{{DiagStatus::OK, "OK"}, {DiagStatus::WARN, "hot"}, {DiagStatus::ERROR, "critical hot"}},
// power on hours
Expand All @@ -364,7 +364,7 @@ class HDDMonitor : public rclcpp::Node
/**
* @brief HDD statistics status messages
*/
const std::map<int, const char *> stat_dicts_[static_cast<uint32_t>(HDDStatItem::SIZE)] = {
const std::map<int, const char *> stat_dicts_[static_cast<uint32_t>(HddStatItem::SIZE)] = {
// data rate of read
{{DiagStatus::OK, "OK"},
{DiagStatus::WARN, "high data rate of read"},
Expand Down
2 changes: 1 addition & 1 deletion system/system_monitor/launch/system_monitor.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def launch_setup(context, *args, **kwargs):
hdd_monitor_config = yaml.safe_load(f)["/**"]["ros__parameters"]
hdd_monitor = ComposableNode(
package="system_monitor",
plugin="HDDMonitor",
plugin="HddMonitor",
name="hdd_monitor",
parameters=[
hdd_monitor_config,
Expand Down
Loading