2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup tag_NSFramework
21 ///////////////////////////////////////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup tag_NSFramework
27 /// This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from
28 /// CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS
29 /// statemachine and implements the reaction associated with the events
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////////////////////////////////
36 #include <native_service/frameworkunified_sm_hsmframework.h>
37 #include <native_service/frameworkunified_framework_if.h>
38 #include <native_service/frameworkunified_framework_types.h>
39 #include <native_service/ns_np_service_protocol.h>
40 #include <native_service/ns_np_service_notification.h>
41 #include <native_service/frameworkunified_sm_framework_dispatch.h>
42 #include <native_service/ns_plogger_if.h>
47 #include "frameworkunified_framework_core.h"
48 #include "frameworkunified_framework_internal.h"
49 #include "frameworkunified_framework_utility.h"
50 #include "frameworkunified_sm_framework_core.h"
52 extern EFrameworkunifiedStatus FrameworkunifiedHSMOnLoadData(HANDLE hApp) __attribute__((weak));
53 extern EFrameworkunifiedStatus FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(HANDLE hApp) __attribute__((weak));
55 CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(): CFrameworkunifiedHSM() {
57 CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(PVOID f_pHApp): CFrameworkunifiedHSM(f_pHApp) {
59 CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(): CFrameworkunifiedHSMFramework() {
61 m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
62 } catch (std::exception &e) {
63 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
66 ///////////////////////////////////////////////////////////////////////////////////////////
67 /// CFrameworkunifiedHSMParentFramework
68 /// default constructor
69 ///////////////////////////////////////////////////////////////////////////////////////////
70 CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
72 m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
73 } catch (std::exception &e) {
74 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
77 ///////////////////////////////////////////////////////////////////////////////////////////
78 /// ~CFrameworkunifiedHSMParentFramework
80 ///////////////////////////////////////////////////////////////////////////////////////////
81 CFrameworkunifiedHSMParentFramework::~CFrameworkunifiedHSMParentFramework() {
82 // TODO(framework_unifeid) Auto-generated destructor stub
85 ///////////////////////////////////////////////////////////////////////////////////////////
86 /// FrameworkunifiedCreate
87 /// Statemachine states and events created and connected in this interface.
88 ///////////////////////////////////////////////////////////////////////////////////////////
89 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
90 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
91 HSMConfigOptions *l_tHSMConfig = NULL;
94 l_tHSMConfig = reinterpret_cast<HSMConfigOptions *>(f_pEventData);
98 CREATE_STATE(sFrameworkunifiedRoot)
99 CREATE_STATE(sFrameworkunifiedApp)
100 CREATE_STATE(sFrameworkunifiedInitialization)
101 CREATE_STATE(sFrameworkunifiedLoadData)
102 CREATE_STATE(sFrameworkunifiedRun)
103 CREATE_STATE(sFrameworkunifiedLoadSessions)
104 CREATE_STATE(sFrameworkunifiedReady)
105 CREATE_STATE(sFrameworkunifiedStop)
106 CREATE_STATE(sFrameworkunifiedStopping)
107 CREATE_STATE(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
108 CREATE_STATE(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
110 // connect states as per the statemachine
111 CONNECT_DEFAULTSTATE(sFrameworkunifiedRoot, sFrameworkunifiedApp)
112 CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedStop)
114 CONNECT_DEFAULTSTATE(sFrameworkunifiedApp, sFrameworkunifiedInitialization)
115 CONNECT_STATE(sFrameworkunifiedApp, sFrameworkunifiedRun)
117 CONNECT_DEFAULTSTATE(sFrameworkunifiedInitialization, sFrameworkunifiedLoadData)
118 CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
119 CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
121 CONNECT_DEFAULTSTATE(sFrameworkunifiedRun, sFrameworkunifiedLoadSessions)
122 CONNECT_STATE(sFrameworkunifiedRun, sFrameworkunifiedReady)
124 CONNECT_DEFAULTSTATE(sFrameworkunifiedStop, sFrameworkunifiedStopping)
126 // Create External Transition
127 CREATE_EXTERNALTRANSITION(sFrameworkunifiedApp)
128 CREATE_EXTERNALTRANSITION(sFrameworkunifiedStop)
130 CREATE_EXTERNALTRANSITION(sFrameworkunifiedLoadSessions)
131 CREATE_EXTERNALTRANSITION(sFrameworkunifiedReady)
133 CREATE_EXTERNALTRANSITION(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
134 CREATE_EXTERNALTRANSITION(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
136 // CREATE_ACTION(aFrameworkunifiedOnStart)
138 // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
139 CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedRunevFrameworkunifiedStart = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedRun);
141 // CONNECT_ACTION(sFrameworkunifiedRunevFrameworkunifiedStart,aFrameworkunifiedOnStart)
143 // Connecting events to sFrameworkunifiedInitialization state
144 CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedStart, sFrameworkunifiedRunevFrameworkunifiedStart)
145 CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedPreStart, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
146 CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedBackgroundStart, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
148 // Create Local transitions
149 CREATE_LOCALTRANSITION(sFrameworkunifiedInitialization);
150 CREATE_LOCALTRANSITION(sFrameworkunifiedStop);
152 // Connect events to state
154 // Connecting events to sFrameworkunifiedLoadData state
155 CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedStart)
156 CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedUserChange)
157 CONNECT_LOCAL_EVENT(sFrameworkunifiedLoadData, evFrameworkunifiedLoadComplete, sFrameworkunifiedInitialization)
159 // Connecting events to App state
160 CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedStop, sFrameworkunifiedStop)
161 CONNECT_LOCAL_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStopComplete, sFrameworkunifiedStop)
162 CONNECT_DEFERREDEVENT(sFrameworkunifiedStopping, evFrameworkunifiedStart)
164 // Connecting events to Connecting state
165 CONNECT_EVENT(sFrameworkunifiedLoadSessions, evFrameworkunifiedReady, sFrameworkunifiedReady)
166 // CONNECT_EVENT(sFrameworkunifiedReady,evFrameworkunifiedLoadSessions,sFrameworkunifiedRun)
167 CONNECT_EVENT(sFrameworkunifiedReady, evFrameworkunifiedLoadSessions, sFrameworkunifiedLoadSessions)
169 // Connecting events to Stop state
170 CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedInit, sFrameworkunifiedApp)
172 // Create internal transitions
173 CREATE_INTERNALTRANSITION(OnEventStartInStopState)
174 CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedStart, OnEventStartInStopState)
176 CREATE_INTERNALTRANSITION(OnEventStopInStoppingState)
177 CONNECT_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStop, OnEventStopInStoppingState)
179 // Connecting events to sFrameworkunifiedRun state
180 CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
181 CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedBackgroundStop, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
183 // Connecting events to sFrameworkunifiedBackground state
184 CONNECT_EVENT(sFrameworkunifiedBackground, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
186 if (NULL != l_tHSMConfig) {
187 if (eUserchangeIgnore != l_tHSMConfig->eUserChange) {
188 if (eUserchangeReInit == l_tHSMConfig->eUserChange) {
189 // Create Internal Transition
190 CREATE_INTERNALTRANSITION(OnEventUserChangeInInitializationState)
191 CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedUserChange, OnEventUserChangeInInitializationState)
193 // Create Internal Transition
194 CREATE_INTERNALTRANSITION(OnEventUserChangeInRunState)
195 CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedUserChange, OnEventUserChangeInRunState)
197 CREATE_ACTION(aFrameworkunifiedOnStop)
199 // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
200 CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedAppevFrameworkunifiedInit = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedApp);
202 CONNECT_ACTION(sFrameworkunifiedAppevFrameworkunifiedInit, aFrameworkunifiedOnStop)
204 CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedInit, sFrameworkunifiedAppevFrameworkunifiedInit)
206 } else if (eUserchangeRetPrevState == l_tHSMConfig->eUserChange) {
207 CREATE_STATE(sFrameworkunifiedUserChange)
209 CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedUserChange)
211 CREATE_EXTERNALTRANSITION(sFrameworkunifiedUserChange)
213 CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedUserChange, sFrameworkunifiedUserChange)
214 CONNECT_EVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStop, sFrameworkunifiedStop)
216 CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStart)
217 CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChange)
219 // add shallow history state in state sFrameworkunifiedApp
220 ADD_SHALLOWHISTORYSTATE(sFrameworkunifiedApp)
222 // create transition to shallow history state in state sFrameworkunifiedApp
223 CREATE_SHALLOWHISTORYTRANSITION(sFrameworkunifiedApp)
225 // Connecting events to UserChange State
226 CONNECT_SHALLOWHISTORYEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChangeComplete, sFrameworkunifiedApp)
228 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Incorrect Userchange config option %d", l_tHSMConfig->eUserChange);
233 // Connecting FrameworkRoot to statemachine
234 CONNECTROOT(sFrameworkunifiedRoot)
236 // Creating the application specific statemachine
238 FrameworkunifiedCreateStateMachineInternal(m_pHApp);
240 // Print statemachine xml
242 } catch (std::exception &e) {
243 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
245 eStatus = eFrameworkunifiedStatusNullPointer;
251 ///////////////////////////////////////////////////////////////////////////////////////////
252 /// FrameworkunifiedFrameworkConnect
253 /// This adds the given state as a sub state of sReady state of the Framework
254 ///////////////////////////////////////////////////////////////////////////////////////////
255 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
256 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
258 CHKNULL(m_pFrameworkunifiedStateList);
259 CHKNULL(f_pAppState);
261 if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady) == m_pFrameworkunifiedStateList->end()) {
262 throw CNullPointerException();
264 CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady)->second);
267 eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
268 } catch (std::exception &e) {
269 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
271 eStatus = eFrameworkunifiedStatusNullPointer;
277 ///////////////////////////////////////////////////////////////////////////////////////////
278 /// FrameworkunifiedFrameworkConnect
279 /// This connects the reaction to event and add event to states
280 ///////////////////////////////////////////////////////////////////////////////////////////
281 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
282 CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName,
283 BOOL f_bIsDeferredEvent) {
284 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
286 CHKNULL(m_pFrameworkunifiedStateList);
288 if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
289 throw CNullPointerException();
291 CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
293 CHKNULL(l_pFrameworkunifiedState);
295 eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
296 } catch (std::exception &e) {
297 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
299 eStatus = eFrameworkunifiedStatusNullPointer;
304 ///////////////////////////////////////////////////////////////////////////////////////////
305 /// CsFrameworkunifiedRoot
306 /// Parameterized constructor
307 ///////////////////////////////////////////////////////////////////////////////////////////
308 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::CsFrameworkunifiedRoot(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
311 ///////////////////////////////////////////////////////////////////////////////////////////
312 /// ~CsFrameworkunifiedRoot
314 ///////////////////////////////////////////////////////////////////////////////////////////
315 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::~CsFrameworkunifiedRoot() {
318 ///////////////////////////////////////////////////////////////////////////////////////////
319 /// FrameworkunifiedOnEntry
320 /// Initializes the application and registers the service availability notification
321 ///////////////////////////////////////////////////////////////////////////////////////////
322 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
323 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
324 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
326 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
329 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
330 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedOnInitializationInternal(l_pHApp))) {
331 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to Initialize application:0x%x ", eStatus);
333 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
335 // Publish service unavailability
336 if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) {
337 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
338 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", eStatus);
340 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
347 ///////////////////////////////////////////////////////////////////////////////////////////
348 /// FrameworkunifiedOnExit
349 /// state cleanup can be performed in this function.
350 ///////////////////////////////////////////////////////////////////////////////////////////
351 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
352 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
353 return eFrameworkunifiedStatusOK;
356 ///////////////////////////////////////////////////////////////////////////////////////////
357 /// CsFrameworkunifiedApp
358 /// Parameterized constructor
359 ///////////////////////////////////////////////////////////////////////////////////////////
360 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::CsFrameworkunifiedApp(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
363 ///////////////////////////////////////////////////////////////////////////////////////////
364 /// ~CsFrameworkunifiedRoot
366 ///////////////////////////////////////////////////////////////////////////////////////////
367 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::~CsFrameworkunifiedApp() {
370 ///////////////////////////////////////////////////////////////////////////////////////////
371 /// FrameworkunifiedOnEntry
372 /// Initializes the application and registers the service availability notification
373 ///////////////////////////////////////////////////////////////////////////////////////////
374 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
375 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
376 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
380 ///////////////////////////////////////////////////////////////////////////////////////////
381 /// FrameworkunifiedOnExit
382 /// state cleanup can be performed in this function.
383 ///////////////////////////////////////////////////////////////////////////////////////////
384 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
385 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
387 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
388 } catch (std::exception &e) {
389 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
390 eStatus = eFrameworkunifiedStatusNullPointer;
396 ///////////////////////////////////////////////////////////////////////////////////////////
397 /// CsFrameworkunifiedUserChange
398 /// Parameterized constructor
399 ///////////////////////////////////////////////////////////////////////////////////////////
400 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::CsFrameworkunifiedUserChange(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
403 ///////////////////////////////////////////////////////////////////////////////////////////
404 /// ~CsFrameworkunifiedRoot
406 ///////////////////////////////////////////////////////////////////////////////////////////
407 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::~CsFrameworkunifiedUserChange() {
410 ///////////////////////////////////////////////////////////////////////////////////////////
411 /// FrameworkunifiedOnEntry
412 /// Initializes the application and registers the service availability notification
413 ///////////////////////////////////////////////////////////////////////////////////////////
414 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
415 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
416 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
418 if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData))) {
419 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedUserChangeComplete");
420 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No reaction for loading user specific data ");
422 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete));
424 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData));
430 ///////////////////////////////////////////////////////////////////////////////////////////
431 /// FrameworkunifiedOnExit
432 /// state cleanup can be performed in this function.
433 ///////////////////////////////////////////////////////////////////////////////////////////
434 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
435 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
436 return eFrameworkunifiedStatusOK;
440 ///////////////////////////////////////////////////////////////////////////////////////////
441 /// CsFrameworkunifiedInitialization
442 /// Parameterized constructor
443 ///////////////////////////////////////////////////////////////////////////////////////////
444 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::CsFrameworkunifiedInitialization(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
447 ///////////////////////////////////////////////////////////////////////////////////////////
448 /// ~CsFrameworkunifiedInitialization
450 ///////////////////////////////////////////////////////////////////////////////////////////
451 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::~CsFrameworkunifiedInitialization() {
454 ///////////////////////////////////////////////////////////////////////////////////////////
455 /// FrameworkunifiedOnEntry
456 /// state initialization can be performed in this function.
457 ///////////////////////////////////////////////////////////////////////////////////////////
458 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
459 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
461 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
462 } catch (std::exception &e) {
463 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
465 eStatus = eFrameworkunifiedStatusNullPointer;
471 ///////////////////////////////////////////////////////////////////////////////////////////
472 /// FrameworkunifiedOnExit
473 /// state cleanup can be performed in this function.
474 ///////////////////////////////////////////////////////////////////////////////////////////
475 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
476 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
477 return eFrameworkunifiedStatusOK;
480 CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInInitializationState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
481 CEventDataPtr f_pEventData) {
483 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInInitializationState");
484 CHKNULL(f_pSourceState);
486 // post the event to move to sFrameworkunifiedApp state
487 f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
488 } catch (std::exception &e) {
489 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
493 return f_pSourceState;
496 ///////////////////////////////////////////////////////////////////////////////////////////
497 /// CsFrameworkunifiedLoadData
498 /// Parameterized constructor
499 ///////////////////////////////////////////////////////////////////////////////////////////
500 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::CsFrameworkunifiedLoadData(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
503 ///////////////////////////////////////////////////////////////////////////////////////////
504 /// CsFrameworkunifiedLoadData
505 /// Parameterized constructor
506 ///////////////////////////////////////////////////////////////////////////////////////////
507 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::~CsFrameworkunifiedLoadData() {
510 ///////////////////////////////////////////////////////////////////////////////////////////
511 /// FrameworkunifiedOnEntry
512 /// state initialization can be performed in this function.
513 ///////////////////////////////////////////////////////////////////////////////////////////
514 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
515 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
516 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
518 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
521 CHKNULL(FrameworkunifiedGetStateMachine(l_pHApp));
523 UI_32 l_uiCurrentEventId = FrameworkunifiedGetStateMachine(l_pHApp)->m_uiCurrentEvent;
524 if (!(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete) == l_uiCurrentEventId)) {
525 if (FrameworkunifiedHSMOnLoadData) {
526 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedHSMOnLoadData(l_pHApp))) {
527 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to load application data:0x%X ", eStatus);
530 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnLoadData not defined by the application");
533 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent(l_pHApp,
534 NTFY_NPPService_UserChange,
535 FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChange)))) {
536 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithHSMEvent "
537 "NTFY_NPPService_UserChange Failed Status:0x%x ", eStatus);
540 // Attach callback : Event to start the StateMachine
541 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(l_pHApp,
542 FRAMEWORKUNIFIED_ANY_SOURCE,
543 NPS_GET_PERS_FILE_ACK,
544 FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck)))) {
545 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__,
546 "FrameworkunifiedAttachCallbackToDispatcher NPS_GET_PERS_FILE_ACK (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ", eStatus);
549 if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck))) {
550 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedLoadFileAck");
552 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
555 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
557 } catch (std::exception &e) {
558 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
560 eStatus = eFrameworkunifiedStatusNullPointer;
566 ///////////////////////////////////////////////////////////////////////////////////////////
567 /// FrameworkunifiedOnExit
568 /// state cleanup can be performed in this function.
569 ///////////////////////////////////////////////////////////////////////////////////////////
570 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
571 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
572 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
574 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
577 CFrameworkunifiedHSM *l_pHSM = FrameworkunifiedGetStateMachine(l_pHApp);
580 UI_32 l_uiCurrentEventId = l_pHSM->m_uiCurrentEvent;
582 if (FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) == l_uiCurrentEventId) {
583 l_pHSM->RemoveEventFromPostedEventQueue(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
585 } catch (std::exception &e) {
586 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
588 eStatus = eFrameworkunifiedStatusNullPointer;
593 ///////////////////////////////////////////////////////////////////////////////////////////
594 /// CsFrameworkunifiedPre
595 /// Parameterized constructor
596 ///////////////////////////////////////////////////////////////////////////////////////////
597 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)
600 ///////////////////////////////////////////////////////////////////////////////////////////
601 /// ~CsFrameworkunifiedPre
603 ///////////////////////////////////////////////////////////////////////////////////////////
604 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::~CsFrameworkunifiedPre() {
607 ///////////////////////////////////////////////////////////////////////////////////////////
608 /// FrameworkunifiedOnEntry
609 /// state initialization can be performed in this function.
610 ///////////////////////////////////////////////////////////////////////////////////////////
611 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
612 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
613 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
615 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
616 CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
617 CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
619 // Only evFrameworkunifiedPreStart or evFrameworkunifiedPreStop events occur when functions are executed.
620 if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStart)) {
621 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
622 eStatus = FrameworkunifiedOnPreStartInternal(l_pHApp);
623 if (eFrameworkunifiedStatusOK != eStatus) {
624 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre start application:0x%x ", eStatus);
626 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
628 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
629 eStatus = FrameworkunifiedOnPreStopInternal(l_pHApp);
630 if (eFrameworkunifiedStatusOK != eStatus) {
631 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre stop application:0x%x ", eStatus);
633 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
639 ///////////////////////////////////////////////////////////////////////////////////////////
640 /// FrameworkunifiedOnExit
641 /// state cleanup can be performed in this function.
642 ///////////////////////////////////////////////////////////////////////////////////////////
643 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
644 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
645 return eFrameworkunifiedStatusOK;
648 ///////////////////////////////////////////////////////////////////////////////////////////
649 /// CsFrameworkunifiedBackground
650 /// Parameterized constructor
651 ///////////////////////////////////////////////////////////////////////////////////////////
652 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)
655 ///////////////////////////////////////////////////////////////////////////////////////////
656 /// ~CsFrameworkunifiedBackground
658 ///////////////////////////////////////////////////////////////////////////////////////////
659 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::~CsFrameworkunifiedBackground() {
662 ///////////////////////////////////////////////////////////////////////////////////////////
663 /// FrameworkunifiedOnEntry
664 /// state initialization can be performed in this function.
665 ///////////////////////////////////////////////////////////////////////////////////////////
666 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
667 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
668 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
670 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
671 CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
672 CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
674 // Only evFrameworkunifiedBackgroundStart or evFrameworkunifiedBackgroundStop events occur when functions are executed.
675 if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStart)) {
676 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
677 eStatus = FrameworkunifiedOnBackgroundStartInternal(l_pHApp);
678 if (eFrameworkunifiedStatusOK != eStatus) {
679 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background start application:0x%x ", eStatus);
681 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
683 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
684 eStatus = FrameworkunifiedOnBackgroundStopInternal(l_pHApp);
685 if (eFrameworkunifiedStatusOK != eStatus) {
686 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background stop application:0x%x ", eStatus);
688 FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
694 ///////////////////////////////////////////////////////////////////////////////////////////
695 /// FrameworkunifiedOnExit
696 /// state cleanup can be performed in this function.
697 ///////////////////////////////////////////////////////////////////////////////////////////
698 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
699 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
700 return eFrameworkunifiedStatusOK;
703 ///////////////////////////////////////////////////////////////////////////////////////////
704 /// CsFrameworkunifiedRun
705 /// Parameterized constructor
706 ///////////////////////////////////////////////////////////////////////////////////////////
707 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::CsFrameworkunifiedRun(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
710 ///////////////////////////////////////////////////////////////////////////////////////////
711 /// ~CsFrameworkunifiedRun
713 ///////////////////////////////////////////////////////////////////////////////////////////
714 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::~CsFrameworkunifiedRun() {
717 ///////////////////////////////////////////////////////////////////////////////////////////
718 /// FrameworkunifiedOnEntry
719 /// Subscribes for the service availability notification and calls FrameworkunifiedOnStart
720 ///////////////////////////////////////////////////////////////////////////////////////////
721 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
722 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
723 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
726 HANDLE hApp = FrameworkunifiedGetAppHandle();
728 if (frameworkunifiedCheckValidAppHandle(hApp)) {
729 FrameworkunifiedOnStartInternal(hApp);
731 CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
733 for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
734 ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
736 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent
737 (hApp, objNotification.sNotificationName, objNotification.uiEventId))) {
738 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to subscribe notification %s"
739 , objNotification.sNotificationName);
741 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully subscribe notification %s"
742 , objNotification.sNotificationName);
746 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
748 } catch (std::exception &e) {
749 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
751 l_eStatus = eFrameworkunifiedStatusNullPointer;
757 ///////////////////////////////////////////////////////////////////////////////////////////
758 /// FrameworkunifiedOnExit
759 /// state cleanup can be performed in this function.
760 ///////////////////////////////////////////////////////////////////////////////////////////
761 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
762 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
763 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
766 HANDLE hApp = FrameworkunifiedGetAppHandle();
767 CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
769 if (frameworkunifiedCheckValidAppHandle(hApp)) {
770 // Let application also handle exit of sFrameworkunifiedRun state
771 if (FrameworkunifiedHSMOnStopInsFrameworkunifiedRun) {
772 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(hApp))) {
773 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun returned: 0x%X ", l_eStatus);
776 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun not defined by the application");
779 for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
780 ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
782 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithHSMEvent(hApp,
783 objNotification.sNotificationName))) {
784 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to unsubscribe notification %s",
785 objNotification.sNotificationName);
787 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully unsubscribed from notification %s",
788 objNotification.sNotificationName);
792 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
794 } catch (std::exception &e) {
795 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
797 l_eStatus = eFrameworkunifiedStatusNullPointer;
802 CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInRunState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
803 CEventDataPtr f_pEventData) {
805 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInRunState");
806 CHKNULL(f_pSourceState);
808 // post the event to move to sFrameworkunifiedApp state
809 f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
811 CHKNULL(f_pSourceState);
813 // post the event to move to sFrameworkunifiedRun state
814 f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
815 } catch (std::exception &e) {
816 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
819 return f_pSourceState;
822 ///////////////////////////////////////////////////////////////////////////////////////////
823 /// CsFrameworkunifiedLoadSessions
824 /// Parameterized constructor
825 ///////////////////////////////////////////////////////////////////////////////////////////
826 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::CsFrameworkunifiedLoadSessions(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
829 ///////////////////////////////////////////////////////////////////////////////////////////
830 /// ~CsFrameworkunifiedLoadSessions
832 ///////////////////////////////////////////////////////////////////////////////////////////
833 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::~CsFrameworkunifiedLoadSessions() {
836 ///////////////////////////////////////////////////////////////////////////////////////////
837 /// FrameworkunifiedOnEntry
838 /// state initialization can be performed in this function.
839 ///////////////////////////////////////////////////////////////////////////////////////////
840 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
841 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
843 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
845 HANDLE hApp = FrameworkunifiedGetAppHandle();
848 CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
850 if (!pApp->servicenotificationlist.size()) {
851 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No Mandatory services set ");
853 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
855 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Wait for service availability of mandatory services ");
857 } catch (std::exception &e) {
858 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
860 l_eStatus = eFrameworkunifiedStatusNullPointer;
866 ///////////////////////////////////////////////////////////////////////////////////////////
867 /// FrameworkunifiedOnExit
868 /// state cleanup can be performed in this function.
869 ///////////////////////////////////////////////////////////////////////////////////////////
870 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
871 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
872 return eFrameworkunifiedStatusOK;
875 ///////////////////////////////////////////////////////////////////////////////////////////
876 /// CsFrameworkunifiedReady
877 /// Parameterized constructor
878 ///////////////////////////////////////////////////////////////////////////////////////////
879 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::CsFrameworkunifiedReady(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
882 ///////////////////////////////////////////////////////////////////////////////////////////
883 /// ~CsFrameworkunifiedReady
885 ///////////////////////////////////////////////////////////////////////////////////////////
886 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::~CsFrameworkunifiedReady() {
889 ///////////////////////////////////////////////////////////////////////////////////////////
890 /// FrameworkunifiedOnEntry
891 /// state initialization can be performed in this function.
892 ///////////////////////////////////////////////////////////////////////////////////////////
893 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
894 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
895 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
897 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
899 if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
900 // Publish Service available this can also be published from FrameworkunifiedOnStart callback
901 if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, TRUE))) {
902 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "warning:Failed to Publish service availability notification:0x%x ",
905 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service available published");
908 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
910 } catch (std::exception &e) {
911 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
913 l_eStatus = eFrameworkunifiedStatusNullPointer;
918 ///////////////////////////////////////////////////////////////////////////////////////////
919 /// FrameworkunifiedOnExit
920 /// state cleanup can be performed in this function.
921 ///////////////////////////////////////////////////////////////////////////////////////////
922 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
923 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
924 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
926 ServiceSessionTable::iterator session_iterator;
927 SessionHandleTable::iterator session_handle_iterator;
929 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
932 if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
933 // Publish Service available this can also be published from FrameworkunifiedOnStart callback
934 if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
935 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", l_eStatus);
937 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
940 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
942 } catch (std::exception &e) {
943 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
945 l_eStatus = eFrameworkunifiedStatusNullPointer;
950 ///////////////////////////////////////////////////////////////////////////////////////////
951 /// CsFrameworkunifiedStop
952 /// Parameterized constructor
953 ///////////////////////////////////////////////////////////////////////////////////////////
954 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::CsFrameworkunifiedStop(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
957 ///////////////////////////////////////////////////////////////////////////////////////////
958 /// ~CsFrameworkunifiedStop
960 ///////////////////////////////////////////////////////////////////////////////////////////
961 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::~CsFrameworkunifiedStop() {
964 ///////////////////////////////////////////////////////////////////////////////////////////
965 /// FrameworkunifiedOnEntry
966 /// state initialization can be performed in this function.
967 ///////////////////////////////////////////////////////////////////////////////////////////
968 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
969 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
970 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
972 HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
975 // every application need to implement this function
976 // all the resource deallocation like file release,etc should be done in this callback
977 l_eStatus = FrameworkunifiedOnStopInternal(l_pHApp);
978 if (eFrameworkunifiedStatusOK != l_eStatus) {
979 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: FrameworkunifiedOnStop returned %d", l_eStatus);
980 // We just need to print the error.
981 // Returning this status to state machine is not required.
982 // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
983 l_eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
985 } catch (std::exception &e) {
986 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
987 l_eStatus = eFrameworkunifiedStatusNullPointer;
992 ///////////////////////////////////////////////////////////////////////////////////////////
993 /// FrameworkunifiedOnExit
994 /// state cleanup can be performed in this function.
995 ///////////////////////////////////////////////////////////////////////////////////////////
996 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
997 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
998 return eFrameworkunifiedStatusOK;
1001 ///////////////////////////////////////////////////////////////////////////////////////////
1002 /// CsFrameworkunifiedStopping
1003 /// Parameterized constructor
1004 ///////////////////////////////////////////////////////////////////////////////////////////
1005 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::CsFrameworkunifiedStopping(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
1008 ///////////////////////////////////////////////////////////////////////////////////////////
1009 /// ~CsFrameworkunifiedStopping
1010 /// class destructor
1011 ///////////////////////////////////////////////////////////////////////////////////////////
1012 CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::~CsFrameworkunifiedStopping() {
1015 ///////////////////////////////////////////////////////////////////////////////////////////
1016 /// FrameworkunifiedOnEntry
1017 /// state initialization can be performed in this function.
1018 ///////////////////////////////////////////////////////////////////////////////////////////
1019 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1020 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1021 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1023 if (FrameworkunifiedIsWaitInStoppingStateEnabled()) {
1024 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event evFrameworkunifiedStopComplete not posted. User has to post it.");
1026 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedStopAck");
1027 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Posting event evFrameworkunifiedStopComplete");
1028 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStopComplete));
1030 } catch (std::exception &e) {
1031 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1032 l_eStatus = eFrameworkunifiedStatusNullPointer;
1037 ///////////////////////////////////////////////////////////////////////////////////////////
1038 /// FrameworkunifiedOnExit
1039 /// state cleanup can be performed in this function.
1040 ///////////////////////////////////////////////////////////////////////////////////////////
1041 EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1042 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1043 return eFrameworkunifiedStatusOK;
1046 CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStopInStoppingState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
1047 CEventDataPtr f_pEventData) {
1049 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStopInStoppingState");
1050 CHKNULL(f_pSourceState);
1052 (VOID)f_pSourceState->FrameworkunifiedRemoveEventFromDeferredEventList(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
1053 } catch (std::exception &e) {
1054 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1057 return f_pSourceState;
1060 CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStartInStopState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
1061 CEventDataPtr f_pEventData) {
1063 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStartInStopState");
1064 CHKNULL(f_pSourceState);
1066 // post the event to move to sFrameworkunifiedApp state
1067 f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
1069 CHKNULL(f_pSourceState);
1071 // post the event to transit to sFrameworkunifiedRun state
1072 f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
1073 } catch (std::exception &e) {
1074 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1077 return f_pSourceState;
1080 VOID CFrameworkunifiedHSMParentFramework::CaFrameworkunifiedOnStop::FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState,
1081 CEventDataPtr f_pData) {
1082 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Action %s", m_strName.c_str());
1084 HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1085 if (NULL != l_pHApp) {
1086 FrameworkunifiedOnStopInternal(l_pHApp);
1088 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Application handle is NULL in Action %s", m_strName.c_str());
1092 CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(): CFrameworkunifiedHSMFramework() {
1096 CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
1098 m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
1099 } catch (std::exception &e) {
1100 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1104 CFrameworkunifiedHSMChildFramework::~CFrameworkunifiedHSMChildFramework() {
1107 ///////////////////////////////////////////////////////////////////////////////////////////
1108 /// FrameworkunifiedCreate
1109 /// Statemachine states and events created and connected in this interface.
1110 ///////////////////////////////////////////////////////////////////////////////////////////
1111 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
1112 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1115 CREATE_STATE(sFrameworkunifiedThreadRoot)
1116 CREATE_STATE(sFrameworkunifiedThreadIdle)
1117 CREATE_STATE(sFrameworkunifiedThreadStart)
1118 CREATE_STATE(sFrameworkunifiedThreadReady)
1119 CREATE_STATE(sFrameworkunifiedThreadStop)
1121 // connect states as per the statemachine
1122 CONNECT_DEFAULTSTATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadIdle)
1123 CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStart)
1124 CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStop)
1125 CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadReady)
1127 // Create External Transition
1128 CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadIdle)
1129 CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStart)
1130 CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadReady)
1131 CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStop)
1133 // Connect events to state
1134 CONNECT_EVENT(sFrameworkunifiedThreadIdle, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
1135 CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedReady, sFrameworkunifiedThreadReady)
1136 CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedError, sFrameworkunifiedThreadIdle)
1137 CONNECT_EVENT(sFrameworkunifiedThreadReady, evFrameworkunifiedStop, sFrameworkunifiedThreadStop)
1138 CONNECT_EVENT(sFrameworkunifiedThreadStop, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
1140 // Create Internal Transition
1141 CREATE_INTERNALTRANSITION(OnDestroyThread)
1142 CONNECT_EVENT(sFrameworkunifiedThreadRoot, evFrameworkunifiedDestroy, OnDestroyThread)
1144 // Connecting AppRoot to statemachine
1145 CONNECTROOT(sFrameworkunifiedThreadRoot)
1146 } catch (std::exception &e) {
1147 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1149 eStatus = eFrameworkunifiedStatusNullPointer;
1154 ///////////////////////////////////////////////////////////////////////////////////////////
1155 /// COnDestroyThread::FrameworkunifiedReaction
1156 /// This reaction is executed when request for terminating the thread is received.
1157 ///////////////////////////////////////////////////////////////////////////////////////////
1158 CFrameworkunifiedState *CFrameworkunifiedHSMChildFramework::COnDestroyThread::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
1159 CEventDataPtr f_pEventData) {
1160 // return the NULL to exit the dispatcher loop of thread
1164 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
1165 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1167 CHKNULL(m_pFrameworkunifiedStateList);
1168 CHKNULL(f_pAppState);
1170 if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady) == m_pFrameworkunifiedStateList->end()) {
1171 throw CNullPointerException();
1173 CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady)->second);
1176 eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
1177 } catch (std::exception &e) {
1178 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1180 eStatus = eFrameworkunifiedStatusNullPointer;
1185 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
1186 CFrameworkunifiedReaction *f_pReaction,
1187 std::string f_strEventName, BOOL f_bIsDeferredEvent) {
1188 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1190 CHKNULL(m_pFrameworkunifiedStateList);
1192 if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
1193 throw CNullPointerException();
1195 CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
1197 CHKNULL(l_pFrameworkunifiedState);
1199 eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
1200 } catch (std::exception &e) {
1201 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1203 eStatus = eFrameworkunifiedStatusNullPointer;
1208 ///////////////////////////////////////////////////////////////////////////////////////////
1209 /// CFrameworkunifiedThreadRoot
1210 /// Parameterized constructor
1211 ///////////////////////////////////////////////////////////////////////////////////////////
1212 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::CsFrameworkunifiedThreadRoot(std::string f_pName)
1213 : CFrameworkunifiedCompositeState(f_pName) {
1216 ///////////////////////////////////////////////////////////////////////////////////////////
1217 /// ~CsFrameworkunifiedThreadRoot
1218 /// class destructor
1219 ///////////////////////////////////////////////////////////////////////////////////////////
1220 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::~CsFrameworkunifiedThreadRoot() {
1223 ///////////////////////////////////////////////////////////////////////////////////////////
1224 /// FrameworkunifiedOnEntry
1225 /// publishes the service availability notification
1226 ///////////////////////////////////////////////////////////////////////////////////////////
1227 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1228 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1229 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1233 ///////////////////////////////////////////////////////////////////////////////////////////
1234 /// FrameworkunifiedOnExit
1235 /// state cleanup can be performed in this function.
1236 ///////////////////////////////////////////////////////////////////////////////////////////
1237 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1238 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1239 return eFrameworkunifiedStatusOK;
1242 ///////////////////////////////////////////////////////////////////////////////////////////
1243 /// CFrameworkunifiedThreadIdle
1244 /// Parameterized constructor
1245 ///////////////////////////////////////////////////////////////////////////////////////////
1246 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::CsFrameworkunifiedThreadIdle(std::string f_pName)
1247 : CFrameworkunifiedCompositeState(f_pName) {
1250 ///////////////////////////////////////////////////////////////////////////////////////////
1251 /// ~CsFrameworkunifiedThreadIdle
1252 /// class destructor
1253 ///////////////////////////////////////////////////////////////////////////////////////////
1254 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::~CsFrameworkunifiedThreadIdle() {
1257 ///////////////////////////////////////////////////////////////////////////////////////////
1258 /// FrameworkunifiedOnEntry
1259 /// publishes the service availability notification
1260 ///////////////////////////////////////////////////////////////////////////////////////////
1261 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1262 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1263 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1267 ///////////////////////////////////////////////////////////////////////////////////////////
1268 /// FrameworkunifiedOnExit
1269 /// state cleanup can be performed in this function.
1270 ///////////////////////////////////////////////////////////////////////////////////////////
1271 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1272 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1273 return eFrameworkunifiedStatusOK;
1276 ///////////////////////////////////////////////////////////////////////////////////////////
1277 /// CFrameworkunifiedThreadStart
1278 /// Parameterized constructor
1279 ///////////////////////////////////////////////////////////////////////////////////////////
1280 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::CsFrameworkunifiedThreadStart(std::string f_pName)
1281 : CFrameworkunifiedCompositeState(f_pName) {
1284 ///////////////////////////////////////////////////////////////////////////////////////////
1285 /// ~CsFrameworkunifiedThreadStart
1286 /// class destructor
1287 ///////////////////////////////////////////////////////////////////////////////////////////
1288 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::~CsFrameworkunifiedThreadStart() {
1291 ///////////////////////////////////////////////////////////////////////////////////////////
1292 /// FrameworkunifiedOnEntry
1293 /// publishes the service availability notification
1294 ///////////////////////////////////////////////////////////////////////////////////////////
1295 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1296 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1299 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1301 CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
1302 (FrameworkunifiedGetAppHandle());
1303 CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
1304 CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread);
1305 if (eFrameworkunifiedStatusOK ==
1306 (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread(pApp)) {
1307 FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
1309 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Thread start Failed: %s", m_strStateName.c_str());
1311 } catch (std::exception &e) {
1312 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1314 eStatus = eFrameworkunifiedStatusNullPointer;
1320 ///////////////////////////////////////////////////////////////////////////////////////////
1321 /// FrameworkunifiedOnExit
1322 /// state cleanup can be performed in this function.
1323 ///////////////////////////////////////////////////////////////////////////////////////////
1324 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1325 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1326 return eFrameworkunifiedStatusOK;
1329 ///////////////////////////////////////////////////////////////////////////////////////////
1330 /// CFrameworkunifiedThreadReady
1331 /// Parameterized constructor
1332 ///////////////////////////////////////////////////////////////////////////////////////////
1333 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::CsFrameworkunifiedThreadReady(std::string f_pName)
1334 : CFrameworkunifiedCompositeState(f_pName) {
1337 ///////////////////////////////////////////////////////////////////////////////////////////
1338 /// ~CsFrameworkunifiedThreadReady
1339 /// class destructor
1340 ///////////////////////////////////////////////////////////////////////////////////////////
1341 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::~CsFrameworkunifiedThreadReady() {
1344 ///////////////////////////////////////////////////////////////////////////////////////////
1345 /// FrameworkunifiedOnEntry
1346 /// publishes the service availability notification
1347 ///////////////////////////////////////////////////////////////////////////////////////////
1348 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1349 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1350 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1354 ///////////////////////////////////////////////////////////////////////////////////////////
1355 /// FrameworkunifiedOnExit
1356 /// state cleanup can be performed in this function.
1357 ///////////////////////////////////////////////////////////////////////////////////////////
1358 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1359 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1360 return eFrameworkunifiedStatusOK;
1363 ///////////////////////////////////////////////////////////////////////////////////////////
1364 /// CFrameworkunifiedThreadStop
1365 /// Parameterized constructor
1366 ///////////////////////////////////////////////////////////////////////////////////////////
1367 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::CsFrameworkunifiedThreadStop(std::string f_pName)
1368 : CFrameworkunifiedLeafState(f_pName) {
1371 ///////////////////////////////////////////////////////////////////////////////////////////
1372 /// ~CsFrameworkunifiedThreadStop
1373 /// class destructor
1374 ///////////////////////////////////////////////////////////////////////////////////////////
1375 CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::~CsFrameworkunifiedThreadStop() {
1378 ///////////////////////////////////////////////////////////////////////////////////////////
1379 /// FrameworkunifiedOnEntry
1380 /// publishes the service availability notification
1381 ///////////////////////////////////////////////////////////////////////////////////////////
1382 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
1383 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1385 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
1387 HANDLE hApp = FrameworkunifiedGetAppHandle();
1389 CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
1391 CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
1392 CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread);
1394 eStatus = (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread(pApp);
1396 if (eFrameworkunifiedStatusOK != eStatus) {
1397 FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: Thread stop function returned %d", eStatus);
1398 // We just need to print the error.
1399 // Returning this status to state machine is not required.
1400 // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
1401 eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
1403 } catch (std::exception &e) {
1404 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1406 eStatus = eFrameworkunifiedStatusNullPointer;
1412 ///////////////////////////////////////////////////////////////////////////////////////////
1413 /// FrameworkunifiedOnExit
1414 /// state cleanup can be performed in this function.
1415 ///////////////////////////////////////////////////////////////////////////////////////////
1416 EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
1417 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
1418 return eFrameworkunifiedStatusOK;