21 executionModel_(executionModel)
35 lastState_ = std::numeric_limits<uint64_t>::quiet_NaN();
50 auto &orthogonal = pair.second;
51 auto &clients = orthogonal->getClients();
53 for (
auto &client : clients)
58 if (updatableClient !=
nullptr)
60 ROS_DEBUG_STREAM(
"Adding updatable client: " <<
demangleType(
typeid(updatableClient)));
65 std::vector<std::shared_ptr<ISmaccComponent>> components;
66 client->getComponents(components);
67 for (
auto &componententry : components)
69 auto updatableComponent =
dynamic_cast<ISmaccUpdatable *
>(componententry.get());
70 if (updatableComponent !=
nullptr)
72 ROS_DEBUG_STREAM(
"Adding updatable component: " <<
demangleType(
typeid(*updatableComponent)));
93 auto &orthogonal = pair.second;
94 auto &behaviors = orthogonal->getClientBehaviors().back();
96 for (
auto ¤tBehavior : behaviors)
100 if (updatableClientBehavior !=
nullptr)
102 ROS_DEBUG_STREAM(
"Adding updatable behavior: " <<
demangleType(
typeid(updatableClientBehavior)));
103 updatableElements.push_back(updatableClientBehavior);
109 if (updatableState !=
nullptr)
111 updatableElements.push_back(updatableState);
115 for (
auto &sr : statereactors)
118 if (updatableStateReactor !=
nullptr)
120 ROS_DEBUG_STREAM(
"Adding updatable stateReactorr: " <<
demangleType(
typeid(updatableStateReactor)));
121 updatableElements.push_back(updatableStateReactor);
126 for (
auto &eg : eventgenerators)
129 if (updatableEventGenerator !=
nullptr)
131 ROS_DEBUG_STREAM(
"Adding updatable eventGenerator: " <<
demangleType(
typeid(updatableEventGenerator)));
132 updatableElements.push_back(updatableEventGenerator);
208 ROS_DEBUG_STREAM(
"[PollOnce] update client call: " <<
demangleType(
typeid(updatableClient)));
209 updatableClient->executeUpdate();
244 for (
auto *udpatableStateElement : stateElement)
246 ROS_DEBUG_STREAM(
"pollOnce update client behavior call: " <<
demangleType(
typeid(*udpatableStateElement)));
247 udpatableStateElement->executeUpdate();
254 catch (std::exception &ex)
256 ROS_ERROR(
"Exception during Signal Detector update loop. %s", ex.what());
280 if (!nh.getParam(
"signal_detector_loop_freq", this->loop_rate_hz))
282 ROS_WARN(
"Signal detector frequency (ros param ~signal_detector_loop_freq) was not set, using default frequency: "
288 ROS_WARN(
"Signal detector frequency (ros param ~signal_detector_loop_freq): %lf", this->
loop_rate_hz);
291 nh.setParam(
"signal_detector_loop_freq", this->
loop_rate_hz);
293 ROS_INFO_STREAM(
"[SignalDetector] loop rate hz:" <<
loop_rate_hz);
297 ROS_INFO_STREAM(
"[SignalDetector] running in single threaded mode");
300 while (ros::ok() && !
end_)
302 ROS_INFO_STREAM_THROTTLE(10,
"[SignalDetector] heartbeat");
310 ROS_INFO_STREAM(
"[SignalDetector] running in multi threaded mode");
311 ros::AsyncSpinner spinner(1);
313 ros::waitForShutdown();
void lockStateMachine(std::string msg)
StateMachineInternalAction stateMachineCurrentAction
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & getOrthogonals() const
void unlockStateMachine(std::string msg)
std::vector< std::shared_ptr< SmaccEventGenerator > > & getEventGenerators()
std::vector< std::shared_ptr< StateReactor > > & getStateReactors()
ExecutionModel executionModel_
std::atomic< bool > initialized_
std::vector< std::vector< ISmaccUpdatable * > > updatableStateElements_
std::vector< ISmaccUpdatable * > updatableClients_
std::atomic< uint64_t > lastState_
void notifyStateConfigured(ISmaccState *currentState)
SignalDetector(SmaccFifoScheduler *scheduler, ExecutionModel executionModel=ExecutionModel::SINGLE_THREAD_SPINNER)
boost::thread signalDetectorThread_
void findUpdatableStateElements(ISmaccState *currentState)
ISmaccStateMachine * smaccStateMachine_
void findUpdatableClients()
void initialize(ISmaccStateMachine *stateMachine)
SmaccFifoScheduler::processor_handle processorHandle_
void setProcessorHandle(SmaccFifoScheduler::processor_handle processorHandle)
void notifyStateExited(ISmaccState *currentState)
SmaccFifoScheduler * scheduler_
std::string demangleType(const std::type_info *tinfo)
std::string cleanShortTypeName(const std::type_info &tinfo)
boost::statechart::fifo_scheduler< SmaccFifoWorker, SmaccAllocator > SmaccFifoScheduler