8 ROS_INFO(
"----------- PRINT STATE MACHINE STRUCTURE -------------------");
10 for (
auto &val : this->
states)
12 smacc_msgs::SmaccState stateMsg;
13 auto state = val.second;
14 stateMsg.index = state->stateIndex_;
17 ss <<
"**** State: " <<
demangleSymbol(val.first.c_str()) << std::endl;
19 stateMsg.name = state->getDemangledFullName();
20 stateMsg.level = (int)state->getStateLevel();
22 ss <<
"**** State: " << stateMsg.name << std::endl;
24 ss <<
"Index: " << stateMsg.index << std::endl;
25 ss <<
"StateLevel: " << stateMsg.level << std::endl;
27 ss <<
" Childstates:" << std::endl;
29 for (
auto &child : state->children_)
31 auto childStateName = child->getDemangledFullName();
32 stateMsg.children_states.push_back(childStateName);
34 ss <<
" - " << childStateName << std::endl;
37 ss <<
" Transitions:" << std::endl;
39 for (
auto &transition : state->transitions_)
41 smacc_msgs::SmaccTransition transitionMsg;
45 ss <<
" - Transition. " << std::endl;
46 ss <<
" - Index: " << transitionMsg.index << std::endl;
47 ss <<
" - Transition Name: " << transitionMsg.transition_name << std::endl;
48 ss <<
" - Transition Type: " << transitionMsg.transition_type << std::endl;
49 ss <<
" - Event Type :" << transitionMsg.event.event_type << std::endl;
50 ss <<
" - Event Source: " << transitionMsg.event.event_source << std::endl;
51 ss <<
" - Event ObjectTag: " << transitionMsg.event.event_object_tag << std::endl;
52 ss <<
" - Event Label: " << transitionMsg.event.label << std::endl;
53 ss <<
" - Destiny State: " << transitionMsg.destiny_state_name << std::endl;
54 ss <<
" - Owner State: " << transitionMsg.destiny_state_name << std::endl;
55 ss <<
" - Is History Node: " << std::to_string(transitionMsg.history_node) << std::endl;
56 ss <<
" - TransitionC++Type: " << transition.transitionTypeInfo->getFullName() << std::endl;
57 ss <<
" - EventC++Type: " << transition.eventInfo->eventType->getFullName() << std::endl;
59 stateMsg.transitions.push_back(transitionMsg);
62 const std::type_info *statetid = state->tid_;
64 std::map<const std::type_info *, std::vector<smacc::ClientBehaviorInfoEntry *>> smaccBehaviorInfoMappingByOrthogonalType;
66 ss <<
" Orthogonals:" << std::endl;
71 if (smaccBehaviorInfoMappingByOrthogonalType.count(bhinfo.orthogonalType) == 0)
73 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType] = std::vector<smacc::ClientBehaviorInfoEntry *>();
76 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType].push_back(&bhinfo);
82 for (
auto &orthogonal : runtimeOrthogonals)
84 smacc_msgs::SmaccOrthogonal orthogonalMsg;
86 const auto *orthogonaltid = &
typeid(*(orthogonal.second));
89 ss <<
" - orthogonal: " << orthogonalMsg.name << std::endl;
91 if (smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid].size() > 0)
93 auto &behaviors = smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid];
94 for (
auto &bhinfo : behaviors)
96 auto ClientBehaviorName =
demangleSymbol(bhinfo->behaviorType->name());
97 orthogonalMsg.client_behavior_names.push_back(ClientBehaviorName);
98 ss <<
" - client behavior: " << ClientBehaviorName << std::endl;
103 ss <<
" - NO Client BEHAVIORS -" << std::endl;
106 auto &clients = orthogonal.second->getClients();
107 if (clients.size() > 0)
109 for (
auto &client : clients)
111 auto clientTid = client->getType();
112 auto clientName = clientTid->getNonTemplatedTypeName();
113 orthogonalMsg.client_names.push_back(clientName);
114 ss <<
" - client: " << clientName << std::endl;
119 ss <<
" - NO CLIENTS - " << std::endl;
121 stateMsg.orthogonals.push_back(orthogonalMsg);
124 ss <<
" State event generators:" << std::endl;
130 smacc_msgs::SmaccEventGenerator eventGeneratorMsg;
131 eventGeneratorMsg.index = k++;
132 eventGeneratorMsg.type_name =
demangleSymbol(eginfo->eventGeneratorType->name());
134 ss <<
" - event generator: " << eventGeneratorMsg.type_name << std::endl;
135 if (eginfo->objectTagType !=
nullptr)
137 eventGeneratorMsg.object_tag = eginfo->objectTagType->getFullName();
138 ss <<
" - object tag: " << eventGeneratorMsg.object_tag << std::endl;
140 stateMsg.event_generators.push_back(eventGeneratorMsg);
144 ss <<
" State reactors:" << std::endl;
150 smacc_msgs::SmaccStateReactor stateReactorMsg;
151 stateReactorMsg.index = k++;
152 stateReactorMsg.type_name =
demangleSymbol(srinfo->stateReactorType->name());
154 ss <<
" - state reactor: " << stateReactorMsg.type_name << std::endl;
155 if (srinfo->objectTagType !=
nullptr)
157 stateReactorMsg.object_tag = srinfo->objectTagType->getFullName();
158 ss <<
" - object tag: " << stateReactorMsg.object_tag << std::endl;
161 for (
auto &tev : srinfo->sourceEventTypes)
164 auto eventTypeName = tev->getEventTypeName();
165 smacc_msgs::SmaccEvent event;
167 ss <<
" - triggering event: " << tev->getEventTypeName() << std::endl;
168 event.event_type = eventTypeName;
170 event.event_source = tev->getEventSourceName();
171 ss <<
" - source type: " <<
event.event_source << std::endl;
173 event.event_object_tag = tev->getOrthogonalName();
174 ss <<
" - source object: " <<
event.event_object_tag << std::endl;
176 event.label = tev->label;
177 ss <<
" - event label: " <<
event.label << std::endl;
179 stateReactorMsg.event_sources.push_back(event);
182 stateMsg.state_reactors.push_back(stateReactorMsg);
187 ss <<
"- NO STATE REACTORS - " << std::endl;
190 ROS_INFO_STREAM(ss.str());
195 return a.index > b.index;
const std::map< std::string, std::shared_ptr< smacc::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< ClientBehaviorInfoEntry > > staticBehaviorInfo
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccEventGeneratorInfo > > > eventGeneratorsInfo
std::vector< smacc_msgs::SmaccState > stateMsgs
void assembleSMStructureMessage(ISmaccStateMachine *sm)
std::map< std::string, std::shared_ptr< SmaccStateInfo > > states
void transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc_msgs::SmaccTransition &transitionMsg)
std::string demangleSymbol()