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 CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
28 /// This class implements interfaces for connecting child states to parent states, connecting events
30 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 #include <native_service/frameworkunified_sm_hsm.h>
33 #include <native_service/frameworkunified_sm_reaction.h>
34 #include <native_service/frameworkunified_sm_state.h>
35 #include <native_service/frameworkunified_sm_compositestate.h>
36 #include <native_service/frameworkunified_sm_framework_types.h>
37 #include <native_service/frameworkunified_sm_orthogonalstate.h>
38 #include <native_service/frameworkunified_framework_if.h>
44 #include "frameworkunified_framework_internal.h"
45 #include "frameworkunified_sm_framework_core.h"
47 ///////////////////////////////////////////////////////////////////////////////////////////
48 /// CFrameworkunifiedHSM
50 ///////////////////////////////////////////////////////////////////////////////////////////
51 CFrameworkunifiedHSM::CFrameworkunifiedHSM(PVOID f_pHApp): m_uiCurrentEvent(0), m_pHApp(f_pHApp), m_pActiveState(NULL), m_pRootState(NULL),
52 m_bIsTransitioning(FALSE) {
53 // PostEventList stores the list of events posted in the state
54 m_pPostEventList = new EventInfoList();
57 ///////////////////////////////////////////////////////////////////////////////////////////
58 /// CFrameworkunifiedHSM
60 ///////////////////////////////////////////////////////////////////////////////////////////
61 CFrameworkunifiedHSM::CFrameworkunifiedHSM(): m_uiCurrentEvent(0), m_pHApp(NULL), m_pActiveState(NULL), m_pRootState(NULL),
62 m_bIsTransitioning(FALSE) {
63 // PostEventList stores the list of events posted in the state
64 m_pPostEventList = new EventInfoList();
68 ///////////////////////////////////////////////////////////////////////////////////////////
69 /// ~CFrameworkunifiedHSM
71 ///////////////////////////////////////////////////////////////////////////////////////////
72 CFrameworkunifiedHSM::~CFrameworkunifiedHSM() {
73 if (NULL != m_pPostEventList) {
74 delete m_pPostEventList;
75 m_pPostEventList = NULL;
79 FrameworkunifiedClose();
82 // we are not deleting this pointer because memory pointed by this pointer
83 // had already been deleted in above step.
84 m_pActiveState = NULL;
87 ///////////////////////////////////////////////////////////////////////////////////////////
88 /// FrameworkunifiedGetActiveState
89 /// Returns the active state of the statemachine
90 ///////////////////////////////////////////////////////////////////////////////////////////
91 CFrameworkunifiedState *CFrameworkunifiedHSM::FrameworkunifiedGetActiveState() {
92 CFrameworkunifiedState *l_pCurrentState = m_pRootState;
93 CFrameworkunifiedState *l_pActiveState = NULL;
96 // Iterate till the current state is leafstate or orthogonal state
97 while (l_pCurrentState != l_pActiveState) {
98 l_pActiveState = l_pCurrentState;
99 l_pCurrentState = l_pCurrentState->FrameworkunifiedGetActiveState();
100 CHKNULL(l_pCurrentState);
104 m_pActiveState = l_pActiveState;
106 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
107 , m_pActiveState->m_strStateName.c_str());
108 } catch (std::exception &e) {
109 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
110 l_pActiveState = NULL;
114 return l_pActiveState;
117 ///////////////////////////////////////////////////////////////////////////////////////////
118 /// FrameworkunifiedStart
119 /// This starts the state machine
120 ///////////////////////////////////////////////////////////////////////////////////////////
121 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedStart(CEventDataPtr f_pEventData) {
122 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
125 CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
127 m_bIsTransitioning = TRUE;
129 // Start the state machine execution on current state
130 m_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
132 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
133 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
134 , m_pActiveState->m_strStateName.c_str());
136 // post the event from events list
137 eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
139 m_bIsTransitioning = FALSE;
140 } catch (std::exception &e) {
141 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
142 eStatus = eFrameworkunifiedStatusNullPointer;
148 ///////////////////////////////////////////////////////////////////////////////////////////
149 /// FrameworkunifiedConnect
150 /// This connects the reaction to event and add event to child states then add child state
151 ///////////////////////////////////////////////////////////////////////////////////////////
152 EFrameworkunifiedStatus CFrameworkunifiedHSM::CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
153 UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
154 BOOL f_bIsDefaultState, BOOL f_bIsDeferredEventType,
155 std::string f_strEventName) {
156 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
159 // attach reaction to event and add it to the child state
160 eStatus = FrameworkunifiedConnect(f_pChildState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEventType);
161 if (eFrameworkunifiedStatusOK == eStatus) {
162 // add child state to parent state
163 eStatus = FrameworkunifiedConnect(f_pParentState, f_pChildState, f_bIsDefaultState);
165 } catch (std::exception &e) {
166 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
168 eStatus = eFrameworkunifiedStatusNullPointer;
172 ///////////////////////////////////////////////////////////////////////////////////////////
173 /// FrameworkunifiedConnect
174 /// This add child state to parent state.
175 ///////////////////////////////////////////////////////////////////////////////////////////
176 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
177 BOOL f_bIsDefaultState) {
178 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
180 CHKNULL(f_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
181 CHKNULL(f_pChildState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
182 // Check if the state is composite state
183 if (f_pParentState->FrameworkunifiedHasSubStates()) {
184 // Check if the child state is default state
185 if (f_bIsDefaultState) {
186 // Add child state as default state
187 (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState,
188 CFrameworkunifiedCompositeState::eFrameworkunifiedDefaultState); // LCOV_EXCL_BR_LINE 11: except branch
190 // Add state as regular state
191 (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState); // LCOV_EXCL_BR_LINE 11: except branch
194 f_pChildState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11: except branch
197 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error %s is not a composite state",
198 f_pParentState->m_strStateName.c_str());
200 } catch (std::exception &e) {
201 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
203 eStatus = eFrameworkunifiedStatusNullPointer;
206 return eStatus; //LCOV_EXCL_BR_LINE 11:except branch
209 ///////////////////////////////////////////////////////////////////////////////////////////
210 /// FrameworkunifiedConnect
211 /// This connects the reaction to event and add event to child states
212 ///////////////////////////////////////////////////////////////////////////////////////////
213 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
214 std::string f_strEventName , BOOL f_bIsDeferredEventType) {
215 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
217 CHKNULL(f_pState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
218 // check if the event is deferred event
219 if (f_bIsDeferredEventType) {
220 // Add event as deferred event
221 f_pState->FrameworkunifiedAddDeferredEvent(f_uiEventId, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
222 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
223 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Deferred Event %d %s is "
224 "associated with Reaction and added to state %s "
225 , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
228 CHKNULL(f_pReaction); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
229 // Add event as regular event
230 f_pState->FrameworkunifiedAddEvent(f_uiEventId, f_pReaction, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
232 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
233 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Event %d %s is associated with Reaction and added to state %s "
234 , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
237 } catch (std::exception &e) {
238 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
239 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d in %s", f_uiEventId,
240 (f_pState->m_strStateName).c_str());
242 eStatus = eFrameworkunifiedStatusNullPointer;
248 ///////////////////////////////////////////////////////////////////////////////////////////
249 /// FrameworkunifiedPostEvent
250 /// This creates the default event data and sends the event to the active HSM state.
251 ///////////////////////////////////////////////////////////////////////////////////////////
252 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(UI_32 f_uiEventId) {
253 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 11: except branch
255 CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch
256 CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
258 l_eStatus = FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
259 } catch (std::exception &e) {
260 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
261 l_eStatus = eFrameworkunifiedStatusNullPointer;
266 ///////////////////////////////////////////////////////////////////////////////////////////
267 /// FrameworkunifiedPostEvent
268 /// This sends the event to the active HSM state
269 ///////////////////////////////////////////////////////////////////////////////////////////
270 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) {
271 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
273 CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
275 if (m_bIsTransitioning) {
276 eStatus = FrameworkunifiedQueueEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
278 m_bIsTransitioning = TRUE;
280 eStatus = ProcessEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
282 m_bIsTransitioning = FALSE;
284 CHKNULL(m_pActiveState);
285 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"
287 } catch (std::exception &e) {
288 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
290 eStatus = eFrameworkunifiedStatusNullPointer;
295 EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEvent(CEventDataPtr f_pEventData) {
296 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
298 CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
299 CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
300 CHKNULL(m_pActiveState->m_pEventName); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
302 EventNameList::iterator l_itEventName;
303 l_itEventName = m_pActiveState->m_pEventName->find(f_pEventData->m_uiEventId);
305 if (m_pActiveState->m_pEventName->end() != l_itEventName) {
306 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
307 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Posting event %d %s to state %s",
308 f_pEventData->m_uiEventId,
309 l_itEventName->second.c_str(),
310 m_pActiveState->m_strStateName.c_str());
314 m_uiCurrentEvent = f_pEventData->m_uiEventId;
316 // Send event to active state for processing
317 m_pActiveState = m_pActiveState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
319 CHKNULL(m_pActiveState);
320 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"
322 // post the event from events list
323 eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
324 } catch (std::exception &e) {
325 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
327 eStatus = eFrameworkunifiedStatusNullPointer;
332 ///////////////////////////////////////////////////////////////////////////////////////////
333 /// FrameworkunifiedClose
334 /// This stops the state machine and destroys all states and events
335 ///////////////////////////////////////////////////////////////////////////////////////////
336 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedClose(CEventDataPtr f_pEventData) {
337 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
339 CHKNULL(m_pRootState);
342 } catch (std::exception &e) {
343 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
345 eStatus = eFrameworkunifiedStatusNullPointer;
350 ///////////////////////////////////////////////////////////////////////////////////////////
351 /// FrameworkunifiedConnect
352 /// This sets the givens state as root state in the state machine
353 ///////////////////////////////////////////////////////////////////////////////////////////
354 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState) {
355 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
357 CHKNULL(f_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
359 m_pActiveState = f_pRootState;
360 m_pRootState = f_pRootState;
362 m_pRootState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11:except branch
363 } catch (std::exception &e) {
364 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
366 eStatus = eFrameworkunifiedStatusNullPointer;
368 return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
371 ///////////////////////////////////////////////////////////////////////////////////////////
372 /// FrameworkunifiedPrintAllStates
373 /// This prints all states and events associated with every state on console.
374 ///////////////////////////////////////////////////////////////////////////////////////////
375 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintAllStates() {
376 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
378 CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
380 m_pRootState->FrameworkunifiedPrintStates();
381 } catch (std::exception &e) {
382 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
384 eStatus = eFrameworkunifiedStatusNullPointer;
386 return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
389 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
390 CFrameworkunifiedCompositeState *f_pOrthogonalRegion) {
391 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
393 CHKNULL(f_pOrthogonalState) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
394 CHKNULL(f_pOrthogonalRegion) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
396 f_pOrthogonalState->FrameworkunifiedAddOrthogonalRegion(f_pOrthogonalRegion);
397 } catch (std::exception &e) {
398 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
399 eStatus = eFrameworkunifiedStatusNullPointer;
404 HANDLE CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle() {
408 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintXML() {
409 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
411 std::ostringstream l_strXMLString;
412 l_strXMLString << "<Statemachine>";
414 CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
416 // Write statemachine information in XML stream
417 m_pRootState->FrameworkunifiedPrintXML(l_strXMLString);
418 l_strXMLString << "</Statemachine>";
420 // Write a stream to XML file
422 size_t l_uiLength = static_cast<size_t>(l_strXMLString.str().length());
424 PCHAR l_pStream = new CHAR[l_uiLength + 1];
425 if (NULL != l_pStream) {
426 std::FILE *l_pFile = NULL;
428 std::memset(l_pStream, 0, l_uiLength + 1);
429 std::strncpy(l_pStream, l_strXMLString.str().c_str(), l_uiLength);
431 std::ostringstream l_strFileName;
433 l_strFileName << "StatemachineXML_";
435 l_strFileName << FrameworkunifiedGetAppName(m_pHApp) << ".xml";
437 l_pFile = std::fopen(l_strFileName.str().c_str(), "wbe");
440 std::fwrite(l_pStream, l_uiLength, 1, l_pFile);
441 std::fclose(l_pFile);
442 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s File Created"
443 , l_strFileName.str().c_str());
448 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: StatemachineXML_%s.xml file not created", FrameworkunifiedGetAppName(m_pHApp));
451 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, l_strXMLString.str().c_str());
452 } catch (std::exception &e) {
453 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
458 EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData) {
459 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
461 CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
462 CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
463 CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
465 // Push the event in the post event list(FIFO)
466 m_pPostEventList->push_back(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
467 } catch (std::exception &e) {
468 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
469 eStatus = eFrameworkunifiedStatusNullPointer;
471 return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
474 ///////////////////////////////////////////////////////////////////////////////////////////
475 /// ProcessEventQueue
476 /// This post the event from events list
477 ///////////////////////////////////////////////////////////////////////////////////////////
478 EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEventQueue() {
479 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
482 CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
484 if (!m_pPostEventList->empty()) {
485 CEventDataPtr l_pEventData = m_pPostEventList->front(); // LCOV_EXCL_BR_LINE 11:except branch
486 CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
488 CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
489 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
490 FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Processing posted event %d in state %s",
491 l_pEventData->m_uiEventId, m_pActiveState->m_strStateName.c_str());
493 m_pPostEventList->erase(m_pPostEventList->begin());
495 eStatus = ProcessEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
497 } catch (std::exception &e) {
498 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
499 eStatus = eFrameworkunifiedStatusNullPointer;
504 ///////////////////////////////////////////////////////////////////////////////////////////
505 /// RemoveEventFromPostedEventQueue
506 /// This API is used to remove the all events of eventId f_uiEventId from event queue of statemachine
507 ///////////////////////////////////////////////////////////////////////////////////////////
508 EFrameworkunifiedStatus CFrameworkunifiedHSM::RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId) {
509 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID;
510 FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
512 if (NULL != m_pPostEventList) {
513 int32_t l_siCnt = static_cast<int32_t>(m_pPostEventList->size() - 1);
515 for (; l_siCnt >= 0; l_siCnt--) {
516 if (NULL != m_pPostEventList->at(l_siCnt).get()) {
517 if (f_uiEventId == m_pPostEventList->at(l_siCnt).get()->m_uiEventId) {
518 m_pPostEventList->erase(m_pPostEventList->begin() + l_siCnt);
519 l_eStatus = eFrameworkunifiedStatusOK;
524 l_eStatus = eFrameworkunifiedStatusNullPointer;
527 FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");