Re-organized sub-directory by category
[staging/basesystem.git] / service / vehicle / positioning / server / src / Sensor / VehicleSens_Did_MotionSpeed_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
19  *  VehicleSens_Did_MotionSpeed_g.cpp
20  * @brief
21  *  Vehicle Speed Information Data Master Management(NMEA 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_g;    // NOLINT(readability/nolint)
35
36 /*---------------------------------------------------------------------------------*
37  * Function                                                                        *
38  *---------------------------------------------------------------------------------*/
39 /**
40  * @brief
41  *   Speed information data master initialization process(NMEA information)
42  */
43 void VehicleSensInitMotionSpeedG(void) {
44     SENSORMOTION_SPEEDINFO_DAT  st_speed;
45
46     memset(&gstMotionSpeed_g, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
47
48     /** Data ID setting */
49     gstMotionSpeed_g.ul_did    = VEHICLE_DID_MOTION_SPEED;
50     /** Data size setting */
51     gstMotionSpeed_g.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_GPS;
55     st_speed.SyncCnt = 0x00;
56     st_speed.isEnable  = SENSORMOTION_STATUS_DISABLE;
57     memcpy(&gstMotionSpeed_g.uc_data[0], &st_speed, sizeof(st_speed));
58 }
59
60 /**
61  * @brief
62  *   Rate information data master SET process(NMEA 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 VehicleSensSetMotionSpeedG(const SENSORMOTION_SPEEDINFO_DAT *pst_speed) {  // LCOV_EXCL_START 8: dead code.
70     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
71     u_int8 uc_ret;
72     VEHICLESENS_DATA_MASTER *pst_master;
73
74     pst_master = &gstMotionSpeed_g;
75
76     /** With the contents of the current data master,Compare received data */
77     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
78
79     /** Received data is set in the data master. */
80     pst_master->ul_did    = VEHICLE_DID_MOTION_SPEED;
81     pst_master->us_size    = sizeof(SENSORMOTION_SPEEDINFO_DAT);
82     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
83     memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
84     memcpy(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
85
86     return(uc_ret);
87 }
88
89 /**
90  * @brief
91  *   Speed information data master GET processing(NMEA information)
92  *
93  * @param[out]  *pst_speed  - VEHICLESENS_DATA_MASTER Pointer to the data master acquisition destination
94  */
95 void VehicleSensGetMotionSpeedG(VEHICLESENS_DATA_MASTER *pst_data) {
96     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
97     const VEHICLESENS_DATA_MASTER *pst_master;
98
99     pst_master = &gstMotionSpeed_g;
100
101     /* Store the data master in the specified destination. */
102     pst_data->ul_did    = pst_master->ul_did;
103     pst_data->us_size    = pst_master->us_size;
104     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
105     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
106 }
107 // LCOV_EXCL_STOP