Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_MotionSpeed_i.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_MotionSpeed_i.cpp
20  * @brief
21  *  Vehicle Speed Information Data Master Management(Internal calculation information)
22  */
23
24 /*---------------------------------------------------------------------------------*
25  * Include Files                                                                   *
26  *---------------------------------------------------------------------------------*/
27 #include <vehicle_service/positioning_base_library.h>
28 #include "VehicleSens_DataMaster.h"
29 #include "CommonDefine.h"
30
31 /*---------------------------------------------------------------------------------*
32  * Grobal Value                                                                    *
33  *---------------------------------------------------------------------------------*/
34 static VEHICLESENS_DATA_MASTER gstMotionSpeed_i;    // NOLINT(readability/nolint)
35
36 /*---------------------------------------------------------------------------------*
37  * Function                                                                        *
38  *---------------------------------------------------------------------------------*/
39 /**
40  * @brief
41  *   Speed information data master initialization process(Internal calculation information)
42  */
43 void VehicleSensInitMotionSpeedI(void) {
44     SENSORMOTION_SPEEDINFO_DAT  st_speed;
45
46     memset(&gstMotionSpeed_i, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
47
48     /** Data ID setting */
49     gstMotionSpeed_i.ul_did    = VEHICLE_DID_MOTION_SPEED_INTERNAL;
50     /** Data size setting */
51     gstMotionSpeed_i.us_size    = sizeof(SENSORMOTION_SPEEDINFO_DAT);
52     /** Data content setting */
53     memset(&st_speed, 0x00, sizeof(st_speed));
54     st_speed.getMethod = SENSOR_GET_METHOD_POS;
55     st_speed.SyncCnt = 0x00;
56     st_speed.isEnable  = SENSORMOTION_STATUS_DISABLE;
57     memcpy(&gstMotionSpeed_i.uc_data[0], &st_speed, sizeof(st_speed));
58 }
59
60 /**
61  * @brief
62  *   Rate information data master SET process(Internal calculation information)
63  *
64  * @param[in]  *pst_speed  - SENSORMOTION_SPEEDINFO_DAT Pointer to vehicle speed information
65  *
66  * @return VEHICLESENS_EQ  : No data change<br>
67  *       VEHICLESENS_NEQ : Data change
68  */
69 u_int8 VehicleSensSetMotionSpeedI(const SENSORMOTION_SPEEDINFO_DAT *pst_speed) {
70     u_int8 uc_ret;
71     VEHICLESENS_DATA_MASTER *pst_master;
72
73     pst_master = &gstMotionSpeed_i;
74
75     /** With the contents of the current data master,Compare received data */
76     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
77
78     /** Received data is set in the data master. */
79     pst_master->ul_did    = VEHICLE_DID_MOTION_SPEED_INTERNAL;
80     pst_master->us_size    = sizeof(SENSORMOTION_SPEEDINFO_DAT);
81     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
82     memcpy(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
83
84     return(uc_ret);
85 }
86
87 /**
88  * @brief
89  *   Speed information data master GET processing(Internal calculation information)
90  *
91  * @param[out]  *pst_speed  - VEHICLESENS_DATA_MASTER Pointer to the data master acquisition destination
92  */
93 void VehicleSensGetMotionSpeedI(VEHICLESENS_DATA_MASTER *pst_data) {
94     const VEHICLESENS_DATA_MASTER *pst_master;
95
96     pst_master = &gstMotionSpeed_i;
97
98     /* Store the data master in the specified destination. */
99     pst_data->ul_did    = pst_master->ul_did;
100     pst_data->us_size    = pst_master->us_size;
101     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
102     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
103 }