diff options
Diffstat (limited to 'video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine')
20 files changed, 0 insertions, 5374 deletions
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp deleted file mode 100755 index 0cb4d67..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines -/// interfaces for implementing action -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_action.h> -#include <string> -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedAction -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedAction::CFrameworkunifiedAction(std::string f_strName): m_strName(f_strName) { -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp deleted file mode 100755 index d975e93..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedCompositeState class definitions. CFrameworkunifiedCompositeState is derived from C -/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Composite -/// state. It provides the standard interfaces for adding state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_compositestate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_hsm.h> -#include <native_service/frameworkunified_sm_historystate.h> - -#include <sstream> -#include <string> -#include <map> -#include <utility> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedCompositeState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedCompositeState::CFrameworkunifiedCompositeState(std::string f_pName): CFrameworkunifiedState(f_pName) { - try { - // ChildState map stores the pointers to sub state, key is state name - m_pChildStates = new ChildStateList(); - - m_pDefaultState = NULL; - - m_pActiveState = NULL; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str()); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedCompositeState::~CFrameworkunifiedCompositeState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedCompositeState destructor"); - StateIterator l_objStateIterator; - try { - CHKNULL(m_pChildStates); - - // Deleting the States - for (l_objStateIterator = m_pChildStates->begin(); - l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the state %s in state %s ", - (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName.c_str(), - m_strStateName.c_str()); - - CHKNULL((*l_objStateIterator).second); - - delete(*l_objStateIterator).second; - (*l_objStateIterator).second = NULL; - } - m_pChildStates->clear(); - delete m_pChildStates; - m_pChildStates = NULL; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to delete state %s", - ((reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName).c_str()); - } -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAddState -/// sets the given state as a substate of the current state. If the f_eStateType is -/// eFrameworkunifiedDefaultState then substate is default state for current state. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedAddState(CFrameworkunifiedState *f_pState, - FRAMEWORKUNIFIED_STATE_TYPE f_eStateType) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates; - CFrameworkunifiedHistoryState *l_pHistoryState = NULL; - try { - CHKNULL(f_pState); - - CHKNULL(m_pChildStates); - - // Set current state as the parent state of given state object - f_pState->m_pParentState = this; - - // if given state is default state then set it as the default and active state of parent - // state - if (eFrameworkunifiedDefaultState == f_eStateType) { - m_pDefaultState = f_pState; - m_pActiveState = f_pState; - - // set default shallow history state - l_itChildStates = m_pChildStates->find(SHALLOWHISTORYSTATE); - if (m_pChildStates->end() != l_itChildStates) { - l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second); - CHKNULL(l_pHistoryState); - eStatus = l_pHistoryState->SetDefaultHistory(); - } - - // set default deep history state - l_itChildStates = m_pChildStates->find(DEEPHISTORYSTATE); - if (m_pChildStates->end() != l_itChildStates) { - l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second); - CHKNULL(l_pHistoryState); - eStatus = l_pHistoryState->SetDefaultHistory(); - } - } - - // Insert the state in the map with key as state name - m_pChildStates->insert(std::pair<std::string, CFrameworkunifiedState *>(f_pState->m_strStateName, f_pState)); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " %s state added in the state %s " - , (f_pState->m_strStateName).c_str(), (this->m_strStateName).c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add state %s", - f_pState->m_strStateName.c_str()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedGetDefaultState -/// Returns the default state of the current composite state. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetDefaultState() { - return m_pDefaultState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPrintStates -/// This logs the state name and events associated with the state -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintStates() { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - StateIterator l_objStateIterator; - EventReactionIterator l_objEventIterator; - try { - CHKNULL(m_pEventList); - - if (m_pParentState) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s", - (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str()); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "NULL:%s", m_strStateName.c_str()); - } - - // print event - for (l_objEventIterator = m_pEventList->begin(); - l_objEventIterator != m_pEventList->end(); l_objEventIterator++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first), - (m_pEventName->find((*l_objEventIterator).first)->second).c_str()); - } - CHKNULL(m_pDeferredEventList); - // print deferred events - for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount), - (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str()); - } - CHKNULL(m_pChildStates); - // print states - for (l_objStateIterator = m_pChildStates->begin(); - l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) { - (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintStates(); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", - m_strStateName.c_str()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus;; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedHasSubStates -/// This indicates if the state has sub states. It returns TRUE only in the CompositeState -/// where this function is overridden -/////////////////////////////////////////////////////////////////////////////////////////// -BOOL CFrameworkunifiedCompositeState::FrameworkunifiedHasSubStates() { - return TRUE; -} - -CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetActiveState() { - CFrameworkunifiedState *l_pActiveState = NULL; - if (NULL != m_pActiveState) { - l_pActiveState = m_pActiveState->FrameworkunifiedGetActiveState(); - } else { - l_pActiveState = this; - } - return l_pActiveState; -} - -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - StateIterator l_objStateIterator; - try { - CHKNULL(f_pStatemachine); - // iterate child states - for (l_objStateIterator = m_pChildStates->begin(); - l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) { - (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedSetHSM(f_pStatemachine); - } - m_pStateMachine = f_pStatemachine; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - EventReactionIterator l_objEventIterator; - StateIterator l_objStateIterator; - try { - CHKNULL(m_pEventList); - CHKNULL(m_pEventName); - CHKNULL(m_pDeferredEventList); - - f_strXMLString << "<" << m_strStateName.c_str() << ">"; - - CHKNULL(m_pChildStates); - f_strXMLString << "<ChildStates>"; - // print states - for (l_objStateIterator = m_pChildStates->begin(); - l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) { - (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintXML(f_strXMLString); - } - - f_strXMLString << "</ChildStates>"; - - f_strXMLString << "<EventList>"; - // print events - for (l_objEventIterator = m_pEventList->begin(); - l_objEventIterator != m_pEventList->end(); l_objEventIterator++) { - std::string l_strEventName = - (m_pEventName->find((*l_objEventIterator).first)->second); - - UI_32 l_uiEventId = (*l_objEventIterator).first; - - f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">"; - - f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>"; - - f_strXMLString << "</Event>"; - } - f_strXMLString << "</EventList>"; - - // print deferred events - f_strXMLString << "<DeferredEventList>"; - for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) { - UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount); - - std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second); - - f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">"; - - f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>"; - - f_strXMLString << "</Event>"; - } - - f_strXMLString << "</DeferredEventList>"; - f_strXMLString << "</" << m_strStateName.c_str() << ">"; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::UpdateHistory() { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - // update shallow history state - l_eStatus = CheckHistory(SHALLOWHISTORYSTATE); - - if (eFrameworkunifiedStatusOK != l_eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Shallow History Update Failed", m_strStateName.c_str()); - return l_eStatus; - } - - // update deep history state - l_eStatus = CheckHistory(DEEPHISTORYSTATE); - - if (eFrameworkunifiedStatusOK != l_eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Deep History Update Failed", m_strStateName.c_str()); - return l_eStatus; - } - - return l_eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// CheckHistory -/// This function searches for history state in this composite state and updates it. -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedCompositeState::CheckHistory(std::string l_cHistoryType) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - CHKNULL(m_pChildStates); - - CFrameworkunifiedState *l_pHistoryState = NULL; - - std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates; - - // update history state - l_itChildStates = m_pChildStates->find(l_cHistoryType); - - if (m_pChildStates->end() != l_itChildStates) { - l_pHistoryState = (*l_itChildStates).second; - CHKNULL(l_pHistoryState); - l_eStatus = l_pHistoryState->UpdateHistory(); - } - - return l_eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp deleted file mode 100755 index 6f27319..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has class definition of the CFrameworkunifiedConditionConnector. This class is responsible for -/// implementing interfaces required to use condition connector in statemachine. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_conditionconnector.h> -#include <native_service/frameworkunified_sm_state.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_guard.h> - -#include <vector> -#include <string> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedConditionConnector -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedConditionConnector::CFrameworkunifiedConditionConnector(std::string f_strName): CFrameworkunifiedExternalTransition(NULL), - m_strName(f_strName) { - // Create the condition list - m_pConditionList = new std::vector<CCondition * >(); -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedConditionConnector -/// destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedConditionConnector::~CFrameworkunifiedConditionConnector() { - if (m_pConditionList) { - TConditionIterator l_itConditionList = m_pConditionList->begin(); - - while (m_pConditionList->end() != l_itConditionList) { - delete *l_itConditionList; - l_itConditionList++; - } - // clear condition list - m_pConditionList->clear(); - delete m_pConditionList; - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CCondition -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedConditionConnector::CCondition::CCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState) - : m_pGuard(f_pGuard), m_pTargetState(f_pTargetState) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedReaction -/// This API evaluates the guards added in the condition list. If the guard is evaluated as -/// true then statemachine transitions to target state associated with guard. -////////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedConditionConnector::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) { - CFrameworkunifiedState *l_pActiveState = NULL; - BOOL l_bAllowTransition = FALSE; - try { - CHKNULL(f_pSourceState); - CHKNULL(m_pConditionList); - TConditionIterator l_itConditionList - = m_pConditionList->begin(); - - // iterate condition list and set the target state - while (m_pConditionList->end() != l_itConditionList) { - CCondition *l_pCondition = *l_itConditionList; - CHKNULL(l_pCondition); - - CFrameworkunifiedGuard *l_pGuard = l_pCondition->m_pGuard; - CFrameworkunifiedState *l_pTargetState = l_pCondition->m_pTargetState; - - CHKNULL(l_pGuard); - CHKNULL(l_pTargetState); - - if (l_pGuard->FrameworkunifiedEvaluate()) { - m_pTargetState = l_pTargetState; - l_bAllowTransition = TRUE; - break; - } - l_itConditionList++; - } - - if (l_bAllowTransition) { - // Transition to target state - l_pActiveState = ExecuteTransition(f_pSourceState, f_pData); - - } else { - // No state changed - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, - "Guard condition for External Transition from state %s to condition connector %s failed", - f_pSourceState->m_strStateName.c_str(), m_strName.c_str()); - - l_pActiveState = f_pSourceState; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - return l_pActiveState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAddCondition -/// Adds condition to condition list -////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedConditionConnector::FrameworkunifiedAddCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState) { - EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pConditionList); - CHKNULL(f_pGuard); - CHKNULL(f_pTargetState); - - CCondition *l_pCondition = new CCondition(f_pGuard, f_pTargetState); - - m_pConditionList->push_back(l_pCondition); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer; - } - - - return l_eFrameworkunifiedStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp deleted file mode 100755 index baac0d4..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedDeepHistoryState class definitions. CFrameworkunifiedDeepHistoryState is derived -/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by -/// HSM DeepHistory state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_deephistorystate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <string> - -// define static members of class -const UI_32 CFrameworkunifiedDeepHistoryState::m_suievDeepHistory = 72; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedDeepHistoryState -/// Parameterized constructor -//////////////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedDeepHistoryState::CFrameworkunifiedDeepHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) { - m_uiEventId = m_suievDeepHistory; - m_cEventName = "evDeepHistory"; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedDeepHistoryState -/// Class destructor -//////////////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedDeepHistoryState::~CFrameworkunifiedDeepHistoryState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedDeepHistoryState destructor"); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedDeepHistoryState::UpdateHistory() { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - CFrameworkunifiedState *l_pActiveState = NULL; - - try { - CHKNULL(m_pParentState); - l_pActiveState = m_pParentState->m_pActiveState; - - while (NULL != l_pActiveState) { - m_pLastActiveState = l_pActiveState; - l_pActiveState = l_pActiveState->m_pActiveState; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp deleted file mode 100755 index a73408a..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// -/// -/////////////////////////////////////////////////////////////////////////////// -#include <pthread.h> - -#include <native_service/ns_logger_if.h> -#include <native_service/ns_plogger_if.h> -#include <native_service/ns_message_center_if.h> -#include <native_service/frameworkunified_sm_hsmframework.h> -#include <native_service/frameworkunified_framework_if.h> -#include <native_service/frameworkunified_sm_dispatcher.h> - -#include "frameworkunified_framework_core.h" -#include "frameworkunified_framework_error_internal.hpp" -#include "frameworkunified_sm_framework_core.h" -#include "frameworkunified_framework_utility.h" - -static HSMConfigOptions s_tHSMConfigOptions = {eUserchangeIgnore, TRUE, FALSE}; - -EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp); -////////////////////////////////////////// -// Function : FrameworkunifiedCreateDispatcher -////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcher(PCSTR cAppName, - HANDLE &hFrameworkApp, // NOLINT (readability/nolint) - BOOL bIsThread, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (NULL != cAppName) { - if (eFrameworkunifiedStatusOK == (eStatus = CreateDispatcher(cAppName, hFrameworkApp, bIsThread))) { - if (NULL != hFrameworkApp) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hFrameworkApp); - - if (NULL != f_pFrameworkunifiedHSM) { - pApp->m_pFrameworkunifiedStateMachine = f_pFrameworkunifiedHSM; - pApp->m_pFrameworkunifiedStateMachine->m_pHApp = pApp; - } else { - if (bIsThread) { - pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMChildFramework(pApp); - } else { - pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMParentFramework(pApp); - } - } - - if (NULL != pApp->m_pFrameworkunifiedStateMachine) { - pApp->m_pFrameworkunifiedStateMachine->FrameworkunifiedCreate(&s_tHSMConfigOptions); - } - } else { - FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL"); - eStatus = eFrameworkunifiedStatusNullPointer; - } - } else { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "CreateDispatcher returned error, status=%d", eStatus); - // LCOV_EXCL_BR_STOP - } - } else { - FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "AppName is NULL"); - eStatus = eFrameworkunifiedStatusInvldParam; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedDispatcherWithArguments -/// Creates, initializes and runs the dispatcher -/// -/// \param [in] cAppname -/// PCSTR - Application/ thread name -/// -/// \return Never does, main loop for your application. -/// -/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock, -/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher, -/// -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[], - const FrameworkunifiedDefaultCallbackHandler *CbHandler, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM, - CustomCommandLineOptions *cmdLineOptions) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (cAppName == NULL) { - return eFrameworkunifiedStatusNullPointer; - } - - NsLogSetProcessName(cAppName); - PLOG_TEXT("FrameworkunifiedHSMDispatcher Start"); - // set main thread name as provided in dispatcher - pthread_setname_np(pthread_self(), cAppName); - - if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) { - return eStatus; - } - - FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - try { - HANDLE hFrameworkApp = NULL; - - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(cAppName, hFrameworkApp, FALSE, f_pFrameworkunifiedHSM))) { - if (NULL != hFrameworkApp) { - THApp hApp(hFrameworkApp); - - /// Parse the Arguments via the FrameworkunifiedArgumentParser - /// passing an handle to the app and argument list - eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions); - - if (eFrameworkunifiedStatusOK == eStatus) { - eStatus = FrameworkunifiedHSMDispatcherMain(hApp); - } - } else { - eStatus = eFrameworkunifiedStatusNullPointer; - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL"); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus); - } - } catch (const THApp::Exception &) { - /** - * @todo - * When an exception error occurs in a FrameworkunifiedCreateHSMDispatcher, - * the caller cannot detect the exception because the exception becomes the eFrameworkunifiedStatusOK return code. - */ - FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedHSMCreateDispatcher "); - } - - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Function : FrameworkunifiedHSMDispatcherMain -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Success: FrameworkunifiedCreateDispatcher "); - - if (frameworkunifiedCheckValidAppHandle(hApp)) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - CFrameworkunifiedHSMFramework *l_pStateMachine = pApp->m_pFrameworkunifiedStateMachine; - - if (l_pStateMachine) { - eStatus = l_pStateMachine->FrameworkunifiedStart(); - - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed "); - l_pStateMachine->FrameworkunifiedClose(); - throw happ_error(); - } else { - eStatus = RunDispatcher(hApp); - } - - l_pStateMachine->FrameworkunifiedClose(); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "l_pStateMachine is NULL"); - eStatus = eFrameworkunifiedStatusNullPointer; - } - } - } catch (const frameworkunified::framework::error::CSystemError &err) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what()); - - FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError); - } catch (const THApp::Exception &) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher "); - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Function : FrameworkunifiedSetHSMType -//////////////////////////////////////////////////////////////////////////////////////////// -void FrameworkunifiedSetHSMType(EUserChangeOptions f_eHSMType) { - s_tHSMConfigOptions.eUserChange = f_eHSMType; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Function : FrameworkunifiedEnableAutoPublishServiceAvailable -//////////////////////////////////////////////////////////////////////////////////////////// -void FrameworkunifiedEnableAutoPublishServiceAvailable() { - s_tHSMConfigOptions.bAutoPublishServiceAvaialble = TRUE; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Function : FrameworkunifiedDisableAutoPublishServiceAvailable -//////////////////////////////////////////////////////////////////////////////////////////// -void FrameworkunifiedDisableAutoPublishServiceAvailable() { - s_tHSMConfigOptions.bAutoPublishServiceAvaialble = FALSE; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Function : FrameworkunifiedIsAutoPublishServiceAvailableEnabled -//////////////////////////////////////////////////////////////////////////////////////////// -BOOL FrameworkunifiedIsAutoPublishServiceAvailableEnabled() { - return s_tHSMConfigOptions.bAutoPublishServiceAvaialble; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedHSMEnableWaitInStoppingState -//////////////////////////////////////////////////////////////////////////////////////////// -VOID FrameworkunifiedHSMEnableWaitInStoppingState() { - s_tHSMConfigOptions.bWaitInStoppingState = TRUE; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedHSMDisableWaitInStoppingState -//////////////////////////////////////////////////////////////////////////////////////////// -VOID FrameworkunifiedHSMDisableWaitInStoppingState() { - s_tHSMConfigOptions.bWaitInStoppingState = FALSE; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedIsWaitInStoppingStateEnabled -//////////////////////////////////////////////////////////////////////////////////////////// -BOOL FrameworkunifiedIsWaitInStoppingStateEnabled() { - return s_tHSMConfigOptions.bWaitInStoppingState; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp deleted file mode 100755 index 294dcf5..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived -/// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition -/// from one state to another state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_externaltransition.h> -#include <native_service/frameworkunified_sm_state.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_guard.h> -#include <native_service/frameworkunified_sm_action.h> -#include <vector> -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) { - m_pGuard = NULL; - - // Create the condition list - m_pActionList = new std::vector<CFrameworkunifiedAction * >(); // LCOV_EXCL_BR_LINE 11:except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedExternalTransition::~CFrameworkunifiedExternalTransition() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+"); - if (m_pActionList) { - TActionListIterator l_itActionList = m_pActionList->begin(); - - while (m_pActionList->end() != l_itActionList) { - if (NULL != *l_itActionList) { - delete *l_itActionList; - *l_itActionList = NULL; - } - l_itActionList++; - } - // clear condition list - m_pActionList->clear(); - delete m_pActionList; - m_pActionList = NULL; - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedReaction -/// The reaction for an event is implemented in this function. For external transition, Exit -/// of the source state is called and entry of the target state is called recursively. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedExternalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) { - CFrameworkunifiedState *l_pActiveState = NULL; - BOOL l_bAllowTransition = FALSE; - - try { - CHKNULL(f_pSourceState); - CHKNULL(m_pTargetState); - - // Check if External transition has Guard condition - if (m_pGuard) { - // Evaluate guard condition - l_bAllowTransition = m_pGuard->FrameworkunifiedEvaluate(); - } else { - // If Guard is not available then allow transition - l_bAllowTransition = TRUE; - } - - if (l_bAllowTransition) { - l_pActiveState = ExecuteTransition(f_pSourceState, f_pData); // LCOV_EXCL_BR_LINE 11:except branch - - } else { - // No state changed - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Guard condition for External Transition " - "from state %s to state %s failed" - , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str()); - - l_pActiveState = f_pSourceState; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pActiveState; -} - -EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard) { - EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pGuard); - m_pGuard = f_pGuard; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eFrameworkunifiedStatus; -} - -CFrameworkunifiedState *CFrameworkunifiedExternalTransition::ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) { - CFrameworkunifiedState *l_pActiveState = NULL; - try { - CHKNULL(m_pTargetState); - CHKNULL(f_pSourceState); - CFrameworkunifiedState *l_pTargetState = m_pTargetState; - CFrameworkunifiedState *l_pCurrentState = f_pSourceState; - - - - - // Find the common parent of the source and target state - // and then call recursively OnExit on source state and - // OnEntry on parent state - BOOL l_bFoundCommonParent = FALSE; - while (l_pCurrentState->m_pParentState) { - while (l_pTargetState->m_pParentState) { - // Check if current source state and target state has common parent - if (l_pCurrentState->m_pParentState == l_pTargetState->m_pParentState) { - l_bFoundCommonParent = TRUE; - break; - } else { - // Set the next target parent state - l_pTargetState = l_pTargetState->m_pParentState; - } - } - - if (l_bFoundCommonParent) { - break; - } else { - // Set the next source parent state - l_pCurrentState = l_pCurrentState->m_pParentState; - l_pTargetState = m_pTargetState; - } - } - - if (l_bFoundCommonParent) { - // recursively execute the exit on the current state - l_pCurrentState->FrameworkunifiedOnHSMStop(f_pData); - - // execute actions associated with the external transition - CHKNULL(m_pActionList); - TActionListIterator l_itActionList = m_pActionList->begin(); - - // iterate action list and execute actions - while (m_pActionList->end() != l_itActionList) { - CFrameworkunifiedAction *l_pAction = *l_itActionList; - CHKNULL(l_pAction); - - l_pAction->FrameworkunifiedAction(f_pSourceState, l_pTargetState, f_pData); - - l_itActionList++; - } - - // Set the target state as a active state - CFrameworkunifiedState *l_pState = m_pTargetState; - while (l_pState->m_pParentState != l_pTargetState->m_pParentState) { - CHKNULL(l_pState->m_pParentState); - - l_pState->m_pParentState->m_pActiveState = l_pState; - l_pState = l_pState->m_pParentState; - } - - - // recursively execute the entry on the target state - l_pActiveState = l_pTargetState->FrameworkunifiedOnHSMStart(f_pData); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s" - , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str()); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s failed" - , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str()); - return NULL; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } - - return l_pActiveState; -} - -EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction) { - EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pActionList); - - CHKNULL(f_pAction); - - m_pActionList->push_back(f_pAction); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eFrameworkunifiedStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp deleted file mode 100755 index 8b361fa..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from C -/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Final -/// state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_hsm.h> -#include <string> -#include "frameworkunified_sm_finalstate.h" -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedFinalState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedFinalState::~CFrameworkunifiedFinalState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedFinalState destructor"); -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedFinalState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedFinalState::CFrameworkunifiedFinalState(std::string f_pName): CFrameworkunifiedState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -CFrameworkunifiedState *CFrameworkunifiedFinalState::FrameworkunifiedGetActiveState() { - return this; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedFinalState::UpdateHistory() { - return eFrameworkunifiedStatusOK; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp deleted file mode 100755 index dfb2d5c..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp +++ /dev/null @@ -1,485 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_framework_dispatch.h> -#include <native_service/frameworkunified_framework_if.h> -#include <native_service/frameworkunified_service_protocol.h> -#include <native_service/ns_message_center_if.h> -#include <native_service/ns_logger_if.h> -#include <map> -#include <utility> -#include "frameworkunified_framework_core.h" - -//////////////////////////////////////////////////////////////////////////////////////////// -/// Registers a single event with the dispatcher for a given service. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventToDispatcher(HANDLE hApp, - PCSTR pServiceName, - UI_32 iCmd, - UI_32 iEvent, - HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - EventServices::iterator s_iterator; - EventSessionTable::iterator session_iterator; - - UI_32 uiSessionId = 0; - if (hSession) { - uiSessionId = FrameworkunifiedGetSessionId(hSession); - } - - // finding the service - s_iterator = pApp->eventservices.find(pServiceName); - if (s_iterator == pApp->eventservices.end()) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (service NOT found): service name [%s]", pApp->cAppName, pServiceName); - pApp->eventservices.insert(std::make_pair(pServiceName, EventSessionTable())); - } - - session_iterator = pApp->eventservices[pServiceName].find(uiSessionId); - if (session_iterator == pApp->eventservices[pServiceName].end()) { - pApp->eventservices[pServiceName].insert - (std::make_pair(uiSessionId, ServiceEventProtocolTable())); - } - - (pApp->eventservices[pServiceName].find(uiSessionId)->second).insert(std::make_pair(iCmd, iEvent)); - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAttachHSMEventsToDispatcher -/// Registers a multiple event with the dispatcher for a given service. -//////////////////////////////////////////////////////////////////////////////////////////// - -EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventsToDispatcher(HANDLE hApp, PCSTR pServiceName, - const FrameworkunifiedProtocolEvent *pEventIds, UI_32 uiEventCount, HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName && pEventIds) { - // setup callbacks - for (UI_32 i = 0; i < uiEventCount; ++i) { - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp, - pServiceName, - pEventIds[ i ].iCmd, - pEventIds[ i ].iEventId, - hSession))) { - break; - } - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -///////////////////////////////////////////////////// -// Function : FrameworkunifiedAttachParentCallbacksToDispatcher -///////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedAttachParentHSMEventsToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolEvent *pEventIds, - UI_32 uiEventCount) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hChildApp)) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp); - - eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp, pApp->cParentAppName, pEventIds, uiEventCount); - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -///////////////////////////////////////////////////// -// Function : FrameworkunifiedDetachParentCallbacksFromDispatcher -///////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedDetachParentHSMEventsFromDispatcher(HANDLE hChildApp, - const PUI_32 puiEventArray, UI_32 uiEventCount) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hChildApp)) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp); - - eStatus = FrameworkunifiedDetachHSMEventsFromDispatcher(hChildApp, pApp->cParentAppName, puiEventArray, uiEventCount); - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - - -///////////////////////////////////////////////////// -// Function : FrameworkunifiedDetachHSMEventsFromDispatcher -///////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventsFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiEventArray, - UI_32 uiEventCount, HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) { - // setup callbacks - for (UI_32 i = 0; i < uiEventCount; ++i) { - /** - * @todo - * When an event-struct pointer is turned NULL, the array is accessed without NULL checking, - * and a segmentation fault occurs. - */ - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachHSMEventFromDispatcher(hApp, pServiceName, - puiEventArray[ i ], hSession))) { - break; - } - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - - -///////////////////////////////////////////// -// Function : FrameworkunifiedDetachHSMEventFromDispatcher -///////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iEvent, HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - EventServices::iterator s_iterator; - - UI_32 uiSessionId = 0; - if (hSession) { - uiSessionId = FrameworkunifiedGetSessionId(hSession); - } - - // finding the service - s_iterator = pApp->eventservices.find(pServiceName); - if (s_iterator != pApp->eventservices.end()) { - EventSessionTable::iterator session_iterator; - session_iterator = (s_iterator->second).find(uiSessionId); - if (session_iterator != (s_iterator->second).end()) { - ServiceEventProtocolTable::iterator spt_iterator; - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName); - - spt_iterator = (session_iterator->second).find(iEvent); - if (spt_iterator != (session_iterator->second).end()) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Cmd found [%d] service [%s]", - pApp->cAppName, iEvent, pServiceName); - (session_iterator->second).erase(spt_iterator); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Error : Cmd NOT found [%d] service [%s]", - pApp->cAppName, iEvent, pServiceName); - } - } - - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find service [%s]", pApp->cAppName, pServiceName); - eStatus = eFrameworkunifiedStatusFail; - } - - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAttachNotificationEventsToDispatcher -/// API to attach a event to the dispatcher on receiving a specific notification. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent, - UI_32 uiEventCount) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - /// Deal with handling batch processing of subscriptions. - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationsEvents(hApp, pNtfyEvent, uiEventCount))) { - for (UI_32 i = 0; i < uiEventCount; ++i) { - // service found - pApp->notificationevents.insert(std::make_pair(pNtfyEvent[ i ].cNotification, pNtfyEvent[ i ].iEventId)); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", pApp->cAppName, - pNtfyEvent[ i ].cNotification); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe " - "to batch set of notifications", pApp->cAppName, - eStatus); - } - } else { - eStatus = eFrameworkunifiedStatusInvldParam; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAttachNotificationEventToDispatcher -/// API to attach a event to the dispatcher on receiving a specific notification. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification, UI_32 iEventId) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationEvent(hApp, pNotification))) { - // service found - pApp->notificationevents.insert(std::make_pair(pNotification, iEventId)); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", - pApp->cAppName, pNotification); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe " - "to notification [%s]", pApp->cAppName, eFrameworkunifiedStatusOK, pNotification); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - - - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedDetachNotificationEventsFromDispatcher -/// API to detach a notification event from the dispatcher. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent, - UI_32 uiEventCount) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - NotificationEventTable::iterator n_iterator; - PCSTR pNotification = NULL; - - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(hApp, pNtfyEvent, uiEventCount))) { - for (UI_32 l_unCount = 0; l_unCount < uiEventCount; ++l_unCount) { - pNotification = pNtfyEvent[ l_unCount ].cNotification; - n_iterator = pApp->notificationevents.find(pNotification); - if (n_iterator != pApp->notificationevents.end()) { - pApp->notificationevents.erase(n_iterator); - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]", - pApp->cAppName, pNotification); - eStatus = eFrameworkunifiedStatusFail; - } - } - - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : detaching call-back for notification [%s]", - pApp->cAppName, pNotification); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notifications ", - pApp->cAppName, eFrameworkunifiedStatusOK); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedDetachNotificationEventsFromDispatcher -/// API to detach a notification event from the dispatcher. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - NotificationEventTable::iterator n_iterator; - - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(hApp, pNotification))) { - // \todo : error handling on all map function calls - n_iterator = pApp->notificationevents.find(pNotification); - if (n_iterator != pApp->notificationevents.end()) { - pApp->notificationevents.erase(n_iterator); - FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]", - pApp->cAppName, pNotification); - eStatus = eFrameworkunifiedStatusFail; - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notification [%s]", - pApp->cAppName, eFrameworkunifiedStatusOK, pNotification); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedGetStateMachine -/// returns the pointer to the statemachine object -//////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMFramework *FrameworkunifiedGetStateMachine(HANDLE hApp) { - CFrameworkunifiedHSMFramework *l_pHSMFramework = NULL; - - if (frameworkunifiedCheckValidAppHandle(hApp)) { - CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp); - l_pHSMFramework = pApp->m_pFrameworkunifiedStateMachine; - } - - return l_pHSMFramework; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedSetStateMachine -/// sets the statemachine object -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedSetStateMachine(HANDLE hApp, - CFrameworkunifiedHSM *f_pFrameworkunifiedHSM) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp)) { - if (NULL != f_pFrameworkunifiedHSM) { - (reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp))->m_pFrameworkunifiedStateMachine = - reinterpret_cast<CFrameworkunifiedHSMFramework *>(f_pFrameworkunifiedHSM); - } else { - eStatus = eFrameworkunifiedStatusNullPointer; - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedSubscribeToSessionEventWithHSMEvent -/// This API is used for subscribing to single event of a service. -/// This API also attaches the session event with HSM events. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithHSMEvent(HANDLE hApp, - UI_32 uiEventId, - UI_32 uiHSMEventId, - HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) { - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp, - (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId, - uiHSMEventId, hSession))) { - eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(UI_32), (PVOID)&uiEventId); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedAttachCallbackToDispatcher " - "for PROTOCOL_REGISTER_EVENTS Failed Status:: %d", eStatus); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedSubscribeToSessionEventsWithHSMEvents -/// This API is used for subscribing to multiple events of a service. -/// This API also attaches the session events with hsm events. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithHSMEvents(HANDLE hApp, const FrameworkunifiedProtocolEvent *pEventIds, - UI_32 uiEventCount, - HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventIds) { - eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hApp, - (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventIds, - uiEventCount, hSession); - - UI_32 l_uiCmdList[uiEventCount]; // NOLINT (readability/nolint) - for (UI_32 l_uiCnt = 0; l_uiCnt < uiEventCount; l_uiCnt++) { - l_uiCmdList[l_uiCnt] = pEventIds[l_uiCnt].iCmd; - } - - eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, static_cast<UI_32>(uiEventCount * sizeof(UI_32)), - l_uiCmdList); - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedUnSubscribeSessionEventWithHSMEvent -/// API to unsubscribe from event of a service. Also detaches HSM event. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithHSMEvent(HANDLE hApp, UI_32 uiEventId, HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) { - eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEventId), (PVOID)&uiEventId); - - if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventFromDispatcher(hApp, - (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId, hSession)) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents -/// API to unsubscribe from multiple events of a service. Also detaches HSM events. -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents(HANDLE hApp, PUI_32 pEventsArray, UI_32 uiListSize, - HANDLE hSession) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventsArray) { - eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, - static_cast<UI_32>(uiListSize * sizeof(uiListSize)), pEventsArray); - - if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventsFromDispatcher(hApp, - (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventsArray, - uiListSize)) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus); - } - } else { - eStatus = eFrameworkunifiedStatusInvldHandle; - } - - return eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp deleted file mode 100755 index 7afabdb..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedGuard class definitions. This is an interface that defines the Evaluate -/// interface for guard condition validation. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_guard.h> -#include <string> -CFrameworkunifiedGuard::~CFrameworkunifiedGuard() { -} - -CFrameworkunifiedGuard::CFrameworkunifiedGuard(std::string f_strName): m_strName(f_strName) { -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp deleted file mode 100755 index 9640276..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedHistoryState class definitions. CFrameworkunifiedHistoryState is derived from -/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM History -/// state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_hsm.h> -#include <native_service/frameworkunified_sm_historystate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_framework_if.h> - -#include <string> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedHistoryState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHistoryState::CFrameworkunifiedHistoryState(std::string f_pName): CFrameworkunifiedState(f_pName), m_pLastActiveState(NULL), m_uiEventId(0) { // LCOV_EXCL_BR_LINE 11:except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedHistoryState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHistoryState::~CFrameworkunifiedHistoryState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedHistoryState destructor"); -} - -CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedGetActiveState() { - return this; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - try { - CHKNULL(m_pLastActiveState); - CHKNULL(m_pEventList); - - CFrameworkunifiedExternalTransition *l_pTrnTargetState = new CFrameworkunifiedExternalTransition(m_pLastActiveState); - - m_pActiveState = l_pTrnTargetState->FrameworkunifiedReaction(this, f_pEventData); - CHKNULL(m_pActiveState); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// SetDefaultHistory -/// This function sets the default active state in history state -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHistoryState::SetDefaultHistory() { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(m_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - m_pLastActiveState = m_pParentState->m_pDefaultState; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; // LCOV_EXCL_BR_LINE 11: except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnHSMStart -/// This function internally calls the Entry function of the current state. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pActiveState = this; - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - // Call Entry method of the current state. Entry method of state is called in the order of - // Hierarchy from Outer state to Inner state - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) { - l_pActiveState = m_pActiveState; - } else { - // If FrameworkunifiedOnEntry failed then statemachine should report the error - // We can throw an exception but for now as a quick fix we are setting - // l_pActiveState as NULL which will stop the statemachine - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in state %s", eStatus, - l_pActiveState->m_strStateName.c_str()); - // l_pActiveState = NULL; - /* Commenting it, because it was making state machine inactive. This should not be the expected behavior. - * Just log and take no action, if user return non-ok value. - * User defined error values should be handled separately */ - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pActiveState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnHSMStop -/// This function internally calls the Exit function of the current state. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) { - return this; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp deleted file mode 100755 index f6cdb09..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework. -/// This class implements interfaces for connecting child states to parent states, connecting events -/// to state. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_hsm.h> -#include <native_service/frameworkunified_sm_reaction.h> -#include <native_service/frameworkunified_sm_state.h> -#include <native_service/frameworkunified_sm_compositestate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_orthogonalstate.h> -#include <native_service/frameworkunified_framework_if.h> - -#include <cstdio> -#include <sstream> -#include <string> - -#include "frameworkunified_framework_internal.h" -#include "frameworkunified_sm_framework_core.h" - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedHSM -/// Class constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSM::CFrameworkunifiedHSM(PVOID f_pHApp): m_uiCurrentEvent(0), m_pHApp(f_pHApp), m_pActiveState(NULL), m_pRootState(NULL), - m_bIsTransitioning(FALSE) { - // PostEventList stores the list of events posted in the state - m_pPostEventList = new EventInfoList(); -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedHSM -/// Class constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSM::CFrameworkunifiedHSM(): m_uiCurrentEvent(0), m_pHApp(NULL), m_pActiveState(NULL), m_pRootState(NULL), - m_bIsTransitioning(FALSE) { - // PostEventList stores the list of events posted in the state - m_pPostEventList = new EventInfoList(); - m_pHApp = NULL; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedHSM -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSM::~CFrameworkunifiedHSM() { - if (NULL != m_pPostEventList) { - delete m_pPostEventList; - m_pPostEventList = NULL; - } - - if (m_pRootState) { - FrameworkunifiedClose(); - } - - // we are not deleting this pointer because memory pointed by this pointer - // had already been deleted in above step. - m_pActiveState = NULL; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedGetActiveState -/// Returns the active state of the statemachine -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedHSM::FrameworkunifiedGetActiveState() { - CFrameworkunifiedState *l_pCurrentState = m_pRootState; - CFrameworkunifiedState *l_pActiveState = NULL; - - try { - // Iterate till the current state is leafstate or orthogonal state - while (l_pCurrentState != l_pActiveState) { - l_pActiveState = l_pCurrentState; - l_pCurrentState = l_pCurrentState->FrameworkunifiedGetActiveState(); - CHKNULL(l_pCurrentState); - } - - // Set active state - m_pActiveState = l_pActiveState; - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s " - , m_pActiveState->m_strStateName.c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_pActiveState = NULL; - } - - - return l_pActiveState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedStart -/// This starts the state machine -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedStart(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - m_bIsTransitioning = TRUE; - - // Start the state machine execution on current state - m_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s " - , m_pActiveState->m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - // post the event from events list - eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch - - m_bIsTransitioning = FALSE; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedConnect -/// This connects the reaction to event and add event to child states then add child state -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState, - UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, - BOOL f_bIsDefaultState, BOOL f_bIsDeferredEventType, - std::string f_strEventName) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - // attach reaction to event and add it to the child state - eStatus = FrameworkunifiedConnect(f_pChildState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEventType); - if (eFrameworkunifiedStatusOK == eStatus) { - // add child state to parent state - eStatus = FrameworkunifiedConnect(f_pParentState, f_pChildState, f_bIsDefaultState); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedConnect -/// This add child state to parent state. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState, - BOOL f_bIsDefaultState) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(f_pChildState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - // Check if the state is composite state - if (f_pParentState->FrameworkunifiedHasSubStates()) { - // Check if the child state is default state - if (f_bIsDefaultState) { - // Add child state as default state - (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState, - CFrameworkunifiedCompositeState::eFrameworkunifiedDefaultState); // LCOV_EXCL_BR_LINE 11: except branch - } else { - // Add state as regular state - (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState); // LCOV_EXCL_BR_LINE 11: except branch - } - - f_pChildState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11: except branch - - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error %s is not a composite state", - f_pParentState->m_strStateName.c_str()); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; //LCOV_EXCL_BR_LINE 11:except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedConnect -/// This connects the reaction to event and add event to child states -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, - std::string f_strEventName , BOOL f_bIsDeferredEventType) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - // check if the event is deferred event - if (f_bIsDeferredEventType) { - // Add event as deferred event - f_pState->FrameworkunifiedAddDeferredEvent(f_uiEventId, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Deferred Event %d %s is " - "associated with Reaction and added to state %s " - , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str()); - // LCOV_EXCL_BR_STOP - } else { - CHKNULL(f_pReaction); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - // Add event as regular event - f_pState->FrameworkunifiedAddEvent(f_uiEventId, f_pReaction, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch - - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Event %d %s is associated with Reaction and added to state %s " - , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str()); - // LCOV_EXCL_BR_STOP - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d in %s", f_uiEventId, - (f_pState->m_strStateName).c_str()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus;; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPostEvent -/// This creates the default event data and sends the event to the active HSM state. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(UI_32 f_uiEventId) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 11: except branch - try { - CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch - CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - l_eStatus = FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11: except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPostEvent -/// This sends the event to the active HSM state -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - if (m_bIsTransitioning) { - eStatus = FrameworkunifiedQueueEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch - } else { - m_bIsTransitioning = TRUE; - - eStatus = ProcessEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch - - m_bIsTransitioning = FALSE; - - CHKNULL(m_pActiveState); - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEvent(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pActiveState->m_pEventName); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - EventNameList::iterator l_itEventName; - l_itEventName = m_pActiveState->m_pEventName->find(f_pEventData->m_uiEventId); - - if (m_pActiveState->m_pEventName->end() != l_itEventName) { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Posting event %d %s to state %s", - f_pEventData->m_uiEventId, - l_itEventName->second.c_str(), - m_pActiveState->m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - } - - m_uiCurrentEvent = f_pEventData->m_uiEventId; - - // Send event to active state for processing - m_pActiveState = m_pActiveState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - - CHKNULL(m_pActiveState); - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - - // post the event from events list - eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedClose -/// This stops the state machine and destroys all states and events -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedClose(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pRootState); - delete m_pRootState; - m_pRootState = NULL; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedConnect -/// This sets the givens state as root state in the state machine -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - m_pActiveState = f_pRootState; - m_pRootState = f_pRootState; - - m_pRootState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11:except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; // LCOV_EXCL_BR_LINE 11:except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPrintAllStates -/// This prints all states and events associated with every state on console. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintAllStates() { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - // Print the states - m_pRootState->FrameworkunifiedPrintStates(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; // LCOV_EXCL_BR_LINE 11:except branch -} - -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState, - CFrameworkunifiedCompositeState *f_pOrthogonalRegion) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pOrthogonalState) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(f_pOrthogonalRegion) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - f_pOrthogonalState->FrameworkunifiedAddOrthogonalRegion(f_pOrthogonalRegion); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -HANDLE CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle() { - return m_pHApp; -} - -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintXML() { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - try { - std::ostringstream l_strXMLString; - l_strXMLString << "<Statemachine>"; - - CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - // Write statemachine information in XML stream - m_pRootState->FrameworkunifiedPrintXML(l_strXMLString); - l_strXMLString << "</Statemachine>"; - - // Write a stream to XML file - if (m_pHApp) { - size_t l_uiLength = static_cast<size_t>(l_strXMLString.str().length()); - - PCHAR l_pStream = new CHAR[l_uiLength + 1]; - if (NULL != l_pStream) { - std::FILE *l_pFile = NULL; - - std::memset(l_pStream, 0, l_uiLength + 1); - std::strncpy(l_pStream, l_strXMLString.str().c_str(), l_uiLength); - - std::ostringstream l_strFileName; - - l_strFileName << "StatemachineXML_"; - - l_strFileName << FrameworkunifiedGetAppName(m_pHApp) << ".xml"; - - l_pFile = std::fopen(l_strFileName.str().c_str(), "wbe"); - - if (l_pFile) { - std::fwrite(l_pStream, l_uiLength, 1, l_pFile); - std::fclose(l_pFile); - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s File Created" - , l_strFileName.str().c_str()); - } - delete[] l_pStream; - l_pStream = NULL; - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: StatemachineXML_%s.xml file not created", FrameworkunifiedGetAppName(m_pHApp)); - } - } - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, l_strXMLString.str().c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } - return l_eStatus; -} - -EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - // Push the event in the post event list(FIFO) - m_pPostEventList->push_back(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; // LCOV_EXCL_BR_LINE 11:except branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ProcessEventQueue -/// This post the event from events list -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEventQueue() { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - if (!m_pPostEventList->empty()) { - CEventDataPtr l_pEventData = m_pPostEventList->front(); // LCOV_EXCL_BR_LINE 11:except branch - CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Processing posted event %d in state %s", - l_pEventData->m_uiEventId, m_pActiveState->m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - m_pPostEventList->erase(m_pPostEventList->begin()); - - eStatus = ProcessEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// RemoveEventFromPostedEventQueue -/// This API is used to remove the all events of eventId f_uiEventId from event queue of statemachine -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSM::RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID; - FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+"); - - if (NULL != m_pPostEventList) { - int32_t l_siCnt = static_cast<int32_t>(m_pPostEventList->size() - 1); - - for (; l_siCnt >= 0; l_siCnt--) { - if (NULL != m_pPostEventList->at(l_siCnt).get()) { - if (f_uiEventId == m_pPostEventList->at(l_siCnt).get()->m_uiEventId) { - m_pPostEventList->erase(m_pPostEventList->begin() + l_siCnt); - l_eStatus = eFrameworkunifiedStatusOK; - } - } - } - } else { - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-"); - return l_eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp deleted file mode 100755 index da060f2..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp +++ /dev/null @@ -1,1419 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from -/// CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS -/// statemachine and implements the reaction associated with the events -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_hsmframework.h> -#include <native_service/frameworkunified_framework_if.h> -#include <native_service/frameworkunified_framework_types.h> -#include <native_service/ns_np_service_protocol.h> -#include <native_service/ns_np_service_notification.h> -#include <native_service/frameworkunified_sm_framework_dispatch.h> -#include <native_service/ns_plogger_if.h> - -#include <map> -#include <string> - -#include "frameworkunified_framework_core.h" -#include "frameworkunified_framework_internal.h" -#include "frameworkunified_framework_utility.h" -#include "frameworkunified_sm_framework_core.h" - -extern EFrameworkunifiedStatus FrameworkunifiedHSMOnLoadData(HANDLE hApp) __attribute__((weak)); -extern EFrameworkunifiedStatus FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(HANDLE hApp) __attribute__((weak)); - -CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(): CFrameworkunifiedHSM() { -} -CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(PVOID f_pHApp): CFrameworkunifiedHSM(f_pHApp) { -} -CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(): CFrameworkunifiedHSMFramework() { - try { - m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedHSMParentFramework -/// default constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) { - try { - m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedHSMParentFramework -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::~CFrameworkunifiedHSMParentFramework() { - // TODO(framework_unifeid) Auto-generated destructor stub -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreate -/// Statemachine states and events created and connected in this interface. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedCreate(PVOID f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - HSMConfigOptions *l_tHSMConfig = NULL; - try { - if (f_pEventData) { - l_tHSMConfig = reinterpret_cast<HSMConfigOptions *>(f_pEventData); - } - - // Create states - CREATE_STATE(sFrameworkunifiedRoot) - CREATE_STATE(sFrameworkunifiedApp) - CREATE_STATE(sFrameworkunifiedInitialization) - CREATE_STATE(sFrameworkunifiedLoadData) - CREATE_STATE(sFrameworkunifiedRun) - CREATE_STATE(sFrameworkunifiedLoadSessions) - CREATE_STATE(sFrameworkunifiedReady) - CREATE_STATE(sFrameworkunifiedStop) - CREATE_STATE(sFrameworkunifiedStopping) - CREATE_STATE(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CREATE_STATE(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - // connect states as per the statemachine - CONNECT_DEFAULTSTATE(sFrameworkunifiedRoot, sFrameworkunifiedApp) - CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedStop) - - CONNECT_DEFAULTSTATE(sFrameworkunifiedApp, sFrameworkunifiedInitialization) - CONNECT_STATE(sFrameworkunifiedApp, sFrameworkunifiedRun) - - CONNECT_DEFAULTSTATE(sFrameworkunifiedInitialization, sFrameworkunifiedLoadData) - CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - CONNECT_DEFAULTSTATE(sFrameworkunifiedRun, sFrameworkunifiedLoadSessions) - CONNECT_STATE(sFrameworkunifiedRun, sFrameworkunifiedReady) - - CONNECT_DEFAULTSTATE(sFrameworkunifiedStop, sFrameworkunifiedStopping) - - // Create External Transition - CREATE_EXTERNALTRANSITION(sFrameworkunifiedApp) - CREATE_EXTERNALTRANSITION(sFrameworkunifiedStop) - - CREATE_EXTERNALTRANSITION(sFrameworkunifiedLoadSessions) - CREATE_EXTERNALTRANSITION(sFrameworkunifiedReady) - - CREATE_EXTERNALTRANSITION(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CREATE_EXTERNALTRANSITION(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - // CREATE_ACTION(aFrameworkunifiedOnStart) - - // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION - CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedRunevFrameworkunifiedStart = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedRun); - - // CONNECT_ACTION(sFrameworkunifiedRunevFrameworkunifiedStart,aFrameworkunifiedOnStart) - - // Connecting events to sFrameworkunifiedInitialization state - CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedStart, sFrameworkunifiedRunevFrameworkunifiedStart) - CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedPreStart, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedBackgroundStart, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - - // Create Local transitions - CREATE_LOCALTRANSITION(sFrameworkunifiedInitialization); - CREATE_LOCALTRANSITION(sFrameworkunifiedStop); - - // Connect events to state - - // Connecting events to sFrameworkunifiedLoadData state - CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedStart) - CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedUserChange) - CONNECT_LOCAL_EVENT(sFrameworkunifiedLoadData, evFrameworkunifiedLoadComplete, sFrameworkunifiedInitialization) - - // Connecting events to App state - CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedStop, sFrameworkunifiedStop) - CONNECT_LOCAL_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStopComplete, sFrameworkunifiedStop) - CONNECT_DEFERREDEVENT(sFrameworkunifiedStopping, evFrameworkunifiedStart) - - // Connecting events to Connecting state - CONNECT_EVENT(sFrameworkunifiedLoadSessions, evFrameworkunifiedReady, sFrameworkunifiedReady) - // CONNECT_EVENT(sFrameworkunifiedReady,evFrameworkunifiedLoadSessions,sFrameworkunifiedRun) - CONNECT_EVENT(sFrameworkunifiedReady, evFrameworkunifiedLoadSessions, sFrameworkunifiedLoadSessions) - - // Connecting events to Stop state - CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedInit, sFrameworkunifiedApp) - - // Create internal transitions - CREATE_INTERNALTRANSITION(OnEventStartInStopState) - CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedStart, OnEventStartInStopState) - - CREATE_INTERNALTRANSITION(OnEventStopInStoppingState) - CONNECT_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStop, OnEventStopInStoppingState) - - // Connecting events to sFrameworkunifiedRun state - CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedBackgroundStop, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - - // Connecting events to sFrameworkunifiedBackground state - CONNECT_EVENT(sFrameworkunifiedBackground, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - if (NULL != l_tHSMConfig) { - if (eUserchangeIgnore != l_tHSMConfig->eUserChange) { - if (eUserchangeReInit == l_tHSMConfig->eUserChange) { - // Create Internal Transition - CREATE_INTERNALTRANSITION(OnEventUserChangeInInitializationState) - CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedUserChange, OnEventUserChangeInInitializationState) - - // Create Internal Transition - CREATE_INTERNALTRANSITION(OnEventUserChangeInRunState) - CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedUserChange, OnEventUserChangeInRunState) - - CREATE_ACTION(aFrameworkunifiedOnStop) - - // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION - CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedAppevFrameworkunifiedInit = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedApp); - - CONNECT_ACTION(sFrameworkunifiedAppevFrameworkunifiedInit, aFrameworkunifiedOnStop) - - CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedInit, sFrameworkunifiedAppevFrameworkunifiedInit) - - } else if (eUserchangeRetPrevState == l_tHSMConfig->eUserChange) { - CREATE_STATE(sFrameworkunifiedUserChange) - - CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedUserChange) - - CREATE_EXTERNALTRANSITION(sFrameworkunifiedUserChange) - - CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedUserChange, sFrameworkunifiedUserChange) - CONNECT_EVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStop, sFrameworkunifiedStop) - - CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStart) - CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChange) - - // add shallow history state in state sFrameworkunifiedApp - ADD_SHALLOWHISTORYSTATE(sFrameworkunifiedApp) - - // create transition to shallow history state in state sFrameworkunifiedApp - CREATE_SHALLOWHISTORYTRANSITION(sFrameworkunifiedApp) - - // Connecting events to UserChange State - CONNECT_SHALLOWHISTORYEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChangeComplete, sFrameworkunifiedApp) - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Incorrect Userchange config option %d", l_tHSMConfig->eUserChange); - } - } - } - - // Connecting FrameworkRoot to statemachine - CONNECTROOT(sFrameworkunifiedRoot) - - // Creating the application specific statemachine - CHKNULL(m_pHApp); - FrameworkunifiedCreateStateMachineInternal(m_pHApp); - - // Print statemachine xml - PRINT_HSM(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedFrameworkConnect -/// This adds the given state as a sub state of sReady state of the Framework -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pFrameworkunifiedStateList); - CHKNULL(f_pAppState); - - if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady) == m_pFrameworkunifiedStateList->end()) { - throw CNullPointerException(); - } - CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady)->second); - CHKNULL(l_pReady); - - eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedFrameworkConnect -/// This connects the reaction to event and add event to states -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId, - CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName, - BOOL f_bIsDeferredEvent) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pFrameworkunifiedStateList); - - if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) { - throw CNullPointerException(); - } - CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second); - - CHKNULL(l_pFrameworkunifiedState); - - eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedRoot -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::CsFrameworkunifiedRoot(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedRoot -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::~CsFrameworkunifiedRoot() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// Initializes the application and registers the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +"); - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedOnInitializationInternal(l_pHApp))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to Initialize application:0x%x ", eStatus); - } - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -"); - - // Publish service unavailability - if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", eStatus); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published"); - } - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedApp -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::CsFrameworkunifiedApp(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedRoot -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::~CsFrameworkunifiedApp() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// Initializes the application and registers the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedUserChange -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::CsFrameworkunifiedUserChange(std::string f_pName): CFrameworkunifiedLeafState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedRoot -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::~CsFrameworkunifiedUserChange() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// Initializes the application and registers the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedUserChangeComplete"); - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No reaction for loading user specific data "); - - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete)); - } else { - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData)); - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedInitialization -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::CsFrameworkunifiedInitialization(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedInitialization -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::~CsFrameworkunifiedInitialization() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInInitializationState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, - CEventDataPtr f_pEventData) { - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInInitializationState"); - CHKNULL(f_pSourceState); - - // post the event to move to sFrameworkunifiedApp state - f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit)); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return f_pSourceState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedLoadData -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::CsFrameworkunifiedLoadData(std::string f_pName): CFrameworkunifiedLeafState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedLoadData -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::~CsFrameworkunifiedLoadData() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - try { - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - - CHKNULL(FrameworkunifiedGetStateMachine(l_pHApp)); - - UI_32 l_uiCurrentEventId = FrameworkunifiedGetStateMachine(l_pHApp)->m_uiCurrentEvent; - if (!(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete) == l_uiCurrentEventId)) { - if (FrameworkunifiedHSMOnLoadData) { - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedHSMOnLoadData(l_pHApp))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to load application data:0x%X ", eStatus); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnLoadData not defined by the application"); - } - - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent(l_pHApp, - NTFY_NPPService_UserChange, - FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChange)))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithHSMEvent " - "NTFY_NPPService_UserChange Failed Status:0x%x ", eStatus); - return eStatus; - } - // Attach callback : Event to start the StateMachine - if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(l_pHApp, - FRAMEWORKUNIFIED_ANY_SOURCE, - NPS_GET_PERS_FILE_ACK, - FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck)))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, - "FrameworkunifiedAttachCallbackToDispatcher NPS_GET_PERS_FILE_ACK (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ", eStatus); - return eStatus; - } - if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedLoadFileAck"); - - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete)); - } - } else { - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete)); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - try { - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - - CFrameworkunifiedHSM *l_pHSM = FrameworkunifiedGetStateMachine(l_pHApp); - CHKNULL(l_pHSM); - - UI_32 l_uiCurrentEventId = l_pHSM->m_uiCurrentEvent; - - if (FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) == l_uiCurrentEventId) { - l_pHSM->RemoveEventFromPostedEventQueue(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart)); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedPre -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::CsFrameworkunifiedPre(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length) -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedPre -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::~CsFrameworkunifiedPre() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - // Only evFrameworkunifiedPreStart or evFrameworkunifiedPreStop events occur when functions are executed. - if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStart)) { - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - eStatus = FrameworkunifiedOnPreStartInternal(l_pHApp); - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre start application:0x%x ", eStatus); - } - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - } else { - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - eStatus = FrameworkunifiedOnPreStopInternal(l_pHApp); - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre stop application:0x%x ", eStatus); - } - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedBackground -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::CsFrameworkunifiedBackground(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length) -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedBackground -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::~CsFrameworkunifiedBackground() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions - - // Only evFrameworkunifiedBackgroundStart or evFrameworkunifiedBackgroundStop events occur when functions are executed. - if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStart)) { - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - eStatus = FrameworkunifiedOnBackgroundStartInternal(l_pHApp); - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background start application:0x%x ", eStatus); - } - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - } else { - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - eStatus = FrameworkunifiedOnBackgroundStopInternal(l_pHApp); - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background stop application:0x%x ", eStatus); - } - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length) - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedRun -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::CsFrameworkunifiedRun(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedRun -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::~CsFrameworkunifiedRun() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// Subscribes for the service availability notification and calls FrameworkunifiedOnStart -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - try { - HANDLE hApp = FrameworkunifiedGetAppHandle(); - - if (frameworkunifiedCheckValidAppHandle(hApp)) { - FrameworkunifiedOnStartInternal(hApp); - - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) { - ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount); - - if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent - (hApp, objNotification.sNotificationName, objNotification.uiEventId))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to subscribe notification %s" - , objNotification.sNotificationName); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully subscribe notification %s" - , objNotification.sNotificationName); - } - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL"); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - - try { - HANDLE hApp = FrameworkunifiedGetAppHandle(); - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - if (frameworkunifiedCheckValidAppHandle(hApp)) { - // Let application also handle exit of sFrameworkunifiedRun state - if (FrameworkunifiedHSMOnStopInsFrameworkunifiedRun) { - if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(hApp))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun returned: 0x%X ", l_eStatus); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun not defined by the application"); - } - - for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) { - ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount); - - if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithHSMEvent(hApp, - objNotification.sNotificationName))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to unsubscribe notification %s", - objNotification.sNotificationName); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully unsubscribed from notification %s", - objNotification.sNotificationName); - } - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL"); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInRunState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, - CEventDataPtr f_pEventData) { - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInRunState"); - CHKNULL(f_pSourceState); - - // post the event to move to sFrameworkunifiedApp state - f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit)); - - CHKNULL(f_pSourceState); - - // post the event to move to sFrameworkunifiedRun state - f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart)); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - return f_pSourceState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedLoadSessions -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::CsFrameworkunifiedLoadSessions(std::string f_pName): CFrameworkunifiedLeafState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedLoadSessions -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::~CsFrameworkunifiedLoadSessions() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - HANDLE hApp = FrameworkunifiedGetAppHandle(); - CHKNULL(hApp); - - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp); - - if (!pApp->servicenotificationlist.size()) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No Mandatory services set "); - - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady)); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Wait for service availability of mandatory services "); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedReady -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::CsFrameworkunifiedReady(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedReady -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::~CsFrameworkunifiedReady() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - try { - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) - // Publish Service available this can also be published from FrameworkunifiedOnStart callback - if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, TRUE))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "warning:Failed to Publish service availability notification:0x%x ", - l_eStatus); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service available published"); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled"); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - try { - ServiceSessionTable::iterator session_iterator; - SessionHandleTable::iterator session_handle_iterator; - - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - - if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) - // Publish Service available this can also be published from FrameworkunifiedOnStart callback - if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", l_eStatus); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published"); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled"); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedStop -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::CsFrameworkunifiedStop(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedStop -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::~CsFrameworkunifiedStop() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - try { - HANDLE l_pHApp = FrameworkunifiedGetAppHandle(); - CHKNULL(l_pHApp); - - // every application need to implement this function - // all the resource deallocation like file release,etc should be done in this callback - l_eStatus = FrameworkunifiedOnStopInternal(l_pHApp); - if (eFrameworkunifiedStatusOK != l_eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: FrameworkunifiedOnStop returned %d", l_eStatus); - // We just need to print the error. - // Returning this status to state machine is not required. - // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead. - l_eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok. - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CsFrameworkunifiedStopping -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::CsFrameworkunifiedStopping(std::string f_pName): CFrameworkunifiedLeafState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedStopping -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::~CsFrameworkunifiedStopping() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - try { - if (FrameworkunifiedIsWaitInStoppingStateEnabled()) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event evFrameworkunifiedStopComplete not posted. User has to post it."); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedStopAck"); - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Posting event evFrameworkunifiedStopComplete"); - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStopComplete)); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStopInStoppingState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, - CEventDataPtr f_pEventData) { - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStopInStoppingState"); - CHKNULL(f_pSourceState); - - (VOID)f_pSourceState->FrameworkunifiedRemoveEventFromDeferredEventList(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart)); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - return f_pSourceState; -} - -CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStartInStopState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, - CEventDataPtr f_pEventData) { - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStartInStopState"); - CHKNULL(f_pSourceState); - - // post the event to move to sFrameworkunifiedApp state - f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit)); - - CHKNULL(f_pSourceState); - - // post the event to transit to sFrameworkunifiedRun state - f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart)); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - return f_pSourceState; -} - -VOID CFrameworkunifiedHSMParentFramework::CaFrameworkunifiedOnStop::FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState, - CEventDataPtr f_pData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Action %s", m_strName.c_str()); - - HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle(); - if (NULL != l_pHApp) { - FrameworkunifiedOnStopInternal(l_pHApp); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Application handle is NULL in Action %s", m_strName.c_str()); - } -} - -CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(): CFrameworkunifiedHSMFramework() { -} - - -CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) { - try { - m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } -} - -CFrameworkunifiedHSMChildFramework::~CFrameworkunifiedHSMChildFramework() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreate -/// Statemachine states and events created and connected in this interface. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedCreate(PVOID f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - // Create states - CREATE_STATE(sFrameworkunifiedThreadRoot) - CREATE_STATE(sFrameworkunifiedThreadIdle) - CREATE_STATE(sFrameworkunifiedThreadStart) - CREATE_STATE(sFrameworkunifiedThreadReady) - CREATE_STATE(sFrameworkunifiedThreadStop) - - // connect states as per the statemachine - CONNECT_DEFAULTSTATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadIdle) - CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStart) - CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStop) - CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadReady) - - // Create External Transition - CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadIdle) - CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStart) - CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadReady) - CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStop) - - // Connect events to state - CONNECT_EVENT(sFrameworkunifiedThreadIdle, evFrameworkunifiedStart, sFrameworkunifiedThreadStart) - CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedReady, sFrameworkunifiedThreadReady) - CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedError, sFrameworkunifiedThreadIdle) - CONNECT_EVENT(sFrameworkunifiedThreadReady, evFrameworkunifiedStop, sFrameworkunifiedThreadStop) - CONNECT_EVENT(sFrameworkunifiedThreadStop, evFrameworkunifiedStart, sFrameworkunifiedThreadStart) - - // Create Internal Transition - CREATE_INTERNALTRANSITION(OnDestroyThread) - CONNECT_EVENT(sFrameworkunifiedThreadRoot, evFrameworkunifiedDestroy, OnDestroyThread) - - // Connecting AppRoot to statemachine - CONNECTROOT(sFrameworkunifiedThreadRoot) - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// COnDestroyThread::FrameworkunifiedReaction -/// This reaction is executed when request for terminating the thread is received. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedHSMChildFramework::COnDestroyThread::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, - CEventDataPtr f_pEventData) { - // return the NULL to exit the dispatcher loop of thread - return NULL; -} - -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pFrameworkunifiedStateList); - CHKNULL(f_pAppState); - - if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady) == m_pFrameworkunifiedStateList->end()) { - throw CNullPointerException(); - } - CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady)->second); - CHKNULL(l_pReady); - - eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId, - CFrameworkunifiedReaction *f_pReaction, - std::string f_strEventName, BOOL f_bIsDeferredEvent) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pFrameworkunifiedStateList); - - if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) { - throw CNullPointerException(); - } - CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second); - - CHKNULL(l_pFrameworkunifiedState); - - eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedThreadRoot -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::CsFrameworkunifiedThreadRoot(std::string f_pName) - : CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedThreadRoot -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::~CsFrameworkunifiedThreadRoot() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// publishes the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedThreadIdle -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::CsFrameworkunifiedThreadIdle(std::string f_pName) - : CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedThreadIdle -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::~CsFrameworkunifiedThreadIdle() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// publishes the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedThreadStart -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::CsFrameworkunifiedThreadStart(std::string f_pName) - : CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedThreadStart -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::~CsFrameworkunifiedThreadStart() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// publishes the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * > - (FrameworkunifiedGetAppHandle()); - CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine)); - CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread); - if (eFrameworkunifiedStatusOK == - (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread(pApp)) { - FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady)); - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Thread start Failed: %s", m_strStateName.c_str()); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedThreadReady -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::CsFrameworkunifiedThreadReady(std::string f_pName) - : CFrameworkunifiedCompositeState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedThreadReady -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::~CsFrameworkunifiedThreadReady() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// publishes the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedThreadStop -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::CsFrameworkunifiedThreadStop(std::string f_pName) - : CFrameworkunifiedLeafState(f_pName) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CsFrameworkunifiedThreadStop -/// class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::~CsFrameworkunifiedThreadStop() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// publishes the service availability notification -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - - HANDLE hApp = FrameworkunifiedGetAppHandle(); - CHKNULL(hApp); - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * > - (hApp); - CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine)); - CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread); - - eStatus = (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread(pApp); - - if (eFrameworkunifiedStatusOK != eStatus) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: Thread stop function returned %d", eStatus); - // We just need to print the error. - // Returning this status to state machine is not required. - // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead. - eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok. - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp deleted file mode 100755 index 6c44ebb..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedLeafState class definitions. CFrameworkunifiedLeafState is derived from C -/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Leafstate. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_leafstate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <string> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedLeafState::CFrameworkunifiedLeafState(std::string f_pName): CFrameworkunifiedState(f_pName) { // LCOV_EXCL_BR_LINE 11:Unexpected branch -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedLeafState::~CFrameworkunifiedLeafState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CFrameworkunifiedLeafState destructor"); -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -CFrameworkunifiedState *CFrameworkunifiedLeafState::FrameworkunifiedGetActiveState() { - return this; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedLeafState::UpdateHistory() { - return eFrameworkunifiedStatusOK; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp deleted file mode 100755 index b5f9c0a..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_localtransition.h> -#include <native_service/frameworkunified_sm_state.h> -#include <native_service/frameworkunified_sm_framework_types.h> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedExternalTransition -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedLocalTransition::CFrameworkunifiedLocalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedExternalTransition -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedLocalTransition::~CFrameworkunifiedLocalTransition() { -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedReaction -/// The reaction for an event is implemented in this function. For local transition from inner -/// state to outer state exit of the inner state is invoked, but entry of outer state is not -/// invoked and from outer state to inner state entry of the inner state is invoked but exit of -/// outer state is not invoked -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedLocalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) { - CFrameworkunifiedState *l_pActiveState = NULL; - CFrameworkunifiedState *l_pCurrentState = NULL; - try { - CHKNULL(f_pSourceState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pTargetState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h - - // Local transition from inner state to outer state - if (f_pSourceState->m_pParentState == m_pTargetState) { - // Source is child of target - l_pCurrentState = f_pSourceState->FrameworkunifiedOnHSMStop(f_pData); - - if (l_pCurrentState == f_pSourceState) { - l_pActiveState = m_pTargetState; - - } else { - l_pActiveState = l_pCurrentState; - } - - /** - * @todo - * If the parent state is registered and OnEvent is performed without OrthogonalReigonList, illegal accesses occur. - */ - l_pActiveState->m_pActiveState = NULL; - - // Local transition from outer state to inner state - } else if (f_pSourceState == m_pTargetState->m_pParentState) { - // Source is parent to target state - l_pActiveState = m_pTargetState->FrameworkunifiedOnHSMStart(f_pData); - } - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Local Transition from state %s to state %s" - , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str()); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - - return NULL; - } - - return l_pActiveState; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp deleted file mode 100755 index 33dab56..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief This file has the function implementation for creating state machine child thread -/// -/// -////////////////////////////////////////////////////////////////////////////////////////////////// -#include <sys/prctl.h> - -#include <native_service/frameworkunified_sm_hsmframework.h> -#include <native_service/frameworkunified_sm_framework_dispatch.h> -#include <native_service/frameworkunified_framework_if.h> -#include <native_service/ns_utility.hpp> -#include <native_service/ns_system_mode.h> -#include <native_service/frameworkunified_sm_multithreading.h> -#include <native_service/frameworkunified_multithreading.h> - -#include <iostream> -#include <string> - -#include "frameworkunified_framework_utility.h" -#include "frameworkunified_framework_core.h" -#include "frameworkunified_framework_internal.h" - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreateHSMDispatcherChild -//////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcherChild(PCSTR childName, - PCSTR parentName, - HANDLE &hChildApp, // NOLINT (readability/nolint) - CbFuncPtr pOnThreadStart, - CbFuncPtr pOnThreadStop) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - if ((NULL != childName) && (NULL != parentName) && (strlen(childName) <= MAX_NAME_SIZE_APP) && - (strlen(parentName) <= MAX_NAME_SIZE_APP)) { - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(childName, hChildApp, TRUE))) { - if (frameworkunifiedCheckValidAppHandle(hChildApp)) { - CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp); - - (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread - = pOnThreadStart; - - (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread - = pOnThreadStop; - - pApp->hParentSndMsgQ = McOpenSender(parentName); - if (NULL == pApp->hParentSndMsgQ) { - eStatus = eFrameworkunifiedStatusNullPointer; - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "McOpenSender failed"); - return eStatus; - } - pApp->uiSessionId = THREAD_SESSION_ID; - - memset(pApp->cParentAppName, 0, sizeof(pApp->cParentAppName)); - memcpy(pApp->cParentAppName, parentName, strlen(parentName)); - } else { - eStatus = eFrameworkunifiedStatusNullPointer; - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hChildApp is NULL"); - } - } else { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus); - // LCOV_EXCL_BR_STOP - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid Param received"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - eStatus = eFrameworkunifiedStatusInvldParam; - } - - return eStatus; -} - -void *child_hsm_thread_proc(void *args) { - if (args == NULL) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "args is NULL"); - return NULL; - } - PCData pcdata = *reinterpret_cast< PCData * >(args); // Create a local copy of data - - try { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - HANDLE hFrameworkApp = NULL; - - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcherChild(pcdata.childName.c_str(), - pcdata.parentName.c_str(), - hFrameworkApp, - pcdata.initFn, - pcdata.shdnFn))) { - if (NULL != hFrameworkApp) { - THApp hChildApp(hFrameworkApp); - - if (pcdata.CbCreateStateMachine) { - pcdata.CbCreateStateMachine(hChildApp); - FRAMEWORKUNIFIED_PRINT_HSM(hChildApp) - } - const FrameworkunifiedProtocolEvent pcbhs[] = { { SYSTEM_ON_INITIALIZATION, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart) }, - { SYSTEM_ON_SHUTDOWN, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) }, - { SYSTEM_ON_DESTROY, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedDestroy) } - }; - - if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp, - pcdata.parentName.c_str(), - &pcbhs[ 0 ], - static_cast<UI_32>(_countof(pcbhs)), - NULL)) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to attach hsm events to child thread %s", - pcdata.childName.c_str()); - } - - // set child thread name - char thread_name[16]; - strncpy(thread_name, pcdata.childName.c_str(), sizeof(thread_name)); - prctl(PR_SET_NAME, thread_name); - thread_name[15] = '\0'; - - setChildThreadSched(pcdata.schedPolicy, pcdata.schedPriority); - - (FrameworkunifiedGetStateMachine(hChildApp))->FrameworkunifiedStart(); - - *pcdata.childStatus = eFrameworkunifiedStatusOK; - if (IsValidWaitBarrier(pthread_barrier_wait(pcdata.barrier))) { - RunChildDispatcher(hChildApp); - } - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL"); - } - } else { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcherChild error, status=%d", eStatus); - // LCOV_EXCL_BR_STOP - - *pcdata.childStatus = eFrameworkunifiedStatusFail; - pthread_barrier_wait(pcdata.barrier); - } - } catch (const THApp::Exception &) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to create child %s", pcdata.childName.c_str()); - } - - return NULL; -} - - - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreateHSMChildThread -//////////////////////////////////////////////////////////////////////////////////////////// -HANDLE FrameworkunifiedCreateHSMChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, - CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine) { - HANDLE hChildQ = NULL; - FrameworkunifiedChildThreadAttr attr; - - if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown && - NULL != CbCreateStateMachine) { - CreateChildThreadAttrInit(&attr); - hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine); - } - - return hChildQ; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreateHSMChildThreadWithPriority -//////////////////////////////////////////////////////////////////////////////////////////// -HANDLE FrameworkunifiedCreateHSMChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, - CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine, SI_32 schedPrio) { - HANDLE hChildQ = NULL; - FrameworkunifiedChildThreadAttr attr; - - if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown && - NULL != CbCreateStateMachine) { - CreateChildThreadAttrInit(&attr); - CreateChildThreadAttrSetSched(&attr, eFrameworkunifiedSchedPolicyRR, schedPrio); - hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine); - } - return hChildQ; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedCreateHSMChildThreadWithAttribute -//////////////////////////////////////////////////////////////////////////////////////////// -HANDLE FrameworkunifiedCreateHSMChildThreadWithAttribute(HANDLE hApp, - PCSTR childName, - CbFuncPtr CbInitialize, - CbFuncPtr CbShutdown, - CbFuncPtr CbCreateStateMachine, - const FrameworkunifiedChildThreadAttr *attr) { - HANDLE hChildQ = NULL; - - if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown && - NULL != CbCreateStateMachine) { - hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, attr, CbCreateStateMachine); - } - return hChildQ; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp deleted file mode 100755 index a8289a0..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedOrthogonalState class definitions. CFrameworkunifiedOrthogonalState is derived from -/// CFrameworkunifiedCompositeState class.This class implements the additional functionality supported by HSM -/// Orthogonal state. It provides the standard interfaces for adding orthogonal state machines. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_orthogonalstate.h> -#include <native_service/frameworkunified_sm_compositestate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_hsm.h> -#include <sstream> -#include <string> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedCompositeState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedOrthogonalState::CFrameworkunifiedOrthogonalState(std::string f_pName): CFrameworkunifiedState(f_pName) { - try { - m_pOrthogonalReigonList = new OrthogonalRegionList(); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedOrthogonalState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedOrthogonalState::~CFrameworkunifiedOrthogonalState() { - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - delete m_pOrthogonalReigonList->at(l_uiCount); - } - } - m_pOrthogonalReigonList->clear(); - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedOrthogonalState destructor"); -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEntry -/// state initialization can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnExit -/// state cleanup can be performed in this function. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str()); - return eFrameworkunifiedStatusOK; -} - -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedAddOrthogonalRegion(CFrameworkunifiedCompositeState *f_pOrthogonalRegion) { - try { - CHKNULL(f_pOrthogonalRegion); - CHKNULL(m_pOrthogonalReigonList); - f_pOrthogonalRegion->m_pParentState = this; - m_pOrthogonalReigonList->push_back(f_pOrthogonalRegion); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return eFrameworkunifiedStatusNullPointer; - } - - return eFrameworkunifiedStatusOK; -} - -CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pCurrentState = NULL; - CFrameworkunifiedState *l_pActiveState = NULL; - - try { - FrameworkunifiedOnEntry(f_pEventData); - - CHKNULL(m_pOrthogonalReigonList); - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount)); - CHKNULL(l_pActiveState); - - l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); - CHKNULL(l_pCurrentState); - - if (!IsOrthogonalChildState(l_pCurrentState)) { - break; - } else { - l_pCurrentState = this; - } - } - } - - // set current state as the active state of its parent state to maintain the Hierarchy - if (m_pParentState) { - m_pParentState->m_pActiveState = l_pCurrentState; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pCurrentState; -} - -CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pCurrentState = NULL; - CFrameworkunifiedState *l_pActiveState = NULL; - - try { - CHKNULL(m_pOrthogonalReigonList); - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount)); - CHKNULL(l_pActiveState); - - l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData); - CHKNULL(l_pCurrentState); - - if (!IsOrthogonalChildState(l_pCurrentState)) { - break; - } else { - l_pCurrentState = this; - } - } - } - FrameworkunifiedOnExit(f_pEventData); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pCurrentState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEvent -/// This function processes the event. If the reaction for event is available in the current -/// state within eventlist and deferred eventlist then it is consumed in the current state -/// otherwise forwarded to the parent state. Event forwarding is done recursively till either -/// event is consumed or the root state has encountered. This also process the events posted -/// in the reactions recursively till all posted events are cleared. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pCurrentState = NULL; - CFrameworkunifiedState *l_pStateIterator = NULL; - CFrameworkunifiedState *l_pOrthogonalRegion = NULL; - BOOL l_bReactionAvailable = FALSE; - BOOL l_bIsEventProcessed = FALSE; - - try { - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - l_pOrthogonalRegion = m_pOrthogonalReigonList->at(l_uiCount); - - if (l_pOrthogonalRegion) { - // get the current active state - l_pCurrentState = l_pOrthogonalRegion->FrameworkunifiedGetActiveState(); - CHKNULL(l_pCurrentState); - - l_pStateIterator = l_pCurrentState; - - // checks whether the reaction for the event is available in this orthogonal region - while (this != l_pStateIterator) { - if (l_pStateIterator->FrameworkunifiedIsReactionAvailable(f_pEventData->m_uiEventId)) { - l_bReactionAvailable = TRUE; - l_bIsEventProcessed = TRUE; - break; - } - - // iterate to parent state in orthogonal region - l_pStateIterator = l_pStateIterator->m_pParentState; - } - - // if reaction is found, post the event - if (l_bReactionAvailable) { - l_bReactionAvailable = FALSE; - - l_pCurrentState = l_pCurrentState->FrameworkunifiedOnEvent(f_pEventData); - CHKNULL(l_pCurrentState); - - // check whether current active state is within the orthogonal state - if (IsOrthogonalChildState(l_pCurrentState)) { - l_pCurrentState = this; - } - - break; - } else { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction not available in orthogonal region %s", - l_pOrthogonalRegion->m_strStateName.c_str()); - l_pCurrentState = this; - } - } - } - - // if event is not processed in any of orthogonal region, post the event to orthogonal state - if (!l_bIsEventProcessed) { - l_pCurrentState = CFrameworkunifiedState::FrameworkunifiedOnEvent(f_pEventData); - - // check whether current active state is within the orthogonal state - if (IsOrthogonalChildState(l_pCurrentState)) { - l_pCurrentState = this; - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pCurrentState; -} - -BOOL CFrameworkunifiedOrthogonalState::FrameworkunifiedHasOrthogoanlRegions() { - try { - CHKNULL(m_pOrthogonalReigonList); - - if (m_pOrthogonalReigonList->size()) { - return TRUE; - } else { - return FALSE; - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return FALSE; - } -} - -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintStates() { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - try { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s", - (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str()); - - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintStates(); - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -BOOL CFrameworkunifiedOrthogonalState::IsOrthogonalChildState(CFrameworkunifiedState *f_pChildState) { - CFrameworkunifiedState *l_pParentState = f_pChildState; - BOOL l_bIsOrthgonalChild = FALSE; - while (l_pParentState) { - if (this == l_pParentState) { - l_bIsOrthgonalChild = TRUE; - break; - } - - l_pParentState = l_pParentState->m_pParentState; - } - - return l_bIsOrthgonalChild; -} - -CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedGetActiveState() { - return this; -} - -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(f_pStatemachine); - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); - l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedSetHSM(f_pStatemachine); - } - } - m_pStateMachine = f_pStatemachine; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - try { - f_strXMLString << "<" << m_strStateName.c_str() << ">"; - f_strXMLString << "<OrthogonalRegions>"; - - for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) { - if (m_pOrthogonalReigonList->at(l_uiCount)) { - m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintXML(f_strXMLString); - } - } - - f_strXMLString << "</OrthogonalRegions>"; - f_strXMLString << "</" << m_strStateName.c_str() << ">"; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::UpdateHistory() { - return eFrameworkunifiedStatusOK; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp deleted file mode 100755 index 97b6e3b..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedShallowHistoryState class definitions. CFrameworkunifiedShallowHistoryState is derived -/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by -/// HSM ShallowHistory state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include <native_service/frameworkunified_sm_shallowhistorystate.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <string> - -// define static members of class -const UI_32 CFrameworkunifiedShallowHistoryState::m_suievShallowHistory = 71; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedShallowHistoryState -/// Parameterized constructor -//////////////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedShallowHistoryState::CFrameworkunifiedShallowHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) { - m_uiEventId = m_suievShallowHistory; - m_cEventName = "evShallowHistory"; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedShallowHistoryState -/// Class destructor -//////////////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedShallowHistoryState::~CFrameworkunifiedShallowHistoryState() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedShallowHistoryState destructor"); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// UpdateHistory -/// This function stores the last active state -//////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedShallowHistoryState::UpdateHistory() { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(m_pParentState); - - m_pLastActiveState = m_pParentState->m_pActiveState; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp deleted file mode 100755 index af90583..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp +++ /dev/null @@ -1,634 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedState class implementation. CFrameworkunifiedState is base class for all types of -/// state classes.This class implements the basic functionality required for HSM state. -/// It provides the standard interfaces for entering, exiting and reacting in a state. -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_state.h> -#include <native_service/frameworkunified_sm_reaction.h> -#include <native_service/frameworkunified_sm_framework_types.h> -#include <native_service/frameworkunified_sm_hsm.h> -#include <sstream> -#include <string> -#include <utility> -#include "frameworkunified_sm_framework_core.h" -#include "frameworkunified_framework_internal.h" - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedState -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState::CFrameworkunifiedState(std::string f_pName): m_strStateName(f_pName) { - try { - // EventList stores the list of events associated with the state - m_pEventList = new EventReactionList(); // LCOV_EXCL_BR_LINE 11:except branch - - // Deferred eventlist stores the list of deferred events associated - // with the state - m_pDeferredEventList = new DeferredEventList(); // LCOV_EXCL_BR_LINE 11:except branch - - // Deferred PostEventList stores the list of posted deferred events posted - // in the state - m_pDeferredPostEventList = new EventInfoList(); // LCOV_EXCL_BR_LINE 11:except branch - - // EventName map stores the Name of event against event id, The event name is - // only used for debugging so this can be disbaled in case of release build - m_pEventName = new EventNameList(); // LCOV_EXCL_BR_LINE 11:except branch - - m_pDefaultState = NULL; - m_pActiveState = NULL; - m_pParentState = NULL; - m_pStateMachine = NULL; - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s state created ", f_pName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str()); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedState -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState::~CFrameworkunifiedState() { - EventReactionIterator l_objEventIterator; - EventReactionIterator l_objDeferredEventIterator; - - try { - // Delete the event list - CHKNULL(m_pEventList); - for (l_objEventIterator = m_pEventList->begin(); - l_objEventIterator != m_pEventList->end(); - l_objEventIterator++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the event %d in state %s", - (*l_objEventIterator).first , m_strStateName.c_str()); - - if (NULL != (*l_objEventIterator).second) { - (*l_objEventIterator).second->m_ucRefCount--; - - if (0 == ((*l_objEventIterator).second->m_ucRefCount)) { - delete(*l_objEventIterator).second; - (*l_objEventIterator).second = NULL; - } - } - } - - // Delete the eventlist - m_pEventList->clear(); - delete m_pEventList; - m_pEventList = NULL; - - // Delete the deferred eventlist - CHKNULL(m_pDeferredEventList); - m_pDeferredEventList->clear(); - delete m_pDeferredEventList; - m_pDeferredEventList = NULL; - - // delete deferred Post event list - CHKNULL(m_pDeferredPostEventList); - m_pDeferredPostEventList->clear(); - delete m_pDeferredPostEventList; - m_pDeferredPostEventList = NULL; - - // delete event name list - CHKNULL(m_pEventName); - m_pEventName->clear(); - delete m_pEventName; - m_pEventName = NULL; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAddEvent -/// Associates the event id with the reaction in the state. When the event is posted to the -/// state the associated reaction is executed. This also adds the event name to the map -/// which is used for debugging. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddEvent(UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pEventName); - CHKNULL(m_pEventList); - CHKNULL(f_pReaction); - // LCOV_EXCL_BR_STOP - // associate the eventname with event id (debugging only) - m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName)); - - f_pReaction->m_ucRefCount++; - - // associate the reaction with event id - m_pEventList->insert(std::pair<UI_32, CFrameworkunifiedReaction *>(f_uiEventId, f_pReaction)); - - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction associated with the event %d %s in the state %s " - , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s", - f_uiEventId , (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnEvent -/// This function processes the event. If the reaction for event is available in the current -/// state within eventlist and deferred eventlist then it is consumed in the current state -/// otherwise forwarded to the parent state. Event forwarding is done recursively till either -/// event is consumed or the root state has encountered. This also process the events posted -/// in the reactions recursively till all posted events are cleared. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pCurrentState = this; - CFrameworkunifiedReaction *l_pEventReaction = NULL; - - try { - // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pEventList); - CHKNULL(m_pDeferredEventList); - // LCOV_EXCL_BR_STOP - // Find the reaction object for given event id - - /** - * @todo - * Unauthorized accesses will occur if NULL is specified for the event data. - */ - if (m_pEventList->end() != m_pEventList->find(f_pEventData->m_uiEventId)) { - l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_pEventData->m_uiEventId))->second); - } - - if (l_pEventReaction) { - // execute the reaction associated with the event - l_pCurrentState = l_pEventReaction->FrameworkunifiedReaction(this, f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction completed for event %d %s in state %s " - , f_pEventData->m_uiEventId, (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(), - m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - } else if (IsEventDeferred(f_pEventData->m_uiEventId)) { - // If given event is deferred event then handle defer event - CHKNULL(m_pDeferredPostEventList); - - m_pDeferredPostEventList->push_back(f_pEventData); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s posted to state %s ", - f_pEventData->m_uiEventId, - (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(), - m_strStateName.c_str()); - - } else { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction not available or event %d not found in state %s" - , f_pEventData->m_uiEventId, m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - // check if the current state has parent state - if (m_pParentState) { - // No reaction available fot given event in the current state - // then forward event to parent state - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Forwarding an event %d to %s" - , f_pEventData->m_uiEventId, m_pParentState->m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - l_pCurrentState = m_pParentState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - - } else { - // No parent is available then reached root state, - // No reaction available in the statemachine then discard the event - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Discarding an event %d ", f_pEventData->m_uiEventId); - // LCOV_EXCL_BR_STOP - } - - CHKNULL(l_pCurrentState); - - // This is a recursive function that recurse in parent states till the event is - // consumed or discarded So Setting the current state as the active state of the - // returned state, as the return state is parent state - if (l_pCurrentState->m_pActiveState) { - l_pCurrentState = l_pCurrentState->m_pActiveState; - - } else { - // do nothing in leaf state, as current state is active state - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - return l_pCurrentState; -} - -////////////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedAddDeferredEvent -/// When the event is posted to the state the event is deferred and stored in the state. -/// In case of implicit recall of the deferred events, events are processed before exiting the state. -/// The deferred events can also be recalled explicitly in the state. -/// This also adds the event name to the map which is used for debugging. -////////////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddDeferredEvent(UI_32 f_uiEventId, std::string f_strEventName) { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pEventName); - - CHKNULL(m_pDeferredEventList); - // LCOV_EXCL_BR_STOP - // associate the deferred eventname with event id (debugging only) - m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName)); - - // associate the reaction with deferred event id - m_pDeferredEventList->push_back(f_uiEventId); // LCOV_EXCL_BR_LINE 11:except branch - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Added deferred event %d %s in the state %s " - , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s", - f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str()); - - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPostEvent -/// This function creates new eventdata object and add the to event queue of the state. -/// The events are posted in the reaction which are executed in the state. -/// The event queue is processed once the execution of the reaction is completed. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(UI_32 f_uiEventId) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - try { - CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h - - CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch - - l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch // LCOV_EXCL_BR_LINE 11:except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPostEvent -/// This function adds the event queue of the state. The events are posted in the reaction -/// which are executed in the state. The event queue is processed once the execution of the -/// reaction is completed. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(m_pStateMachine); - CHKNULL(f_pEventData); - - l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(f_pEventData); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnHSMStart -/// This function is called recursively till the leaf state is reached. This internally -/// calls the Entry function of the current state. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pActiveState = this; - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - - try { - // Call Entry method of the current state. Entry method of state is called in the order of - // Hierarchy from Outer state to Inner state - if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) { - // If current state has sub states then enter into active state for state entry - // active state is same as the default state. In this case the FrameworkunifiedOnStart is called - // recursively and recursion breaks when the current state is leafstate that does not have - // any active/default state. - if (m_pActiveState) { - l_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch - } else { - l_pActiveState = this; - } - - // set current state as the active state of its parent state to maintain the Hierarchy - if (m_pParentState) { - m_pParentState->m_pActiveState = this; - } - } else { - // If FrameworkunifiedOnEntry failed then statemachine should report the error - // We can throw an exception but for now as a quick fix we are setting - // l_pActiveState as NULL which will stop the statemachine - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in FrameworkunifiedOnEntry of state %s", eStatus, - l_pActiveState->m_strStateName.c_str()); - // LCOV_EXCL_BR_STOP - // l_pActiveState = NULL; - /* Commenting it, because it was making state machine inactive. This should not be the expected behavior. - * Just log and take no action, if user return non-ok value. - * User defined error values should be handled separately */ - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pActiveState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedOnHSMStop -/// This function is called recursively till the required parent state is reached. This -/// internally calls the Exit function of the current state. -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) { - CFrameworkunifiedState *l_pActiveState = this; - try { - // if active state is composite state, update the shallow and deep history state(if exists) - UpdateHistory(); // LCOV_EXCL_BR_LINE 11:except branch - - // if current state has active state then recursively call the FrameworkunifiedOnHSMStop till current - // state has no active state i.e. current state is leaf state - if (m_pActiveState) { - m_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData); - } - - m_pActiveState = m_pDefaultState; - - // Post deferred events to statemachine event queue - CHKNULL(m_pDeferredPostEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h - - // recall deferred events till the vector is empty - while (!m_pDeferredPostEventList->empty()) { - // get the first event list object - CEventDataPtr l_pEventData = m_pDeferredPostEventList->front(); - - CHKNULL(l_pEventData); - CHKNULL(m_pEventName); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Recalling event %d %s in state %s" - , l_pEventData->m_uiEventId, - (m_pEventName->find(l_pEventData->m_uiEventId)->second).c_str(), m_strStateName.c_str()); - - m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin()); - - // recall the event stored in the eventinfo object - FrameworkunifiedPostEvent(l_pEventData); - } - - FrameworkunifiedOnExit(f_pEventData); - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - return NULL; - } - - return l_pActiveState; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// IsEventDeferred -/// This checks if the given event is marked as deferred in the state. -/////////////////////////////////////////////////////////////////////////////////////////// -BOOL CFrameworkunifiedState::IsEventDeferred(UI_32 f_uiEventId) { - BOOL bStatus = FALSE; - try { - CHKNULL(m_pDeferredEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h - for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) { - if (f_uiEventId == m_pDeferredEventList->at(l_uiCount)) { - bStatus = TRUE; - break; - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } - - return bStatus; // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedRemoveEventFromDeferredEventList -/// This function removes the event from the posted deferred queue list of the state. -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedRemoveEventFromDeferredEventList(UI_32 f_uiEventId) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID; - FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+"); - - try { - CHKNULL(m_pDeferredPostEventList); - int32_t l_siCnt = static_cast<int32_t>(m_pDeferredPostEventList->size() - 1); - - for (; l_siCnt >= 0; l_siCnt--) { - if (NULL != m_pDeferredPostEventList->at(l_siCnt).get()) { - if (f_uiEventId == m_pDeferredPostEventList->at(l_siCnt).get()->m_uiEventId) { - m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin() + l_siCnt); - l_eStatus = eFrameworkunifiedStatusOK; - } - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-"); - return l_eStatus; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedRecallEvent -/// This indicates if the state has sub states. It returns TRUE only in the CompositeState -/// where this function is overridden -/////////////////////////////////////////////////////////////////////////////////////////// -BOOL CFrameworkunifiedState::FrameworkunifiedHasSubStates() { - return FALSE; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/// FrameworkunifiedPrintStates -/// This logs the state name and events associated with the state -/////////////////////////////////////////////////////////////////////////////////////////// -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintStates() { - EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; - EventReactionIterator l_objEventIterator; - try { - CHKNULL(m_pEventList); - CHKNULL(m_pDeferredEventList); - CHKNULL(m_pEventName); - - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s", - (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str()); - - // print events - for (l_objEventIterator = m_pEventList->begin(); - l_objEventIterator != m_pEventList->end(); l_objEventIterator++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first), - (m_pEventName->find((*l_objEventIterator).first)->second).c_str()); - } - - // print deferred events - for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount), - (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str()); - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str()); - eStatus = eFrameworkunifiedStatusNullPointer; - } - - return eStatus; -} - -BOOL CFrameworkunifiedState::FrameworkunifiedHasOrthogoanlRegions() { - return FALSE; -} - -BOOL CFrameworkunifiedState::FrameworkunifiedIsReactionAvailable(UI_32 f_uiEventId) { - BOOL IsReactionAvailable = FALSE; - CFrameworkunifiedReaction *l_pEventReaction = NULL; - - try { - // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h - CHKNULL(m_pEventList); - CHKNULL(m_pDeferredEventList); - // LCOV_EXCL_BR_STOP - if (m_pEventList->end() != m_pEventList->find(f_uiEventId)) { - // Find the reaction object for given event id - l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_uiEventId))->second); - } - - if (l_pEventReaction) { - IsReactionAvailable = TRUE; - } else { - if (IsEventDeferred(f_uiEventId)) { - IsReactionAvailable = TRUE; - } - } - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } - - return IsReactionAvailable; // LCOV_EXCL_BR_LINE 11:except branch -} - -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - - try { - CHKNULL(f_pStatemachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h - m_pStateMachine = f_pStatemachine; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; // LCOV_EXCL_BR_LINE 11:except branch -} - -HANDLE CFrameworkunifiedState:: FrameworkunifiedGetAppHandle() { - HANDLE l_pHApp = NULL; - try { - CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h - l_pHApp = m_pStateMachine->FrameworkunifiedGetAppHandle(); // LCOV_EXCL_BR_LINE 11:except branch - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - } - return l_pHApp; // LCOV_EXCL_BR_LINE 11:except branch -} - -EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) { - EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; - EventReactionIterator l_objEventIterator; - try { - CHKNULL(m_pEventList); - CHKNULL(m_pDeferredEventList); - CHKNULL(m_pEventName); - - f_strXMLString << "<" << m_strStateName.c_str() << ">"; - - f_strXMLString << "<EventList>"; - // print events - for (l_objEventIterator = m_pEventList->begin(); - l_objEventIterator != m_pEventList->end(); l_objEventIterator++) { - std::string l_strEventName = - (m_pEventName->find((*l_objEventIterator).first)->second); - - UI_32 l_uiEventId = (*l_objEventIterator).first; - - f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">"; - - f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>"; - - f_strXMLString << "</Event>"; - } - f_strXMLString << "</EventList>"; - - // print deferred events - f_strXMLString << "<DeferredEventList>"; - for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) { - UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount); - - std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second); - - f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">"; - - f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>"; - - f_strXMLString << "</Event>"; - } - - f_strXMLString << "</DeferredEventList>"; - f_strXMLString << "</" << m_strStateName.c_str() << ">"; - } catch (std::exception &e) { - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); - FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str()); - l_eStatus = eFrameworkunifiedStatusNullPointer; - } - return l_eStatus; -} diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp deleted file mode 100755 index 1162f61..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \defgroup <<Group Tag>> <<Group Name>> -/// \ingroup tag_NSFramework -/// . -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup tag_NSFramework -/// \brief -/// -/// This file has the CFrameworkunifiedTransition class definitions.This class provides the interface -/// for reacting local transition and external transition -/// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include Files -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include <native_service/frameworkunified_sm_transition.h> -#include <native_service/frameworkunified_sm_state.h> - -/////////////////////////////////////////////////////////////////////////////////////////// -/// CFrameworkunifiedTransition -/// Parameterized constructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedTransition::CFrameworkunifiedTransition(CFrameworkunifiedState *f_pTargetState): m_pTargetState(f_pTargetState) { - if (m_pTargetState) { - // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" - FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Transition created with Target %s ", - (m_pTargetState->m_strStateName).c_str()); - // LCOV_EXCL_BR_STOP - } -} -/////////////////////////////////////////////////////////////////////////////////////////// -/// ~CFrameworkunifiedTransition -/// Class destructor -/////////////////////////////////////////////////////////////////////////////////////////// -CFrameworkunifiedTransition::~CFrameworkunifiedTransition() { - FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+"); -} - diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile deleted file mode 100755 index 964a1f5..0000000 --- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile +++ /dev/null @@ -1,99 +0,0 @@ -# -# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# Standard Module Makefile version 2.0 -# - -COMPONENT_NAME = NS_FrameworkCore - -include $(PRJ_ROOT)cfg/depends.mk - -# Additive Compile Flags (Flags from initiating make process will still apply) -DEFS += - - -INCLUDES = \ - $(CFG_INCS) \ - $(CC_IFLAG). \ - $(CC_IFLAG)../../inc \ - $(CC_IFLAG)../../inc/statemachine \ - $(DEPENDS_INCLUDES) \ - - -## Sources Section - -SOURCES = \ - $(wildcard *.c*) - -# -# Convert the source files to object files with correct folder location. -# -# -C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) ) -CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) ) - - -# List of all sources to be generated. Can be assembled from the other defintitions. -OBJECTS = \ - $(C_LANG_OBJECTS) \ - $(CPP_LANG_OBJECTS) - - -# All headers that are dependencies. Wildcard is easy to pickup local headers. -# This is only to automate the rebuilding, all builds on the servers are cleans -# So this is not a huge deal when building on a component level. -HEADERS = \ - $(wildcard *.h) \ - $(wildcard ../../inc/*.h) \ - $(wildcard ../../inc/NS_Statemachine/*.h) \ - $(wildcard $(REPOSITORY_ROOT)NativeServices/inc/*.h) \ - -# Make targets -# Standard -all: banner module_dirs local - -base: banner module_dirs subdirs local - -binary: base - -local: $(OBJECTS) - -# Standard set of derived targets -library: base \ - $(LIBRARIES) - @echo "***** `date` Done building library: $(COMPONENT_NAME) ******" - -# Defines specific for each deliverable - - -# Default source file build rules -$(OBJECTS): $(HEADERS) - -# Standard Building of Source Files (Default builds for all objects defined above) -$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS) - $(CC_CMD) - -$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS) - $(CPP_CMD) - - -clean: - -rm -f $(BINARIES) - -rm -f $(LIBRARIES) - -rm -f $(OBJECTS) - -module_dirs: build_dirs |