Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_LocationAltitude_n.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_LocationAltitude_n.cpp
20  * @brief
21  */
22 /*---------------------------------------------------------------------------------*
23  * Include Files                                                                   *
24  *---------------------------------------------------------------------------------*/
25 #include <vehicle_service/positioning_base_library.h>
26 #include "VehicleSens_DataMaster.h"
27 #include "SensorLocation_API.h"
28 #include "CommonDefine.h"
29
30 /*---------------------------------------------------------------------------------*
31  * Global Value                                                                    *
32  *---------------------------------------------------------------------------------*/
33 static  VEHICLESENS_DATA_MASTER  gstLocationAltitude_n;    // NOLINT(readability/nolint)
34
35 /**
36  * @brief
37  *  Altitude information data master initialization processing(NAVI information)
38  *
39  *  Initialize the altitude information data master
40  *
41  * @param[in]   none
42  * @param[out]  none
43  * @return      none
44  * @retval      none
45  */
46 void VehicleSensInitLocationAltitudeN(void) {
47     SENSORLOCATION_ALTITUDEINFO_DAT  st_altitude;
48
49     memset(&gstLocationAltitude_n, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
50
51     /** Data ID setting */
52     gstLocationAltitude_n.ul_did   = VEHICLE_DID_LOCATION_ALTITUDE_NAVI;
53
54     /** Data size setting */
55     gstLocationAltitude_n.us_size  = sizeof(SENSORLOCATION_ALTITUDEINFO_DAT);
56
57     /** Data content setting */
58     memset(&st_altitude, 0x00, sizeof(st_altitude));
59     st_altitude.getMethod = SENSOR_GET_METHOD_NAVI;
60     st_altitude.SyncCnt   = 0x00;
61     st_altitude.isEnable  = SENSORLOCATION_STATUS_DISABLE;
62     st_altitude.Altitude  = 0x00;
63     memcpy(&gstLocationAltitude_n.uc_data[0], &st_altitude, sizeof(st_altitude));
64
65     return;
66 }
67
68 /**
69  * @brief
70  *  Altitude information data master SET processing(NAVI information)
71  *
72  *  Update the altitude information data master
73  *
74  * @param[in]  VEHICLESENS_DATA_MASTER *pst_data     : Pointer to the data master acquisition destination
75  * @param[out] none
76  * @return     u_int8
77  * @retval     VEHICLESENS_EQ  : No data change
78  * @retval     VEHICLESENS_NEQ : Data change
79  */
80 u_int8 VehicleSensSetLocationAltitudeN(const SENSORLOCATION_ALTITUDEINFO_DAT *pst_altitude) {
81     u_int8            uc_ret;
82     VEHICLESENS_DATA_MASTER    *pst_master;
83
84     pst_master = &gstLocationAltitude_n;
85
86     /** With the contents of the current data master,Compare received data */
87     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_altitude, sizeof(SENSORLOCATION_ALTITUDEINFO_DAT));
88
89     /** Received data is set in the data master. */
90     pst_master->ul_did    = VEHICLE_DID_LOCATION_ALTITUDE_NAVI;
91     pst_master->us_size    = sizeof(SENSORLOCATION_ALTITUDEINFO_DAT);
92     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
93     memcpy(pst_master->uc_data, pst_altitude, sizeof(SENSORLOCATION_ALTITUDEINFO_DAT));
94
95     return(uc_ret);
96 }
97
98 /**
99  * @brief
100  *  Altitude Information Data Master GET Processing(NAVI information)
101  *
102  *  Provide an altitude information data master
103  *
104  * @param[in]  none
105  * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
106  * @return     none
107  * @retval     none
108  */
109 void VehicleSensGetLocationAltitudeN(VEHICLESENS_DATA_MASTER *pst_data) {
110     const VEHICLESENS_DATA_MASTER *pst_master;
111
112     pst_master = &gstLocationAltitude_n;
113
114     /** Store the data master in the specified destination. */
115     pst_data->ul_did    = pst_master->ul_did;
116     pst_data->us_size    = pst_master->us_size;
117     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
118     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
119
120     return;
121 }