18#include <boost/algorithm/string.hpp>
19#include <lifecycle_msgs/msg/state.hpp>
20#include <rclcpp/logger.hpp>
21#include <rclcpp/logging.hpp>
32 const std::vector<std::string>& camera_entries,
33 const long driver_timeout)
34 : critical_drivers_(critical_driver_names.begin(), critical_driver_names.end()),
35 camera_entries_(camera_entries.begin(), camera_entries.end()),
36 driver_timeout_(driver_timeout)
39 em_ = std::make_shared<EntryManager>(critical_driver_names, camera_entries);
46 carma_msgs::msg::SystemAlert alert;
49 if(status.compare(
"s_1_c_1") == 0)
52 alert.description =
"All essential drivers are ready";
53 alert.type = carma_msgs::msg::SystemAlert::DRIVERS_READY;
56 else if(
starting_up_ && (time_now - start_up_timestamp <= startup_duration))
58 alert.description =
"System is starting up...";
59 alert.type = carma_msgs::msg::SystemAlert::NOT_READY;
62 else if(status.compare(
"s_1_c_0")==0)
64 alert.description =
"Camera Failed";
68 else if(status.compare(
"s_0") == 0)
70 alert.description =
"SSC Failed";
76 alert.description =
"Unknown problem assessing essential driver availability";
77 alert.type = carma_msgs::msg::SystemAlert::FATAL;
87 Entry driver_status(msg->status == carma_driver_msgs::msg::DriverStatus::OPERATIONAL || msg->status == carma_driver_msgs::msg::DriverStatus::DEGRADED,
88 msg->name,current_time);
90 em_->update_entry(driver_status);
97 if((!available) || (current_time-timestamp > driver_timeout))
113 std::vector<Entry> driver_list =
em_->get_entries();
114 for(
auto i = driver_list.begin();
i < driver_list.end(); ++
i)
116 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"subsystem_controller"),
"i->name_: " <<
i->name_
117 <<
", current_time: " << current_time
118 <<
", i->timestamp_: " <<
i->timestamp_
119 <<
", difference: " << current_time-(
i->timestamp_) );
120 if(
em_->is_entry_required(
i->name_))
124 else if(
em_->is_camera_entry_required(
i->name_)==0)
138 if (ssc == 1 && camera == 1)
142 else if (ssc == 1 && camera == 0)
std::chrono::milliseconds std_msec
void update_driver_status(const carma_driver_msgs::msg::DriverStatus::SharedPtr msg, long current_time)
Update driver status.
std::string are_critical_drivers_operational(long current_time)
Check if all critical drivers are operational.
carma_msgs::msg::SystemAlert handle_spin(long time_now, long start_up_timestamp, long startup_duration)
Handle the spin and publisher.
std::shared_ptr< EntryManager > em_
Entry manager to keep track of detected plugins.
std::vector< std::string > critical_drivers_
void evaluate_sensor(int &sensor_input, bool available, long current_time, long timestamp, long driver_timeout)
Evaluate if the sensor is available.
DriverManager()
Default constructor for DriverManager with driver_timeout_ = 1000ms.
An entry represents a driver details for the purposes of tracking.