Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_LocationLonLat_g.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       VehicleSens_Did_LocationLonLat_g.cpp
19 @detail     Latitude and longitudeManagement of information data master(NMEA information)
20 ******************************************************************************/
21 #include <vehicle_service/positioning_base_library.h>
22 #include "VehicleSens_DataMaster.h"
23 #include "CommonDefine.h"
24
25 /*************************************************
26  *           Global variable                      *
27  *************************************************/
28 static  VEHICLESENS_DATA_MASTER  gstLocationLonLat_g;  // NOLINT(readability/nolint)
29
30 /****************************************************************************
31 @brief      VehicleSensInitLocationLonLatG<BR>
32             Latitude and longitudeInitialization of information data master(NMEA information)
33 @outline    Latitude and longitudeInitialize the information data master
34 @param[in]  none
35 @param[out] none
36 @return     none
37 @retval     none
38 *******************************************************************************/
39 void VehicleSensInitLocationLonLatG(void) {
40     SENSORLOCATION_LONLATINFO_DAT  st_lonlat;
41
42     memset(&gstLocationLonLat_g, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
43
44     /** Data ID setting */
45     gstLocationLonLat_g.ul_did    = VEHICLE_DID_LOCATION_LONLAT;
46     /** Data size setting */
47     gstLocationLonLat_g.us_size    = sizeof(SENSORLOCATION_LONLATINFO_DAT);
48     /** Data content setting */
49     memset(&st_lonlat, 0x00, sizeof(st_lonlat));
50     st_lonlat.getMethod = SENSOR_GET_METHOD_GPS;
51     st_lonlat.SyncCnt  = 0x00;
52     st_lonlat.isEnable = SENSORLOCATION_STATUS_DISABLE;
53     memcpy(&gstLocationLonLat_g.uc_data[0], &st_lonlat, sizeof(st_lonlat));
54 }
55
56 /****************************************************************************
57 @brief      VehicleSensSetLocationLonLatG<BR>
58             Latitude and longitudeInformation data master SET process(NMEA information)
59 @outline    Latitude and longitudeUpdate the information data master
60 @param[in]  SENSORLOCATION_LONLATINFO_DAT *    pst_lonlat : Latitude and longitude information
61 @param[out] none
62 @return     u_int8
63 @retval     VEHICLESENS_EQ  : No data change
64 @retval     VEHICLESENS_NEQ : Data change
65 *******************************************************************************/
66 u_int8 VehicleSensSetLocationLonLatG(const SENSORLOCATION_LONLATINFO_DAT *pst_lonlat) {
67     u_int8  uc_ret;
68     VEHICLESENS_DATA_MASTER      *pst_master;
69
70     pst_master = &gstLocationLonLat_g;
71
72     /** With the contents of the current data master,Compare received data */
73     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
74
75     /** Received data is set in the data master. */
76     pst_master->ul_did    = VEHICLE_DID_LOCATION_LONLAT;
77     pst_master->us_size    = sizeof(SENSORLOCATION_LONLATINFO_DAT);
78     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
79     memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
80     memcpy(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
81
82     return(uc_ret);
83 }
84
85 /****************************************************************************
86 @brief      VehicleSensGetLocationLonLatG<BR>
87             Latitude and longitudeInformation Data Master GET Processing(NMEA information)
88 @outline    Latitude and longitudeProvide an information data master
89 @param[in]  none
90 @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
91 @return     none
92 @retval     none
93 *******************************************************************************/
94 void VehicleSensGetLocationLonLatG(VEHICLESENS_DATA_MASTER *pst_data) {
95     const VEHICLESENS_DATA_MASTER *pst_master;
96
97     pst_master = &gstLocationLonLat_g;
98
99     /* Store the data master in the specified destination. */
100     pst_data->ul_did    = pst_master->ul_did;
101     pst_data->us_size    = pst_master->us_size;
102     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
103     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
104 }