2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_SystemManager
19 /// \brief This file provides support for the application heartbeat system.
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <system_service/ss_heartbeat_service_protocol.h>
23 #include <system_service/ss_system_manager_if.h>
24 #include <system_service/ss_system_manager_if_local.h>
27 #include <native_service/frameworkunified_framework_if.h>
28 #include <system_service/ss_services.h>
29 #include <system_service/ss_templates.h>
31 #include "ss_hb_thread.h"
32 #include "ss_sm_systemmanagerlog.h"
34 /*****************************************************************************
35 @ingroup: SS_SystemManager
36 @brief: HBOnTimerExpiry
38 @param HANDLE - Handle to message queue of HeartBeat Service.
39 @return EFrameworkunifiedStatus
40 *****************************************************************************/
41 EFrameworkunifiedStatus CHeartBeatThread::HBOnTimerExpiry(HANDLE f_hThread) {
42 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
43 EFrameworkunifiedStatus l_eStatus;
45 // check heart beat replies received from clients.
46 l_eStatus = HBCheckHeartBeatResponses(f_hThread);
47 LOG_STATUS_IF_ERRORED(l_eStatus, "HBCheckHeartBeatResponses()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
49 // send heart beat requests to clients
50 l_eStatus = HBSendRequest(f_hThread);
51 LOG_STATUS_IF_ERRORED(l_eStatus, "HBSendRequest()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
53 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
57 /*****************************************************************************
58 @ingroup: SS_SystemManager
59 @brief: HBOnClientResponse
61 @param HANDLE - Handle to message queue of HeartBeat Service.
62 @return EFrameworkunifiedStatus OK or Fail
63 *****************************************************************************/
64 EFrameworkunifiedStatus CHeartBeatThread::HBOnClientResponse(HANDLE f_hThread) {
65 EFrameworkunifiedStatus l_eStatus;
66 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
67 l_eStatus = m_oSessionHandler.HBProcessClientResponse(f_hThread);
68 LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBProcessClientResponse(f_hThread)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
69 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
73 /*****************************************************************************
74 @ingroup: SS_SystemManager
75 @brief: HBOnPeriodicStatusRequest
77 @param HANDLE - Handle to message queue of HeartBeat Service.
78 @return EFrameworkunifiedStatus OK or Fail
79 *****************************************************************************/
80 EFrameworkunifiedStatus CHeartBeatThread::HBOnPeriodicStatusRequest(HANDLE f_hThread) {
81 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
82 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
83 // LCOV_EXCL_BR_START 4: NSFW error case.
84 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_PERIODIC_RESP, 0, NULL))) {
86 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
87 LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_PERIODIC_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case.
89 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "Successful");
92 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
96 /*****************************************************************************
97 @ingroup: SS_SystemManager
98 @brief: HBOnPeriodicStatusRequest
100 @param HANDLE - Handle to message queue of HeartBeat Service.
101 @return EFrameworkunifiedStatus OK or Fail
102 *****************************************************************************/
103 EFrameworkunifiedStatus CHeartBeatThread::HBOnAvailCheckRequest(HANDLE f_hThread) {
104 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "+");
106 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
108 l_eStatus = m_oSessionHandler.HBAvailableCheck(check);
109 SS_ASERT(l_eStatus == eFrameworkunifiedStatusOK); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
111 // LCOV_EXCL_BR_START 4: NSFW error case.
112 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_AVAIL_CHECK_RESP, sizeof(check), &check))) {
114 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
115 LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_AVAIL_CHECK_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case.
121 /*****************************************************************************
122 @ingroup: SS_SystemManager
123 @brief: HBOnRemoveModule
125 @param HANDLE - Handle to message queue of HeartBeat Service.
126 @return EFrameworkunifiedStatus OK or Fail
127 *****************************************************************************/
128 EFrameworkunifiedStatus CHeartBeatThread::HBOnRemoveModule(HANDLE f_hThread) {
129 EFrameworkunifiedStatus l_eStatus;
130 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
132 TSMRequestMessage tReqMsgData;
134 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
135 // Report any errors found. *
137 // LCOV_EXCL_BR_START 4: NSFW error case.
138 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg <TSMRequestMessage> (f_hThread, tReqMsgData))) {
140 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
141 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
143 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
144 " %s is required to be Deleted from HeartBeat Monitor List", tReqMsgData.pstModuleName);
146 // delete module entry from map
147 l_eStatus = m_oSessionHandler.HBDeleteRegisteredClientEntry(f_hThread, tReqMsgData.pstModuleName);
148 LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBDeleteRegisteredProcessEntry()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
150 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
154 /*****************************************************************************
155 @ingroup: SS_SystemManager
156 @brief: HBOnAppendModule
158 @param HANDLE - Handle to message queue of HeartBeat Service.
159 @return EFrameworkunifiedStatus OK or Fail
160 *****************************************************************************/
161 EFrameworkunifiedStatus CHeartBeatThread::HBOnAppendModule(HANDLE f_hThread) {
162 EFrameworkunifiedStatus l_eStatus;
163 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
165 TSMRequestMessage tReqMsgData;
167 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
168 // Report any errors found. *
170 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSMRequestMessage > (f_hThread, tReqMsgData))) {
171 LOG_ERROR("ReadMsg()");
173 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
174 " %s is required to be Appended from HeartBeat Monitor List", tReqMsgData.pstModuleName);
176 // append module entry from map
177 SubscriberName l_Subscriber = tReqMsgData.pstModuleName;
178 l_eStatus = m_oSessionHandler.HBEntrySubscriber(l_Subscriber); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
179 LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBEntrySubscriber()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
181 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");