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_SS_LoggerService
19 /// \brief This file supports notifying CAN abou HK and CAN error events
21 ///////////////////////////////////////////////////////////////////////////////
24 #include <stub/Clock_API.h>
25 #include "ss_logger_error_event_can_evt_reply.h"
26 CLoggerErrorEventCANEvtReply::CLoggerErrorEventCANEvtReply() {
29 CLoggerErrorEventCANEvtReply::~CLoggerErrorEventCANEvtReply() { // LCOV_EXCL_START 14:globle instance
30 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
34 EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::Initialize(CLoggerCfg* f_pLoggerCfg) {
35 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
36 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
37 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
41 BOOL CLoggerErrorEventCANEvtReply::IsEventNeeded(TLoggerErrorEvent f_event) {
42 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
44 ((f_event.EventBitMask & EVENT_BIT_CAN_NOTIFICATION) != 0) ? TRUE : FALSE;
45 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
49 EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishStartEvent(
50 HANDLE f_hApp, TLoggerErrorEvent f_event) {
51 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
52 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
53 if (TRUE == IsEventNeeded(f_event)) {
54 l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventStart, NULL, 0);
55 LOG_STATUS_IF_ERRORED(
57 "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventStart,NULL,0)");
59 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
63 EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishEndEvent(
64 HANDLE f_hApp, TLoggerErrorEvent f_event, UI_32 f_triggerNumber,
66 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
67 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
68 if (TRUE == IsEventNeeded(f_event)) {
69 STEventCANLoggerEventInfo l_info;
71 CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
72 if (CLOCK_OK == clock_ret) {
74 l_info.success = TRUE;
75 l_info.triggerNumber = f_triggerNumber;
76 l_info.dateAndTime.DateTime_Stat = 0;
77 l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
78 l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
79 l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
80 l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
81 l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
82 l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
83 l_info.dateAndTime.TimeFormat = 0;
84 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
85 " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
86 l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
87 l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
88 l_info.dateAndTime.DateTimeMinute,
89 l_info.dateAndTime.DateTimeSecond);
92 l_info.success = TRUE;
94 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
96 l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
97 &l_info, sizeof(l_info));
99 LOG_STATUS_IF_ERRORED(
101 "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
103 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
107 EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishErrorEvent(
108 HANDLE f_hApp, TLoggerErrorEvent f_event, BOOL f_isValid,
109 UI_32 f_triggerNumber, uint32_t f_time) {
110 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
111 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
112 if (TRUE == IsEventNeeded(f_event)) {
113 STEventCANLoggerEventInfo l_info;
115 CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
116 l_info.valid = f_isValid;
117 l_info.success = FALSE;
118 if (CLOCK_OK == clock_ret) {
119 l_info.triggerNumber = f_triggerNumber;
120 l_info.dateAndTime.DateTime_Stat = 0;
121 l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
122 l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
123 l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
124 l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
125 l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
126 l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
127 l_info.dateAndTime.TimeFormat = 0;
128 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
129 " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
130 l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
131 l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
132 l_info.dateAndTime.DateTimeMinute,
133 l_info.dateAndTime.DateTimeSecond);
136 l_info.valid = FALSE;
137 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
139 l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
140 &l_info, sizeof(l_info));
141 LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: macro
143 "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
145 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");