common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_LocationLonLat_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_LocationLonLat_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  gstLocationLonLat_n;    // NOLINT(readability/nolint)
34
35 /**
36  * @brief
37  *  Latitude and longitudeInitialization of information data master(NAVI information)
38  *
39  *  Latitude and longitudeInitialize the information data master
40  *
41  * @param[in]   none
42  * @param[out]  none
43  * @return      none
44  * @retval      none
45  */
46 void VehicleSensInitLocationLonLatN(void) {
47     SENSORLOCATION_LONLATINFO_DAT  st_lonlat;
48
49     memset(&gstLocationLonLat_n, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
50
51     /** Data ID setting */
52     gstLocationLonLat_n.ul_did  = VEHICLE_DID_LOCATION_LONLAT_NAVI;
53
54     /** Data size setting */
55     gstLocationLonLat_n.us_size  = sizeof(SENSORLOCATION_LONLATINFO_DAT);
56
57     /** Data content setting */
58     memset(&st_lonlat, 0x00, sizeof(st_lonlat));
59     st_lonlat.getMethod = SENSOR_GET_METHOD_NAVI;
60     st_lonlat.SyncCnt   = 0x00;
61     st_lonlat.isEnable  = SENSORLOCATION_STATUS_DISABLE;
62     st_lonlat.posSts    = 0x00;
63     st_lonlat.posAcc    = 0x00;
64     st_lonlat.Longitude = 0x00;
65     st_lonlat.Latitude  = 0x00;
66     memcpy(&gstLocationLonLat_n.uc_data[0], &st_lonlat, sizeof(st_lonlat));
67
68     return;
69 }
70
71 /**
72  * @brief
73  *  Latitude and longitudeInformation data master SET process(NAVI information)
74  *
75  *  Latitude and longitudeUpdate the information data master
76  *
77  * @param[in]  VEHICLESENS_DATA_MASTER *pst_data     : Pointer to the data master acquisition destination
78  * @param[out] none
79  * @return     u_int8
80  * @retval     VEHICLESENS_EQ  : No data change
81  * @retval     VEHICLESENS_NEQ : Data change
82  */
83 u_int8 VehicleSensSetLocationLonLatN(const SENSORLOCATION_LONLATINFO_DAT *pst_lonlat) {
84     u_int8            uc_ret;
85     VEHICLESENS_DATA_MASTER    *pst_master;
86
87     pst_master = &gstLocationLonLat_n;
88
89     /** With the contents of the current data master,Compare received data */
90     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
91
92     /** Received data is set in the data master. */
93     pst_master->ul_did    = VEHICLE_DID_LOCATION_LONLAT_NAVI;
94     pst_master->us_size    = sizeof(SENSORLOCATION_LONLATINFO_DAT);
95     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
96     memcpy(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
97
98     return(uc_ret);
99 }
100
101 /**
102  * @brief
103  *  Latitude and longitudeInformation Data Master GET Processing(NAVI information)
104  *
105  *  Latitude and longitudeProvide an information data master
106  *
107  * @param[in]  none
108  * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
109  * @return     none
110  * @retval     none
111  */
112 void VehicleSensGetLocationLonLatN(VEHICLESENS_DATA_MASTER *pst_data) {
113     const VEHICLESENS_DATA_MASTER *pst_master;
114
115     pst_master = &gstLocationLonLat_n;
116
117     /** Store the data master in the specified destination. */
118     pst_data->ul_did    = pst_master->ul_did;
119     pst_data->us_size    = pst_master->us_size;
120     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
121     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
122
123     return;
124 }
125
126 /**
127  * @brief
128  *  Latitude and longitudeInformation Data Master GET Processing(NAVI information)
129  *
130  *  Latitude and longitudeProvide an information data master(Unit:10^-7th degree)
131  *
132  * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
133  */
134 void VehicleSensGetLocationLonLatnUnitCnv(VEHICLESENS_DATA_MASTER *pst_data) {
135     const VEHICLESENS_DATA_MASTER *pst_master;
136     SENSORLOCATION_LONLATINFO_DAT  st_lonlat;
137     int32_t l_lon;
138     int32_t l_lat;
139     int64_t ll_tmp;
140
141     pst_master = &gstLocationLonLat_n;
142
143     /* Perform unit conversion[1/128Second] -> [10^-7 degree] */
144     memcpy(&st_lonlat, pst_master->uc_data, sizeof(st_lonlat));
145
146     /* Longitude */
147     l_lon = st_lonlat.Longitude;
148     ll_tmp = (int64_t)l_lon * 10000000;
149     st_lonlat.Longitude = (int32_t)(ll_tmp / (128 * 60 * 60));
150
151     /* Latitude */
152     l_lat = st_lonlat.Latitude;
153     ll_tmp = (int64_t)l_lat * 10000000;
154     st_lonlat.Latitude = (int32_t)(ll_tmp / (128 * 60 * 60));
155
156     /** Store the data master in the specified destination. */
157     pst_data->ul_did    = pst_master->ul_did;
158     pst_data->us_size    = pst_master->us_size;
159     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
160     memcpy(pst_data->uc_data, &st_lonlat, sizeof(st_lonlat));
161
162     return;
163 }