SMACC2
Loading...
Searching...
No Matches
reflection.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/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
22#include "rclcpp/rclcpp.hpp"
23
24namespace smacc2
25{
26namespace introspection
27{
28rclcpp::Node::SharedPtr globalNh_;
29
31 const SmaccTransitionInfo & transition, smacc2_msgs::msg::SmaccTransition & transitionMsg)
32{
33 transitionMsg.index = transition.index;
34
35 if (transition.sourceState != nullptr)
36 {
37 transitionMsg.source_state_name = transition.sourceState->demangledStateName;
38 }
39
40 transitionMsg.transition_name = transition.transitionTag;
41 transitionMsg.transition_type = transition.transitionType;
42
43 if (transition.eventInfo != nullptr)
44 {
45 transitionMsg.event.event_type = transition.eventInfo->getEventTypeName();
46 transitionMsg.event.event_source = transition.eventInfo->getEventSourceName();
47 transitionMsg.event.event_object_tag = transition.eventInfo->getOrthogonalName();
48 transitionMsg.event.label = transition.eventInfo->label;
49 }
50
51 transitionMsg.history_node = transition.historyNode;
52
53 if (transition.historyNode)
54 {
55 if (transition.destinyState->parentState_ != nullptr)
56 {
57 transitionMsg.destiny_state_name = transition.destinyState->parentState_->demangledStateName;
58 }
59 else
60 {
61 transitionMsg.destiny_state_name = "";
62 }
63 }
64 else
65 {
66 transitionMsg.destiny_state_name = transition.destinyState->demangledStateName;
67 }
68}
69} // namespace introspection
70} // namespace smacc2
rclcpp::Node::SharedPtr globalNh_
Definition: reflection.cpp:28
void transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc2_msgs::msg::SmaccTransition &transitionMsg)
Definition: reflection.cpp:30
std::shared_ptr< const SmaccStateInfo > destinyState
std::shared_ptr< SmaccEventInfo > eventInfo
std::shared_ptr< const SmaccStateInfo > sourceState