diff options
Diffstat (limited to 'nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine')
3 files changed, 216 insertions, 0 deletions
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h new file mode 100644 index 00000000..20ed3f62 --- /dev/null +++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h @@ -0,0 +1,97 @@ +/* + * @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_StateMachine +/// \brief +/// +/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from +/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM Final +/// state. +/// +/////////////////////////////////////////////////////////////////////////////// +//@{ + +#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_ +#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_ + + +#include <native_service/frameworkunified_sm_state.h> + +/////////////////////////////////////////////////////////////////////////////////////////////////// +/// This class implements the additional functionality supported by HSM Final state. +/////////////////////////////////////////////////////////////////////////////////////////////////// +class CFrameworkunifiedFinalState : public CFrameworkunifiedState { + public : + + /////////////////////////////////////////////////////////////////////////////////////////// + /// CFrameworkunifiedFinalState + /// Parameterized constructor + /// \param [in] f_pName + /// string - Name of the state + /// + /// \return none + /////////////////////////////////////////////////////////////////////////////////////////// + CFrameworkunifiedFinalState(std::string f_pName); // NOLINT (readability/nolint) + + /////////////////////////////////////////////////////////////////////////////////////////// + /// ~CFrameworkunifiedFinalState + /// Class destructor + /// + /// \return none + /////////////////////////////////////////////////////////////////////////////////////////// + virtual ~CFrameworkunifiedFinalState(); + + virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState(); + + /////////////////////////////////////////////////////////////////////////////////////////// + /// UpdateHistory + /// This function stores the last active state + /// + /// \return EFrameworkunifiedStatus + /// EFrameworkunifiedStatus - Returns status of operation + /////////////////////////////////////////////////////////////////////////////////////////// + EFrameworkunifiedStatus UpdateHistory(); + + protected : + + /////////////////////////////////////////////////////////////////////////////////////////// + /// FrameworkunifiedOnEntry + /// state initialization can be performed in this function. + /// + /// \param [in] f_pEventData + /// CEventDataPtr - Event data + /// + /// \return EFrameworkunifiedStatus + /// EFrameworkunifiedStatus - Returns status of operation + /////////////////////////////////////////////////////////////////////////////////////////// + virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData); + + /////////////////////////////////////////////////////////////////////////////////////////// + /// FrameworkunifiedOnExit + /// state cleanup can be performed in this function. + /// + /// \param [in] f_pEventData + /// CEventDataPtr - Event data + /// + /// \return EFrameworkunifiedStatus + /// EFrameworkunifiedStatus - Returns status of operation + /////////////////////////////////////////////////////////////////////////////////////////// + virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData); +}; + +#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_ +// @} diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h new file mode 100644 index 00000000..ea564df7 --- /dev/null +++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h @@ -0,0 +1,89 @@ +/* + * @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_StateMachine +/// \brief +/// +/// This File has public Macro definition that simplifies the statemachine implementation +/// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_ +#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_ +/// Include files +#include <native_service/frameworkunified_framework_types.h> +#include <vector> +#include <utility> + +/// connect child state to parent state and sets it as default state +#define CONNECT_DEFAULTSTATE(parent, child) \ + FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE); + +/// connect child state to parent state +#define CONNECT_STATE(parent, child) \ + FrameworkunifiedConnect(l_p## parent, l_p## child); + +/// connect the deferred event and reactions and associate them with the state +#define CONNECT_DEFERREDEVENT(state, eventid) \ + FrameworkunifiedConnect(l_p## state, _## eventid, NULL, #eventid, TRUE); \ + +/// connect the event and reactions and associate them with the state +#define CONNECT_EVENT(state, eventid, reaction) \ + FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid); + +/// connect the event and reactions and associate them with the state +#define CONNECT_LOCAL_EVENT(state, eventid, reaction) \ + FrameworkunifiedConnect(l_p## state, _## eventid, l_pLocalTrn## reaction, #eventid); + +/// Sets the state as root state in the statemachine +#define CONNECTROOT(state) \ + FrameworkunifiedConnect(l_p## state); + +/// Creates the state +#define CREATE_STATE(class_name) \ + CHKNULL(m_pFrameworkunifiedStateList) \ + C## class_name *l_p## class_name = new C## class_name(#class_name); \ + CHKNULL(l_p## class_name) \ + m_pFrameworkunifiedStateList->insert(std::pair<UI_32, CFrameworkunifiedState*>(e## class_name, l_p## class_name)); + +// create a new shallow history state and add it in parent state +#define ADD_SHALLOWHISTORYSTATE(parent) \ + CFrameworkunifiedShallowHistoryState *l_p##parent##SHALLOWHISTORYSTATE = new CFrameworkunifiedShallowHistoryState(SHALLOWHISTORYSTATE);\ + FrameworkunifiedConnect(l_p## parent, l_p##parent##SHALLOWHISTORYSTATE);\ + l_p##parent##SHALLOWHISTORYSTATE->SetDefaultHistory(); + +// create a new shallow history state and add it in parent state +#define ADD_DEEPHISTORYSTATE(parent) \ + CFrameworkunifiedDeepHistoryState *l_p##parent##DEEPHISTORYSTATE = new CFrameworkunifiedDeepHistoryState(DEEPHISTORYSTATE);\ + FrameworkunifiedConnect(l_p## parent, l_p##parent##DEEPHISTORYSTATE);\ + l_p##parent##DEEPHISTORYSTATE->SetDefaultHistory(); + +/// connect deep history event to reaction and add to state +#define CONNECT_DEEPHISTORYEVENT(state, eventid, reaction) \ + FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##DEEPHISTORYSTATE, #eventid); + +/// connect shallow history event to reaction and add to state +#define CONNECT_SHALLOWHISTORYEVENT(state, eventid, reaction) \ + FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##SHALLOWHISTORYSTATE, #eventid); + +typedef struct _HSMConfigOptions { + EUserChangeOptions eUserChange; + BOOL bAutoPublishServiceAvaialble; + BOOL bWaitInStoppingState; +} HSMConfigOptions; + +#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_ diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h new file mode 100644 index 00000000..ff670295 --- /dev/null +++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h @@ -0,0 +1,30 @@ +/* + * @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 Internal functions related to state machine child threads +/// +/// +/// +////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_ +#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_ + +void *child_hsm_thread_proc(void *args); + +#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_ |