30 ss <<
"----------- PRINT STATE MACHINE STRUCTURE -------------------" << std::endl;
32 for (
auto & val : this->
states)
34 smacc2_msgs::msg::SmaccState stateMsg;
35 auto state = val.second;
36 stateMsg.index = state->stateIndex_;
38 ss <<
"**** State: " <<
demangleSymbol(val.first.c_str()) << std::endl;
40 stateMsg.name = state->getDemangledFullName();
41 stateMsg.level = (int)state->getStateLevel();
43 ss <<
"Index: " << stateMsg.index << std::endl;
44 ss <<
"StateLevel: " << stateMsg.level << std::endl;
46 ss <<
" Childstates:" << std::endl;
48 for (
auto & child : state->children_)
50 auto childStateName = child->getDemangledFullName();
51 stateMsg.children_states.push_back(childStateName);
53 ss <<
" - " << childStateName << std::endl;
56 ss <<
" Transitions:" << std::endl;
58 for (
auto & transition : state->transitions_)
60 smacc2_msgs::msg::SmaccTransition transitionMsg;
64 ss <<
" - Transition. " << std::endl;
65 ss <<
" - Index: " << transitionMsg.index << std::endl;
66 ss <<
" - Transition Name: " << transitionMsg.transition_name << std::endl;
67 ss <<
" - Transition Type: " << transitionMsg.transition_type << std::endl;
68 ss <<
" - Event Type :" << transitionMsg.event.event_type << std::endl;
69 ss <<
" - Event Source: " << transitionMsg.event.event_source << std::endl;
70 ss <<
" - Event ObjectTag: " << transitionMsg.event.event_object_tag << std::endl;
71 ss <<
" - Event Label: " << transitionMsg.event.label << std::endl;
72 ss <<
" - Destiny State: " << transitionMsg.destiny_state_name << std::endl;
73 ss <<
" - Owner State: " << transitionMsg.destiny_state_name << std::endl;
74 ss <<
" - Is History Node: " << std::to_string(transitionMsg.history_node) << std::endl;
75 ss <<
" - TransitionC++Type: " << transition.transitionTypeInfo->getFullName()
77 ss <<
" - EventC++Type: " << transition.eventInfo->eventType->getFullName() << std::endl;
79 stateMsg.transitions.push_back(transitionMsg);
82 const std::type_info * statetid = state->tid_;
84 std::map<const std::type_info *, std::vector<smacc2::ClientBehaviorInfoEntry *>>
85 smaccBehaviorInfoMappingByOrthogonalType;
87 ss <<
" Orthogonals:" << std::endl;
92 if (smaccBehaviorInfoMappingByOrthogonalType.count(bhinfo.orthogonalType) == 0)
94 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType] =
95 std::vector<smacc2::ClientBehaviorInfoEntry *>();
98 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType].push_back(&bhinfo);
104 for (
auto & orthogonal : runtimeOrthogonals)
106 smacc2_msgs::msg::SmaccOrthogonal orthogonalMsg;
108 const auto * orthogonaltid = &
typeid(*(orthogonal.second));
111 ss <<
" - orthogonal: " << orthogonalMsg.name << std::endl;
113 if (smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid].size() > 0)
115 auto & behaviors = smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid];
116 for (
auto & bhinfo : behaviors)
118 auto ClientBehaviorName =
demangleSymbol(bhinfo->behaviorType->name());
119 orthogonalMsg.client_behavior_names.push_back(ClientBehaviorName);
120 ss <<
" - client behavior: " << ClientBehaviorName << std::endl;
125 ss <<
" - NO CLIENT BEHAVIORS -" << std::endl;
128 auto & clients = orthogonal.second->getClients();
129 if (clients.size() > 0)
131 for (
auto & client : clients)
133 auto clientTid = client->getType();
134 auto clientName = clientTid->getNonTemplatedTypeName();
135 orthogonalMsg.client_names.push_back(clientName);
136 ss <<
" - client: " << clientName << std::endl;
141 ss <<
" - NO CLIENTS - " << std::endl;
143 stateMsg.orthogonals.push_back(orthogonalMsg);
146 ss <<
" State event generators:" << std::endl;
152 smacc2_msgs::msg::SmaccEventGenerator eventGeneratorMsg;
153 eventGeneratorMsg.index = k++;
154 eventGeneratorMsg.type_name = eginfo->eventGeneratorType->getFullName();
156 ss <<
" - event generator: " << eventGeneratorMsg.type_name << std::endl;
157 if (eginfo->objectTagType !=
nullptr)
159 eventGeneratorMsg.object_tag = eginfo->objectTagType->getFullName();
160 ss <<
" - object tag: " << eventGeneratorMsg.object_tag << std::endl;
162 stateMsg.event_generators.push_back(eventGeneratorMsg);
166 ss <<
" State reactors:" << std::endl;
172 smacc2_msgs::msg::SmaccStateReactor stateReactorMsg;
173 stateReactorMsg.index = k++;
174 stateReactorMsg.type_name = srinfo->stateReactorType->getFullName();
176 ss <<
" - state reactor: " << stateReactorMsg.type_name << std::endl;
177 if (srinfo->objectTagType !=
nullptr)
179 stateReactorMsg.object_tag = srinfo->objectTagType->getFullName();
180 ss <<
" - object tag: " << stateReactorMsg.object_tag << std::endl;
183 for (
auto & tev : srinfo->sourceEventTypes)
186 auto eventTypeName = tev->getEventTypeName();
187 smacc2_msgs::msg::SmaccEvent event;
189 ss <<
" - triggering event: " << tev->getEventTypeName() << std::endl;
190 event.event_type = eventTypeName;
192 event.event_source = tev->getEventSourceName();
193 ss <<
" - source type: " <<
event.event_source << std::endl;
195 event.event_object_tag = tev->getOrthogonalName();
196 ss <<
" - source object: " <<
event.event_object_tag << std::endl;
198 event.label = tev->label;
199 ss <<
" - event label: " <<
event.label << std::endl;
201 stateReactorMsg.event_sources.push_back(event);
204 stateMsg.state_reactors.push_back(stateReactorMsg);
209 ss <<
"- NO STATE REACTORS - " << std::endl;
212 ss <<
"----------------------------------------------------------" << std::endl;
214 auto resumeMsg = ss.str();
215 RCLCPP_INFO(
getLogger(),
"%s", resumeMsg.c_str());
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals() const
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccStateReactorInfo > > > stateReactorsInfo
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccEventGeneratorInfo > > > eventGeneratorsInfo
static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo
rclcpp::Logger getLogger()
std::map< std::string, std::shared_ptr< SmaccStateInfo > > states
std::vector< smacc2_msgs::msg::SmaccState > stateMsgs
void assembleSMStructureMessage(ISmaccStateMachine *sm)
std::string demangleSymbol(const std::string &name)
void transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc2_msgs::msg::SmaccTransition &transitionMsg)