From a0b81882b4a9b7761e2dbfdda37b7559714c416c Mon Sep 17 00:00:00 2001 From: ToshikazuOhiwa Date: Mon, 30 Mar 2020 09:41:01 +0900 Subject: ss-powerservice branch --- .../server/src/powerservice_application.cpp | 236 +++ power_service/server/src/powerservice_main.cpp | 70 + power_service/server/src/ss_power.cpp | 1672 ++++++++++++++++++++ power_service/server/src/ss_power_config.cpp | 188 +++ power_service/server/src/ss_power_session.cpp | 276 ++++ .../server/src/ss_power_state_machine.cpp | 924 +++++++++++ .../server/src/ss_pwr_test_client_handlers.cpp | 204 +++ .../server/src/ss_supervisor_handlers.cpp | 498 ++++++ power_service/server/src/ss_system_handlers.cpp | 52 + 9 files changed, 4120 insertions(+) create mode 100644 power_service/server/src/powerservice_application.cpp create mode 100644 power_service/server/src/powerservice_main.cpp create mode 100644 power_service/server/src/ss_power.cpp create mode 100644 power_service/server/src/ss_power_config.cpp create mode 100644 power_service/server/src/ss_power_session.cpp create mode 100644 power_service/server/src/ss_power_state_machine.cpp create mode 100644 power_service/server/src/ss_pwr_test_client_handlers.cpp create mode 100644 power_service/server/src/ss_supervisor_handlers.cpp create mode 100644 power_service/server/src/ss_system_handlers.cpp (limited to 'power_service/server/src') diff --git a/power_service/server/src/powerservice_application.cpp b/power_service/server/src/powerservice_application.cpp new file mode 100644 index 00000000..52c6cfe4 --- /dev/null +++ b/power_service/server/src/powerservice_application.cpp @@ -0,0 +1,236 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief This file contains the standard set functions called by the NS +// dispatcher on application initialization, cleanup and wakeup. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +#include "ss_power_powerservicelog.h" +#include "ss_power.h" + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) + * @brief Handles setup for SS_Power subsystem, registers with + * NP_Service and indicates that its ready. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) { + EFrameworkunifiedStatus eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + eStatus = Power::GetInstance().Initialize(h_app); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return eStatus; +} + +/** + * EFrameworkunifiedStatus PowerserviceOnWakepup(HANDLE h_app) + * @brief This is not handled by the Power Subsystem since send out the + * notifications that indicated Wakeup. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus PowerserviceOnWakepup(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 200: not called by NSFW + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE h_app) + * @brief This is not handled by the Power Subsystem since send out the + * notifications that indicated Shutdown. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 200: not called by NSFW + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE h_app) + * @brief This is not handled by the Power Subsystem since send out the + * notifications that indicated Emergency Shutdown. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 200: not called by NSFW + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) + * @brief SS_Power will exit when this method is invoked, + * return value will always be invalid. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, + " This method is not valid for %s, returning " + "eFrameworkunifiedStatusNotImplemented", + SERVICE_POWER); + return eFrameworkunifiedStatusNotImplemented; +} +// LCOV_EXCL_STOP 200: not called by NSFW + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) + * @brief Used to ask SS_Power to dump its vital information about the subsystem. + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7: debug code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + + Power* l_instance = &Power::GetInstance(); + + if (l_instance != NULL) { + l_instance->SSPowerDebugDump(h_app); + + } else { + eStatus = eFrameworkunifiedStatusInvldHandle; + } + return eStatus; +} +// LCOV_EXCL_STOP 7: debug code + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) + * @brief Used to . + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) + * @brief Used to . + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ + +EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app) + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ + +EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app) + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ + +EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app) + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ + +EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app) + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ + +EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} + +/** + * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) + * @brief Used to . + * + * @param h_app Handle to the SS_Power Framework Obj. + * + * @return method status of completion or failure. + */ +EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 200: not called by NSFW +// EOF + diff --git a/power_service/server/src/powerservice_main.cpp b/power_service/server/src/powerservice_main.cpp new file mode 100644 index 00000000..4e33a71d --- /dev/null +++ b/power_service/server/src/powerservice_main.cpp @@ -0,0 +1,70 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief Application entry point. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include + +#include "ss_power_powerservicelog.h" + +CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION); + +/// \brief: Name of the Queue that will be +/// used to read data from. +const CHAR AppName[] = SERVICE_POWER; + +/// \brief: public structure that is used +/// for logging by NSLogger. +FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { +FRAMEWORKUNIFIEDLOGOPTIONS, { +ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12, +ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15, +ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18, +ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21, +ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24, +ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27, +ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30, +ZONE_TEXT_31 }, FRAMEWORKUNIFIEDLOGZONES }; + +/** + *int main(int argc, char *argv[]) + * @brief Main function for SS_Power subsystem. + * + * @param argc number of arguments passed to SS_Power + * @param argv array of arguments passed to SS_Power + * + * @return int status of applications exit. + */ +int main(int argc, char *argv[]) { + FRAMEWORKUNIFIED_SET_ZONES(); + FrameworkunifiedDefaultCallbackHandler cbFuncs; + FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs); + + EFrameworkunifiedStatus eStatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, + &cbFuncs); + return eStatus; +} + diff --git a/power_service/server/src/ss_power.cpp b/power_service/server/src/ss_power.cpp new file mode 100644 index 00000000..abf1c8c0 --- /dev/null +++ b/power_service/server/src/ss_power.cpp @@ -0,0 +1,1672 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief Handles Power Service Business logic +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "ss_power.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ss_power_powerservicelog.h" + +using namespace std; // NOLINT (build/namespaces) + +static Power g_PowerSubsystem; + +/** + * @brief + * + * @param + * @param + * + * @return + */ +template EFrameworkunifiedStatus PowerCallback( + HANDLE h_app) { + + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail; + + C * pObj = static_cast(&g_PowerSubsystem); + + if (pObj) { + l_eStatus = (pObj->*M)(h_app); + } + + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// GetInstance +/// Return global instance of Power object. Power is singleton class +/// +////////////////////////////////////////////////////////////////////// +Power & Power::GetInstance() { + return g_PowerSubsystem; +} + +/////////////////////////////////////////////////////////////////////// +/// Power +/// Constructor of Power class +/// +////////////////////////////////////////////////////////////////////// +Power::Power() + : m__CWORD56_RepHist(SS_PWR__CWORD56__REP_HIST_SIZE), + m_PubCmdHist(SS_PWR_PUB_CMD_HIST_SIZE), + m_ErrHist(SS_PWR_ERR_HIST_SIZE), + m_VCmdHist(SS_PWR_V_HIST_SIZE), + m_PowerState(SS_PS_READY_TO_WAKEUP), + m_VoltageState(epsvsINVALID), + m_CrankState(epscsINVALID), + m_MaxShutdownTimeout(0) { + m_PPStateStrMap[SS_PS_READY_TO_WAKEUP] = "SS_PS_READY_TO_WAKEUP"; + m_PPStateStrMap[SS_PS_WAKEUP_INITIATED] = "SS_PS_WAKEUP_INITIATED"; + m_PPStateStrMap[SS_PS_WAKEUP_COMPLETE] = "SS_PS_WAKEUP_COMPLETE"; + m_PPStateStrMap[SS_PS_POWER_ON_COMPLETE] = "SS_PS_POWER_ON_COMPLETE"; + m_PPStateStrMap[SS_PS_POWER_OFF_INITIATED] = "SS_PS_POWER_OFF_INITIATED"; + m_PPStateStrMap[SS_PS_POWER_OFF_COMPLETE] = "SS_PS_POWER_OFF_COMPLETE"; + m_PPStateStrMap[SS_PS_SHUTDOWN_INITIATED] = "SS_PS_SHUTDOWN_INITIATED"; + m_PPStateStrMap[SS_PS_SHUTDOWN_COMPLETE] = "SS_PS_SHUTDOWN_COMPLETE"; + m_PPStateStrMap[SS_PS_STATE_MAX] = "SS_PS_STATE_MAX"; + + m__CWORD56_RepIter = m__CWORD56_RepHist.begin(); + m_PubHistIter = m_PubCmdHist.begin(); + m_ErrHistIter = m_ErrHist.begin(); + m_VHistIter = m_VCmdHist.begin(); + bzero(&m_WakeUpData, sizeof(m_WakeUpData)); +} + +/////////////////////////////////////////////////////////////////////// +/// ~Power +/// Destructor of Power class +/// +////////////////////////////////////////////////////////////////////// +Power::~Power() { // LCOV_EXCL_START 14 Resident process, not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +} +// LCOV_EXCL_STOP 14 Resident process, not called by NSFW + +/////////////////////////////////////////////////////////////////////// +/// Initialize +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::Initialize(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + BOOL l_SpecifiedCfgLoaded; + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + SetPowerServiceState(SS_PS_READY_TO_WAKEUP); + + pthread_mutex_init(&pwr_hist_mutex, NULL); + + /// Open and parse the configuration data for Power + const CHAR configFileName[] = "/agl/scfg/gpf_ss_ps_config.cfg"; + + PowerConfiguration config(configFileName); + l_SpecifiedCfgLoaded = config.LoadParameters(m_tConfigData); + if (FALSE == l_SpecifiedCfgLoaded) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, __FUNCTION__, + "Reading configuration from file: %s failed. Using default parameters.", + configFileName); + config.LoadDefaultParameters(m_tConfigData); + } + + config.PrintConfigInfo(m_tConfigData); + + /// init PowerStateMachine + m_oStateMachine.initialize(h_app, m_tConfigData); + + // Register all callbacks to dispatcher and notifications + l_eStatus = RegisterAllCallbacksAndNofitications(h_app); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, "RegisterAllCallbacksAndNofitications()"); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// RegisterAllCallbacksAndNofitications +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::RegisterAllCallbacksAndNofitications(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, szNTFY_PowerAvailability))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR( + "FrameworkunifiedRegisterServiceAvailabilityNotification( "szNTFY_PowerAvailability" )"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + l_eStatus = FrameworkunifiedPublishServiceAvailability(h_app, FALSE); + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedPublishServiceAvailability()"); + } + // LCOV_EXCL_STOP 4: NSFW error case. + + SS_PWR_LOG_HIST("FrameworkunifiedPublishServiceAvailability()", m_PubCmdHist, + m_PubHistIter, "", l_eStatus); + } + + // Attach Notification callbacks to dispatcher + FrameworkunifiedNotificationsList + ss_power_notifications[] = { + { szNTFY_PowerLVI1, sizeof(PowerSrvLVIStatus), eFrameworkunifiedStateVar} + , {szNTFY_PowerLVI2, sizeof(PowerSrvLVIStatus), eFrameworkunifiedStateVar} + , {szNTFY_PowerLevel, sizeof(PowerSrvLevelType), eFrameworkunifiedStateVar} + , {szNTFY_ShutdownPopup, sizeof(EPWR_SHUTDOWN_POPUP_TYPE), eFrameworkunifiedStateVar} + , {szNTFY_PowerPopup, sizeof(EPWR_POWER_POPUP_TYPE), eFrameworkunifiedStateVar} + }; + // Register Notifications + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(h_app, ss_power_notifications, _countof(ss_power_notifications)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedNPRegisterNotifications(ss_power_notifications)"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + // Subscribe and attach call back for notification + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(h_app, NTFY_SSSystemMgrPowerOnOff, PowerCallback))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedSubscribeNotificationWithCallback()"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + +//************************* + +/// < Attach to the following session handles. + FrameworkunifiedProtocolCallbackHandler ss_power_session_req_handlers[] = { + /// session handles. + { PROTOCOL_OPEN_SESSION_REQ, PowerCallback }, { PROTOCOL_CLOSE_SESSION_REQ, + PowerCallback }, { + SS_POWER_STATE_CHANGE_REQ, PowerCallback }, { SS_POWER_POWER_REQUEST_MSG, + PowerCallback }, { + SS_POWER_COMM_WAKEUP, + PowerCallback }, { + SS_POWER_SHUTDOWN_REQ, + PowerCallback }, { + SS_POWER_SHUTDOWN_REQUEST_MSG, PowerCallback } + + /// Wake-up / Shutdown Protocol commands for System Manager. + , { SS_SM_WAKEUP_MODULES_CMPL_RSPN, PowerCallback }, { SS_SM_SHUTDOWN_MODULES_CMPL_RSPN, + PowerCallback } + // + , { SS_POWER_PRINT_CONNECTIONS, PowerCallback }, { SS_POWER_PRINT_STACK, + PowerCallback } + /// Set Voltage & Crank states from shadow? + , { SS_POWER_VOLTAGE_STATE, PowerCallback }, { SS_POWER_CRANK_STATE, + PowerCallback } + /// Current Power Service State inquiry from Test Client + , { SS_POWER_CRNT_STATE_QUERY, PowerCallback }, { + SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback }, { + SS_SM_SYSTEM_MODE_INFO_RSPN, PowerCallback } + /// InitComp report to SystemManager + , { SS_POWER_INITCOMP_REP, PowerCallback } + // + // Startup Confirmation Request ( from Power Shadow ) and + // Startup Confirmation Response ( from System Manager ) + , { SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback }, { + SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, PowerCallback } + // + // User Mode Request ( from Power Shadow ) and + // User Mode Response ( from System Manager ) + , { SS_SM_USER_MODE_SET_RESP, PowerCallback } + + // + // Heartbeat Request ( from Power Shadow ) + , { SS_POWER_HEARTBEAT_REQ, PowerCallback }, { SS_SM__CWORD56__HEARTBEAT_RSPN, + PowerCallback } + + // System Manager to Power Services + , { SS_SM_CPU_RESET_REQ, PowerCallback }, { SS_SM_REMOTE_DATA_RESET_REQ, + PowerCallback } }; + + // Attach callback + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, ss_power_session_req_handlers, _countof(ss_power_session_req_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher( ss_power_session_req_handlers )"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + + //************************* + + // Publish szNTFY_PowerAvailable so that other services can start connecting via sessions. + + l_eStatus = RegisterSMSessionAckCallback( + PowerCallback); + LOG_STATUS(l_eStatus, "RegisterSMSessionAckCallback()"); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnSetCommWakeUp +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSetCommWakeUp(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + Pwr_ServiceSetInterface l_CanStatesData; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_CanStatesData))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else if (l_CanStatesData.data.commwake.state == epscnCANWAKEUP) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Received WakeUp from %s, Processing Ignored !!", + FrameworkunifiedGetMsgSrc(h_app)); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnSetCommSleep +/// +/// +////////////////////////////////////////////////////////////////////// +// LCOV_EXCL_START 200: can not be called from power class +EFrameworkunifiedStatus Power::OnSetCommSleep(HANDLE h_app) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + Pwr_ServiceSetInterface l_CanStatesData; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_CanStatesData))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else if (l_CanStatesData.data.commwake.state != epscnCANSLEEP) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Error: %s: l_CanStatesData.data.commwake.state != epscnCANSLEEP", + FrameworkunifiedGetMsgSrc(h_app)); + l_eStatus = eFrameworkunifiedStatusInvldParam; + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Received Sleep from %s", + FrameworkunifiedGetMsgSrc(h_app)); + + // Send to System Manager to WakeUp Modules + l_eStatus = SendShutdownToSystemManager(&l_CanStatesData); + if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("SendShutdownToSystemManager()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + SetPowerServiceState(SS_PS_SHUTDOWN_INITIATED); + LOG_SUCCESS("SendShutdownToSystemManager()"); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// LCOV_EXCL_STOP 200: can not be called from power class + +/////////////////////////////////////////////////////////////////////// +/// SetPowerServiceState +/// +/// +////////////////////////////////////////////////////////////////////// +VOID Power::SetPowerServiceState(SS_PSState f_NewState) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Changing State from '%s' to '%s'", + m_PPStateStrMap[m_PowerState].c_str(), + m_PPStateStrMap[f_NewState].c_str()); + + m_PowerState = f_NewState; +} + +/////////////////////////////////////////////////////////////////////// +/// OnPowerOnOffNotification +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnPowerOnOffNotification(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + T_SS_SM_UserModeOnOffNotification_StructType l_userModeOnOffStruct; + INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app); + + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_userModeOnOffStruct))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " User Mode is '%s', User Mode Change Reason is '%s'", + GetStr(l_userModeOnOffStruct.isUserModeOn).c_str(), + GetStr(l_userModeOnOffStruct.userModeChangeReason).c_str()); + SetPowerServiceState( + l_userModeOnOffStruct.isUserModeOn ? + SS_PS_POWER_ON_COMPLETE : SS_PS_POWER_OFF_COMPLETE); + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// ProcessSystemWakeUp +/// On receipt of this notification send wake up notification to +/// System Manager to wake up (START) all modules +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSetPowerState(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + Pwr_ServiceSetInterface l_serviceSetIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_serviceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + switch (l_serviceSetIf.data.wake.powerupType) { + case epswsPWRON: + case epswsPWROFF: + m_WakeUpData = l_serviceSetIf.data.wake; + + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, __FUNCTION__, " Received Power %s from %s, level 0x%X", + l_serviceSetIf.data.wake.powerupType == epswsPWRON ? "On" : "Off", + FrameworkunifiedGetMsgSrc(h_app), m_WakeUpData.up.level); + // Send to System Manager to WakeUp Modules + l_eStatus = SendWakeUpToSystemManager(&m_WakeUpData); + if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + SetPowerServiceState(SS_PS_WAKEUP_INITIATED); + LOG_SUCCESS("SendWakeUpToSystemManager()"); + } else { + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("SendWakeUpToSystemManager()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } + break; + default: + l_eStatus = eFrameworkunifiedStatusInvldParam; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: Invalid PowerOnOff State received: 0x%X", + l_serviceSetIf.data.wake.powerupType); + break; + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// Session Request Handlers +/// +////////////////////////////////////////////////////////////////////// + +EFrameworkunifiedStatus Power::OnOpenSession(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app); + l_eStatus = m_oSessionHandler.OpenSesion(h_app); + + /// < Test Code TODO: Remove ME!!! + // m_oSessionHandler.Print(); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnCloseSession(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app); + l_eStatus = m_oSessionHandler.CloseSession(h_app); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnWakeUpComplete(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + wakeInfo l_Wake; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_Wake))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else if (l_Wake.up.level == m_WakeUpData.up.level) { + SetPowerServiceState(SS_PS_WAKEUP_COMPLETE); + + /// < send the state machine a wakeup event. + m_oStateMachine.onEvent(h_app, m_oSessionHandler, + PowerStateMachine::epsmeWAKEUP); + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " Sending SS_POWER_STATE_CHANGE_RESP(%s) to PSM", + l_Wake.powerupType == epswsPWRON ? "User_On" : "User_Off"); + + // send Wake-up complete response to Supervisor + m_oSessionHandler.SendToSupervisor(SS_POWER_STATE_CHANGE_RESP, + sizeof(l_Wake), (PVOID) &l_Wake); + SS_PWR_LOG_HIST("SS_POWER_STATE_CHANGE_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter, + "SS_PS_WAKEUP_COMPLETE", l_eStatus); + + /// < Test Code TODO: Remove ME!!! + // m_oSessionHandler.Print(); + } else { + l_eStatus = eFrameworkunifiedStatusInvldParam; + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Error: Power WakeUp Threshold (%d) and SM WakeUp Threshold (%d) Mismatch", + m_WakeUpData.up.level, l_Wake.up.level); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnShutdownComplete(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + SetPowerServiceState(SS_PS_SHUTDOWN_COMPLETE); + + m_oStateMachine.onEvent(h_app, m_oSessionHandler, + PowerStateMachine::epsmeSHUTDOWN); + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending SS_POWER_SHUTDOWN_RESP to PSM"); + // send Shutdown complete response to Power Shadow / Supervisor + m_oSessionHandler.SendToSupervisor(SS_POWER_SHUTDOWN_RESP, 0, (PVOID) NULL); + + SS_PWR_LOG_HIST("SS_POWER_SHUTDOWN_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter, + "SS_PS_SHUTDOWN_COMPLETE", l_eStatus); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnShutdownComplete(HANDLE h_app) + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnPrintConnections(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + m_oSessionHandler.Print(); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnPrintStack(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + m_oSessionHandler.Print(); + // m_oStateMachine.Print(); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnHysteresisTimeout(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + m_oStateMachine.onEvent(h_app, m_oSessionHandler, + PowerStateMachine::epsmeLVI1_HYSTERESIS_TM_OUT); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// + +EFrameworkunifiedStatus PowerStateMachine::initialize(HANDLE h_app, + PowerConfigParams & refConfigParms) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + /// Set all hysteresis objects with the configuration data obtained from PowerService.xml + m_oShutdownHysteresis.set(refConfigParms.shutdown); + m_oLowVoltage1Hysteresis.set(refConfigParms.lvi1); + m_oLowVoltage2Hysteresis.set(refConfigParms.lvi2); + + /// Copy the list of required modules. + m_lstWakeupModules = refConfigParms.wakeup_modules; + m_lstShutdownModules = refConfigParms.shutdown_modules; + m_lstLvi2Modules = refConfigParms.lvi2_modules; + + m_hHysteresisTimer = FrameworkunifiedAttachTimerCallback( + h_app, 0, 0, PowerCallback); + if (NULL == m_hHysteresisTimer) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Error: FrameworkunifiedAttachTimerCallback() returned NULL"); + l_eStatus = eFrameworkunifiedStatusInvldHandle; + } + // LCOV_EXCL_STOP 4: NSFW error case. + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus PowerSessionHandler::OpenSesion(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + // check if the subscriber is already in map + PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app)); + + // the iter is set to the end then the subscriber is not in the map + if (m_mapSessions.end() == iter) { + string subscriber(FrameworkunifiedGetMsgSrc(h_app)); + PwSessionInfo newEntry; + newEntry.frunning = FALSE; + newEntry.hsession = FrameworkunifiedMcOpenSender(h_app, subscriber.c_str()); + newEntry.sz_name = subscriber; + newEntry.sz_servicename = ""; // we will get this on the start complete. + newEntry.esessiontype = epsstBASIC; + newEntry.ui_groupid = 0; + + if (NULL != newEntry.hsession) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // + // Set the Session Handle for Framework so FrameworkunifiedSendResponse won't error due to a null + // session handle. + // + // LCOV_EXCL_BR_START 4: NSFW error case. + if (eFrameworkunifiedStatusOK + // [in] PCSTR - Name of the associated service name + // [in] HANDLE - Session handle + != (l_eStatus = FrameworkunifiedSetSessionHandle(h_app, subscriber.c_str(), newEntry.hsession))) { // NOLINT[whitespace/line_length] + // LCOV_EXCL_BR_STOP + // LCOV_EXCL_START 4: NSFW error case. + LOG_ERROR("FrameworkunifiedSetSessionHandle()"); + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + // LCOV_EXCL_STOP 4: NSFW error case. + } + + OpenSessionAck openSessionAck; + memset(&openSessionAck, 0, sizeof(openSessionAck)); + strcpy(openSessionAck.cSessionName, SERVICE_POWER); // NOLINT (runtime/printf) + openSessionAck.eStatus = eFrameworkunifiedStatusOK; + openSessionAck.sessionId = 0; /// Only one session handles all the heartbeat clients + + // Send Ack to subscriber + l_eStatus = FrameworkunifiedSendMsg(newEntry.hsession, PROTOCOL_OPEN_SESSION_ACK, + sizeof(OpenSessionAck), (PVOID) &openSessionAck); + char l_cBuf[100]; + snprintf(l_cBuf, sizeof(l_cBuf), + "FrameworkunifiedSendMsg(%s, PROTOCOL_OPEN_SESSION_ACK)", subscriber.c_str()); + LOG_STATUS(l_eStatus, l_cBuf); + } + + // If this is not a basic module then we will need to register some other protocols + if (0 != FrameworkunifiedGetMsgLength(h_app)) { + EPWR_SESSION_TYPE tOpenSessionReq; + if (sizeof(EPWR_SESSION_TYPE) == FrameworkunifiedGetMsgLength(h_app)) { + if (eFrameworkunifiedStatusOK + == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tOpenSessionReq, + sizeof(EPWR_SESSION_TYPE)))) { + switch (tOpenSessionReq) { + case epsstBASIC: { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Subscriber : %s , open a session using type: BASIC", + subscriber.c_str()); + FrameworkunifiedProtocolCallbackHandler ss_power_session_basic_handlers[] = { { + PROTOCOL_OPEN_SESSION_REQ, PowerCallback }, { PROTOCOL_CLOSE_SESSION_REQ, + PowerCallback } }; + + // Attach callback : Power Session Requests + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_session_basic_handlers, _countof(ss_power_session_basic_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR( + "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_session_basic_handlers)"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Subscriber '%s' opened a type 'BASIC' session", + subscriber.c_str()); + } + break; + case epsstSUPERVISOR: { + FrameworkunifiedProtocolCallbackHandler ss_power_sprv_session_handlers[] = { { + PROTOCOL_OPEN_SESSION_REQ, PowerCallback }, { PROTOCOL_CLOSE_SESSION_REQ, + PowerCallback }, { + SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback }, { + SS_POWER_STATE_CHANGE_REQ, PowerCallback }, { SS_POWER_SHUTDOWN_REQ, + PowerCallback } + , { SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback }, { + SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ, PowerCallback< + Power, &Power::OnPublishShutdownPopupRequest> }, { + SS_POWER_PUBLISH_POWER_POPUP_REQ, PowerCallback }, { + SS_POWER_POWER_REQUEST_MSG, PowerCallback } }; + + // Attach callback : Power Supervisor Session Requests + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_sprv_session_handlers, _countof(ss_power_sprv_session_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR( + "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_sprv_session_handlers)"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Subscriber '%s' opened a 'SUPERVISOR' session", + subscriber.c_str()); + newEntry.esessiontype = tOpenSessionReq; + + static BOOL first_supervisor = TRUE; + if (first_supervisor) { + AttachCallbackToSystemManager( // LCOV_EXCL_BR_LINE 4: NSFW error case. + h_app, SS_SM_SYSTEM_MODE_INFO_RSPN, + PowerCallback); + first_supervisor = FALSE; + } + } + break; + case epsstSYSTEM: { + FrameworkunifiedProtocolCallbackHandler ss_power_system_session_handlers[] = { + { PROTOCOL_OPEN_SESSION_REQ, PowerCallback }, { PROTOCOL_CLOSE_SESSION_REQ, + PowerCallback }, { + SS_POWER_SYSTEM_LAUNCH_COMPLETE, PowerCallback }, { + SS_POWER_SHUTDOWN_RESP, PowerCallback } }; + + // Attach callback : Power System Session Requests + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_system_session_handlers, _countof(ss_power_system_session_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR( + "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_session_handlers)"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; + } + // LCOV_EXCL_STOP 4: NSFW error case. + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Subscriber '%s' opened a 'SYSTEM' session", + subscriber.c_str()); + newEntry.esessiontype = tOpenSessionReq; + } + break; + case epsstUNKNOWN: { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Subscriber '%s' tried to open a type 'UNKNOWN' session", + subscriber.c_str()); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return eFrameworkunifiedStatusInvldParam; + } + break; + } + } + } + } + + // insert this newEntry into the map + m_mapSessions.insert(make_pair(subscriber, newEntry)); + } else { + // This Subscriber is already in our map, just send and ack to keep them quote. + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, __FUNCTION__, + "Subscriber : %s , is already in the map, will Just send back an ACK", + iter->second.sz_name.c_str()); + if (NULL != iter->second.hsession) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + OpenSessionAck openSessionAck; + memset(&openSessionAck, 0, sizeof(openSessionAck)); + strcpy(openSessionAck.cSessionName, SERVICE_POWER); // NOLINT (runtime/printf) + openSessionAck.eStatus = eFrameworkunifiedStatusOK; + // I can't think of a reason why we would need more that one session per subscriber. + openSessionAck.sessionId = 0; + + // Send Ack to subscriber + l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, PROTOCOL_OPEN_SESSION_ACK, + sizeof(OpenSessionAck), (PVOID) &openSessionAck); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "FrameworkunifiedSendMsg Success to : %s , status: 0x%x", + iter->second.sz_name.c_str(), l_eStatus); + } else { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, + "What! NULL == iter->second.hsession TODO: Need to handle this!"); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus PowerSessionHandler::StopComplete(HANDLE h_app) { // LCOV_EXCL_START 8: can not be called + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + // ToDo Jay 2012 November 02 Can this be deleted ? + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " No-op function - It's here, but it doesn't do anything"); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// LCOV_EXCL_STOP 8: can not be called + +/////////////////////////////////////////////////////////////////////// +/// ProcessVoltageNotifyRequest +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::PublishVoltageStateChange(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + PowerSrvLVIStatus l_LVIStatus; + PowerSrvLevelType l_PowerLevel; + + switch (m_VoltageState) { // LCOV_EXCL_BR_LINE 6: double check + case epsvsNORMAL: + l_PowerLevel = epspltNORMAL; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltNORMAL)"); + + l_LVIStatus = ePwSrvLVI_Status_InActive; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_InActive)"); + +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_InActive)"); + break; + + case epsvsLVI1: + l_PowerLevel = epspltEMERGENCY; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltEMERGENCY)"); + + l_LVIStatus = ePwSrvLVI_Status_Active; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_Active)"); + + l_LVIStatus = ePwSrvLVI_Status_InActive; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_InActive)"); + break; + + case epsvsLVI2: + l_PowerLevel = epspltEMERGENCY; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltEMERGENCY)"); + + l_LVIStatus = ePwSrvLVI_Status_InActive; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_InActive)"); + + l_LVIStatus = ePwSrvLVI_Status_Active; +l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus)); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, + "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_Active)"); + break; + + case epsvsINVALID: + // LCOV_EXCL_START 6: double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_eStatus = eFrameworkunifiedStatusInvldParam; + LOG_ERROR(" epsvsINVALID == m_VoltageState"); + break; + // LCOV_EXCL_STOP 6: double check + + default: + // LCOV_EXCL_START 6: double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_eStatus = eFrameworkunifiedStatusInvldParam; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Error: Invalid 'm_VoltageState' value detected: 0x%X/%d", + m_VoltageState, m_VoltageState); + break; + // LCOV_EXCL_STOP 6: double check + } + + SS_PWR_LOG_HIST("PublishVoltageStateChange()", m_PubCmdHist, m_PubHistIter, + "", l_eStatus); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +/////////////////////////////////////////////////////////////////////// +/// OnSystemModeInfoResponse +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSystemModeInfoResponse(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + SystemModeInfo l_SystemModeInfo; + + std::memset(&l_SystemModeInfo, 0, sizeof(SystemModeInfo)); + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_SystemModeInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Sending SS_POWER_SYSTEM_MODE_INFO_RESP to PSM"); + // send Wake-up complete response to System Power Manager + l_eStatus = m_oSessionHandler.SendToSupervisor( + SS_POWER_SYSTEM_MODE_INFO_RESP, sizeof(SystemModeInfo), + (PVOID) &l_SystemModeInfo); + + SS_PWR_LOG_HIST("SS_POWER_SYSTEM_MODE_INFO_RESP", m__CWORD56_RepHist, + m__CWORD56_RepIter, "", l_eStatus); + + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, "m_oSessionHandler.SendToSupervisor( " + "SS_POWER_SYSTEM_MODE_INFO_RESP)"); + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnSystemModeInfoRequest +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSystemModeInfoRequest(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + if (eFrameworkunifiedStatusOK != (l_eStatus = SendSystemModeRequestToSystemManager())) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("SendSystemModeRequestToSystemManager()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnInitCompReport +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnInitCompReport(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + if (eFrameworkunifiedStatusOK != (l_eStatus = SendInitCompReportToSystemManager())) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("SendInitCompReportToSystemManager()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnCurrentPowerStateQuery +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnCurrentPowerStateQuery(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + SS_PSCurrentState l_CurrentState; + std::memset(&l_CurrentState, 0, sizeof(SS_PSCurrentState)); + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_CurrentState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else if (eFrameworkunifiedStatusOK != (l_eStatus = ConstructPwrStateResponse(l_CurrentState.printRespmsg))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 8: dead code. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ConstructPwrStateResponse(l_CurrentState.printRespmsg)"); + // LCOV_EXCL_STOP + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response is %s", + l_CurrentState.printRespmsg); + // Send Power State to client + + HANDLE l_handle = FrameworkunifiedOpenService(h_app, FrameworkunifiedGetMsgSrc(h_app)); + if (NULL != l_handle) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + l_eStatus = FrameworkunifiedSendMsg(l_handle, SS_POWER_CRNT_STATE_QUERY_RSPN, + sizeof(SS_PSCurrentState), + (PVOID) &l_CurrentState); + + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_CRNT_STATE_QUERY_RSPN)"); + + l_eStatus = FrameworkunifiedCloseService(h_app, l_handle); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(l_eStatus, + "FrameworkunifiedCloseService()"); + } else { + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_eStatus = eFrameworkunifiedStatusNullPointer; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. FrameworkunifiedOpenService(%s) returned NULL", + FrameworkunifiedGetMsgSrc(h_app)); + // LCOV_EXCL_STOP 4: NSFW error case. + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnSetVoltageState +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSetVoltageState(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + std::string stLvl = "INVALID"; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + Pwr_ServiceSetInterface l_VoltageState; + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_VoltageState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + m_VoltageState = static_cast(l_VoltageState.data + .voltage.state); + if (eFrameworkunifiedStatusOK != (l_eStatus = PublishVoltageStateChange(h_app))) { // LCOV_EXCL_BR_LINE 4:NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("PublishVoltageStateChange()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } + + SS_PWR_LOG_HIST("OnSetVoltageState", m_PubCmdHist, m_PubHistIter, + "PublishVoltageStateChange()", l_eStatus); + + switch (l_VoltageState.data.voltage.state) { + case epsvsINVALID: { + stLvl = "INVALID"; + } + break; + + case epsvsNORMAL: { + stLvl = "NORMAL"; + } + break; + + case epsvsLVI1: { + stLvl = "LVI1"; + } + break; + + case epsvsLVI2: { + stLvl = "LVI2"; + } + break; + + default: + break; + } + + SS_PWR_LOG_HIST("OnSetVoltageState()", m_VCmdHist, m_VHistIter, stLvl, + l_eStatus); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// OnSetCrankState +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::OnSetCrankState(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + Pwr_ServiceSetInterface l_CrankState; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_CrankState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + m_CrankState = static_cast(l_CrankState.data.crank + .state); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +EFrameworkunifiedStatus Power::OnSystemMgrConnectionEstablished(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + l_eStatus = FrameworkunifiedPublishServiceAvailability(h_app, TRUE); + + SS_PWR_LOG_HIST("FrameworkunifiedPublishServiceAvailability()", m_PubCmdHist, + m_PubHistIter, "", l_eStatus); + + LOG_STATUS(l_eStatus, + "FrameworkunifiedPublishServiceAvailability(" szNTFY_PowerAvailability ",TRUE)"); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +EFrameworkunifiedStatus Power::OnUserModeResponse(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + EPWR_USER_MODE_TYPE l_eUserModeState = epsumINVALID; + Pwr_ServiceSetInterface tServiceSetIf; + + l_eStatus = ValidateUserModeMessage(h_app, l_eUserModeState); + if (eFrameworkunifiedStatusOK != l_eStatus) { + LOG_ERROR("ValidateUserModeMessage(&l_eUserModeState)"); + } else { + PCSTR p_sStateName = l_eUserModeState == epsumON ? "epsumON" : "epsumOFF"; + tServiceSetIf.data.user_mode.mode = l_eUserModeState; + + l_eStatus = m_oSessionHandler.SendToSupervisor( + SS_POWER_USER_MODE_SET_RESP, sizeof(Pwr_ServiceSetInterface), + (PVOID) &tServiceSetIf); + + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Error: m_oSessionHandler.SendToSupervisor(" " SS_POWER_USER_MODE_SET_RESP, %s) errored: %d/'%s'", + p_sStateName, l_eStatus, GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP + } else { + SS_PWR_LOG_HIST("SS_POWER_USER_MODE_SET_RESP", m__CWORD56_RepHist, + m__CWORD56_RepIter, p_sStateName, l_eStatus); + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, + __FUNCTION__, + " m_oSessionHandler.SendToSupervisor(" " SS_POWER_USER_MODE_SET_RESP, %s) successful ", + p_sStateName); + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnUserModeResponse( HANDLE h_app ) + +EFrameworkunifiedStatus Power::ValidateUserModeMessage( + HANDLE h_app, EPWR_USER_MODE_TYPE &l_eUserModeState) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + Pwr_ServiceSetInterface tServiceSetIf; + EPWR_USER_MODE_TYPE l_my_eUserModeState; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + l_my_eUserModeState = tServiceSetIf.data.user_mode.mode; + switch (l_my_eUserModeState) { + case epsumINVALID: + l_eStatus = eFrameworkunifiedStatusInvldParam; + LOG_ERROR("l_eUserModeState == epsumINVALID"); + break; + + case epsumOFF: + case epsumON: + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Validated '%s'", + l_my_eUserModeState == epsumON ? "epsumON" : "epsumOFF"); + l_eUserModeState = l_my_eUserModeState; + l_eStatus = eFrameworkunifiedStatusOK; + break; + + default: + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Error: Unknown 'l_my_eUserModeState' value: 0x%x", + l_my_eUserModeState); + l_eStatus = eFrameworkunifiedStatusInvldParam; + break; + } // End switch + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::ValidateUserModeMessage( HANDLE h_app, EPWR_USER_MODE_TYPE &l_eUserModeState ) + +//***************************************************************************** +// Start Confirmation Protocol callback functions +// +EFrameworkunifiedStatus Power::OnSendStartupConfirmationRequest(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + EFrameworkunifiedStatus l_responseStatus = eFrameworkunifiedStatusOK; + Pwr_ServiceSetInterface tServiceSetIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + StartupConfirmationMsgStrut l_startupConfirmationMsg = tServiceSetIf.data + .startupConfirmationMsg; + l_eStatus = SendStartupConfirmationToSystemManager( + l_startupConfirmationMsg); + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, "SendStartupConfirmationToSystemManager()"); + } + + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:interface_unified if can not be error. + // LCOV_EXCL_START 200:interface_unified if can not be error. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_responseStatus = l_eStatus; // Save the current status as-is to + // send in the message response to the + // requester. + l_eStatus = m_oSessionHandler.SendToSupervisor( + SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus), + (PVOID) &l_responseStatus); + + SS_PWR_LOG_HIST("SS_POWER_FWD_START_CONFIRMATION_MSG_RESP", m__CWORD56_RepHist, + m__CWORD56_RepIter, "", l_eStatus); + + LOG_STATUS( + l_eStatus, + "m_oSessionHandler.SendToSupervisor( " "SS_POWER_FWD_START_CONFIRMATION_MSG_RESP)"); + // LCOV_EXCL_STOP 200:interface_unified if can not be error. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " SendStartupConfirmationToSystemManager() successful"); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnSendStartupConfirmationRequest( HANDLE h_app ) + +EFrameworkunifiedStatus Power::OnSendStartupConfirmationResponse(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + EFrameworkunifiedStatus l_responseStatus; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_responseStatus))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + l_eStatus = m_oSessionHandler.SendToSupervisor( + SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus), + (PVOID) &l_responseStatus); + + SS_PWR_LOG_HIST("SS_POWER_FWD_START_CONFIRMATION_MSG_RESP", m__CWORD56_RepHist, + m__CWORD56_RepIter, "", l_eStatus); + + LOG_STATUS( + l_eStatus, + "m_oSessionHandler.SendToSupervisor(" " SS_POWER_FWD_START_CONFIRMATION_MSG_RESP)"); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnSendStartupConfirmationResponse( HANDLE h_app ) +// +// End of Start Confirmation Protocol callback functions +//***************************************************************************** + +//***************************************************************************** +// Start HeartBeat Protocol callback functions +// Theory of operation: Forward HB request to SM. If SM crashes, then the HB +// will cease between SM and the _CWORD56_. Consequently, the _CWORD56_ will reset the +// system. +EFrameworkunifiedStatus Power::On_CWORD56_HeartBeatRequest(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + EPWR_HB_REQ_MSG_STRUCT l_HbReq; + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "_CWORD56_ HeartBeat Request received."); + + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_HbReq))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else if (eFrameworkunifiedStatusOK != (l_eStatus = Send_CWORD56_HeartBeatRequestToSystemManager(l_HbReq))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("Send_CWORD56_HeartBeatRequestToSystemManager()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +EFrameworkunifiedStatus Power::OnSM_CWORD56_HeartBeatResponse(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from SM."); + + l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HEARTBEAT_RESP, 0, + NULL); + + SS_PWR_LOG_HIST("SS_POWER_HEARTBEAT_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter, "", + l_eStatus); + + LOG_STATUS(l_eStatus, + "m_oSessionHandler.SendToSupervisor( SS_POWER_HEARTBEAT_RESP)"); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +// +// End of Heartbeat Protocol callback functions +//***************************************************************************** + +//***************************************************************************** +// Start CPU Reset Request Protocol callback functions +// +EFrameworkunifiedStatus Power::OnCpuResetRequest(HANDLE h_app) { // SS_SM_CPU_RESET_REQ + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + TSystemManagerCpuResetInfo l_SmCpuResetInfo; // SS Type + SS_Pwr_CpuResetMsgStruct l_PsCpuResetInfo; // SS Type translated to PSM type. + + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_SmCpuResetInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CPU Reset Type: %d", + l_SmCpuResetInfo.resetReason); + + switch (l_SmCpuResetInfo.resetReason) { + case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR: + case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR: + l_PsCpuResetInfo.resetReason = epsCpuResetReasonGeneric; + break; + + case e_SS_SM_CPU_RESET_REASON_DSP_ERR: + l_PsCpuResetInfo.resetReason = epsCpuResetReasonFatalError; + break; + + case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET: + l_PsCpuResetInfo.resetReason = epsCpuResetReasonUserForceReset; + break; + + case e_SS_SM_CPU_RESET_REASON_NORMAL: + l_PsCpuResetInfo.resetReason = epsCpuResetReasonNormalReset; + break; + default: + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reset reason '%d' not defined", + l_SmCpuResetInfo.resetReason); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return (eFrameworkunifiedStatusInvldParam); + } + + snprintf(l_PsCpuResetInfo.messageStr, PWR_RESET_MSG_STR_SIZE, "%s", + l_SmCpuResetInfo.messageStr); + + l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HARD_RESET_REQ, + sizeof(l_PsCpuResetInfo), + (PVOID) &l_PsCpuResetInfo); + + SS_PWR_LOG_HIST("SS_POWER_HARD_RESET_REQ", m__CWORD56_RepHist, m__CWORD56_RepIter, "", + l_eStatus); + + LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING( + l_eStatus, "m_oSessionHandler.SendToSupervisor( " + "SS_POWER_HARD_RESET_REQ)"); + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// +// End of CPU Reset Request Protocol callback functions +//***************************************************************************** + +/////////////////////////////////////////////////////////////////////// +/// SetCmdHist +/// +/// +////////////////////////////////////////////////////////////////////// +void Power::SetCmdHist(std::string cmd, cmdHist &hist, cmdHistIter &it, + std::string sender) { + pthread_mutex_lock(&pwr_hist_mutex); + + UI_64 l_clkcycles = ClockCycle(); + /* find out how many cycles per millisecond */ + UI_64 l_totalmsec = l_clkcycles / 1000; + + it->m_time = l_totalmsec; + it->m_cmd = cmd; + it->m_sender = sender; + it++; + + if (it == hist.end()) { + it = hist.begin(); + } + + pthread_mutex_unlock(&pwr_hist_mutex); +} + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup SSPowerDebugDump +/// implement post mortem function +/// +/// \param +/// +/// \return void +/////////////////////////////////////////////////////////////////////////////// +VOID Power::SSPowerDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7:debug code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + char l_debugDumpData[SS_PWR_DEBUG_DUMP_MAX_SIZE]; + UI_16 l_byteCount = 0; + cmdHistIter i; + memset((void*) l_debugDumpData, 0x00, sizeof(l_debugDumpData)); // NOLINT (readability/casting) + + l_byteCount = snprintf(l_debugDumpData, SS_PWR_DEBUG_DUMP_MAX_SIZE, + ("\n \n")); + + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n ***Error history***\n"); + + for (i = m_ErrHist.begin(); i != m_ErrHist.end(); ++i) { + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n %s @ %llums EC:%s \n", i->m_cmd.c_str(), + i->m_time, i->m_sender.c_str()); + } + + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n ***_CWORD56_ Reply history***\n"); + + for (i = m__CWORD56_RepHist.begin(); i != m__CWORD56_RepHist.end(); ++i) { + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n %s @ %llums\n", i->m_cmd.c_str(), i->m_time); + } + + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n ***Voltage history***\n"); + + for (i = m_VCmdHist.begin(); i != m_VCmdHist.end(); ++i) { + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n %s @ %llums %s \n", i->m_cmd.c_str(), i->m_time, + i->m_sender.c_str()); + } + + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n ***Publishshing history***\n"); + + for (i = m_PubCmdHist.begin(); i != m_PubCmdHist.end(); ++i) { + l_byteCount += snprintf(l_debugDumpData + l_byteCount, + SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount, + "\n %s @ %llums \n", i->m_cmd.c_str(), i->m_time); + } + + SSDEBUGDUMP("%s", (const char *) &l_debugDumpData); +} +// LCOV_EXCL_STOP 7:debug code + +//***************************************************************************** +// Start Remote Data Reset Protocol callback functions +// From SM to PS +EFrameworkunifiedStatus Power::OnRemoteDataResetRequest(HANDLE h_app) { // SS_SM_REMOTE_DATA_RESET_REQ + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + ESMDataResetType l_eSmDataResetType; // SS Type + epsCpuResetReason l_ePsCpuResetReason; // SS Type translated to PSM CPU reset reason. + BOOL l_bResetRequired; + + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, l_eSmDataResetType))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Remote Data Reset Type: %d", + l_eSmDataResetType); + l_bResetRequired = FALSE; + switch (l_eSmDataResetType) { + case e_SS_SM_DATA_RESET_TYPE_USER: + l_ePsCpuResetReason = epsCpuResetReasonUserDataReset; + l_bResetRequired = TRUE; + break; + + case e_SS_SM_DATA_RESET_TYPE_FACTORY: + l_ePsCpuResetReason = epsCpuResetReasonFactoryDataReset; + l_bResetRequired = TRUE; + break; + + case e_SS_SM_DATA_RESET_TYPE_CONFIGURATION: // No reset action required. + l_bResetRequired = FALSE; + break; + + default: + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Error: Remote Reset Data type : %d not defined", + l_eSmDataResetType); + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return (eFrameworkunifiedStatusInvldParam); + } + + if (TRUE == l_bResetRequired) { + SS_Pwr_CpuResetMsgStruct l_PsCpuResetInfo = { }; + l_PsCpuResetInfo.resetReason = l_ePsCpuResetReason; + l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HARD_RESET_REQ, + sizeof(l_PsCpuResetInfo), + (PVOID) &l_PsCpuResetInfo); + + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Error: m_oSessionHandler.SendToSupervisor( " "SS_POWER_HARD_RESET_REQ, Reason '%d') errored:%d/'%s'", + l_ePsCpuResetReason, l_eStatus, GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "SS_POWER_HARD_RESET_REQ Reason '%d' sent to PSMShadow", + l_ePsCpuResetReason); + } + SS_PWR_LOG_HIST("SS_POWER_HARD_RESET_REQ", m__CWORD56_RepHist, m__CWORD56_RepIter, + "", l_eStatus); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// +// End of Remote Data Reset Protocol callback functions +//***************************************************************************** + +// EOF of /SS_PowerService/src/ss_power.cpp + diff --git a/power_service/server/src/ss_power_config.cpp b/power_service/server/src/ss_power_config.cpp new file mode 100644 index 00000000..1f04b6ed --- /dev/null +++ b/power_service/server/src/ss_power_config.cpp @@ -0,0 +1,188 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief This file supports power service configuration. +/// +/////////////////////////////////////////////////////////////////////////////// +#include +#include "ss_power_config.h" + +// define all the configuration parmeters that will be used to get data +const char * PowerConfiguration::kPowerLogicPlugin = "PowerLogicPlugin.dll"; +const char * PowerConfiguration::kLVI1Timeout = "LVI1.Timeouts_Timeout"; +const char * PowerConfiguration::kLVI1HysteresisTimeout = + "LVI1.Hysteresis_Timeout"; +const char * PowerConfiguration::kLVI1HysteresisEnabled = + "LVI1.Hysteresis_Enabled"; +const char * PowerConfiguration::kLVI1HysteresisTries = "LVI1.Hysteresis_Tries"; +const char * PowerConfiguration::kLVI2Timeout = "LVI2.Timeouts_Timeout"; +const char * PowerConfiguration::kLVI2HysteresisTimeout = + "LVI2.Hysteresis_Timeout"; +const char * PowerConfiguration::kLVI2HysteresisEnabled = + "LVI2.Hysteresis_Enabled"; +const char * PowerConfiguration::kLVI2HysteresisTries = "LVI2.Hysteresis_Tries"; +const char * PowerConfiguration::kShutdownTimeout = "Shutdown.Timeouts_Timeout"; +const char * PowerConfiguration::kShutdownHysteresisTimeout = + "Shutdown.Hysteresis_Timeout"; +const char * PowerConfiguration::kShutdownHysteresisEnabled = + "Shutdown.Hysteresis_Enabled"; +const char * PowerConfiguration::kShutdownHysteresisTries = + "Shutdown.Hysteresis_Tries"; +/// < defines the names in the cfg file that are used to get required modules names +const char * PowerConfiguration::kRequiredWakeupModules = + "Wakeup.RequiredModules."; /// < once all the modules have been wakened up send wake-up complete +const char * PowerConfiguration::kRequiredShutdownModules = + "Shutdown.RequiredModules."; /// < once all the modules have been shutdown send shutdown complete +const char * PowerConfiguration::kRequiredLvi2Modules = + "LVI2.RequiredModules."; /// < once all the modules have been wakened up send wake-up complete + +PowerConfiguration::PowerConfiguration(std::string f_configfilename) + : m_ConfigFileName(f_configfilename) { +} + +PowerConfiguration::~PowerConfiguration() { +} + +BOOL PowerConfiguration::LoadParameters(PowerConfigParams & params) { + EFrameworkunifiedStatus l_eStatus; + BOOL l_rtnCode = FALSE; + + CNSConfigReader *l_pReaderCfg = new CNSConfigReader(); + if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5:new error case + // LCOV_EXCL_START 5:new error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error. new CNSConfigReader() returned NULL pointer."); + // LCOV_EXCL_STOP 5:new error case + } else { + if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(m_ConfigFileName))) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error. l_pReaderCfg->Open(%s) returned NULL pointer.", + m_ConfigFileName.c_str()); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kShutdownTimeout, + params.shutdown.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(ShutdownTimeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI1Timeout, params.lvi1.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(LVI1Timeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI2Timeout, params.lvi2.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(LVI2Timeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kShutdownHysteresisTimeout, + params.shutdown.hysteresis.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(ShutdownHysteresisTimeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI1HysteresisTimeout, + params.lvi1.hysteresis.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI1HysteresisTimeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI2HysteresisTimeout, + params.lvi2.hysteresis.timeout))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI2HysteresisTimeout)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kShutdownHysteresisTries, + params.shutdown.hysteresis.tries))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(ShutdownHysteresisTries)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI1HysteresisTries, + params.lvi1.hysteresis.tries))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI1HysteresisTries)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetInt(kLVI2HysteresisTries, + params.lvi2.hysteresis.tries))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI2HysteresisTries)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetBool( + kShutdownHysteresisEnabled, params.shutdown.hysteresis.enabled))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(ShutdownHysteresisEnabled)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetBool(kLVI1HysteresisEnabled, + params.lvi1.hysteresis.enabled))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI1HysteresisEnabled)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetBool(kLVI2HysteresisEnabled, + params.lvi2.hysteresis.enabled))) { + LOG_STATUS_IF_ERRORED(l_eStatus, + "l_pReaderCfg->GetInt(LVI2HysteresisEnabled)"); + } else if (eFrameworkunifiedStatusOK + != (l_eStatus = l_pReaderCfg->GetString(kPowerLogicPlugin, + params.power_logic_plugin))) { + LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(PowerLogicPlugin)"); + } else { + l_rtnCode = TRUE; + } + + delete l_pReaderCfg; + } + + return (l_rtnCode); +} + +void PowerConfiguration::LoadDefaultParameters(PowerConfigParams & params) { + params.power_logic_plugin = "ss_powerlogic.dll"; + params.shutdown.timeout = 600; // thats 5mins + params.shutdown.hysteresis.enabled = FALSE; // There should be hysteresis for Shutdown + params.shutdown.hysteresis.timeout = 0; // Don't Care since disabled. + params.shutdown.hysteresis.tries = 0; // Don't Care since disabled. + params.lvi1.timeout = 2; // thats 2secs + params.lvi1.hysteresis.enabled = TRUE; // Enable LVI1 hysteresis + params.lvi1.hysteresis.tries = 2; // check twice before switching to LVI1 + params.lvi1.hysteresis.timeout = 500; // thats 500 msecs + params.lvi2.timeout = 2; // thats 2secs + params.lvi2.hysteresis.enabled = TRUE; // Enable LVI2 hysteresis + params.lvi2.hysteresis.tries = 2; // check twice before switching to LVI2 + params.lvi2.hysteresis.timeout = 100; // thats 100 msecs +} + +void PowerConfiguration::PrintConfigInfo(PowerConfigParams & f_params) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.timeout: %d", + f_params.shutdown.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.timeout: %d", f_params.lvi1.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.timeout: %d", f_params.lvi2.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.timeout: %d", + f_params.shutdown.hysteresis.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.timeout: %d", + f_params.lvi1.hysteresis.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.hysteresis.timeout: %d", + f_params.lvi2.hysteresis.timeout); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.tries: %d", + f_params.shutdown.hysteresis.tries); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.tries: %d", + f_params.lvi1.hysteresis.tries); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.tries: %d", + f_params.lvi1.hysteresis.tries); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.enabled: %d", + f_params.shutdown.hysteresis.enabled); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.enabled: %d", + f_params.lvi1.hysteresis.enabled); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.hysteresis.enabled: %d", + f_params.lvi2.hysteresis.enabled); + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "power_logic_plugin: %s", + f_params.power_logic_plugin.c_str()); + return; +} diff --git a/power_service/server/src/ss_power_session.cpp b/power_service/server/src/ss_power_session.cpp new file mode 100644 index 00000000..70dbc692 --- /dev/null +++ b/power_service/server/src/ss_power_session.cpp @@ -0,0 +1,276 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_Power +/// \brief This file supports power service session management. +/// +/////////////////////////////////////////////////////////////////////////////// +#include "ss_power_session.h" +#include +#include +#include +#include +#include +#include +#include + +#include "ss_power_powerservicelog.h" + + +PowerSessionHandler::PowerSessionHandler() { + // TODO(my_username) Auto-generated constructor stub +} + +PowerSessionHandler::~PowerSessionHandler() { // LCOV_EXCL_START 14 Resident process, not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // TODO(my_username) Auto-generated destructor stub +} +// LCOV_EXCL_STOP 14 Resident process, not called by NSFW + +EFrameworkunifiedStatus PowerSessionHandler::CloseSession(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app); + + // find the subscriber... + PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app)); + + // the iter is set to the end then the subscriber is not in the map + if (m_mapSessions.end() == iter) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_START 11:unexpected branch + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + " Error: Subscriber '%s' was not found in the map; the Close " "Session Request is being ignored!", + FrameworkunifiedGetMsgSrc(h_app)); + l_eStatus = eFrameworkunifiedStatusDbRecNotFound; + } else if (NULL == iter->second.hsession) { // LCOV_EXCL_BR_LINE 11:unexpected branch + l_eStatus = eFrameworkunifiedStatusInvldHandle; + LOG_ERROR("Client's PwSessionInfo handle"); + // LCOV_EXCL_STOP 11:unexpected branch + } else { + CloseSessionAck closeSessionAck; + closeSessionAck.sessionId = FrameworkunifiedGetSessionId(iter->second.hsession); + closeSessionAck.eStatus = eFrameworkunifiedStatusOK; + + // Send Ack to subscriber + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, PROTOCOL_CLOSE_SESSION_ACK, sizeof(CloseSessionAck), (PVOID) &closeSessionAck))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + " Error: FrameworkunifiedSendMsg(%s, PROTOCOL_CLOSE_SESSION_ACK) " "errored: %d/'%s'", + iter->second.sz_name.c_str(), l_eStatus, GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " FrameworkunifiedSendMsg(%s, PROTOCOL_CLOSE_SESSION_ACK) successful", + iter->second.sz_name.c_str()); + iter->second.frunning = FALSE; + + // + // ToDo Jay 2012 November 05 1) Can't detach just basic callbacks; + // client could be Supervisor or System. This has been solved + // in another Power Service Change Set. Need to get all + // Change Sets merged and delivered. + UI_32 ss_power_basic_session_ids[] = { PROTOCOL_CLOSE_SESSION_REQ }; + + // Detach callback : Power System Session Requests + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(h_app, iter->second.sz_name.c_str(), ss_power_basic_session_ids, _countof(ss_power_basic_session_ids)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedDetachCallbacksFromDispatcher()"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " FrameworkunifiedDetachCallbacksFromDispatcher() successful"); + } + + CALL_AND_LOG_STATUS(FrameworkunifiedDestroySession(h_app, iter->second.hsession)); + iter->second.hsession = NULL; + m_mapSessions.erase(iter); + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +EFrameworkunifiedStatus PowerSessionHandler::StartComplete(HANDLE h_app) { // LCOV_EXCL_START 8: can not be called + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + StartCompleteAck ack; + + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, ack))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); + } else { + // find the subscriber... + PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app)); + + // the iter is set to the end then the subscriber is not in the map + if (m_mapSessions.end() != iter) { + iter->second.sz_servicename = ack.szServiceName; + iter->second.frunning = TRUE; + + if (AllClientsInGroupStarted(iter->second.ui_groupid)) { + // NOP + } + } else { + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Subscriber: %s , was not found in the map, the close session is being ignored!", + FrameworkunifiedGetMsgSrc(h_app)); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// LCOV_EXCL_STOP 8: can not be called +VOID PowerSessionHandler::Print() { + // find the subscriber... + PwSessionIter iter = m_mapSessions.begin(); + for (; iter != m_mapSessions.end(); iter++) { + FRAMEWORKUNIFIEDLOG(ZONE_DEBUG_DUMP, __FUNCTION__, + " Power Service is session-connected to '%s'; running: %s", + iter->second.sz_name.data(), (iter->second.frunning ? "YES" : "NO")); + } +} + +// LCOV_EXCL_START 8: can not be called +BOOL PowerSessionHandler::WakeupComplete(RequiredModuleList & wakeup_modules) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + BOOL rtn = TRUE; // set the return TRUE until we find a missing module + RequiredModuleListIter iter = wakeup_modules.begin(); + for (; iter != wakeup_modules.end(); iter++) { + PwSessionIter psi = m_mapSessions.find(*iter); + if (m_mapSessions.end() == psi) { + rtn = FALSE; // Module Not Found in Power Service Session Handler + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, + __FUNCTION__, + "Required Wakeup: %s has not connected to Power Service, Wakeup NOT COMPLETE!", + iter->data()); + } else if (FALSE == psi->second.frunning) { + rtn = FALSE; // Module Found in Power Service Session Handler but hasn't started yet + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, + __FUNCTION__, + "Required Wakeup: %s has connected to Power Service but is not running (FrameworkunifiedStart Response missing)," + " Wakeup NOT COMPLETE!", + iter->data()); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return rtn; +} +// LCOV_EXCL_STOP 8: can not be called + +BOOL PowerSessionHandler::ShutdownComplete( + RequiredModuleList & shutdown_modules) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + BOOL rtn = TRUE; // set the return TRUE until we find a missing module + RequiredModuleListIter iter = shutdown_modules.begin(); + for (; iter != shutdown_modules.end(); iter++) { + PwSessionIter psi = m_mapSessions.find(*iter); + if (m_mapSessions.end() == psi) { + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, + __FUNCTION__, + "Required Shutdown: %s is not in Power Service session list, Shutdown pending!", + iter->data()); + } else if (TRUE == psi->second.frunning) { + rtn = FALSE; // Module Found in Power Service Session Handler but hasn't stopped yet + FRAMEWORKUNIFIEDLOG( + ZONE_INFO, + __FUNCTION__, + "Required Shutdown: %s is connected to Power Service but is running (Stop Response missing)," + " Shutdown NOT COMPLETE!", + iter->data()); + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return rtn; +} + +EFrameworkunifiedStatus PowerSessionHandler::SendToSupervisor(UI_32 cmd, UI_32 length, + PVOID data) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + if (NULL == data && length > 0) { // LCOV_EXCL_BR_LINE 6: it will not be true at the other place + // LCOV_EXCL_START 6: it will not be true at the other place + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("NULL == data && length > 0"); + l_eStatus = eFrameworkunifiedStatusInvldBuf; + // LCOV_EXCL_STOP 6: it will not be true at the other place + } else { + // get first client from the map... + PwSessionIter iter = m_mapSessions.begin(); + BOOL l_bFoundSupervisor = FALSE; + + for (; iter != m_mapSessions.end() && !l_bFoundSupervisor; iter++) { + l_bFoundSupervisor = (epsstSUPERVISOR == iter->second.esessiontype); + if (l_bFoundSupervisor) { + l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, cmd, length, data); + LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg()"); + } + } + if (!l_bFoundSupervisor) { + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, __FUNCTION__, + "Error: Did not find a Supervisor session; did not " "send cmd %d !", + cmd); + l_eStatus = eFrameworkunifiedStatusDbRecNotFound; + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +BOOL PowerSessionHandler::AllClientsInGroupStarted(UI_32 f_ungrpid) { // LCOV_EXCL_START 8: can not be called + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + BOOL fStatus = TRUE; + BOOL fGrpFnd = FALSE; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + PwSessionIter iter = m_mapSessions.begin(); + + if (iter == m_mapSessions.end()) + fStatus = TRUE; + + for (; iter != m_mapSessions.end() && fStatus; iter++) { + if (f_ungrpid == iter->second.ui_groupid) { + fGrpFnd = TRUE; + if (FALSE == iter->second.frunning) { + fStatus = FALSE; + } + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return flag: %s", + ((fStatus && fGrpFnd) ? "TRUE" : "FALSE")); + return (fStatus && fGrpFnd); +} +// LCOV_EXCL_STOP 8: can not be called diff --git a/power_service/server/src/ss_power_state_machine.cpp b/power_service/server/src/ss_power_state_machine.cpp new file mode 100644 index 00000000..092e88c6 --- /dev/null +++ b/power_service/server/src/ss_power_state_machine.cpp @@ -0,0 +1,924 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief This file supports the power service state machine. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "ss_power_state_machine.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "ss_power_session.h" +#include "ss_power_powerservicelog.h" + +/// Define static members of the class. +PowerStateMachine::Wakeup PowerStateMachine::WakeupState; +PowerStateMachine::WakeupActive PowerStateMachine::WakeupActiveState; +PowerStateMachine::WakeupPending PowerStateMachine::WakeupPendingState; +PowerStateMachine::LowVoltage1 PowerStateMachine::LowVoltage1State; +PowerStateMachine::LowVoltage1Active PowerStateMachine::LowVoltage1ActiveState; +PowerStateMachine::LowVoltage2 PowerStateMachine::LowVoltage2State; +PowerStateMachine::LowVoltage2Active PowerStateMachine::LowVoltage2ActiveState; +PowerStateMachine::Shutdown PowerStateMachine::ShutdownState; +PowerStateMachine::ShutdownActive PowerStateMachine::ShutdownActiveState; +PowerStateMachine::NormalVoltage PowerStateMachine::NormalVoltageState; +PowerStateMachine::SoftwareUpdate PowerStateMachine::SoftwareUpdateState; + +/// Constructor +PowerStateMachine::PowerStateMachine() + : m_pCurrentState(&WakeupState), + m_pPreviousState(NULL), + m_pOnHysteresisTimeoutState(NULL), + m_oShutdownHysteresis(), + m_oLowVoltage1Hysteresis(), + m_oLowVoltage2Hysteresis(), + m_hHysteresisTimer(NULL), + m_tStateInfo() { +} + +/// Deconstructor +PowerStateMachine::~PowerStateMachine() { // LCOV_EXCL_START 14 Resident process, not called by NSFW + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +} +// LCOV_EXCL_STOP 14 Resident process, not called by NSFW + +void PowerStateMachine::onEvent(HANDLE h_app, PowerSessionHandler & oSession, + ePowerStateMachineEvents evt) { + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "(ENTRY) Power StateMachine Current State: %s, Previous State: %s", + m_pCurrentState->name(), + (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name())); + + switch (evt) { // LCOV_EXCL_BR_LINE 8: dead code + case PowerStateMachine::epsmeWAKEUP: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeWAKEUP"); + m_pCurrentState->onWakeup(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeSTART_COMPLETE: // LCOV_EXCL_START 8: no one send the event + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTART_COMPLETE"); + m_pCurrentState->onStartComplete(*this, h_app, oSession); + break; + // LCOV_EXCL_STOP 8: no one send the event + case PowerStateMachine::epsmeSHUTDOWN: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSHUTDOWN"); + m_pCurrentState->onShutdown(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeSTOP_COMPLETE: // LCOV_EXCL_START 8: no one send the event + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTOP_COMPLETE"); + m_pCurrentState->onStopComplete(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeLVI1_ENCOUNTERED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_ENCOUNTERED"); + m_pCurrentState->onLowVoltage1Encountered(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeLVI2_ENCOUNTERED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_ENCOUNTERED"); + m_pCurrentState->onLowVoltage2Encountered(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeNORMAL_VOLTAGE_ENCOUNTERED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "Power StateMachine Event Received: epsmeNORMAL_VOLTAGE_ENCOUNTERED"); + m_pCurrentState->onNormalVoltageEncountered(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeSOFTWARE_UPDATE: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSOFTWARE_UPDATE"); + m_pCurrentState->onSoftwareUpdate(*this, h_app, oSession); + break; + case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_ABORTED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "Power StateMachine Event Received: epsmeSHUTDOWN_HYSTERESIS_ABORTED"); + case PowerStateMachine::epsmeLVI1_HYSTERESIS_ABORTED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_HYSTERESIS_ABORTED"); + case PowerStateMachine::epsmeLVI2_HYSTERESIS_ABORTED: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_HYSTERESIS_ABORTED"); + m_pCurrentState->onHysteresisAborted(*this, h_app, oSession); + break; + // LCOV_EXCL_STOP 8: no one send the event + case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_TM_OUT: + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + "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] + case PowerStateMachine::epsmeLVI1_HYSTERESIS_TM_OUT: + 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] + case PowerStateMachine::epsmeLVI2_HYSTERESIS_TM_OUT: + 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] + m_pCurrentState->onHysteresisTimeout(*this, h_app, oSession); + break; + default: + 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] + break; + } // ZONE_POWER_STATEMACHINE + + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-"); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "(EXIT) Power StateMachine Current State: %s, Previous State: %s", + m_pCurrentState->name(), + (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name())); +} + +PCSTR PowerStateMachine::name() { // LCOV_EXCL_START 8: do not be called + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (NULL != m_pCurrentState) { + return m_pCurrentState->name(); + } + + return "Invalid Current State is NULL..."; +} +// LCOV_EXCL_STOP 8: do not be called + +/// Switch to the next State and save the previous state. +void PowerStateMachine::NextState(Base_State & refState, HANDLE h_app, + PowerSessionHandler & oSession) { + m_pPreviousState = m_pCurrentState; + m_pPreviousState->onExit(*this, h_app, oSession); + m_pCurrentState = &refState; + m_pCurrentState->onEntry(*this, h_app, oSession); +} + +// LCOV_EXCL_START 8: do not be called +void PowerStateMachine::OnVoltage(Base_State * pState, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) { + Pwr_ServiceSetInterface tServiceIf; + + if (eFrameworkunifiedStatusOK + == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf, + sizeof(Pwr_ServiceSetInterface))) { + /// Need to store the voltage information + m_tStateInfo.voltage = tServiceIf.data.voltage.state; + + if (NULL != pState) { + NextState(*pState, h_app, oSession); + } + } + } +} +// LCOV_EXCL_STOP 8: do not be called +void PowerStateMachine::GotoStateOnHysteresisTimeout(Base_State & refState) { + m_pOnHysteresisTimeoutState = &refState; +} + +void PowerStateMachine::startHysteresisTimer(PowerStateHysteresis & hys_info) { + /// clear the try counter. + hys_info.clearTryCounter(); + + /// bump the hysteresis try counter (prime the counter). + hys_info.bumbTryCounter(); + + /// setup the hysteresis timer + NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()), + MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 }; + + /// start the hysteresis timer + NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis); +} + +void PowerStateMachine::reStartHysteresisTimer( + PowerStateHysteresis & hys_info) { + /// bump the hysteresis try counter. + hys_info.bumbTryCounter(); + + /// setup the hysteresis timer (one shot) + NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()), + MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 }; + /// start the hysteresis timer + NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis); +} + +void PowerStateMachine::stopHysteresisTimer(PowerStateHysteresis & hys_info) { + NSTimerInfo turn_off_hysteresis = { 0, 0, 0, 0, 0 }; + NS_TimerSetTime(m_hHysteresisTimer, turn_off_hysteresis); + /// clear the try counter. + hys_info.clearTryCounter(); +} + +// LCOV_EXCL_START 8: can not be called +void PowerStateMachine::publishPowerLVIStatus(HANDLE h_app, PCSTR nNotifNm, + UI_32 value) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + PowerSrvLVIStatus eLviStatus = static_cast(value); + if (eFrameworkunifiedStatusOK + != (eStatus = FrameworkunifiedNPPublishNotification(h_app, nNotifNm, &eLviStatus, + sizeof(eLviStatus)))) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: FrameworkunifiedNPPublishNotification( %s ) errored: 0x%X", nNotifNm, + eStatus); + } +} +// LCOV_EXCL_STOP 8: can not be called +void PowerStateMachine::publishPowerLevelType(HANDLE h_app, UI_32 value) { + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + PowerSrvLevelType eLevelType = static_cast(value); + if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPPublishNotification (h_app, szNTFY_PowerLevel, &eLevelType, sizeof (eLevelType)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: FrameworkunifiedNPPublishNotification %s Failed Status:0x%x ", + szNTFY_PowerLevel, eStatus); + // LCOV_EXCL_STOP 4: NSFW error case. + } +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Base_State::onStartComplete( + PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + oSession.StartComplete(h_app); +} +// LCOV_EXCL_STOP 8: do not be called + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Base_State::onStopComplete( + PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + oSession.StopComplete(h_app); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: no one call this function +void PowerStateMachine::Base_State::onLaunchComplete( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FrameworkunifiedDeferMessage(h_app); +} +// LCOV_EXCL_STOP 8: do not be called + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Base_State::onShutdownComplete( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FrameworkunifiedDeferMessage(h_app); +} +// LCOV_EXCL_STOP 8: no one call this function +PCSTR PowerStateMachine::Wakeup::name() { + return "Wakeup"; +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Wakeup::onLowVoltage1Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage1State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: do not be called + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Wakeup::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage2State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::Wakeup::onNormalVoltageEncountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "NORMAL ENCOUNTERED %s (no switch)", FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event +void PowerStateMachine::Wakeup::onShutdown(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + u.NextState(ShutdownState, h_app, oSession); +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Wakeup::onSoftwareUpdate( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.NextState(SoftwareUpdateState, h_app, oSession); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Wakeup::onWakeup(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + Pwr_ServiceSetInterface tServiceIf; + if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) { + if (eFrameworkunifiedStatusOK + == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf, + sizeof(Pwr_ServiceSetInterface))) { + if (epswsPWRON == tServiceIf.data.wake.powerupType) { + /// Need to store the wakeup \ shutdown information + u.m_tStateInfo.wake = tServiceIf.data.wake.powerupType; + u.m_tStateInfo.level = tServiceIf.data.wake.up.level; + u.m_tStateInfo.factor = tServiceIf.data.wake.up.factor; + + u.NextState(WakeupPendingState, h_app, oSession); + } + } + } +} +// LCOV_EXCL_STOP 8: no one send the event + +PCSTR PowerStateMachine::WakeupActive::name() { + return "Wakeup Active"; +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::WakeupActive::onLowVoltage1Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage1State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::WakeupActive::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage2State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event +void PowerStateMachine::WakeupActive::onShutdown( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + u.NextState(ShutdownState, h_app, oSession); +} + +PCSTR PowerStateMachine::WakeupPending::name() { + return "Wakeup Pending"; +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::WakeupPending::onNormalVoltageEncountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&NormalVoltageState, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::WakeupPending::onStartComplete( + PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + oSession.StartComplete(h_app); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: no one call this function +void PowerStateMachine::WakeupPending::onLaunchComplete( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL); + if (epsvsNORMAL == u.m_tStateInfo.voltage) { + u.NextState(NormalVoltageState, h_app, oSession); + } +} +// LCOV_EXCL_STOP 8: no one call this function + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::WakeupPending::onWakeup( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (oSession.WakeupComplete(u.m_lstWakeupModules)) { + oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL); + } +} +// LCOV_EXCL_STOP 8: no one send the event + +void PowerStateMachine::WakeupPending::onEntry(PowerStateMachine &u, + HANDLE h_app, + PowerSessionHandler & oSession) { + if (!FrameworkunifiedIsDeferQueueEmpty(h_app)) { + FrameworkunifiedRetrieveDeferMessage(h_app); + } +} + +PCSTR PowerStateMachine::Shutdown::name() { + return "Shutdown"; +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Shutdown::onLowVoltage1Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(LowVoltage1State); + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::Shutdown::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(LowVoltage2State); + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::Shutdown::onHysteresisAborted( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.NextState(*(u.m_pPreviousState), h_app, oSession); +} +// LCOV_EXCL_STOP 8: no one send the event +void PowerStateMachine::Shutdown::onHysteresisTimeout( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + if (!u.m_oShutdownHysteresis.maxTries()) { + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "epsmeSHUTDOWN_TM_OUT tries: %d", u.m_oShutdownHysteresis.getTries()); + + u.reStartHysteresisTimer(u.m_oShutdownHysteresis); + } else { + // Move directorly to next state. + u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession); + } +} + +void PowerStateMachine::Shutdown::onEntry(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + if (u.m_oShutdownHysteresis.getEnabled()) { + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "Starting epsmeSHUTDOWN_HYSTERESIS_TM_OUT timeout: %d tries: %d", + u.m_oShutdownHysteresis.getTimeout(), + u.m_oShutdownHysteresis.getTries()); + // Set the goto state state. + u.GotoStateOnHysteresisTimeout(ShutdownActiveState); + // Start the hysteresis timer for low voltage 2 + u.startHysteresisTimer(u.m_oShutdownHysteresis); + } else { + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "SHUTDOWN_HYSTERESIS is not enabled. Going directly to ShutdownActiveState"); + // Move directly to next state. + u.NextState(ShutdownActiveState, h_app, oSession); + } +} + +void PowerStateMachine::Shutdown::onExit(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + u.stopHysteresisTimer(u.m_oShutdownHysteresis); + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) Shutdown State"); +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::Shutdown::onWakeup(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(WakeupPendingState); +} +// LCOV_EXCL_STOP 8: no one send the event + +PCSTR PowerStateMachine::ShutdownActive::name() { + return "Shutdown Active"; +} + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::ShutdownActive::onLowVoltage1Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage1State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::ShutdownActive::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage2State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event +void PowerStateMachine::ShutdownActive::onEntry( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + u.publishPowerLevelType(h_app, epspltSHUTDOWN); + + if (oSession.ShutdownComplete(u.m_lstShutdownModules)) { + oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL); + } +} + +void PowerStateMachine::ShutdownActive::onShutdown( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + if (oSession.ShutdownComplete(u.m_lstShutdownModules)) { + oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL); + } +} + +PCSTR PowerStateMachine::LowVoltage1::name() { // LCOV_EXCL_START 8: can not be LowVoltage1status + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return "Low Voltage I"; +} +// LCOV_EXCL_STOP 8: can not be LowVoltage1status + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage1::onHysteresisAborted( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.NextState(*(u.m_pPreviousState), h_app, oSession); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be LowVoltage1status +void PowerStateMachine::LowVoltage1::onHysteresisTimeout( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (!u.m_oLowVoltage1Hysteresis.maxTries()) { + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT tries: %d", + u.m_oLowVoltage1Hysteresis.getTries()); + + u.reStartHysteresisTimer(u.m_oLowVoltage1Hysteresis); + } else { + // Move directorly to next state. + u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession); + } +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage1::onWakeup(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(NormalVoltageState); + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: can not be LowVoltage1status + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage1::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(LowVoltage2State); + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage1::onNormalVoltageEncountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.GotoStateOnHysteresisTimeout(NormalVoltageState); + u.OnVoltage(NULL, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be LowVoltage1status +void PowerStateMachine::LowVoltage1::onEntry(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (u.m_oLowVoltage1Hysteresis.getEnabled()) { + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d", + u.m_oLowVoltage1Hysteresis.getTimeout(), + u.m_oLowVoltage1Hysteresis.getTries()); + // Set the goto state state. + u.GotoStateOnHysteresisTimeout(LowVoltage1ActiveState); + // Start the hysteresis timer for low voltage 1 + u.startHysteresisTimer(u.m_oLowVoltage1Hysteresis); + } else { + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW_VOLTAGE_HYSTERESIS is not enabled. Going directly to LowVoltage1ActiveState"); + // Move directly to next state. + u.NextState(LowVoltage1ActiveState, h_app, oSession); + } +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage1::onExit(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.stopHysteresisTimer(u.m_oLowVoltage1Hysteresis); + FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage1 State"); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +PCSTR PowerStateMachine::LowVoltage1Active::name() { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return "Low Voltage I Active"; +} +// LCOV_EXCL_STOP 8: can not be LowVoltage1status + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage1Active::onLowVoltage2Encountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&LowVoltage2State, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage1Active::onNormalVoltageEncountered( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.OnVoltage(&NormalVoltageState, h_app, oSession); + FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be LowVoltage1Activestatus +void PowerStateMachine::LowVoltage1Active::onEntry( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u.publishPowerLevelType(h_app, epspltEMERGENCY); +u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_Active); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage1Active::onExit( + PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_InActive); +} +// LCOV_EXCL_STOP 8: can not be LowVoltage1Activestatus + +PCSTR PowerStateMachine::LowVoltage2::name() { // LCOV_EXCL_START 8: can not be LowVoltage2status + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +return "Low Voltage II"; +} +// LCOV_EXCL_STOP 8: can not be LowVoltage2status + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage2::onHysteresisAborted( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.NextState(*(u.m_pPreviousState), h_app, oSession); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be LowVoltage2status +void PowerStateMachine::LowVoltage2::onHysteresisTimeout( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +if (!u.m_oLowVoltage2Hysteresis.maxTries()) { +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "epsmeLOW_VOLTAGE2_HYSTERESIS_TM_OUT tries: %d", + u.m_oLowVoltage2Hysteresis.getTries()); + +u.reStartHysteresisTimer(u.m_oLowVoltage2Hysteresis); +} else { +// Move directorly to next state. +u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession); +} +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2::onEntry(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +if (u.m_oLowVoltage2Hysteresis.getEnabled()) { +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d", + u.m_oLowVoltage2Hysteresis.getTimeout(), + u.m_oLowVoltage2Hysteresis.getTries()); +// Set the goto state state. +u.GotoStateOnHysteresisTimeout(LowVoltage2ActiveState); +// Start the hysteresis timer for low voltage 2 +u.startHysteresisTimer(u.m_oLowVoltage2Hysteresis); +} else { +FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW_VOLTAGE2_HYSTERESIS is not enabled. Going directly to LowVoltage2ActiveState"); +// Move directly to next state. +u.NextState(LowVoltage2ActiveState, h_app, oSession); +} +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2::onExit(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.stopHysteresisTimer(u.m_oLowVoltage2Hysteresis); +FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage2 State"); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2::onWakeup(PowerStateMachine &u, HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.GotoStateOnHysteresisTimeout(WakeupPendingState); +} +// LCOV_EXCL_STOP 8: can not be LowVoltage2status + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage2::onLowVoltage1Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.GotoStateOnHysteresisTimeout(LowVoltage1State); +u.OnVoltage(NULL, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2::onNormalVoltageEncountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.GotoStateOnHysteresisTimeout(NormalVoltageState); +u.OnVoltage(NULL, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, + "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +PCSTR PowerStateMachine::LowVoltage2Active::name() { // LCOV_EXCL_START 8: can not be LowVoltage2Activestatus + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +return "Low Voltage II Active"; +} +// LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::LowVoltage2Active::onLowVoltage1Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&LowVoltage1State, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2Active::onNormalVoltageEncountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&NormalVoltageState, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be LowVoltage2Activestatus +void PowerStateMachine::LowVoltage2Active::onEntry( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.publishPowerLevelType(h_app, epspltEMERGENCY); +u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_Active); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::LowVoltage2Active::onExit( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_InActive); +oSession.SendToSupervisor(SS_POWER_LVI2_SHUTDOWN_COMPLETE, 0, NULL); +} +// LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus + +PCSTR PowerStateMachine::NormalVoltage::name() { // LCOV_EXCL_START 8: can not be NormalVoltageState + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +return "Normal Voltage"; +} +// LCOV_EXCL_STOP 8: can not be NormalVoltageState + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::NormalVoltage::onLowVoltage1Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&LowVoltage1State, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::NormalVoltage::onLowVoltage2Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&LowVoltage2State, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be NormalVoltageState +void PowerStateMachine::NormalVoltage::onShutdown( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.NextState(ShutdownState, h_app, oSession); +} +// LCOV_EXCL_STOP 8: can not be NormalVoltageState + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::NormalVoltage::onSoftwareUpdate( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.NextState(SoftwareUpdateState, h_app, oSession); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be NormalVoltageState +void PowerStateMachine::NormalVoltage::onEntry(PowerStateMachine &u, + HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.publishPowerLevelType(h_app, epspltNORMAL); +} +// LCOV_EXCL_STOP 8: can not be NormalVoltageState + +PCSTR PowerStateMachine::SoftwareUpdate::name() { // LCOV_EXCL_START 8: can not be SoftwareUpdatestatus + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +return "Software Update"; +} +// LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus + +// LCOV_EXCL_START 8: no one send the event +void PowerStateMachine::SoftwareUpdate::onLowVoltage1Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&LowVoltage1State, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::SoftwareUpdate::onLowVoltage2Encountered( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +u.OnVoltage(&LowVoltage2State, h_app, oSession); +FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s", + FrameworkunifiedGetMsgSrc(h_app)); +} +// LCOV_EXCL_STOP 8: no one send the event + +// LCOV_EXCL_START 8: can not be SoftwareUpdatestatus +void PowerStateMachine::SoftwareUpdate::onShutdown( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::SoftwareUpdate::onEntry( +PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +} +// LCOV_EXCL_STOP 8: no one send the event to call this function + +// LCOV_EXCL_START 8: no one send the event to call this function +void PowerStateMachine::SoftwareUpdate::onExit(PowerStateMachine &u, + HANDLE h_app, + PowerSessionHandler & oSession) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +} +// LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus diff --git a/power_service/server/src/ss_pwr_test_client_handlers.cpp b/power_service/server/src/ss_pwr_test_client_handlers.cpp new file mode 100644 index 00000000..10e2f556 --- /dev/null +++ b/power_service/server/src/ss_pwr_test_client_handlers.cpp @@ -0,0 +1,204 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief This file supports the power service test client. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "ss_power.h" +#include +#include +#include +#include +#include +#include +#include "ss_power_powerservicelog.h" + +using namespace std; // NOLINT (build/namespaces) + +#define SS_CRANK_STATE_STRING_LENGTH 5 +#define SS_VOLTAGE_STATE_STRING_LENGTH 5 +#define SS_MODULE_STATE_STRING_LENGTH 5 +#define SS_HEX_BASE_VALUE 16 + +const CHAR ReeadyToWakeUpDescription[] = "_READY_TO_WAKEUP:"; +const CHAR WakeUpInitiatedDescription[] = "_WAKEUP_INITIATED:"; +const CHAR WakeUpCompletedDescription[] = "_WAKEUP_COMPLETED:"; +const CHAR PowerOnCompletedDescription[] = "_POWER_ON_COMPLETED:"; +const CHAR PowerOffInitiatedDescription[] = "_POWER_OFF_INITIATED:"; +const CHAR PowerOffCompletedDescription[] = "_POWER_OFF_COMPLETED:"; +const CHAR ShutdownInitiatedDescription[] = "_SHUTDOWN_INITIATED:"; +const CHAR ShutdownCompletedDescription[] = "_SHUTDOWN_COMPLETED:"; + +const CHAR CrankInvalidDescription[] = "_INVALID:"; +const CHAR CrankEntryDescription[] = "_ENTRY:"; +const CHAR CrankExitDescription[] = "_EXIT:"; + +const CHAR VoltageInvalidDescription[] = "_INVALID:"; +const CHAR VoltageNormalDescription[] = "_NORMAL:"; +const CHAR VoltageLVI1Description[] = "_LVI1:"; +const CHAR VoltageLVI2Description[] = "_LVI2:"; + +/////////////////////////////////////////////////////////////////////// +/// AddCrankInformationToResponse +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::AddCrankInformationToResponse(CHAR *f_MessageResponse) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + CHAR l_Buffer[SS_CRANK_STATE_STRING_LENGTH] = { 0 }; + UI_32 l_Index = 0; + + std::map CrankMap; + CrankMap[epscsINVALID] = CrankInvalidDescription; + CrankMap[epscsENTRY] = CrankEntryDescription; + CrankMap[epscsEXIT] = CrankExitDescription; + + // confirm that CrankState value would fit in buffer array + if (m_CrankState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code + itoa(m_CrankState, l_Buffer, SS_HEX_BASE_VALUE); + while (l_Buffer[l_Index]) { + l_Buffer[l_Index] = toupper(l_Buffer[l_Index]); + l_Index++; + } + } + + if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(CrankMap[m_CrankState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf) + strcat(f_MessageResponse, CrankMap[m_CrankState].c_str()); // NOLINT (runtime/printf) + } else { + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Buffer Overrun Condition : Failed to add Crank State description to response"); + l_eStatus = eFrameworkunifiedStatusFail; + } + + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +/////////////////////////////////////////////////////////////////////// +/// AddVoltageInformationToResponse +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::AddVoltageInformationToResponse(CHAR *f_MessageResponse) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + CHAR l_Buffer[SS_VOLTAGE_STATE_STRING_LENGTH] = { 0 }; + UI_32 l_Index = 0; + + std::map VoltageMap; + VoltageMap[epsvsINVALID] = VoltageInvalidDescription; + VoltageMap[epsvsNORMAL] = VoltageNormalDescription; + VoltageMap[epsvsLVI1] = VoltageLVI1Description; + VoltageMap[epsvsLVI2] = VoltageLVI2Description; + + // confirm that VoltageState value would fit in buffer array + if (m_VoltageState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code + itoa(m_VoltageState, l_Buffer, SS_HEX_BASE_VALUE); + while (l_Buffer[l_Index]) { + l_Buffer[l_Index] = toupper(l_Buffer[l_Index]); + l_Index++; + } + } + + if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(VoltageMap[m_VoltageState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf) + strcat(f_MessageResponse, VoltageMap[m_VoltageState].c_str()); // NOLINT (runtime/printf) + } else { + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Buffer Overrun Condition : Failed to add Voltage State description to response"); + l_eStatus = eFrameworkunifiedStatusFail; + } + + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +/////////////////////////////////////////////////////////////////////// +/// AddStateInformationToResponse +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::AddStateInformationToResponse(CHAR *f_MessageResponse) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + CHAR l_Buffer[SS_MODULE_STATE_STRING_LENGTH] = { 0 }; + UI_32 l_Index = 0; + + std::map StateMap; // State Map + StateMap[SS_PS_READY_TO_WAKEUP] = ReeadyToWakeUpDescription; + StateMap[SS_PS_WAKEUP_INITIATED] = WakeUpInitiatedDescription; + StateMap[SS_PS_WAKEUP_COMPLETE] = WakeUpCompletedDescription; + StateMap[SS_PS_POWER_ON_COMPLETE] = PowerOnCompletedDescription; + StateMap[SS_PS_POWER_OFF_INITIATED] = PowerOffInitiatedDescription; + StateMap[SS_PS_POWER_OFF_COMPLETE] = PowerOffCompletedDescription; + StateMap[SS_PS_SHUTDOWN_INITIATED] = ShutdownInitiatedDescription; + StateMap[SS_PS_SHUTDOWN_COMPLETE] = ShutdownCompletedDescription; + + // confirm that PowerState value would fit in buffer array + if (m_PowerState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code + itoa(m_PowerState, l_Buffer, SS_HEX_BASE_VALUE); + while (l_Buffer[l_Index]) { + l_Buffer[l_Index] = toupper(l_Buffer[l_Index]); + l_Index++; + } + } + + if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(StateMap[m_PowerState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf) + strcat(f_MessageResponse, StateMap[m_PowerState].c_str()); // NOLINT (runtime/printf) + } else { + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + "Buffer Overrun Condition : Failed to add Module State description to response"); + l_eStatus = eFrameworkunifiedStatusFail; + } + + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/////////////////////////////////////////////////////////////////////// +/// ConstructPwrStateResponse +/// +/// +////////////////////////////////////////////////////////////////////// +EFrameworkunifiedStatus Power::ConstructPwrStateResponse(CHAR *f_MessageResponse) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + + if (f_MessageResponse == NULL) { // LCOV_EXCL_BR_LINE 8: dead code + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return eFrameworkunifiedStatusFail; + } + + if (eFrameworkunifiedStatusOK == (l_eStatus = AddStateInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + if (eFrameworkunifiedStatusOK == (l_eStatus = AddVoltageInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + if (eFrameworkunifiedStatusOK == (l_eStatus = AddCrankInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length] + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response Constructed"); + } + } + } + + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} diff --git a/power_service/server/src/ss_supervisor_handlers.cpp b/power_service/server/src/ss_supervisor_handlers.cpp new file mode 100644 index 00000000..993d7a4c --- /dev/null +++ b/power_service/server/src/ss_supervisor_handlers.cpp @@ -0,0 +1,498 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief Handles SSM message for Wakeup State, Crank State, and Voltage +/// State. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "ss_power.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ss_power_powerservicelog.h" + + +EFrameworkunifiedStatus Power::OnPowerRequestMsg(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + // ToDo Jay 2012 December 05 Would like to provide better general overall + // solution then this local hack - but, for the time being... + std::map UserModeToPowerTypeMap; + UserModeToPowerTypeMap[epsumON] = epswsPWRON; + UserModeToPowerTypeMap[epsumOFF] = epswsPWROFF; + // End of ToDo Jay 2012 December 05 Would like to provide better general + + Pwr_ServiceSetInterface tServiceIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + BOOL b_isValid = FALSE; + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "StartupReason is '%s'", + GetStr(tServiceIf.data.powerRequestMsg.startupReason).c_str()); + + switch (tServiceIf.data.powerRequestMsg.startupReason) { + case epswfINVALID: + case epswfTESTACC: + case epswfUSER_DATA_RESET: + // Not startup conditions; don't log + b_isValid = TRUE; + break; + + case epswfON_KEY: + LOG_POWERSERVICELOG_EVT(epswfON_KEY, Ei_StartUp_HK_On, epseisuedHK_ON_Key); + b_isValid = TRUE; + break; + + case epswfIGN_ACC: + LOG_POWERSERVICELOG_EVT(epswfIGN_ACC, Ei_StartUp_Cansignal, epseisuedIGNITION); + LOG_POWERSERVICELOG_CNT(epswfIGN_ACC, CT_Startup_CanSignal); + b_isValid = TRUE; + break; + + case epswfDR_OPEN_CLOSE: + LOG_POWERSERVICELOG_EVT(epswfDR_OPEN_CLOSE, Ei_StartUp_Cansignal, + epseisuedDOOR_MODULES); + LOG_POWERSERVICELOG_CNT(epswfDR_OPEN_CLOSE, CT_Startup_CanSignal); + b_isValid = TRUE; + break; + + case epswfDX_ACTIVATION: + LOG_POWERSERVICELOG_EVT(epswfDX_ACTIVATION, Ei_StartUp_DiagMsg, epseisuedHU); + LOG_POWERSERVICELOG_CNT(epswfDX_ACTIVATION, CT_Startup_DiagMsg); + b_isValid = TRUE; + break; + + case epswfPASS_ACTIVATION: + LOG_POWERSERVICELOG_EVT(epswfPASS_ACTIVATION, Ei_StartUp_Cansignal, + epseisuedPASS); + LOG_POWERSERVICELOG_CNT(epswfPASS_ACTIVATION, CT_Startup_CanSignal); + b_isValid = TRUE; + break; + + case epswfSPVACTIVATION: + LOG_POWERSERVICELOG_EVT(epswfSPVACTIVATION, Ei_StartUp_Cansignal, epseisuedSNA); + LOG_POWERSERVICELOG_CNT(epswfSPVACTIVATION, CT_Startup_CanSignal); + b_isValid = TRUE; + break; + + // default: Don't code a 'default' here - let the compiler + // issue a warning ( set via -Wall or -Wswitch ) when the set of + // enumerations changes - then the maintainer will + // automagically know to update this switch statement. + } // End switch(tServiceIf.data.powerRequestMsg.startupReason) + + if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_START 11:unexpected branch + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_eStatus = eFrameworkunifiedStatusInvldParam; + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, __FUNCTION__, + " Error: Unknown 'powerRequestMsg.startupReason' value: " "0x%X / %d", + tServiceIf.data.powerRequestMsg.startupReason, + tServiceIf.data.powerRequestMsg.startupReason); + // LCOV_EXCL_STOP 11:unexpected branch + } else { + m_WakeUpData.powerupType = UserModeToPowerTypeMap[tServiceIf.data + .powerRequestMsg.userMode]; + m_WakeUpData.up.factor = tServiceIf.data.powerRequestMsg.startupReason; + m_WakeUpData.up.level = epswlFULLRUN; + m_WakeUpData.up.userModeChangeReason = tServiceIf.data.powerRequestMsg.userModeChangeReason; + + l_eStatus = FrameworkunifiedSendMsg(GetSystemManagerSessionHandle(), + SS_SM_POWER_REQUEST_MSG, sizeof(tServiceIf), + &tServiceIf); + char l_cBuf[200]; + snprintf( + l_cBuf, sizeof(l_cBuf), + "FrameworkunifiedSendMsg( SS_SM_POWER_REQUEST_MSG, %s, %s)", + GetStr(tServiceIf.data.powerRequestMsg.userMode).c_str(), + GetStr(tServiceIf.data.powerRequestMsg.userModeChangeReason).c_str()); + LOG_STATUS(l_eStatus, l_cBuf); + } + } // End else a good ReadMsg() + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnpowerRequestMsg( HANDLE h_app ) + +EFrameworkunifiedStatus Power::OnShutdownRequestMsg(HANDLE h_app) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + Pwr_ServiceSetInterface tServiceIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + BOOL b_isValid = FALSE; + EPWR_SHUTDOWN_TRIGGER_TYPE l_shutdownTrigger = tServiceIf.data + .shutdownRequestMsg.shutdownTrigger; + switch (l_shutdownTrigger) { + case epssdmsdtINVALID: + case epssdmsdtTESTACC_OFF: + // Not shutdown conditions; don't log + b_isValid = TRUE; + break; + + case epssdmsdtON_KEY: + LOG_POWERSERVICELOG_EVT(epssdmsdtON_KEY, Ei_shutdown_HkOFF, 0x00); + b_isValid = TRUE; + break; + + case epssdmsdtIGN_LOCK: + LOG_POWERSERVICELOG_EVT(epssdmsdtIGN_LOCK, Ei_shutdown_CANsignal, + epseisdcsIGN_STATE); + LOG_POWERSERVICELOG_CNT(epssdmsdtIGN_LOCK, CT_Shutdown_CanSignal); + b_isValid = TRUE; + break; + + case epssdmsdtPWR_SAVE: // test from peripheralservice/power_supply_manager_shadow + LOG_POWERSERVICELOG_CNT(epssdmsdtPWR_SAVE, CT_Shutdown_Timeout); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtTMP_STARTUP: + LOG_POWERSERVICELOG_CNT(epssdmsdtTMP_STARTUP, CT_Shutdown_Timeout); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtDIAG_DEACTIVATION: + LOG_POWERSERVICELOG_CNT(epssdmsdtDIAG_DEACTIVATION, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtABNORMAL_VOLTAGE: + LOG_POWERSERVICELOG_EVT(epssdmsdtABNORMAL_VOLTAGE, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + epseisdnvoltUNKNOWN); + LOG_POWERSERVICELOG_CNT(epssdmsdtABNORMAL_VOLTAGE, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtABNORMAL_TEMP: + LOG_POWERSERVICELOG_EVT(epssdmsdtABNORMAL_TEMP, Ei_shutdown_Temperature, 0x00); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + LOG_POWERSERVICELOG_CNT(epssdmsdtABNORMAL_TEMP, CT_Shutdown_Temperature); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtBATTERYCUTOFF: + LOG_POWERSERVICELOG_EVT(epssdmsdtBATTERYCUTOFF, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + epseisdnvoltBATTERY_CUT_OFF); + LOG_POWERSERVICELOG_CNT(epssdmsdtBATTERYCUTOFF, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtLIMPHOME: + LOG_POWERSERVICELOG_EVT(epssdmsdtLIMPHOME, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + epseisdnvoltLIMP_HOME); + LOG_POWERSERVICELOG_CNT(epssdmsdtLIMPHOME, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtHU_CAN_ERROR: + LOG_POWERSERVICELOG_EVT(epssdmsdtHU_CAN_ERROR, Ei_shutdown_NetworkError, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + epseisdneHU_CAN); + LOG_POWERSERVICELOG_CNT(epssdmsdtHU_CAN_ERROR, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtBODY_CAN_ERROR: + LOG_POWERSERVICELOG_EVT(epssdmsdtBODY_CAN_ERROR, Ei_shutdown_NetworkError, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + epseisdneHMI_CAN); + LOG_POWERSERVICELOG_CNT(epssdmsdtBODY_CAN_ERROR, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtTRANSPORT_MODE: + LOG_POWERSERVICELOG_CNT(epssdmsdtTRANSPORT_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtPRODUCTION_MODE: + LOG_POWERSERVICELOG_CNT(epssdmsdtPRODUCTION_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtIGN_OFF: + LOG_POWERSERVICELOG_CNT(epssdmsdtIGN_OFF, CT_Shutdown_CanSignal); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtGENERIC_ERROR_RESET: + LOG_POWERSERVICELOG_CNT(epssdmsdtGENERIC_ERROR_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtFATAL_ERROR_RESET: + LOG_POWERSERVICELOG_CNT(epssdmsdtFATAL_ERROR_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtUSER_DATA_RESET: + LOG_POWERSERVICELOG_CNT(epssdmsdtUSER_DATA_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtFACTORY_DATA_RESET: + LOG_POWERSERVICELOG_CNT(epssdmsdtFACTORY_DATA_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtFAST_SLEEP_MODE: + LOG_POWERSERVICELOG_CNT(epssdmsdtFAST_SLEEP_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtNORMAL_RESET: + LOG_POWERSERVICELOG_CNT(epssdmsdtNORMAL_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + + case epssdmsdtPROGUPDATE_RESET: // this is dead code + LOG_POWERSERVICELOG_CNT(epssdmsdtPROGUPDATE_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length] + b_isValid = TRUE; + break; + // default: Don't code a 'default' here - let the compiler + // issue a warning ( set via -Wall or -Wswitch ) when the set of + // enumerations changes - then the maintainer will + // automagically know to update this switch statement. + } // End switch(l_shutdownTrigger) + if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_START 11:unexpected branch + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + l_eStatus = eFrameworkunifiedStatusInvldParam; + FRAMEWORKUNIFIEDLOG( + ZONE_ERR, + __FUNCTION__, + " Error: Unknown 'shutdownRequestMsg.shutdownTrigger' " "value: 0x%X/%d", + l_shutdownTrigger, l_shutdownTrigger); + // LCOV_EXCL_STOP 11:unexpected branch + } else { + l_eStatus = SendShutdownToSystemManager(&tServiceIf); + LOG_STATUS(l_eStatus, "SendShutdownToSystemManager()"); + if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + SetPowerServiceState(SS_PS_SHUTDOWN_INITIATED); + } + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnShutdownRequestMsg( HANDLE h_app ) + +//***************************************************************************** +// Shutdown Condition Notification Protocol function +// +EFrameworkunifiedStatus Power::OnPublishShutdownPopupRequest(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + Pwr_ServiceSetInterface tServiceIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + BOOL b_isValid = FALSE; + EPWR_SHUTDOWN_POPUP_TYPE l_eShutdownPopup = tServiceIf.data.shutdownPopup + .shutdownPopupEvent; + switch (l_eShutdownPopup) { + case epsspPowerSave1: + case epsspPowerSave2: + case epsspPowerSave3: + case epsspPowerSaveClr: + case epsspLowVoltage1: + case epsspLowVoltage2: + case epsspLowVoltage3: + case epsspLowVoltageClr: + case epsspBattCouplingSW1: + case epsspBattCouplingSW2: + case epsspBattCouplingSW3: + case epsspBattCouplingSWClr: + case epsspAbnormalTemp_1st: + case epsspAbnormalTemp_Clr: + case epsspLimpHome_1st: + case epsspLimpHome_2nd: + case epsspLimpHome_3rd: + case epsspLimpHome_Clr: + case epsspProdMd_1st: + case epsspProdMd_Clr: + case epsspTransMd_1st: + case epsspTransMd_Clr: + case epsspAllClr: + l_eStatus = FrameworkunifiedNPPublishNotification(h_app + , szNTFY_ShutdownPopup + , &l_eShutdownPopup + , sizeof(EPWR_SHUTDOWN_POPUP_TYPE)); + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: FrameworkunifiedNPPublishNotification(%s, %d) errored: %d/'%s'", + szNTFY_ShutdownPopup, l_eShutdownPopup, l_eStatus, + GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP 4: NSFW error case. + } + + SS_PWR_LOG_HIST("szNTFY_ShutdownPopup()", m_PubCmdHist, m_PubHistIter, + "", l_eStatus); + + b_isValid = TRUE; + break; + + // default: Don't code a 'default' here - let the compiler + // issue a warning ( set via -Wall or -Wswitch ) when the set of + // enumerations changes - then the maintainer will + // automagically know to update this switch statement. + } // End switch + + if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_START 11:unexpected branch + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: Unknown 'l_eShutdownPopup' value: 0x%X / %d", + l_eShutdownPopup, l_eShutdownPopup); + l_eStatus = eFrameworkunifiedStatusInvldParam; + // LCOV_EXCL_STOP 11:unexpected branch + } else { + EFrameworkunifiedStatus l_responseStatus = l_eStatus; // Save the current status as-is to + // send in the message response to the + // requester. + l_eStatus = FrameworkunifiedSendResponse(h_app, + SS_POWER_PUBLISH_SHUTDOWN_CONDITION_RESP, + sizeof(EFrameworkunifiedStatus), + (PVOID) &l_responseStatus); + + char l_cBuf[200]; + snprintf(l_cBuf, sizeof(l_cBuf), + "FrameworkunifiedSendResponse(%s, %s, status: %d/'%s')", FrameworkunifiedGetMsgSrc(h_app), + "SS_POWER_PUBLISH_SHUTDOWN_CONDITION_RESP", l_responseStatus, + GetStr(l_responseStatus).c_str()); + LOG_STATUS(l_eStatus, l_cBuf); + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnPublishShutdownPopupRequest( HANDLE h_app ) +// +// End of Shutdown Condition Notification Protocol function +//***************************************************************************** + +//***************************************************************************** +// Power Popup Notification Protocol function +// +EFrameworkunifiedStatus Power::OnPublishPowerPopupRequest(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + Pwr_ServiceSetInterface tServiceIf; + + // ReadMsg(): * + // Check h_app ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length] + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + BOOL b_isValid = FALSE; + EPWR_POWER_POPUP_TYPE l_ePowerPopup = tServiceIf.data.powerPopup + .powerPopupEvent; + switch (l_ePowerPopup) { + case epssppNormal: + case epssppCritical: + case epssppAppCritical: + case epssppAllClr: + l_eStatus = FrameworkunifiedNPPublishNotification(h_app + , szNTFY_PowerPopup + , &l_ePowerPopup + , sizeof(EPWR_POWER_POPUP_TYPE)); + if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: FrameworkunifiedNPPublishNotification(%s, %d) errored: %d/'%s'", + szNTFY_PowerPopup, l_ePowerPopup, l_eStatus, + GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP 4: NSFW error case. + } + + SS_PWR_LOG_HIST("OnPublishPowerPopupRequest()", m_PubCmdHist, + m_PubHistIter, "", l_eStatus); + + b_isValid = TRUE; + break; + + // default: Don't code a 'default' here - let the compiler + // issue a warning ( set via -Wall or -Wswitch ) when the set of + // enumerations changes - then the maintainer will + // automagically know to update this switch statement. + } // End switch + + if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_START 11:unexpected branch + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: Unknown 'l_ePowerPopup' value: 0x%X/%d", l_ePowerPopup, + l_ePowerPopup); + l_eStatus = eFrameworkunifiedStatusInvldParam; + // LCOV_EXCL_STOP 11:unexpected branch + } else { + EFrameworkunifiedStatus l_responseStatus = l_eStatus; // Save the current status as-is to + // send in the message response to the + // requester. + l_eStatus = FrameworkunifiedSendResponse(h_app, SS_POWER_PUBLISH_POWER_POPUP_RESP, + sizeof(EFrameworkunifiedStatus), + (PVOID) &l_responseStatus); + char l_cBuf[200]; + snprintf(l_cBuf, sizeof(l_cBuf), + "FrameworkunifiedSendResponse(%s, %s, status: %d/'%s')", FrameworkunifiedGetMsgSrc(h_app), + "SS_POWER_PUBLISH_POWER_POPUP_RESP", l_responseStatus, + GetStr(l_responseStatus).c_str()); + LOG_STATUS(l_eStatus, l_cBuf); + } + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} // End of EFrameworkunifiedStatus Power::OnPublishPowerPopupRequest( HANDLE h_app ) +// +// End of Power Popup Notification Protocol function +//***************************************************************************** + +// EOF of /SS_PowerService/src/ss_supervisor_handlers.cpp diff --git a/power_service/server/src/ss_system_handlers.cpp b/power_service/server/src/ss_system_handlers.cpp new file mode 100644 index 00000000..10e8ee50 --- /dev/null +++ b/power_service/server/src/ss_system_handlers.cpp @@ -0,0 +1,52 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_PowerService +/// \brief Handles Power Service Business logic +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "ss_power.h" +#include +#include +#include +#include "ss_power_powerservicelog.h" + +EFrameworkunifiedStatus Power::OnSystemLaunchComplete(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Power Service received SS_POWER_SYSTEM_LAUNCH_COMPLETE from: %s", + FrameworkunifiedGetMsgSrc(h_app)); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return EFrameworkunifiedStatus: 0x%X", eStatus); + return eStatus; +} + +// test from peripheralservice/power_supply_manager_shadow +EFrameworkunifiedStatus Power::OnSystemShutdownComplete(HANDLE h_app) { + FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + "Power Service received SS_POWER_SYSTEM_SHUTDOWN_COMPLETE from: %s", + FrameworkunifiedGetMsgSrc(h_app)); + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return EFrameworkunifiedStatus: 0x%X", eStatus); + return eStatus; +} -- cgit 1.2.3-korg