summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:41:01 +0900
committerToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:41:01 +0900
commita0b81882b4a9b7761e2dbfdda37b7559714c416c (patch)
treee7b3d7cac27c90527a640b7c915fbadaf2489692
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
ss-powerservice branch
-rw-r--r--power_service/LICENSE177
-rw-r--r--power_service/Makefile.server19
-rw-r--r--power_service/server/Makefile51
-rw-r--r--power_service/server/include/ss_power.h318
-rw-r--r--power_service/server/include/ss_power_config.h147
-rw-r--r--power_service/server/include/ss_power_powerservicelog.h85
-rw-r--r--power_service/server/include/ss_power_session.h70
-rw-r--r--power_service/server/include/ss_power_state_hysteresis.h74
-rw-r--r--power_service/server/include/ss_power_state_machine.h414
-rw-r--r--power_service/server/src/powerservice_application.cpp236
-rw-r--r--power_service/server/src/powerservice_main.cpp70
-rw-r--r--power_service/server/src/ss_power.cpp1672
-rw-r--r--power_service/server/src/ss_power_config.cpp188
-rw-r--r--power_service/server/src/ss_power_session.cpp276
-rw-r--r--power_service/server/src/ss_power_state_machine.cpp924
-rw-r--r--power_service/server/src/ss_pwr_test_client_handlers.cpp204
-rw-r--r--power_service/server/src/ss_supervisor_handlers.cpp498
-rw-r--r--power_service/server/src/ss_system_handlers.cpp52
-rw-r--r--system_service.mk44
19 files changed, 5519 insertions, 0 deletions
diff --git a/power_service/LICENSE b/power_service/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/power_service/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/power_service/Makefile.server b/power_service/Makefile.server
new file mode 100644
index 00000000..c956695d
--- /dev/null
+++ b/power_service/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS = server
+
+include ../system_service.mk
diff --git a/power_service/server/Makefile b/power_service/server/Makefile
new file mode 100644
index 00000000..bc59b540
--- /dev/null
+++ b/power_service/server/Makefile
@@ -0,0 +1,51 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = SS_PowerService
+
+
+######### compiled sources #############
+SS_PowerService_SRCS += ./src/powerservice_application.cpp
+SS_PowerService_SRCS += ./src/powerservice_main.cpp
+SS_PowerService_SRCS += ./src/ss_power.cpp
+SS_PowerService_SRCS += ./src/ss_power_config.cpp
+SS_PowerService_SRCS += ./src/ss_power_session.cpp
+SS_PowerService_SRCS += ./src/ss_power_state_machine.cpp
+SS_PowerService_SRCS += ./src/ss_pwr_test_client_handlers.cpp
+SS_PowerService_SRCS += ./src/ss_supervisor_handlers.cpp
+SS_PowerService_SRCS += ./src/ss_system_handlers.cpp
+
+
+######### add include path #############
+CPPFLAGS += -I./include
+
+
+######### add compile option #############
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x09 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,13,9,8,3 ## open log-tag
+CPPFLAGS += -DTARGET_SOC_$(TARGET_SOC)
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+
+######### add library path #############
+LDFLAGS += -g -Wl,--gc-sections
+
+include ../../system_service.mk
diff --git a/power_service/server/include/ss_power.h b/power_service/server/include/ss_power.h
new file mode 100644
index 00000000..0cec9c0f
--- /dev/null
+++ b/power_service/server/include/ss_power.h
@@ -0,0 +1,318 @@
+/*
+ * @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
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
+
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_templates.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <vector>
+#include <string>
+#include <exception>
+
+#include "ss_power_session.h"
+#include "ss_power_config.h"
+#include "ss_power_state_machine.h"
+#include "ss_power_powerservicelog.h"
+
+typedef enum _SS_PSState {
+ SS_PS_READY_TO_WAKEUP = 0x01,
+ SS_PS_WAKEUP_INITIATED,
+ SS_PS_WAKEUP_COMPLETE,
+ SS_PS_POWER_ON_COMPLETE,
+ SS_PS_POWER_OFF_INITIATED,
+ SS_PS_POWER_OFF_COMPLETE,
+ SS_PS_SHUTDOWN_INITIATED,
+ SS_PS_SHUTDOWN_COMPLETE
+ // This is not real state, used only to know total states
+ ,
+ SS_PS_STATE_MAX
+} SS_PSState;
+
+typedef struct {
+ std::string m_cmd;
+ UI_64 m_time;
+ std::string m_sender;
+} Ts_cmdHist;
+
+typedef std::vector<Ts_cmdHist> cmdHist;
+typedef cmdHist::iterator cmdHistIter;
+
+class Power {
+ public:
+ Power();
+ virtual ~Power();
+ EFrameworkunifiedStatus Initialize(HANDLE h_app);
+ static Power & GetInstance();
+
+ /// Session Request Handlers
+ EFrameworkunifiedStatus OnOpenSession(HANDLE h_app);
+ EFrameworkunifiedStatus OnCloseSession(HANDLE h_app);
+
+ /// Session Response\Ack Handlers
+ EFrameworkunifiedStatus OnWakeUpComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnPrintConnections(HANDLE h_app);
+ EFrameworkunifiedStatus OnPrintStack(HANDLE h_app);
+
+ /// SSM Handlers
+
+ /// Supervisor Handlers
+ EFrameworkunifiedStatus OnPowerRequestMsg(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetPowerState(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCommWakeUp(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCommSleep(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownRequestMsg(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE h_app);
+ EFrameworkunifiedStatus OnStartModules(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownModules(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnHysteresisTimeout(HANDLE h_app);
+
+ // System Handlers
+ EFrameworkunifiedStatus OnSystemLaunchComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnSystemShutdownComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnWakeUpTimeout(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownTimeout(HANDLE h_app);
+
+ // Get Result query from power test client
+ EFrameworkunifiedStatus OnCurrentPowerStateQuery(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSetVoltageState(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCrankState(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSystemModeInfoRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSystemModeInfoResponse(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnInitCompReport(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSystemMgrConnectionEstablished(HANDLE h_app);
+
+ //
+ // Start Confirmation callback functions
+ //
+ EFrameworkunifiedStatus OnSendStartupConfirmationRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSendStartupConfirmationResponse(HANDLE h_app);
+
+ //
+ // User Mode Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnUserModeResponse(HANDLE h_app);
+
+ //
+ // Shutdown Condition Notification Protocol function
+ //
+ EFrameworkunifiedStatus OnPublishShutdownPopupRequest(HANDLE h_app);
+
+ //
+ // Power Popup Notification Protocol function
+ //
+ EFrameworkunifiedStatus OnPublishPowerPopupRequest(HANDLE h_app);
+
+ //
+ // HeartBeat Protocol callback functions
+ //
+ EFrameworkunifiedStatus On_CWORD56_HeartBeatRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSM_CWORD56_HeartBeatResponse(HANDLE h_app);
+
+ //
+ // Hard Reset Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnCpuResetRequest(HANDLE h_app);
+
+ //
+ // Remote Data Reset Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnRemoteDataResetRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnRemoteDataResetResponse(HANDLE h_app);
+
+ cmdHist m__CWORD56_RepHist;
+ cmdHistIter m__CWORD56_RepIter;
+ cmdHist m_PubCmdHist;
+ cmdHistIter m_PubHistIter;
+ cmdHist m_ErrHist;
+ cmdHistIter m_ErrHistIter;
+ cmdHist m_VCmdHist;
+ cmdHistIter m_VHistIter;
+
+ void SSPowerDebugDump(HANDLE h_app);
+
+ private:
+#define LOG_POWERSERVICELOG_CNT(caseid, Cnt) \
+ FRAMEWORKUNIFIEDLOG_CNT(ZONE_INFO, Cnt, 0); \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " case " #caseid \
+ ": FRAMEWORKUNIFIEDLOG_CNT(ZONE_INFO, " #Cnt ", 0)");
+
+#define LOG_POWERSERVICELOG_EVT(caseid, Evt, Data0) \
+ FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, Evt, 1, Data0); \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " case " #caseid \
+ ": FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, " #Evt ", " #Data0 ")");
+
+#define LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(l_eStatus, pStr) \
+ if (eFrameworkunifiedStatusOK != l_eStatus) { \
+ LOG_ERROR(pStr); \
+ SetCmdHist(pStr, m_ErrHist, m_ErrHistIter, GetStr(static_cast<EFrameworkunifiedStatus>(l_eStatus)).c_str()); \
+ } // End of #define LOG_STATUS_IF_ERRORED(l_eStatus,pStr)
+
+#define SS_PWR_LOG_HIST(cmd, hist, it, sender, l_eStatus) \
+ if (eFrameworkunifiedStatusOK == l_eStatus) { \
+ SetCmdHist((static_cast< std::string> (cmd)), (static_cast<cmdHist&> (hist)), \
+ (static_cast<cmdHistIter&> (it)), (static_cast< std::string> (sender))); \
+ }
+ //**************************************************************************
+ // Counter Logging enums & typedefs *
+ // *
+ // Counter Event IDs *
+ typedef enum { // *
+ CT_Startup_CanSignal = 0x0114, // *
+ CT_Startup_DiagMsg = 0x0118, // *
+ // *
+ CT_Shutdown_CanSignal = 0x0121, // *
+ CT_Shutdown_Timeout = 0x0124, // *
+ CT_Shutdown_Temperature = 0x0125, // *
+ CT_Shutdown_Error = 0x0126, // *
+ CT_Shutdown_Voltage = 0x0127 // *
+ } EPWR_COUNTER_EVENT_ID_TYPE; // *
+ // *
+ // End of Counter Logging enums & typedefs *
+ //**************************************************************************
+
+ //**************************************************************************
+ // Event Logging enums & typedefs *
+ // *
+ // Event ID *
+ typedef enum { // *
+ // Startup Event IDs *
+ Ei_StartUp_Cansignal = 0x0101, // *
+ Ei_StartUp_HK_On = 0x0102, // *
+ // 0x0103 not specified // *
+ // 0x0104 not specified // *
+ // 0x0105 System Svcs not responsible// *
+ // 0x0106 not specified // *
+ Ei_StartUp_ActivationLine = 0x0107, // *
+ Ei_StartUp_DiagMsg = 0x0108, // *
+ // *
+ // Shutdown Event IDs *
+ Ei_shutdown_CANsignal = 0x0201, // *
+ Ei_shutdown_HkOFF = 0x0202, // *
+ // 0x0203 not specified // *
+ // 0x0204 not specified // *
+ Ei_shutdown_Temperature = 0x0205, // *
+ Ei_shutdown_NetworkError = 0x0206, // *
+ Ei_shutdown_Voltage = 0x0207 // *
+ } EPWR_LOGGING_EVENT_ID_TYPE; // *
+ // *
+ // Ei_StartUp_CanSignal byte0 Event Detail *
+ typedef enum { // *
+ epseisuedIGNITION = 0x00, // *
+ epseisuedHK_ON = 0x01, // *
+ epseisuedDOOR_MODULES = 0x02, // *
+ // 0x03 not specified // *
+ // 0x04 not specified // *
+ epseisuedPASS = 0x05, // *
+ epseisuedIHTM = 0x06, // *
+ epseisuedMPM = 0x07, // *
+ epseisuedSNA = 0xFF // *
+ } EPWR_LOGGING_EVT_DETAIL_SU_CAN_TYPE; // *
+
+ //
+ // Ei_StartUp_HkOn
+ typedef enum {
+ epseisuedHK_ON_Key = 0x00
+ } EPWR_LOGGING_EVT_DETAIL_SU_KEY_TYPE;
+
+ //
+ // Ei_StartUp_ActivationLine
+ typedef enum {
+ epseisuedACV_LINE = 0x00
+ } EPWR_LOGGING_EVT_DETAIL_SU_LINE_TYPE;
+
+ // *
+ // Ei_StartUp_DiagMsg byte0 Event Detail *
+ typedef enum { // *
+ epseisuedHU = 0x01, // *
+ epseisuedCAN = 0x02, // *
+ } EPWR_LOGGING_EVT_DETAIL_SU_DIAG_TYPE; // *
+ // *
+ // Ei_ShutDown_CanSignal byte0 Event Detail *
+ typedef enum { // *
+ epseisdcsIGN_STATE = 0x00, // *
+ epseisdcsHK_ON = 0x01 // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_CAN_TYPE; // *
+ // *
+ // Ei_ShutDown_Temperature byte0 Event Detail *
+ typedef enum { // *
+ epseisdtempECU_LOW = 0x00, // *
+ epseisdtempECU_HIGH = 0x01, // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_TEMP_TYPE; // *
+ // *
+ // Ei_ShutDown_NetworkError byte0 Event Detail *
+ typedef enum { // *
+ epseisdneHMI_CAN = 0x00, // *
+ epseisdneHU_CAN = 0x01 // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_NETWORK_ERROR_TYPE; // *
+ // *
+ // Ei_ShutDown_Voltage byte0 Event Detail *
+ typedef enum { // *
+ epseisdnvoltBATTERY_CUT_OFF = 0x00, // *
+ epseisdnvoltLIMP_HOME = 0x01, // *
+ epseisdnvoltUNKNOWN = 0xFF // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_VOLTAGE_TYPE; // *
+ // *
+ // End of Event Logging enums & typedefs *
+ //**************************************************************************
+
+ PowerSessionHandler m_oSessionHandler;
+ PowerConfigParams m_tConfigData;
+ PowerStateMachine m_oStateMachine;
+ UI_32 m_aTimerIDs[15];
+ wakeInfo m_WakeUpData; /// WakeUp data received from SPM
+ SS_PSState m_PowerState;
+ ePowerSrvVoltageStates m_VoltageState;
+ ePowerSrvCrankStates m_CrankState;
+ UI_32 m_MaxShutdownTimeout;
+ std::map<SS_PSState, std::string> m_PPStateStrMap;
+
+ // Notify Module on Voltage change detected.
+ EFrameworkunifiedStatus PublishVoltageStateChange(HANDLE h_app);
+ EFrameworkunifiedStatus ConstructPwrStateResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddStateInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddVoltageInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddCrankInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus RegisterAllCallbacksAndNofitications(HANDLE h_app);
+ VOID SetPowerServiceState(SS_PSState f_NewState);
+ EFrameworkunifiedStatus ValidateUserModeMessage(HANDLE h_app,
+ EPWR_USER_MODE_TYPE &l_eUserModeState); // NOLINT (runtime/references)
+
+ pthread_mutex_t pwr_hist_mutex;
+
+ void SetCmdHist(std::string cmd,
+ cmdHist &hist, // NOLINT (runtime/references)
+ cmdHistIter &it, // NOLINT (runtime/references)
+ std::string sender);
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
diff --git a/power_service/server/include/ss_power_config.h b/power_service/server/include/ss_power_config.h
new file mode 100644
index 00000000..d73a41b4
--- /dev/null
+++ b/power_service/server/include/ss_power_config.h
@@ -0,0 +1,147 @@
+/*
+ * @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.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
+
+
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_config_parser_if.h>
+#include <list>
+#include <string>
+#include "ss_power_powerservicelog.h"
+
+typedef std::list<SS_String> RequiredModuleList;
+typedef RequiredModuleList::iterator RequiredModuleListIter;
+
+#define SS_PWR__CWORD56__REP_HIST_SIZE (10u)
+#define SS_PWR_PUB_CMD_HIST_SIZE (5u)
+#define SS_PWR_ERR_HIST_SIZE (5u)
+#define SS_PWR_V_HIST_SIZE (10u)
+#define SS_PWR_DEBUG_DUMP_MAX_SIZE (4096u)
+
+typedef struct _PowerConfigParams { // NOLINT (readability/naming) // LCOV_EXCL_BR_LINE 14:it will be called when poweron
+ typedef struct {
+ SI_32 timeout;
+ struct {
+ BOOL enabled;
+ SI_32 timeout;
+ SI_32 tries;
+ } hysteresis;
+ } PowerOffInfo;
+
+ SS_String power_logic_plugin;
+ PowerOffInfo lvi1;
+ PowerOffInfo lvi2;
+ PowerOffInfo shutdown;
+ RequiredModuleList wakeup_modules;
+ RequiredModuleList shutdown_modules;
+ RequiredModuleList lvi2_modules;
+} PowerConfigParams;
+
+class PowerConfiguration {
+ public:
+ // define all the configuration parmeters that will be used to get data
+ static const char * kPowerLogicPlugin;
+ static const char * kLVI1Timeout;
+ static const char * kLVI1HysteresisTimeout;
+ static const char * kLVI1HysteresisEnabled;
+ static const char * kLVI1HysteresisTries;
+ static const char * kLVI2Timeout;
+ static const char * kLVI2HysteresisTimeout;
+ static const char * kLVI2HysteresisEnabled;
+ static const char * kLVI2HysteresisTries;
+ static const char * kShutdownTimeout;
+ static const char * kShutdownHysteresisTimeout;
+ static const char * kShutdownHysteresisEnabled;
+ static const char * kShutdownHysteresisTries;
+
+ /// < defines the names in the xml file that are used to get required modules names
+ static const char * kRequiredWakeupModules; /// < once all the modules have been wakened up send wake-up complete
+ static const char * kRequiredShutdownModules; /// < once all the modules have been shutdown send shutdown complete
+ static const char * kRequiredLvi2Modules; /// < once all the modules have been wakened up send wake-up complete
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PowerConfiguration
+ /// \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
+ /// connection is to be disconnected or to be paused or to be played simultaneously.
+ ///
+ /// \param [in] f_configFileName Configuration file name.
+ ///
+ /// \return NA
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ explicit PowerConfiguration(std::string f_configfilename);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~PowerConfiguration
+ /// \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
+ /// connection is to be disconnected or to be paused or to be played simultaneously.
+ ///
+ /// \param [in] pRequestingSrc
+ /// Source* - Pointer to the requesting source.
+ ///
+ /// \return bool
+ /// bool - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~PowerConfiguration();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadParameters
+ /// \brief Load module parameters from configuration file.
+ ///
+ /// \param [in] params - Ref to variable which to store the loaded module parameters.
+ ///
+ /// \return bool
+ /// bool - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL LoadParameters(PowerConfigParams & params); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadDefaultParameters
+ /// \brief Laod default power services parameters.
+ ///
+ /// \param [in] params - Ref to variable for which to store the default module parameters.
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void LoadDefaultParameters(PowerConfigParams & params); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintConfigInfo
+ /// \brief Print configuration information.
+ ///
+ /// \param [in] params - Ref to variable containing the configuration parameters to load.params
+ ///
+ /// \return none.
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void PrintConfigInfo(PowerConfigParams & f_params); // NOLINT (runtime/references)
+
+ protected:
+ PowerConfiguration(const PowerConfiguration &);
+ PowerConfiguration & operator =(const PowerConfiguration &); // NOLINT (runtime/references)
+
+ private:
+ std::string m_ConfigFileName;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
diff --git a/power_service/server/include/ss_power_powerservicelog.h b/power_service/server/include/ss_power_powerservicelog.h
new file mode 100644
index 00000000..0269d9a5
--- /dev/null
+++ b/power_service/server/include/ss_power_powerservicelog.h
@@ -0,0 +1,85 @@
+/*
+ * @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 002 application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_FUNC_IPC ZONEMASK(13)
+#define ZONE_POWER_MONITOR ZONEMASK(14)
+#define ZONE_POWER_STATEMACHINE ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_INFO_IPC ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 "Ipc Function"
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 "Power StateMachine"
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 "Ipc Info"
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR //, ZONE_INFO,ZONE_POWER_STATEMACHINE, ZONE_DEBUG_DUMP, ZONE_FUNC
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[]; // NOLINT (readability/naming)
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
diff --git a/power_service/server/include/ss_power_session.h b/power_service/server/include/ss_power_session.h
new file mode 100644
index 00000000..ae9788f9
--- /dev/null
+++ b/power_service/server/include/ss_power_session.h
@@ -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 This file supports power service session management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
+
+#include <system_service/ss_power_service.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <string>
+#include "ss_power_config.h"
+
+typedef std::string SubscriberName; // The name of the module that is trying to open a session with Power
+
+/*
+ *
+ */
+class PowerSessionHandler {
+ public:
+ PowerSessionHandler();
+ virtual ~PowerSessionHandler();
+ EFrameworkunifiedStatus OpenSesion(HANDLE h_app);
+ EFrameworkunifiedStatus CloseSession(HANDLE h_app);
+ EFrameworkunifiedStatus StartComplete(HANDLE h_app);
+ EFrameworkunifiedStatus StopComplete(HANDLE h_app);
+
+ VOID Print();
+
+ // Methods that do the heavy lifting
+ BOOL WakeupComplete(RequiredModuleList & wakeup_modules); // NOLINT (runtime/references)
+ BOOL ShutdownComplete(RequiredModuleList & shutdown_modules); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus SendToSupervisor(UI_32 cmd, UI_32 length, PVOID data);
+ BOOL AllClientsInGroupStarted(UI_32 f_ungrpid);
+ BOOL ClientPresent(PCSTR f_sclientname);
+
+ private:
+ struct PwSessionInfo {
+ std::string sz_name;
+ std::string sz_servicename;
+ HANDLE hsession;
+ BOOL frunning;
+ EPWR_SESSION_TYPE esessiontype;
+ UI_32 ui_groupid;
+ };
+
+ typedef std::map<SubscriberName, PwSessionInfo> PwSessionMap;
+ typedef PwSessionMap::iterator PwSessionIter;
+
+ PwSessionMap m_mapSessions;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
diff --git a/power_service/server/include/ss_power_state_hysteresis.h b/power_service/server/include/ss_power_state_hysteresis.h
new file mode 100644
index 00000000..8220789c
--- /dev/null
+++ b/power_service/server/include/ss_power_state_hysteresis.h
@@ -0,0 +1,74 @@
+/*
+ * @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 hysteresis management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
+
+#include "ss_power_config.h"
+
+class PowerStateHysteresis {
+ public:
+ PowerStateHysteresis()
+ : m_unTries(0) {
+ bzero(&m_tHysteresisInfo, sizeof(m_tHysteresisInfo));
+ }
+
+ virtual ~PowerStateHysteresis() { // LCOV_EXCL_START 14: do it when power off
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_unTries = 0;
+ }
+ // LCOV_EXCL_STOP 14: do it when power off
+ explicit PowerStateHysteresis(PowerConfigParams::PowerOffInfo & info) // NOLINT (runtime/references)
+ : m_unTries(0),
+ m_tHysteresisInfo(info) {
+ }
+ void set(PowerConfigParams::PowerOffInfo & info) { // NOLINT (runtime/references)
+ m_tHysteresisInfo = info;
+ }
+ BOOL getEnabled() const {
+ return m_tHysteresisInfo.hysteresis.enabled;
+ }
+ UI_32 getTimeout() const {
+ return m_tHysteresisInfo.hysteresis.timeout;
+ }
+ UI_32 getTries() const {
+ return m_tHysteresisInfo.hysteresis.tries;
+ }
+
+ void clearTryCounter() {
+ m_unTries = 0;
+ }
+ void bumbTryCounter() {
+ m_unTries++;
+ }
+ BOOL maxTries() const {
+ if (m_unTries < getTries())
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ private:
+ UI_32 m_unTries;
+ PowerConfigParams::PowerOffInfo m_tHysteresisInfo;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
diff --git a/power_service/server/include/ss_power_state_machine.h b/power_service/server/include/ss_power_state_machine.h
new file mode 100644
index 00000000..fb5b7c33
--- /dev/null
+++ b/power_service/server/include/ss_power_state_machine.h
@@ -0,0 +1,414 @@
+/*
+ * @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.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
+
+#include <system_service/ss_power_service.h>
+#include "ss_power_state_hysteresis.h"
+
+class PowerSessionHandler;
+
+class PowerStateMachine {
+ class Base_State {
+ public:
+ virtual void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ virtual void onStartComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual void onLaunchComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ virtual void onStopComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual void onShutdownComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ virtual PCSTR name() = 0;
+
+ /// State Entry and Exit methods
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ };
+
+ friend class Base_State;
+
+ class Wakeup : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual PCSTR name();
+
+ // LCOV_EXCL_START 8: fist status, no entry
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 8: fist status, no entry
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class Wakeup;
+
+ class WakeupActive : public Wakeup {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class WakeupActive;
+
+ class WakeupPending : public Wakeup {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onStartComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLaunchComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class WakeupPending;
+
+ class Shutdown : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class Shutdown;
+
+ class ShutdownActive : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class ShutdownActive;
+
+ class LowVoltage1 : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage1;
+
+ class LowVoltage1Active : public Base_State {
+ public:
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage1Active;
+
+ class LowVoltage2 : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage2;
+
+ class LowVoltage2Active : public Base_State {
+ public:
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage2Active;
+
+ class NormalVoltage : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class NormalVoltage;
+
+ class SoftwareUpdate : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class SoftwareUpdate;
+
+ public:
+ typedef enum _Power_State_Machine_Events {
+ epsmeWAKEUP = epswsPWRON,
+ epsmeSHUTDOWN = epscnCANSLEEP,
+ epsmeLVI1_ENCOUNTERED = epsvsLVI1,
+ epsmeLVI2_ENCOUNTERED = epsvsLVI2,
+ epsmeNORMAL_VOLTAGE_ENCOUNTERED = epsvsNORMAL,
+ epsmeSTART_COMPLETE = 0xD1,
+ epsmeSTOP_COMPLETE = 0xD2,
+ epsmeSOFTWARE_UPDATE = 0xE1,
+ epsmeSHUTDOWN_HYSTERESIS_ABORTED = 0xF1,
+ epsmeLVI1_HYSTERESIS_ABORTED = 0xF2,
+ epsmeLVI2_HYSTERESIS_ABORTED = 0xF3,
+ epsmeSHUTDOWN_HYSTERESIS_TM_OUT = 0xFA,
+ epsmeLVI1_HYSTERESIS_TM_OUT = 0xFB,
+ epsmeLVI2_HYSTERESIS_TM_OUT = 0xFC,
+ } ePowerStateMachineEvents;
+
+ PowerStateMachine();
+ virtual ~PowerStateMachine();
+ void onEvent(HANDLE h_app, PowerSessionHandler & oSession, // NOLINT (runtime/references)
+ ePowerStateMachineEvents evt);
+ EFrameworkunifiedStatus initialize(HANDLE h_app, PowerConfigParams & refConfigParms); // NOLINT (runtime/references)
+ PCSTR name();
+
+ private:
+ static Wakeup WakeupState;
+ static WakeupActive WakeupActiveState;
+ static WakeupPending WakeupPendingState;
+ static LowVoltage1 LowVoltage1State;
+ static LowVoltage1Active LowVoltage1ActiveState;
+ static LowVoltage2 LowVoltage2State;
+ static LowVoltage2Active LowVoltage2ActiveState;
+ static Shutdown ShutdownState;
+ static ShutdownActive ShutdownActiveState;
+ static NormalVoltage NormalVoltageState;
+ static SoftwareUpdate SoftwareUpdateState;
+
+ Base_State *m_pCurrentState;
+ Base_State *m_pPreviousState;
+ Base_State *m_pOnHysteresisTimeoutState;
+ PowerStateHysteresis m_oShutdownHysteresis;
+ PowerStateHysteresis m_oLowVoltage1Hysteresis;
+ PowerStateHysteresis m_oLowVoltage2Hysteresis;
+ RequiredModuleList m_lstWakeupModules;
+ RequiredModuleList m_lstShutdownModules;
+ RequiredModuleList m_lstLvi2Modules;
+ HANDLE m_hHysteresisTimer;
+
+ typedef struct _state_info {
+ EPWR_POWER_STATE_TYPE wake;
+ EPWR_VOLTAGE_STATE_TYPE voltage;
+ EPWR_WAKEUP_LEVEL_TYPE level;
+ EPWR_WAKEUP_FACTOR_TYPE factor;
+ EPWR_CRANK_STATE_TYPE crank;
+ } Pwr_StateInfo;
+
+ Pwr_StateInfo m_tStateInfo;
+
+ PowerStateMachine(PowerStateMachine&);
+ PowerStateMachine & operator=(PowerStateMachine &);
+
+ /// Helper methods
+ void NextState(Base_State & refState, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void GotoStateOnHysteresisTimeout(Base_State & refState); // NOLINT (runtime/references)
+ void startHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void reStartHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void stopHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void publishPowerLVIStatus(HANDLE h_app, PCSTR nNotifNm, UI_32 value);
+ void publishPowerLevelType(HANDLE h_app, UI_32 value);
+
+ void OnVoltage(Base_State * pState, HANDLE h_app,
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
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 <system_service/ss_services.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#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 <system_service/ss_services.h>
+#include <system_service/ss_version.h>
+#include <system_service/ss_system_if.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/ns_message_center_if.h>
+
+#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 <inttypes.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_timer.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#include <utility>
+#include <string>
+
+#include "ss_power_powerservicelog.h"
+
+using namespace std; // NOLINT (build/namespaces)
+
+static Power g_PowerSubsystem;
+
+/**
+ * @brief
+ *
+ * @param
+ * @param
+ *
+ * @return
+ */
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus PowerCallback(
+ HANDLE h_app) {
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ C * pObj = static_cast<C *>(&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<Power, &Power::OnPowerOnOffNotification>))) { // 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<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_STATE_CHANGE_REQ, PowerCallback<Power,
+ &Power::OnSetPowerState> }, { SS_POWER_POWER_REQUEST_MSG,
+ PowerCallback<Power, &Power::OnPowerRequestMsg> }, {
+ SS_POWER_COMM_WAKEUP,
+ PowerCallback<Power, &Power::OnSetCommWakeUp> }, {
+ SS_POWER_SHUTDOWN_REQ,
+ PowerCallback<Power, &Power::OnSetCommSleep> }, {
+ SS_POWER_SHUTDOWN_REQUEST_MSG, PowerCallback<Power,
+ &Power::OnShutdownRequestMsg> }
+
+ /// Wake-up / Shutdown Protocol commands for System Manager.
+ , { SS_SM_WAKEUP_MODULES_CMPL_RSPN, PowerCallback<Power,
+ &Power::OnWakeUpComplete> }, { SS_SM_SHUTDOWN_MODULES_CMPL_RSPN,
+ PowerCallback<Power, &Power::OnShutdownComplete> }
+ //
+ , { SS_POWER_PRINT_CONNECTIONS, PowerCallback<Power,
+ &Power::OnPrintConnections> }, { SS_POWER_PRINT_STACK,
+ PowerCallback<Power, &Power::OnPrintStack> }
+ /// Set Voltage & Crank states from shadow?
+ , { SS_POWER_VOLTAGE_STATE, PowerCallback<Power,
+ &Power::OnSetVoltageState> }, { SS_POWER_CRANK_STATE,
+ PowerCallback<Power, &Power::OnSetCrankState> }
+ /// Current Power Service State inquiry from Test Client
+ , { SS_POWER_CRNT_STATE_QUERY, PowerCallback<Power,
+ &Power::OnCurrentPowerStateQuery> }, {
+ SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback<Power,
+ &Power::OnSystemModeInfoRequest> }, {
+ SS_SM_SYSTEM_MODE_INFO_RSPN, PowerCallback<Power,
+ &Power::OnSystemModeInfoResponse> }
+ /// InitComp report to SystemManager
+ , { SS_POWER_INITCOMP_REP, PowerCallback<Power,
+ &Power::OnInitCompReport> }
+ //
+ // Startup Confirmation Request ( from Power Shadow ) and
+ // Startup Confirmation Response ( from System Manager )
+ , { SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationRequest> }, {
+ SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationResponse> }
+ //
+ // User Mode Request ( from Power Shadow ) and
+ // User Mode Response ( from System Manager )
+ , { SS_SM_USER_MODE_SET_RESP, PowerCallback<Power,
+ &Power::OnUserModeResponse> }
+
+ //
+ // Heartbeat Request ( from Power Shadow )
+ , { SS_POWER_HEARTBEAT_REQ, PowerCallback<Power,
+ &Power::On_CWORD56_HeartBeatRequest> }, { SS_SM__CWORD56__HEARTBEAT_RSPN,
+ PowerCallback<Power, &Power::OnSM_CWORD56_HeartBeatResponse> }
+
+ // System Manager to Power Services
+ , { SS_SM_CPU_RESET_REQ, PowerCallback<Power,
+ &Power::OnCpuResetRequest> }, { SS_SM_REMOTE_DATA_RESET_REQ,
+ PowerCallback<Power, &Power::OnRemoteDataResetRequest> } };
+
+ // 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<Power, &Power::OnSystemMgrConnectionEstablished>);
+ 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<Pwr_ServiceSetInterface>(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<Pwr_ServiceSetInterface>(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<T_SS_SM_UserModeOnOffNotification_StructType>(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<Pwr_ServiceSetInterface>(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<wakeInfo>(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<Power, &Power::OnHysteresisTimeout>);
+ 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<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> } };
+
+ // 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<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationRequest> }, {
+ SS_POWER_STATE_CHANGE_REQ, PowerCallback<Power,
+ &Power::OnSetPowerState> }, { SS_POWER_SHUTDOWN_REQ,
+ PowerCallback<Power, &Power::OnShutdownRequestMsg> }
+ , { SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback<Power,
+ &Power::OnSystemModeInfoRequest> }, {
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ, PowerCallback<
+ Power, &Power::OnPublishShutdownPopupRequest> }, {
+ SS_POWER_PUBLISH_POWER_POPUP_REQ, PowerCallback<Power,
+ &Power::OnPublishPowerPopupRequest> }, {
+ SS_POWER_POWER_REQUEST_MSG, PowerCallback<Power,
+ &Power::OnPowerRequestMsg> } };
+
+ // 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<Power, &Power::OnSystemModeInfoResponse>);
+ first_supervisor = FALSE;
+ }
+ }
+ break;
+ case epsstSYSTEM: {
+ FrameworkunifiedProtocolCallbackHandler ss_power_system_session_handlers[] = {
+ { PROTOCOL_OPEN_SESSION_REQ, PowerCallback<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_SYSTEM_LAUNCH_COMPLETE, PowerCallback<Power,
+ &Power::OnSystemLaunchComplete> }, {
+ SS_POWER_SHUTDOWN_RESP, PowerCallback<Power,
+ &Power::OnSystemShutdownComplete> } };
+
+ // 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<SystemModeInfo>(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<SS_PSCurrentState>(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<Pwr_ServiceSetInterface>(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<ePowerSrvVoltageStates>(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<Pwr_ServiceSetInterface>(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<ePowerSrvCrankStates>(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<Pwr_ServiceSetInterface>(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<Pwr_ServiceSetInterface>(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<EFrameworkunifiedStatus>(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<EPWR_HB_REQ_MSG_STRUCT>(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<TSystemManagerCpuResetInfo>(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 <SS POWER DUMP DATA> \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<ESMDataResetType>(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 <string>
+#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 <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#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<StartCompleteAck>(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 <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_local.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_services.h>
+#include <native_service/ns_timer_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+
+#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<PowerSrvLVIStatus>(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<PowerSrvLevelType>(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 <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <other_service/itoa.h>
+#include <map>
+#include <string>
+#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<ePowerSrvCrankStates, std::string> 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<ePowerSrvVoltageStates, std::string> 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<SS_PSState, std::string> 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 <stdio.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_services.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+
+#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<EPWR_USER_MODE_TYPE, EPWR_POWER_STATE_TYPE> 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<Pwr_ServiceSetInterface>(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<Pwr_ServiceSetInterface>(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<Pwr_ServiceSetInterface>(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<Pwr_ServiceSetInterface>(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 <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service.h>
+#include <native_service/frameworkunified_framework_if.h>
+#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;
+}
diff --git a/system_service.mk b/system_service.mk
new file mode 100644
index 00000000..a8a06b06
--- /dev/null
+++ b/system_service.mk
@@ -0,0 +1,44 @@
+#############################################################
+#
+# Common Makefile for system_service
+# Copyright (C) 2017-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.
+#
+#############################################################
+
+CURRENT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+#############################################################
+# COMPONENT_NAME must not be blank and be named snake_case
+
+COMPONENT_NAME := system_service
+
+#############################################################
+
+
+
+#############################################################
+# You can add several flags and libraries.
+# When you add -I or -L path, DO NOT USE relative path.
+# Instead, use $(CURRENT_DIR) variable
+# that indicates the path this .mk file is stored.
+
+COMPONENT_CFLAGS :=
+COMPONENT_CXXFLAGS :=
+COMPONENT_LDLIBS :=
+COMPONENT_LDFLAGS :=
+
+##############################################################
+
+include $(SDKTARGETSYSROOT)/usr/agl/share/agl.mk