Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / DeadReckoning_Did_GyroScaleFactor_dr.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      DeadReckoning_Did_GyroScaleFactor_dr.cpp
19 @detail      DeadReckoning data Master(VEHICLE_DID_DR_GYRO_SCALE_FACTOR)
20 *****************************************************************************/
21
22 #include <vehicle_service/positioning_base_library.h>
23 #include "DeadReckoning_DataMaster.h"
24
25 /*************************************************/
26 /*           Global variable                      */
27 /*************************************************/
28 static  DEADRECKONING_DATA_MASTER  gst_gyroscalefactor;    // NOLINT(readability/nolint)
29
30 /************************************************************************
31 @brief      GyroScaleFactor initialization function
32 @outline    GyroScaleFactor initialization process data master
33 @type      Completion return type
34 @param[in]    none
35 @threshold    none
36 @return      void
37 @retval      none
38 @trace
39 **************************************************************************** */
40 void DeadReckoningInitGyroScaleFactorDr(void) {  // LCOV_EXCL_START 8: dead code.
41     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
42     (void)memset(reinterpret_cast<void *>(&gst_gyroscalefactor), 0x00, sizeof(gst_gyroscalefactor));
43     gst_gyroscalefactor.ul_did    = VEHICLE_DID_DR_GYRO_SCALE_FACTOR;
44     gst_gyroscalefactor.us_size    = VEHICLE_DSIZE_GYRO_SCALE_FACTOR;
45     gst_gyroscalefactor.uc_rcv_flag  = DEADRECKONING_RCVFLAG_OFF;
46     gst_gyroscalefactor.dr_status    = 0U;              /* Not used */
47 }
48
49 /************************************************************************
50 @brief      GyroScaleFactor SET function
51 @outline    To update the master data GyroScaleFactor
52 @type      Completion return type
53 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  The pointer to incoming message data
54 @threshold    none
55 @return      u_int8
56 @retval      DEADRECKONING_EQ  :   No data changes
57 @retval      DEADRECKONING_NEQ  :   With data changes
58 @trace
59 *****************************************************************************/
60 u_int8 DeadReckoningSetGyroScaleFactorDr(const DEADRECKONING_DATA_MASTER *p_st_data) {
61     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
62     u_int8 uc_ret = DEADRECKONING_EQ;
63     DEADRECKONING_DATA_MASTER *p_st_master;
64
65     if (p_st_data == NULL) {
66         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "p_st_data == NULL\r\n");
67     } else {
68         p_st_master = &gst_gyroscalefactor;
69
70         /** Compare data master and received data */
71         uc_ret = DeadReckoningMemcmp(reinterpret_cast<void *>(&(p_st_master->uc_data)),
72             (const void *)(&(p_st_data->uc_data)), (size_t)(p_st_data->us_size));
73
74         /** Received data is set in the data master. */
75         p_st_master->ul_did    = p_st_data->ul_did;
76         p_st_master->us_size    = p_st_data->us_size;
77         p_st_master->uc_rcv_flag  = DEADRECKONING_RCVFLAG_ON;
78         p_st_master->dr_status    = 0U;              /* Not used */
79
80         (void)memcpy(reinterpret_cast<void *>(&(p_st_master->uc_data)),
81             (const void *)(&(p_st_data->uc_data) ), sizeof(p_st_master->uc_data));
82     }
83
84     return (uc_ret);
85 }
86
87 /************************************************************************
88 @brief      GyroScaleFactor GET function
89 @outline    Master Data provides the GyroScaleFactor
90 @type      Completion return type
91 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  Where to get a pointer to the data master
92 @threshold    none
93 @return      void
94 @retval      none
95 @trace
96 *****************************************************************************/
97 void DeadReckoningGetGyroScaleFactorDr(DEADRECKONING_DATA_MASTER *p_st_data) {
98     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
99     const DEADRECKONING_DATA_MASTER *p_st_master;
100
101     if (p_st_data == NULL) {
102         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "p_st_data == NULL\r\n");
103     } else {
104         p_st_master = &gst_gyroscalefactor;
105
106         /** Store the data master in the specified destination. */
107         p_st_data->ul_did    = p_st_master->ul_did;
108         p_st_data->us_size    = p_st_master->us_size;
109         p_st_data->uc_rcv_flag  = p_st_master->uc_rcv_flag;
110         p_st_data->dr_status  = p_st_master->dr_status;        /* Not used(Set DataMaster defaults) */
111         (void)memcpy(reinterpret_cast<void *>(&(p_st_data->uc_data)),
112             (const void *)(&(p_st_master->uc_data)), (size_t)p_st_master->us_size);
113     }
114 }
115 // LCOV_EXCL_STOP