common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / power_service / server / src / ss_power_state_machine.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_PowerService
19 /// \brief    This file supports the power service state machine.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include "ss_power_state_machine.h"
24 #include <system_service/ss_power_service_protocol.h>
25 #include <system_service/ss_power_service.h>
26 #include <system_service/ss_power_service_notifications.h>
27 #include <system_service/ss_power_service_local.h>
28 #include <system_service/ss_power_service_notifications_local.h>
29 #include <system_service/ss_services.h>
30 #include <native_service/ns_timer_if.h>
31 #include <native_service/frameworkunified_framework_if.h>
32
33
34 #include "ss_power_session.h"
35 #include "ss_power_powerservicelog.h"
36
37 /// Define static members of the class.
38 PowerStateMachine::Wakeup PowerStateMachine::WakeupState;
39 PowerStateMachine::WakeupActive PowerStateMachine::WakeupActiveState;
40 PowerStateMachine::WakeupPending PowerStateMachine::WakeupPendingState;
41 PowerStateMachine::LowVoltage1 PowerStateMachine::LowVoltage1State;
42 PowerStateMachine::LowVoltage1Active PowerStateMachine::LowVoltage1ActiveState;
43 PowerStateMachine::LowVoltage2 PowerStateMachine::LowVoltage2State;
44 PowerStateMachine::LowVoltage2Active PowerStateMachine::LowVoltage2ActiveState;
45 PowerStateMachine::Shutdown PowerStateMachine::ShutdownState;
46 PowerStateMachine::ShutdownActive PowerStateMachine::ShutdownActiveState;
47 PowerStateMachine::NormalVoltage PowerStateMachine::NormalVoltageState;
48 PowerStateMachine::SoftwareUpdate PowerStateMachine::SoftwareUpdateState;
49
50 /// Constructor
51 PowerStateMachine::PowerStateMachine()
52     : m_pCurrentState(&WakeupState),
53       m_pPreviousState(NULL),
54       m_pOnHysteresisTimeoutState(NULL),
55       m_oShutdownHysteresis(),
56       m_oLowVoltage1Hysteresis(),
57       m_oLowVoltage2Hysteresis(),
58       m_hHysteresisTimer(NULL),
59       m_tStateInfo() {
60 }
61
62 /// Deconstructor
63 PowerStateMachine::~PowerStateMachine() {  // LCOV_EXCL_START 14 Resident process, not called by NSFW
64   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
65 }
66 // LCOV_EXCL_STOP 14 Resident process, not called by NSFW
67
68 void PowerStateMachine::onEvent(HANDLE h_app, PowerSessionHandler & oSession,
69                                 ePowerStateMachineEvents evt) {
70   FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
71   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
72          "(ENTRY) Power StateMachine Current State: %s, Previous State: %s",
73          m_pCurrentState->name(),
74          (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name()));
75
76   switch (evt) {  // LCOV_EXCL_BR_LINE 8: dead code
77     case PowerStateMachine::epsmeWAKEUP:
78       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeWAKEUP");
79       m_pCurrentState->onWakeup(*this, h_app, oSession);
80       break;
81     case PowerStateMachine::epsmeSTART_COMPLETE:  // LCOV_EXCL_START 8: no one send the event
82     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
83       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTART_COMPLETE");
84       m_pCurrentState->onStartComplete(*this, h_app, oSession);
85       break;
86     // LCOV_EXCL_STOP 8: no one send the event
87     case PowerStateMachine::epsmeSHUTDOWN:
88       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSHUTDOWN");
89       m_pCurrentState->onShutdown(*this, h_app, oSession);
90       break;
91     case PowerStateMachine::epsmeSTOP_COMPLETE:  // LCOV_EXCL_START 8: no one send the event
92     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
93       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTOP_COMPLETE");
94       m_pCurrentState->onStopComplete(*this, h_app, oSession);
95       break;
96     case PowerStateMachine::epsmeLVI1_ENCOUNTERED:
97       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_ENCOUNTERED");
98       m_pCurrentState->onLowVoltage1Encountered(*this, h_app, oSession);
99       break;
100     case PowerStateMachine::epsmeLVI2_ENCOUNTERED:
101       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_ENCOUNTERED");
102       m_pCurrentState->onLowVoltage2Encountered(*this, h_app, oSession);
103       break;
104     case PowerStateMachine::epsmeNORMAL_VOLTAGE_ENCOUNTERED:
105       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
106               "Power StateMachine Event Received: epsmeNORMAL_VOLTAGE_ENCOUNTERED");
107       m_pCurrentState->onNormalVoltageEncountered(*this, h_app, oSession);
108       break;
109     case PowerStateMachine::epsmeSOFTWARE_UPDATE:
110       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSOFTWARE_UPDATE");
111       m_pCurrentState->onSoftwareUpdate(*this, h_app, oSession);
112       break;
113     case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_ABORTED:
114       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
115               "Power StateMachine Event Received: epsmeSHUTDOWN_HYSTERESIS_ABORTED");
116     case PowerStateMachine::epsmeLVI1_HYSTERESIS_ABORTED:
117       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_HYSTERESIS_ABORTED");
118     case PowerStateMachine::epsmeLVI2_HYSTERESIS_ABORTED:
119       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_HYSTERESIS_ABORTED");
120       m_pCurrentState->onHysteresisAborted(*this, h_app, oSession);
121       break;
122     // LCOV_EXCL_STOP 8: no one send the event
123     case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_TM_OUT:
124       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"  // NOLINT[whitespace/line_length]
125               "Power StateMachine Event Received: epsmeSHUTDOWN_HYSTERESIS_TM_OUT");  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"  // NOLINT[whitespace/line_length]
126     case PowerStateMachine::epsmeLVI1_HYSTERESIS_TM_OUT:
127       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_HYSTERESIS_TM_OUT");  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"  // NOLINT[whitespace/line_length]
128     case PowerStateMachine::epsmeLVI2_HYSTERESIS_TM_OUT:
129       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_HYSTERESIS_TM_OUT");  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"  // NOLINT[whitespace/line_length]
130       m_pCurrentState->onHysteresisTimeout(*this, h_app, oSession);
131       break;
132     default:
133       FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: WAS INVALID");  // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"  // NOLINT[whitespace/line_length]
134       break;
135   }  // ZONE_POWER_STATEMACHINE
136
137   FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
138   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
139          "(EXIT) Power StateMachine Current State: %s, Previous State: %s",
140          m_pCurrentState->name(),
141          (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name()));
142 }
143
144 PCSTR PowerStateMachine::name() {  // LCOV_EXCL_START 8: do not be called
145   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
146   if (NULL != m_pCurrentState) {
147     return m_pCurrentState->name();
148   }
149
150   return "Invalid Current State is NULL...";
151 }
152 // LCOV_EXCL_STOP 8: do not be called
153
154 /// Switch to the next State and save the previous state.
155 void PowerStateMachine::NextState(Base_State & refState, HANDLE h_app,
156                                   PowerSessionHandler & oSession) {
157   m_pPreviousState = m_pCurrentState;
158   m_pPreviousState->onExit(*this, h_app, oSession);
159   m_pCurrentState = &refState;
160   m_pCurrentState->onEntry(*this, h_app, oSession);
161 }
162
163 // LCOV_EXCL_START 8: do not be called
164 void PowerStateMachine::OnVoltage(Base_State * pState, HANDLE h_app,
165                                   PowerSessionHandler & oSession) {
166   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
167   if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) {
168     Pwr_ServiceSetInterface tServiceIf;
169
170     if (eFrameworkunifiedStatusOK
171         == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf,
172                                sizeof(Pwr_ServiceSetInterface))) {
173       /// Need to store the voltage information
174       m_tStateInfo.voltage = tServiceIf.data.voltage.state;
175
176       if (NULL != pState) {
177         NextState(*pState, h_app, oSession);
178       }
179     }
180   }
181 }
182 // LCOV_EXCL_STOP 8: do not be called
183 void PowerStateMachine::GotoStateOnHysteresisTimeout(Base_State & refState) {
184   m_pOnHysteresisTimeoutState = &refState;
185 }
186
187 void PowerStateMachine::startHysteresisTimer(PowerStateHysteresis & hys_info) {
188   /// clear the try counter.
189   hys_info.clearTryCounter();
190
191   /// bump the hysteresis try counter (prime the counter).
192   hys_info.bumbTryCounter();
193
194   /// setup the hysteresis timer
195   NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()),
196       MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 };
197
198   /// start the hysteresis timer
199   NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis);
200 }
201
202 void PowerStateMachine::reStartHysteresisTimer(
203     PowerStateHysteresis & hys_info) {
204   /// bump the hysteresis try counter.
205   hys_info.bumbTryCounter();
206
207   /// setup the hysteresis timer (one shot)
208   NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()),
209       MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 };
210   /// start the hysteresis timer
211   NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis);
212 }
213
214 void PowerStateMachine::stopHysteresisTimer(PowerStateHysteresis & hys_info) {
215   NSTimerInfo turn_off_hysteresis = { 0, 0, 0, 0, 0 };
216   NS_TimerSetTime(m_hHysteresisTimer, turn_off_hysteresis);
217   /// clear the try counter.
218   hys_info.clearTryCounter();
219 }
220
221 // LCOV_EXCL_START 8: can not be called
222 void PowerStateMachine::publishPowerLVIStatus(HANDLE h_app, PCSTR nNotifNm,
223                                               UI_32 value) {
224   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
225   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
226   PowerSrvLVIStatus eLviStatus = static_cast<PowerSrvLVIStatus>(value);
227   if (eFrameworkunifiedStatusOK
228       != (eStatus = FrameworkunifiedNPPublishNotification(h_app, nNotifNm, &eLviStatus,
229                                              sizeof(eLviStatus)))) {
230     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
231            " Error: FrameworkunifiedNPPublishNotification( %s ) errored: 0x%X", nNotifNm,
232            eStatus);
233   }
234 }
235 // LCOV_EXCL_STOP 8: can not be called
236 void PowerStateMachine::publishPowerLevelType(HANDLE h_app, UI_32 value) {
237   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
238   PowerSrvLevelType eLevelType = static_cast<PowerSrvLevelType>(value);
239   if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPPublishNotification (h_app, szNTFY_PowerLevel, &eLevelType, sizeof (eLevelType)))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
240     // LCOV_EXCL_START 4: NSFW error case.
241     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
242     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
243            " Error: FrameworkunifiedNPPublishNotification %s Failed Status:0x%x ",
244            szNTFY_PowerLevel, eStatus);
245   // LCOV_EXCL_STOP 4: NSFW error case.
246   }
247 }
248
249 // LCOV_EXCL_START 8: no one send the event
250 void PowerStateMachine::Base_State::onStartComplete(
251     PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
252   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
253   oSession.StartComplete(h_app);
254 }
255 // LCOV_EXCL_STOP 8: do not be called
256
257 // LCOV_EXCL_START 8: no one send the event
258 void PowerStateMachine::Base_State::onStopComplete(
259     PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
260   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
261   oSession.StopComplete(h_app);
262 }
263 // LCOV_EXCL_STOP 8: no one send the event
264
265 // LCOV_EXCL_START 8: no one call this function
266 void PowerStateMachine::Base_State::onLaunchComplete(
267     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
268     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
269   FrameworkunifiedDeferMessage(h_app);
270 }
271 // LCOV_EXCL_STOP 8: do not be called
272
273 // LCOV_EXCL_START 8: no one send the event
274 void PowerStateMachine::Base_State::onShutdownComplete(
275     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
276   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
277   FrameworkunifiedDeferMessage(h_app);
278 }
279 // LCOV_EXCL_STOP 8: no one call this function
280 PCSTR PowerStateMachine::Wakeup::name() {
281   return "Wakeup";
282 }
283
284 // LCOV_EXCL_START 8: no one send the event
285 void PowerStateMachine::Wakeup::onLowVoltage1Encountered(
286     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
287     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
288   u.OnVoltage(&LowVoltage1State, h_app, oSession);
289   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
290          FrameworkunifiedGetMsgSrc(h_app));
291 }
292 // LCOV_EXCL_STOP 8: do not be called
293
294 // LCOV_EXCL_START 8: no one send the event
295 void PowerStateMachine::Wakeup::onLowVoltage2Encountered(
296     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
297     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
298   u.OnVoltage(&LowVoltage2State, h_app, oSession);
299   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
300          FrameworkunifiedGetMsgSrc(h_app));
301 }
302 // LCOV_EXCL_STOP 8: no one send the event to call this function
303
304 // LCOV_EXCL_START 8: no one send the event to call this function
305 void PowerStateMachine::Wakeup::onNormalVoltageEncountered(
306     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
307     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
308   u.OnVoltage(NULL, h_app, oSession);
309   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
310          "NORMAL ENCOUNTERED %s (no switch)", FrameworkunifiedGetMsgSrc(h_app));
311 }
312 // LCOV_EXCL_STOP 8: no one send the event
313 void PowerStateMachine::Wakeup::onShutdown(PowerStateMachine &u, HANDLE h_app,
314                                            PowerSessionHandler & oSession) {
315   u.NextState(ShutdownState, h_app, oSession);
316 }
317
318 // LCOV_EXCL_START 8: no one send the event
319 void PowerStateMachine::Wakeup::onSoftwareUpdate(
320     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
321     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
322   u.NextState(SoftwareUpdateState, h_app, oSession);
323 }
324 // LCOV_EXCL_STOP 8: no one send the event
325
326 // LCOV_EXCL_START 8: no one send the event
327 void PowerStateMachine::Wakeup::onWakeup(PowerStateMachine &u, HANDLE h_app,
328                                          PowerSessionHandler & oSession) {
329   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
330   Pwr_ServiceSetInterface tServiceIf;
331   if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) {
332     if (eFrameworkunifiedStatusOK
333         == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf,
334                                sizeof(Pwr_ServiceSetInterface))) {
335       if (epswsPWRON == tServiceIf.data.wake.powerupType) {
336         /// Need to store the wakeup \ shutdown information
337         u.m_tStateInfo.wake = tServiceIf.data.wake.powerupType;
338         u.m_tStateInfo.level = tServiceIf.data.wake.up.level;
339         u.m_tStateInfo.factor = tServiceIf.data.wake.up.factor;
340
341         u.NextState(WakeupPendingState, h_app, oSession);
342       }
343     }
344   }
345 }
346 // LCOV_EXCL_STOP 8: no one send the event
347
348 PCSTR PowerStateMachine::WakeupActive::name() {
349   return "Wakeup Active";
350 }
351
352 // LCOV_EXCL_START 8: no one send the event
353 void PowerStateMachine::WakeupActive::onLowVoltage1Encountered(
354     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
355     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
356   u.OnVoltage(&LowVoltage1State, h_app, oSession);
357   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
358          FrameworkunifiedGetMsgSrc(h_app));
359 }
360 // LCOV_EXCL_STOP 8: no one send the event to call this function
361
362 // LCOV_EXCL_START 8: no one send the event to call this function
363 void PowerStateMachine::WakeupActive::onLowVoltage2Encountered(
364     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
365     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
366   u.OnVoltage(&LowVoltage2State, h_app, oSession);
367   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
368          FrameworkunifiedGetMsgSrc(h_app));
369 }
370 // LCOV_EXCL_STOP 8: no one send the event
371 void PowerStateMachine::WakeupActive::onShutdown(
372     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
373   u.NextState(ShutdownState, h_app, oSession);
374 }
375
376 PCSTR PowerStateMachine::WakeupPending::name() {
377   return "Wakeup Pending";
378 }
379
380 // LCOV_EXCL_START 8: no one send the event
381 void PowerStateMachine::WakeupPending::onNormalVoltageEncountered(
382     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
383     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
384   u.OnVoltage(&NormalVoltageState, h_app, oSession);
385   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL ENCOUNTERED %s",
386          FrameworkunifiedGetMsgSrc(h_app));
387 }
388 // LCOV_EXCL_STOP 8: no one send the event to call this function
389
390 // LCOV_EXCL_START 8: no one send the event to call this function
391 void PowerStateMachine::WakeupPending::onStartComplete(
392     PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
393     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
394   oSession.StartComplete(h_app);
395 }
396 // LCOV_EXCL_STOP 8: no one send the event
397
398 // LCOV_EXCL_START 8: no one call this function
399 void PowerStateMachine::WakeupPending::onLaunchComplete(
400     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
401     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
402   oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL);
403   if (epsvsNORMAL == u.m_tStateInfo.voltage) {
404     u.NextState(NormalVoltageState, h_app, oSession);
405   }
406 }
407 // LCOV_EXCL_STOP 8: no one call this function
408
409 // LCOV_EXCL_START 8: no one send the event
410 void PowerStateMachine::WakeupPending::onWakeup(
411     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
412     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
413   if (oSession.WakeupComplete(u.m_lstWakeupModules)) {
414     oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL);
415   }
416 }
417 // LCOV_EXCL_STOP 8: no one send the event
418
419 void PowerStateMachine::WakeupPending::onEntry(PowerStateMachine &u,
420                                                HANDLE h_app,
421                                                PowerSessionHandler & oSession) {
422   if (!FrameworkunifiedIsDeferQueueEmpty(h_app)) {
423     FrameworkunifiedRetrieveDeferMessage(h_app);
424   }
425 }
426
427 PCSTR PowerStateMachine::Shutdown::name() {
428   return "Shutdown";
429 }
430
431 // LCOV_EXCL_START 8: no one send the event
432 void PowerStateMachine::Shutdown::onLowVoltage1Encountered(
433     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
434     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
435   u.GotoStateOnHysteresisTimeout(LowVoltage1State);
436   u.OnVoltage(NULL, h_app, oSession);
437   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
438          "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)",
439          FrameworkunifiedGetMsgSrc(h_app));
440 }
441 // LCOV_EXCL_STOP 8: no one send the event to call this function
442
443 // LCOV_EXCL_START 8: no one send the event to call this function
444 void PowerStateMachine::Shutdown::onLowVoltage2Encountered(
445     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
446   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
447   u.GotoStateOnHysteresisTimeout(LowVoltage2State);
448   u.OnVoltage(NULL, h_app, oSession);
449   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
450          "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)",
451          FrameworkunifiedGetMsgSrc(h_app));
452 }
453 // LCOV_EXCL_STOP 8: no one send the event to call this function
454
455 // LCOV_EXCL_START 8: no one send the event to call this function
456 void PowerStateMachine::Shutdown::onHysteresisAborted(
457     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
458     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
459   u.NextState(*(u.m_pPreviousState), h_app, oSession);
460 }
461 // LCOV_EXCL_STOP 8: no one send the event
462 void PowerStateMachine::Shutdown::onHysteresisTimeout(
463     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
464   if (!u.m_oShutdownHysteresis.maxTries()) {
465     FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
466            "epsmeSHUTDOWN_TM_OUT tries: %d", u.m_oShutdownHysteresis.getTries());
467
468     u.reStartHysteresisTimer(u.m_oShutdownHysteresis);
469   } else {
470     // Move directorly to next state.
471     u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
472   }
473 }
474
475 void PowerStateMachine::Shutdown::onEntry(PowerStateMachine &u, HANDLE h_app,
476                                           PowerSessionHandler & oSession) {
477   if (u.m_oShutdownHysteresis.getEnabled()) {
478     FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
479            "Starting epsmeSHUTDOWN_HYSTERESIS_TM_OUT timeout: %d tries: %d",
480            u.m_oShutdownHysteresis.getTimeout(),
481            u.m_oShutdownHysteresis.getTries());
482     // Set the goto state state.
483     u.GotoStateOnHysteresisTimeout(ShutdownActiveState);
484     // Start the hysteresis timer for low voltage 2
485     u.startHysteresisTimer(u.m_oShutdownHysteresis);
486   } else {
487     FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
488             "SHUTDOWN_HYSTERESIS is not enabled. Going directly to ShutdownActiveState");
489     // Move directly to next state.
490     u.NextState(ShutdownActiveState, h_app, oSession);
491   }
492 }
493
494 void PowerStateMachine::Shutdown::onExit(PowerStateMachine &u, HANDLE h_app,
495                                          PowerSessionHandler & oSession) {
496   u.stopHysteresisTimer(u.m_oShutdownHysteresis);
497   FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) Shutdown State");
498 }
499
500 // LCOV_EXCL_START 8: no one send the event
501 void PowerStateMachine::Shutdown::onWakeup(PowerStateMachine &u, HANDLE h_app,
502                                            PowerSessionHandler & oSession) {
503   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
504   u.GotoStateOnHysteresisTimeout(WakeupPendingState);
505 }
506 // LCOV_EXCL_STOP 8: no one send the event
507
508 PCSTR PowerStateMachine::ShutdownActive::name() {
509   return "Shutdown Active";
510 }
511
512 // LCOV_EXCL_START 8: no one send the event
513 void PowerStateMachine::ShutdownActive::onLowVoltage1Encountered(
514     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
515     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
516   u.OnVoltage(&LowVoltage1State, h_app, oSession);
517   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
518          FrameworkunifiedGetMsgSrc(h_app));
519 }
520 // LCOV_EXCL_STOP 8: no one send the event to call this function
521
522 // LCOV_EXCL_START 8: no one send the event to call this function
523 void PowerStateMachine::ShutdownActive::onLowVoltage2Encountered(
524     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
525     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
526   u.OnVoltage(&LowVoltage2State, h_app, oSession);
527   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
528          FrameworkunifiedGetMsgSrc(h_app));
529 }
530 // LCOV_EXCL_STOP 8: no one send the event
531 void PowerStateMachine::ShutdownActive::onEntry(
532     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
533   u.publishPowerLevelType(h_app, epspltSHUTDOWN);
534
535   if (oSession.ShutdownComplete(u.m_lstShutdownModules)) {
536     oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL);
537   }
538 }
539
540 void PowerStateMachine::ShutdownActive::onShutdown(
541     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
542   if (oSession.ShutdownComplete(u.m_lstShutdownModules)) {
543     oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL);
544   }
545 }
546
547 PCSTR PowerStateMachine::LowVoltage1::name() {  // LCOV_EXCL_START 8: can not be LowVoltage1status
548   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
549   return "Low Voltage I";
550 }
551 // LCOV_EXCL_STOP 8: can not be LowVoltage1status
552
553 // LCOV_EXCL_START 8: no one send the event
554 void PowerStateMachine::LowVoltage1::onHysteresisAborted(
555     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
556     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
557   u.NextState(*(u.m_pPreviousState), h_app, oSession);
558 }
559 // LCOV_EXCL_STOP 8: no one send the event
560
561 // LCOV_EXCL_START 8: can not be LowVoltage1status
562 void PowerStateMachine::LowVoltage1::onHysteresisTimeout(
563     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
564     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
565   if (!u.m_oLowVoltage1Hysteresis.maxTries()) {
566     FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
567            "epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT tries: %d",
568            u.m_oLowVoltage1Hysteresis.getTries());
569
570     u.reStartHysteresisTimer(u.m_oLowVoltage1Hysteresis);
571   } else {
572     // Move directorly to next state.
573     u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
574   }
575 }
576 // LCOV_EXCL_STOP 8: no one send the event to call this function
577
578 // LCOV_EXCL_START 8: no one send the event to call this function
579 void PowerStateMachine::LowVoltage1::onWakeup(PowerStateMachine &u, HANDLE h_app,
580                                               PowerSessionHandler & oSession) {
581   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
582   u.GotoStateOnHysteresisTimeout(NormalVoltageState);
583   u.OnVoltage(NULL, h_app, oSession);
584   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
585          "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
586          FrameworkunifiedGetMsgSrc(h_app));
587 }
588 // LCOV_EXCL_STOP 8: can not be LowVoltage1status
589
590 // LCOV_EXCL_START 8: no one send the event
591 void PowerStateMachine::LowVoltage1::onLowVoltage2Encountered(
592     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
593     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
594   u.GotoStateOnHysteresisTimeout(LowVoltage2State);
595   u.OnVoltage(NULL, h_app, oSession);
596   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
597          "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)",
598          FrameworkunifiedGetMsgSrc(h_app));
599 }
600 // LCOV_EXCL_STOP 8: no one send the event to call this function
601
602 // LCOV_EXCL_START 8: no one send the event to call this function
603 void PowerStateMachine::LowVoltage1::onNormalVoltageEncountered(
604     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
605     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
606   u.GotoStateOnHysteresisTimeout(NormalVoltageState);
607   u.OnVoltage(NULL, h_app, oSession);
608   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
609          "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
610          FrameworkunifiedGetMsgSrc(h_app));
611 }
612 // LCOV_EXCL_STOP 8: no one send the event
613
614 // LCOV_EXCL_START 8: can not be LowVoltage1status
615 void PowerStateMachine::LowVoltage1::onEntry(PowerStateMachine &u, HANDLE h_app,
616                                              PowerSessionHandler & oSession) {
617   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
618   if (u.m_oLowVoltage1Hysteresis.getEnabled()) {
619     FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
620            "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d",
621            u.m_oLowVoltage1Hysteresis.getTimeout(),
622            u.m_oLowVoltage1Hysteresis.getTries());
623     // Set the goto state state.
624     u.GotoStateOnHysteresisTimeout(LowVoltage1ActiveState);
625     // Start the hysteresis timer for low voltage 1
626     u.startHysteresisTimer(u.m_oLowVoltage1Hysteresis);
627   } else {
628     FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
629             "LOW_VOLTAGE_HYSTERESIS is not enabled. Going directly to LowVoltage1ActiveState");
630     // Move directly to next state.
631     u.NextState(LowVoltage1ActiveState, h_app, oSession);
632   }
633 }
634 // LCOV_EXCL_STOP 8: no one send the event to call this function
635
636 // LCOV_EXCL_START 8: no one send the event to call this function
637 void PowerStateMachine::LowVoltage1::onExit(PowerStateMachine &u, HANDLE h_app,
638                                             PowerSessionHandler & oSession) {
639   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
640   u.stopHysteresisTimer(u.m_oLowVoltage1Hysteresis);
641   FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage1 State");
642 }
643 // LCOV_EXCL_STOP 8: no one send the event to call this function
644
645 // LCOV_EXCL_START 8: no one send the event to call this function
646 PCSTR PowerStateMachine::LowVoltage1Active::name() {
647   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
648   return "Low Voltage I Active";
649 }
650 // LCOV_EXCL_STOP 8: can not be LowVoltage1status
651
652 // LCOV_EXCL_START 8: no one send the event
653 void PowerStateMachine::LowVoltage1Active::onLowVoltage2Encountered(
654     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
655     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
656   u.OnVoltage(&LowVoltage2State, h_app, oSession);
657   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
658          FrameworkunifiedGetMsgSrc(h_app));
659 }
660 // LCOV_EXCL_STOP 8: no one send the event to call this function
661
662 // LCOV_EXCL_START 8: no one send the event to call this function
663 void PowerStateMachine::LowVoltage1Active::onNormalVoltageEncountered(
664     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
665     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
666   u.OnVoltage(&NormalVoltageState, h_app, oSession);
667   FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s",
668          FrameworkunifiedGetMsgSrc(h_app));
669 }
670 // LCOV_EXCL_STOP 8: no one send the event
671
672 // LCOV_EXCL_START 8: can not be LowVoltage1Activestatus
673 void PowerStateMachine::LowVoltage1Active::onEntry(
674     PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
675     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
676   u.publishPowerLevelType(h_app, epspltEMERGENCY);
677 u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_Active);
678 }
679 // LCOV_EXCL_STOP 8: no one send the event to call this function
680
681 // LCOV_EXCL_START 8: no one send the event to call this function
682 void PowerStateMachine::LowVoltage1Active::onExit(
683   PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
684     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
685 u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_InActive);
686 }
687 // LCOV_EXCL_STOP 8: can not be LowVoltage1Activestatus
688
689 PCSTR PowerStateMachine::LowVoltage2::name() {  // LCOV_EXCL_START 8: can not be LowVoltage2status
690   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
691 return "Low Voltage II";
692 }
693 // LCOV_EXCL_STOP 8: can not be LowVoltage2status
694
695 // LCOV_EXCL_START 8: no one send the event
696 void PowerStateMachine::LowVoltage2::onHysteresisAborted(
697 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
698     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
699 u.NextState(*(u.m_pPreviousState), h_app, oSession);
700 }
701 // LCOV_EXCL_STOP 8: no one send the event
702
703 // LCOV_EXCL_START 8: can not be LowVoltage2status
704 void PowerStateMachine::LowVoltage2::onHysteresisTimeout(
705 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
706     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
707 if (!u.m_oLowVoltage2Hysteresis.maxTries()) {
708 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
709        "epsmeLOW_VOLTAGE2_HYSTERESIS_TM_OUT tries: %d",
710        u.m_oLowVoltage2Hysteresis.getTries());
711
712 u.reStartHysteresisTimer(u.m_oLowVoltage2Hysteresis);
713 } else {
714 // Move directorly to next state.
715 u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
716 }
717 }
718 // LCOV_EXCL_STOP 8: no one send the event to call this function
719
720 // LCOV_EXCL_START 8: no one send the event to call this function
721 void PowerStateMachine::LowVoltage2::onEntry(PowerStateMachine &u, HANDLE h_app,
722                                              PowerSessionHandler & oSession) {
723   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
724 if (u.m_oLowVoltage2Hysteresis.getEnabled()) {
725 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
726        "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d",
727        u.m_oLowVoltage2Hysteresis.getTimeout(),
728        u.m_oLowVoltage2Hysteresis.getTries());
729 // Set the goto state state.
730 u.GotoStateOnHysteresisTimeout(LowVoltage2ActiveState);
731 // Start the hysteresis timer for low voltage 2
732 u.startHysteresisTimer(u.m_oLowVoltage2Hysteresis);
733 } else {
734 FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
735         "LOW_VOLTAGE2_HYSTERESIS is not enabled. Going directly to LowVoltage2ActiveState");
736 // Move directly to next state.
737 u.NextState(LowVoltage2ActiveState, h_app, oSession);
738 }
739 }
740 // LCOV_EXCL_STOP 8: no one send the event to call this function
741
742 // LCOV_EXCL_START 8: no one send the event to call this function
743 void PowerStateMachine::LowVoltage2::onExit(PowerStateMachine &u, HANDLE h_app,
744                                             PowerSessionHandler & oSession) {
745   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
746 u.stopHysteresisTimer(u.m_oLowVoltage2Hysteresis);
747 FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage2 State");
748 }
749 // LCOV_EXCL_STOP 8: no one send the event to call this function
750
751 // LCOV_EXCL_START 8: no one send the event to call this function
752 void PowerStateMachine::LowVoltage2::onWakeup(PowerStateMachine &u, HANDLE h_app,
753                                               PowerSessionHandler & oSession) {
754   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
755 u.GotoStateOnHysteresisTimeout(WakeupPendingState);
756 }
757 // LCOV_EXCL_STOP 8: can not be LowVoltage2status
758
759 // LCOV_EXCL_START 8: no one send the event
760 void PowerStateMachine::LowVoltage2::onLowVoltage1Encountered(
761 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
762     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
763 u.GotoStateOnHysteresisTimeout(LowVoltage1State);
764 u.OnVoltage(NULL, h_app, oSession);
765 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
766        "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)",
767        FrameworkunifiedGetMsgSrc(h_app));
768 }
769 // LCOV_EXCL_STOP 8: no one send the event to call this function
770
771 // LCOV_EXCL_START 8: no one send the event to call this function
772 void PowerStateMachine::LowVoltage2::onNormalVoltageEncountered(
773 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
774     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
775 u.GotoStateOnHysteresisTimeout(NormalVoltageState);
776 u.OnVoltage(NULL, h_app, oSession);
777 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
778        "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
779        FrameworkunifiedGetMsgSrc(h_app));
780 }
781 // LCOV_EXCL_STOP 8: no one send the event
782
783 PCSTR PowerStateMachine::LowVoltage2Active::name() {  // LCOV_EXCL_START 8: can not be LowVoltage2Activestatus
784   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
785 return "Low Voltage II Active";
786 }
787 // LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus
788
789 // LCOV_EXCL_START 8: no one send the event
790 void PowerStateMachine::LowVoltage2Active::onLowVoltage1Encountered(
791 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
792     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
793 u.OnVoltage(&LowVoltage1State, h_app, oSession);
794 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
795        FrameworkunifiedGetMsgSrc(h_app));
796 }
797 // LCOV_EXCL_STOP 8: no one send the event to call this function
798
799 // LCOV_EXCL_START 8: no one send the event to call this function
800 void PowerStateMachine::LowVoltage2Active::onNormalVoltageEncountered(
801 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
802     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
803 u.OnVoltage(&NormalVoltageState, h_app, oSession);
804 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s",
805        FrameworkunifiedGetMsgSrc(h_app));
806 }
807 // LCOV_EXCL_STOP 8: no one send the event
808
809 // LCOV_EXCL_START 8: can not be LowVoltage2Activestatus
810 void PowerStateMachine::LowVoltage2Active::onEntry(
811 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
812     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
813 u.publishPowerLevelType(h_app, epspltEMERGENCY);
814 u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_Active);
815 }
816 // LCOV_EXCL_STOP 8: no one send the event to call this function
817
818 // LCOV_EXCL_START 8: no one send the event to call this function
819 void PowerStateMachine::LowVoltage2Active::onExit(
820 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
821     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
822 u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_InActive);
823 oSession.SendToSupervisor(SS_POWER_LVI2_SHUTDOWN_COMPLETE, 0, NULL);
824 }
825 // LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus
826
827 PCSTR PowerStateMachine::NormalVoltage::name() {  // LCOV_EXCL_START 8: can not be NormalVoltageState
828   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
829 return "Normal Voltage";
830 }
831 // LCOV_EXCL_STOP 8: can not be NormalVoltageState
832
833 // LCOV_EXCL_START 8: no one send the event
834 void PowerStateMachine::NormalVoltage::onLowVoltage1Encountered(
835 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
836     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
837 u.OnVoltage(&LowVoltage1State, h_app, oSession);
838 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
839        FrameworkunifiedGetMsgSrc(h_app));
840 }
841 // LCOV_EXCL_STOP 8: no one send the event to call this function
842
843 // LCOV_EXCL_START 8: no one send the event to call this function
844 void PowerStateMachine::NormalVoltage::onLowVoltage2Encountered(
845 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
846     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
847 u.OnVoltage(&LowVoltage2State, h_app, oSession);
848 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
849        FrameworkunifiedGetMsgSrc(h_app));
850 }
851 // LCOV_EXCL_STOP 8: no one send the event
852
853 // LCOV_EXCL_START 8: can not be NormalVoltageState
854 void PowerStateMachine::NormalVoltage::onShutdown(
855 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
856     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
857 u.NextState(ShutdownState, h_app, oSession);
858 }
859 // LCOV_EXCL_STOP 8: can not be NormalVoltageState
860
861 // LCOV_EXCL_START 8: no one send the event
862 void PowerStateMachine::NormalVoltage::onSoftwareUpdate(
863 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
864     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
865 u.NextState(SoftwareUpdateState, h_app, oSession);
866 }
867 // LCOV_EXCL_STOP 8: no one send the event
868
869 // LCOV_EXCL_START 8: can not be NormalVoltageState
870 void PowerStateMachine::NormalVoltage::onEntry(PowerStateMachine &u,
871                                                HANDLE h_app,
872                                                PowerSessionHandler & oSession) {
873   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
874 u.publishPowerLevelType(h_app, epspltNORMAL);
875 }
876 // LCOV_EXCL_STOP 8: can not be NormalVoltageState
877
878 PCSTR PowerStateMachine::SoftwareUpdate::name() {  // LCOV_EXCL_START 8: can not be SoftwareUpdatestatus
879   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
880 return "Software Update";
881 }
882 // LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus
883
884 // LCOV_EXCL_START 8: no one send the event
885 void PowerStateMachine::SoftwareUpdate::onLowVoltage1Encountered(
886 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
887     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
888 u.OnVoltage(&LowVoltage1State, h_app, oSession);
889 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
890        FrameworkunifiedGetMsgSrc(h_app));
891 }
892 // LCOV_EXCL_STOP 8: no one send the event to call this function
893
894 // LCOV_EXCL_START 8: no one send the event to call this function
895 void PowerStateMachine::SoftwareUpdate::onLowVoltage2Encountered(
896 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
897     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
898 u.OnVoltage(&LowVoltage2State, h_app, oSession);
899 FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
900        FrameworkunifiedGetMsgSrc(h_app));
901 }
902 // LCOV_EXCL_STOP 8: no one send the event
903
904 // LCOV_EXCL_START 8: can not be SoftwareUpdatestatus
905 void PowerStateMachine::SoftwareUpdate::onShutdown(
906 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
907   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
908 }
909 // LCOV_EXCL_STOP 8: no one send the event to call this function
910
911 // LCOV_EXCL_START 8: no one send the event to call this function
912 void PowerStateMachine::SoftwareUpdate::onEntry(
913 PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
914   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
915 }
916 // LCOV_EXCL_STOP 8: no one send the event to call this function
917
918 // LCOV_EXCL_START 8: no one send the event to call this function
919 void PowerStateMachine::SoftwareUpdate::onExit(PowerStateMachine &u,
920                                                HANDLE h_app,
921                                                PowerSessionHandler & oSession) {
922   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
923 }
924 // LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus