Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_SettingTime_clock.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file
19  *   VehicleSens_Did_SettingTime_clock.cpp
20  * @brief
21  */
22 /*---------------------------------------------------------------------------------*
23  * Include Files                                                                   *
24  *---------------------------------------------------------------------------------*/
25 #include <vehicle_service/positioning_base_library.h>
26 #include "VehicleSens_DataMaster.h"
27
28 /*---------------------------------------------------------------------------------*
29  * Global Value                                                                    *
30  *---------------------------------------------------------------------------------*/
31 static  VEHICLESENS_DATA_MASTER  gstSettingTime_clock;    // NOLINT(readability/nolint)
32
33 /**
34  * @brief
35  *  GPS setting time information data master initialization process(NAVI information)
36  *
37  *  Initialize the GPS setting time information data master
38  *
39  * @param[in]   none
40  * @param[out]  none
41  * @return      none
42  * @retval      none
43  */
44 void VehicleSensInitSettingTimeclock(void) {
45     POS_DATETIME  st_time;
46
47     memset(&gstSettingTime_clock, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
48
49     /** Data ID setting */
50     gstSettingTime_clock.ul_did    = VEHICLE_DID_SETTINGTIME;
51
52     /** Data size setting */
53     gstSettingTime_clock.us_size    = sizeof(POS_DATETIME);
54
55     /** Data content setting */
56     memset(&st_time, 0x00, sizeof(st_time));
57     memcpy(&gstSettingTime_clock.uc_data[0], &st_time, sizeof(st_time));
58
59     return;
60 }
61
62 /**
63  * @brief
64  *  GPS setting time information data master SET process(NAVI information)
65  *
66  *  Update the GPS setting time information data master
67  *
68  * @param[in]  VEHICLESENS_DATA_MASTER *pst_data     : Pointer to the data master acquisition destination
69  * @param[out] none
70  * @return     u_int8
71  * @retval     VEHICLESENS_EQ  : No data change
72  * @retval     VEHICLESENS_NEQ : Data change
73  */
74 u_int8 VehicleSensSetSettingTimeclock(const POS_DATETIME *pst_rcv_time) {
75     u_int8            uc_ret;
76     VEHICLESENS_DATA_MASTER    *pst_master;
77
78     pst_master = &gstSettingTime_clock;
79
80     /** Compare the data master and generated data */
81     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_rcv_time, sizeof(POS_DATETIME));
82
83     /** Received data is set in the data master. */
84     pst_master->ul_did    = VEHICLE_DID_SETTINGTIME;
85     pst_master->us_size    = sizeof(POS_DATETIME);
86     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
87     memcpy(pst_master->uc_data, pst_rcv_time, sizeof(POS_DATETIME));
88
89     return(uc_ret);
90 }
91
92 /**
93  * @brief
94  *  GPS setting time information data master GET process(NAVI information)
95  *
96  *  Provide the GPS setting time information data master
97  *
98  * @param[in]  none
99  * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
100  * @return     none
101  * @retval     none
102  */
103 void VehicleSensGetSettingTimeclock(VEHICLESENS_DATA_MASTER *pst_data) {
104     const VEHICLESENS_DATA_MASTER *pst_master;
105
106     pst_master = &gstSettingTime_clock;
107
108     /** Store the data master in the specified destination. */
109     pst_data->ul_did    = pst_master->ul_did;
110     pst_data->us_size    = pst_master->us_size;
111     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
112     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
113
114     return;
115 }
116