23#include <boost/thread.hpp>
24#include <rclcpp/contexts/default_context.hpp>
26#include <smacc2_msgs/msg/smacc_status.hpp>
64 template <
typename EventType>
67 boost::intrusive_ptr<EventType> weakPtrEvent = ev;
77 rclcpp::Node::SharedPtr
getNode();
119 rclcpp::Publisher<smacc2_msgs::msg::SmaccStatus>::SharedPtr
statusPub_;
139template <
typename StateMachineType>
156 SmaccFifoScheduler::processor_handle sm =
157 scheduler1.create_processor<StateMachineType>(&signalDetector);
162 scheduler1.initiate_processor(sm);
165 boost::thread schedulerThread(boost::bind(&sc::fifo_scheduler<>::operator(), &scheduler1, 0));
172 RCLCPP_INFO(rclcpp::get_logger(
"SMACC"),
"Polling loop exited. Terminating scheduler...");
176 RCLCPP_INFO(rclcpp::get_logger(
"SMACC"),
"Waiting for scheduler thread to join...");
177 schedulerThread.join();
183 rclcpp::contexts::get_global_default_context()->shutdown(
"SMACC2 run finished");
190 RCLCPP_INFO(rclcpp::get_logger(
"SMACC"),
"Scheduler thread terminated. Shutdown complete.");
void joinAsyncClientBehaviorThreads()
SmaccFifoScheduler * scheduler_
void notifyStateInitializationFailed()
void terminateScheduler()
boost::thread signalDetectorThread_
static constexpr double kInitializationPollRateHz
void queueWorkItem(const SmaccFifoWorker::work_item &item)
void postEvent(EventType *ev)
void notifyStateExited(ISmaccState *currentState)
ExecutionModel executionModel_
void initialize(ISmaccStateMachine *stateMachine)
std::vector< std::vector< ISmaccUpdatable * > > updatableStateElements_
std::atomic< bool > rosInitialized_
static constexpr double kDefaultLoopRateHz
rclcpp::Logger getLogger()
rclcpp::Node::SharedPtr getNode()
SmaccFifoScheduler::processor_handle processorHandle_
SignalDetector(SmaccFifoScheduler *scheduler, ExecutionModel executionModel=ExecutionModel::SINGLE_THREAD_SPINNER)
std::vector< ISmaccUpdatable * > updatableClients_
void notifyRosInitialized()
void setProcessorHandle(SmaccFifoScheduler::processor_handle processorHandle)
rclcpp::Publisher< smacc2_msgs::msg::SmaccStatus >::SharedPtr statusPub_
void findUpdatableStateElements(ISmaccState *currentState)
void findUpdatableClientsAndComponents()
ISmaccStateMachine * smaccStateMachine_
void notifyStateConfigured(ISmaccState *currentState)
std::atomic< bool > initialized_
void run(ExecutionModel executionModel=ExecutionModel::SINGLE_THREAD_SPINNER)
boost::statechart::fifo_scheduler< SmaccFifoWorker, SmaccAllocator > SmaccFifoScheduler