Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / DeadReckoning_Did_SpeedPulseScaleFactorLevel_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_SpeedPulseScaleFactorLevel_dr.cpp
19 @detail      DeadReckoning data Master(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL)
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_speedpulsescalefactor_level;    // NOLINT(readability/nolint)
29
30 /************************************************************************
31 @brief      SpeedPulseScaleFactorLevel initialization function
32 @outline    SpeedPulseScaleFactorLevel 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 DeadReckoningInitSpeedPulseScaleFactorLevelDr(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_speedpulsescalefactor_level), 0x00,
43         sizeof(gst_speedpulsescalefactor_level));
44     gst_speedpulsescalefactor_level.ul_did      = VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL;
45     gst_speedpulsescalefactor_level.us_size    = VEHICLE_DSIZE_SPEED_PULSE_SCALE_FACTOR_LEVEL;
46     gst_speedpulsescalefactor_level.uc_rcv_flag    = DEADRECKONING_RCVFLAG_OFF;
47     gst_speedpulsescalefactor_level.dr_status    = 0U;              /* Not used */
48 }
49
50 /************************************************************************
51 @brief      SpeedPulseScaleFactorLevel SET function
52 @outline    To update the master data SpeedPulseScaleFactorLevel
53 @type      Completion return type
54 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  The pointer to incoming message data
55 @threshold    none
56 @return      u_int8
57 @retval      DEADRECKONING_EQ  :   No data changes
58 @retval      DEADRECKONING_NEQ  :   With data changes
59 @trace
60 *****************************************************************************/
61 u_int8 DeadReckoningSetSpeedPulseScaleFactorLevelDr(const DEADRECKONING_DATA_MASTER *p_st_data) {
62     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
63     u_int8 uc_ret = DEADRECKONING_EQ;
64     DEADRECKONING_DATA_MASTER *p_st_master;
65
66     if (p_st_data == NULL) {
67         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "p_st_data == NULL\r\n");
68     } else {
69         p_st_master = &gst_speedpulsescalefactor_level;
70
71         /** Compare data master and received data */
72         uc_ret = DeadReckoningMemcmp(reinterpret_cast<void *>(&(p_st_master->uc_data)),
73          (const void *)(&(p_st_data->uc_data)), (size_t)(p_st_data->us_size));
74
75         /** Received data is set in the data master. */
76         p_st_master->ul_did    = p_st_data->ul_did;
77         p_st_master->us_size    = p_st_data->us_size;
78         p_st_master->uc_rcv_flag  = DEADRECKONING_RCVFLAG_ON;
79         p_st_master->dr_status    = 0U;              /* Not used */
80
81         (void)memcpy(reinterpret_cast<void *>(&(p_st_master->uc_data)),
82             (const void *)(&(p_st_data->uc_data)), sizeof(p_st_master->uc_data));
83     }
84
85     return (uc_ret);
86 }
87
88 /************************************************************************
89 @brief      SpeedPulseScaleFactorLevel GET function
90 @outline    Master Data provides the SpeedPulseScaleFactorLevel
91 @type      Completion return type
92 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  Where to get a pointer to the data master
93 @threshold    none
94 @return      void
95 @retval      none
96 @trace
97 *****************************************************************************/
98 void DeadReckoningGetSpeedPulseScaleFactorLevelDr(DEADRECKONING_DATA_MASTER *p_st_data) {
99     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
100     const DEADRECKONING_DATA_MASTER *p_st_master;
101
102     if (p_st_data == NULL) {
103         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "p_st_data == NULL\r\n");
104     } else {
105         p_st_master = &gst_speedpulsescalefactor_level;
106
107         /** Store the data master in the specified destination. */
108         p_st_data->ul_did    = p_st_master->ul_did;
109         p_st_data->us_size    = p_st_master->us_size;
110         p_st_data->uc_rcv_flag  = p_st_master->uc_rcv_flag;
111         p_st_data->dr_status  = p_st_master->dr_status;        /* Not used(Set DataMaster defaults) */
112         (void)memcpy(reinterpret_cast<void *>(&(p_st_data->uc_data)),
113             (const void *)(&(p_st_master->uc_data)), (size_t)p_st_master->us_size);
114     }
115 }
116 // LCOV_EXCL_STOP