SMACC2
Loading...
Searching...
No Matches
sr_event_countdown.cpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include <memory>
16#include <smacc2/common.hpp>
18
19namespace smacc2
20{
21namespace state_reactors
22{
23using namespace smacc2::introspection;
24SrEventCountdown::SrEventCountdown(int eventCount) : eventCount_(eventCount) {}
25
27{
28 for (auto type : eventTypes)
29 {
30 triggeredEvents[type] = false;
31 }
32}
33
34void SrEventCountdown::onEventNotified(const std::type_info * eventType)
35{
37 RCLCPP_INFO_STREAM(
38 getLogger(), "SB COUNTDOWN (" << eventCount_ << ") RECEIVED EVENT OF TYPE:"
39 << demangleSymbol(eventType->name()));
40
41 // RCLCPP_INFO_STREAM(getLogger(),"SB ALL RECEIVED EVENT OF TYPE:" << demangleSymbol(eventType->name()));
42 // triggeredEvents[eventType] = true;
43
44 // for (auto &entry : triggeredEvents)
45 // {
46 // RCLCPP_INFO_STREAM(getLogger(),demangleSymbol(entry.first->name()) << " = " << entry.second);
47 // }
48}
49
51{
52 if (eventCount_ == 0)
53 {
54 RCLCPP_INFO_STREAM(getLogger(), "SB COUNTDOWN (" << eventCount_ << ") TRIGGERS!");
55 return true;
56 }
57 else
58 {
59 return false;
60 }
61
62 // RCLCPP_INFO(getLogger(),"SB All TRIGGERS?");
63 // for (auto &entry : triggeredEvents)
64 // {
65 // if (!entry.second)
66 // return false;
67 // }
68 // RCLCPP_INFO(getLogger(),"SB ALL TRIGGERED");
69 // return true;
70}
71
72} // namespace state_reactors
73} // namespace smacc2
rclcpp::Logger getLogger()
std::vector< const std::type_info * > eventTypes
virtual void onEventNotified(const std::type_info *eventType) override
std::map< const std::type_info *, bool > triggeredEvents
std::string demangleSymbol()