2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 ///////////////////////////////////////////////////////////////////////////////////////////////////
20 #include <native_service/frameworkunified_sm_localtransition.h>
21 #include <native_service/frameworkunified_sm_state.h>
22 #include <native_service/frameworkunified_sm_framework_types.h>
24 ///////////////////////////////////////////////////////////////////////////////////////////
25 /// CFrameworkunifiedExternalTransition
26 /// Parameterized constructor
27 ///////////////////////////////////////////////////////////////////////////////////////////
28 CFrameworkunifiedLocalTransition::CFrameworkunifiedLocalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) {
31 ///////////////////////////////////////////////////////////////////////////////////////////
32 /// ~CFrameworkunifiedExternalTransition
34 ///////////////////////////////////////////////////////////////////////////////////////////
35 CFrameworkunifiedLocalTransition::~CFrameworkunifiedLocalTransition() {
38 ///////////////////////////////////////////////////////////////////////////////////////////
39 /// FrameworkunifiedReaction
40 /// The reaction for an event is implemented in this function. For local transition from inner
41 /// state to outer state exit of the inner state is invoked, but entry of outer state is not
42 /// invoked and from outer state to inner state entry of the inner state is invoked but exit of
43 /// outer state is not invoked
44 ///////////////////////////////////////////////////////////////////////////////////////////
45 CFrameworkunifiedState *CFrameworkunifiedLocalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
46 CFrameworkunifiedState *l_pActiveState = NULL;
47 CFrameworkunifiedState *l_pCurrentState = NULL;
49 CHKNULL(f_pSourceState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
50 CHKNULL(m_pTargetState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
52 // Local transition from inner state to outer state
53 if (f_pSourceState->m_pParentState == m_pTargetState) {
54 // Source is child of target
55 l_pCurrentState = f_pSourceState->FrameworkunifiedOnHSMStop(f_pData);
57 if (l_pCurrentState == f_pSourceState) {
58 l_pActiveState = m_pTargetState;
61 l_pActiveState = l_pCurrentState;
66 * If the parent state is registered and OnEvent is performed without OrthogonalReigonList, illegal accesses occur.
68 l_pActiveState->m_pActiveState = NULL;
70 // Local transition from outer state to inner state
71 } else if (f_pSourceState == m_pTargetState->m_pParentState) {
72 // Source is parent to target state
73 l_pActiveState = m_pTargetState->FrameworkunifiedOnHSMStart(f_pData);
75 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Local Transition from state %s to state %s"
76 , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
77 } catch (std::exception &e) {
78 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
83 return l_pActiveState;