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 ///////////////////////////////////////////////////////////////////////////////
23 #ifndef HEARTBEAT_WORKER_H_ // NOLINT
24 #define HEARTBEAT_WORKER_H_
26 #include <native_service/frameworkunified_types.h>
27 #include <native_service/frameworkunified_framework_if.h>
28 #include <native_service/frameworkunified_multithreading.h>
29 #include <system_service/ss_system_timer.h>
31 #include "ss_hb_session.h"
32 #include "ss_sm_config.h"
35 class CHeartBeatThread {
37 explicit CHeartBeatThread(HANDLE f_hThread);
38 virtual ~CHeartBeatThread();
40 ///////////////////////////
41 /// HBPublishAvailabilityStatus
42 /// At HeartBeat sends NTFY_Availability with availability
43 /// notification to alert client that HeartBeat is available/not available.
45 /// \param [in] hThread
46 /// HANDLE - Handle of HeartBeat
49 /// EFrameworkunifiedStatus - success or error
51 ////////////////////////////////////////////////////////////////////////////////////////////
52 EFrameworkunifiedStatus HBPublishAvailabilityStatus(HANDLE hThread, BOOL f_AvailabiltyStatus);
54 ///////////////////////////
56 /// Creates and starts the HeartBeat timer
58 /// \param [in] hThread
59 /// HANDLE - Handle of HeartBeat
62 /// EFrameworkunifiedStatus - success or error
64 ////////////////////////////////////////////////////////////////////////////////////////////
65 EFrameworkunifiedStatus HBOnStartThread(HANDLE hThread);
68 ///////////////////////////
70 /// Stops and deletes the HeartBeat timer
72 /// \param [in] hThread
73 /// HANDLE - Handle of HeartBeat
76 /// EFrameworkunifiedStatus - success or error
78 ////////////////////////////////////////////////////////////////////////////////////////////
79 EFrameworkunifiedStatus HBOnStopThread(HANDLE hThread);
81 ////////////////////////////////////////////////////////////////////////////////////////////
82 /// HBOnPrintConnections
83 /// Prints all active sessions connected to HeartBeat
85 /// \param [in] hThread
86 /// HANDLE - Handle of HeartBeat
89 /// EFrameworkunifiedStatus - success or error
91 ////////////////////////////////////////////////////////////////////////////////////////////
92 EFrameworkunifiedStatus HBOnPrintConnections(HANDLE hThread);
94 ////////////////////////////////////////////////////////////////////////////////////////////
96 /// Prints all sessions connected to HeartBeat
98 /// \param [in] hThread
99 /// HANDLE - Handle of HeartBeat
102 /// EFrameworkunifiedStatus - success or error
104 ////////////////////////////////////////////////////////////////////////////////////////////
105 EFrameworkunifiedStatus HBOnPrintStack(HANDLE hThread);
107 ///////////////////////////
109 /// When APP timer expires, this method sends the HeartBeat request to the client.
111 /// \param [in] hThread
112 /// HANDLE - Handle of HeartBeat
115 /// EFrameworkunifiedStatus - success or error
117 ////////////////////////////////////////////////////////////////////////////////////////////
118 EFrameworkunifiedStatus HBOnTimerExpiry(HANDLE hThread);
120 ///////////////////////////
121 /// HBOnClientResponse
122 /// When the response from a client is received, this method updates the map
123 /// containing client status to indicate the response.
126 /// \param [in] hThread
127 /// HANDLE - Handle of HeartBeat
130 /// EFrameworkunifiedStatus - success or error
132 ////////////////////////////////////////////////////////////////////////////////////////////
133 EFrameworkunifiedStatus HBOnClientResponse(HANDLE hThread);
135 ///////////////////////////
136 /// HBOnPeriodicStatusRequest
137 /// Reply to Status request from System Manager
139 /// \param [in] hThread
140 /// HANDLE - Handle of HeartBeat
143 /// EFrameworkunifiedStatus - success or error
145 ////////////////////////////////////////////////////////////////////////////////////////////
146 EFrameworkunifiedStatus HBOnPeriodicStatusRequest(HANDLE hThread);
149 ///////////////////////////
150 /// HBOnAvailCheckRequest
151 /// Reply to service's availability condition request from System Manager
153 /// \param [in] hThread
154 /// HANDLE - Handle of HeartBeat
157 /// EFrameworkunifiedStatus - success or error
159 ////////////////////////////////////////////////////////////////////////////////////////////
160 EFrameworkunifiedStatus HBOnAvailCheckRequest(HANDLE hThread);
162 ///////////////////////////
164 /// Upon receiving delete module notification from sysmgr, this method removes
165 /// a client from the client session map.
167 /// \param [in] hThread
168 /// HANDLE - Handle of HeartBeat
171 /// EFrameworkunifiedStatus - success or error
173 ////////////////////////////////////////////////////////////////////////////////////////////
174 EFrameworkunifiedStatus HBOnRemoveModule(HANDLE hApp);
176 ///////////////////////////
178 /// Upon receiving append module notification from sysmgr, this method append
179 /// a client from the client session map.
181 /// \param [in] hThread
182 /// HANDLE - Handle of HeartBeat
185 /// EFrameworkunifiedStatus - success or error
187 ////////////////////////////////////////////////////////////////////////////////////////////
188 EFrameworkunifiedStatus HBOnAppendModule(HANDLE hApp);
190 // Service notification handlers
191 EFrameworkunifiedStatus HBSendRequest(HANDLE hApp);
192 EFrameworkunifiedStatus HBCheckHeartBeatResponses(HANDLE hThread);
193 EFrameworkunifiedStatus HBDeleteRegisteredClientEntry(PSTR pModuleName);
195 EFrameworkunifiedStatus HeartBeatTimerInit(HANDLE hThread);
196 EFrameworkunifiedStatus HeartBeatTimersDelete(void);
199 CHeartBeatSessionHandler m_oSessionHandler;
200 TimerCtrl m_oTimerCtrl;
202 HBConfigParameters m_HBConfigParams;
203 SI_32 m_NextChkIndex;
206 #endif // HEARTBEAT_WORKER_H_ // NOLINT