7 {
8 ROS_INFO("----------- PRINT STATE MACHINE STRUCTURE -------------------");
10 for (
auto &val : this->
states)
11 {
12 smacc_msgs::SmaccState stateMsg;
13 auto state = val.second;
14 stateMsg.index = state->stateIndex_;
15
16 std::stringstream ss;
17 ss <<
"**** State: " <<
demangleSymbol(val.first.c_str()) << std::endl;
18
19 stateMsg.name = state->getDemangledFullName();
20 stateMsg.level = (int)state->getStateLevel();
21
22 ss << "**** State: " << stateMsg.name << std::endl;
23
24 ss << "Index: " << stateMsg.index << std::endl;
25 ss << "StateLevel: " << stateMsg.level << std::endl;
26
27 ss << " Childstates:" << std::endl;
28
29 for (auto &child : state->children_)
30 {
31 auto childStateName = child->getDemangledFullName();
32 stateMsg.children_states.push_back(childStateName);
33
34 ss << " - " << childStateName << std::endl;
35 }
36
37 ss << " Transitions:" << std::endl;
38
39 for (auto &transition : state->transitions_)
40 {
41 smacc_msgs::SmaccTransition transitionMsg;
42
44
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;
58
59 stateMsg.transitions.push_back(transitionMsg);
60 }
61
62 const std::type_info *statetid = state->tid_;
63
64 std::map<const std::type_info *, std::vector<smacc::ClientBehaviorInfoEntry *>> smaccBehaviorInfoMappingByOrthogonalType;
65
66 ss << " Orthogonals:" << std::endl;
68 {
70 {
71 if (smaccBehaviorInfoMappingByOrthogonalType.count(bhinfo.orthogonalType) == 0)
72 {
73 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType] = std::vector<smacc::ClientBehaviorInfoEntry *>();
74 }
75
76 smaccBehaviorInfoMappingByOrthogonalType[bhinfo.orthogonalType].push_back(&bhinfo);
77 }
78 }
79
80 auto &runtimeOrthogonals = sm->getOrthogonals();
81
82 for (auto &orthogonal : runtimeOrthogonals)
83 {
84 smacc_msgs::SmaccOrthogonal orthogonalMsg;
85
86 const auto *orthogonaltid = &typeid(*(orthogonal.second));
88
89 ss << " - orthogonal: " << orthogonalMsg.name << std::endl;
90
91 if (smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid].size() > 0)
92 {
93 auto &behaviors = smaccBehaviorInfoMappingByOrthogonalType[orthogonaltid];
94 for (auto &bhinfo : behaviors)
95 {
96 auto ClientBehaviorName =
demangleSymbol(bhinfo->behaviorType->name());
97 orthogonalMsg.client_behavior_names.push_back(ClientBehaviorName);
98 ss << " - client behavior: " << ClientBehaviorName << std::endl;
99 }
100 }
101 else
102 {
103 ss << " - NO Client BEHAVIORS -" << std::endl;
104 }
105
106 auto &clients = orthogonal.second->getClients();
107 if (clients.size() > 0)
108 {
109 for (auto &client : clients)
110 {
111 auto clientTid = client->getType();
112 auto clientName = clientTid->getNonTemplatedTypeName();
113 orthogonalMsg.client_names.push_back(clientName);
114 ss << " - client: " << clientName << std::endl;
115 }
116 }
117 else
118 {
119 ss << " - NO CLIENTS - " << std::endl;
120 }
121 stateMsg.orthogonals.push_back(orthogonalMsg);
122 }
123
124 ss << " State event generators:" << std::endl;
126 {
127 int k = 0;
129 {
130 smacc_msgs::SmaccEventGenerator eventGeneratorMsg;
131 eventGeneratorMsg.index = k++;
132 eventGeneratorMsg.type_name =
demangleSymbol(eginfo->eventGeneratorType->name());
133
134 ss << " - event generator: " << eventGeneratorMsg.type_name << std::endl;
135 if (eginfo->objectTagType != nullptr)
136 {
137 eventGeneratorMsg.object_tag = eginfo->objectTagType->getFullName();
138 ss << " - object tag: " << eventGeneratorMsg.object_tag << std::endl;
139 }
140 stateMsg.event_generators.push_back(eventGeneratorMsg);
141 }
142 }
143
144 ss << " State reactors:" << std::endl;
146 {
147 int k = 0;
149 {
150 smacc_msgs::SmaccStateReactor stateReactorMsg;
151 stateReactorMsg.index = k++;
152 stateReactorMsg.type_name =
demangleSymbol(srinfo->stateReactorType->name());
153
154 ss << " - state reactor: " << stateReactorMsg.type_name << std::endl;
155 if (srinfo->objectTagType != nullptr)
156 {
157 stateReactorMsg.object_tag = srinfo->objectTagType->getFullName();
158 ss << " - object tag: " << stateReactorMsg.object_tag << std::endl;
159 }
160
161 for (auto &tev : srinfo->sourceEventTypes)
162 {
163
164 auto eventTypeName = tev->getEventTypeName();
165 smacc_msgs::SmaccEvent event;
166
167 ss << " - triggering event: " << tev->getEventTypeName() << std::endl;
168 event.event_type = eventTypeName;
169
170 event.event_source = tev->getEventSourceName();
171 ss << " - source type: " << event.event_source << std::endl;
172
173 event.event_object_tag = tev->getOrthogonalName();
174 ss << " - source object: " << event.event_object_tag << std::endl;
175
176 event.label = tev->label;
177 ss << " - event label: " << event.label << std::endl;
178
179 stateReactorMsg.event_sources.push_back(event);
180 }
181
182 stateMsg.state_reactors.push_back(stateReactorMsg);
183 }
184 }
185 else
186 {
187 ss << "- NO STATE REACTORS - " << std::endl;
188 }
189
190 ROS_INFO_STREAM(ss.str());
192 }
193
195 return a.index > b.index;
196 });
197 }
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 transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc_msgs::SmaccTransition &transitionMsg)
std::string demangleSymbol()