2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /*******************************************************************************
18 * File name :DeadReckoning_DataMasterMain.cpp
20 * Subsystem name :Vehicle sensor process
21 * Program name :Vehicle SW Data Master
22 * Module configuration :DeadReckoningInitDataMaster() Guess Navigation Data Master Initialization Function
23 * :DeadReckoningSetDataMaster() Estimated Navigational Data Master SW Data Set Processing
24 * :DeadReckoningGetDataMaster() Estimated Navigational Data Master Get Processing
25 ******************************************************************************/
27 #include <vehicle_service/positioning_base_library.h>
28 #include "DeadReckoning_DataMaster.h"
30 /*************************************************/
32 /*************************************************/
36 /*******************************************************************************
37 * MODULE : DeadReckoningInitDataMaster
38 * ABSTRACT : Initialization of Guess Navigation Data Master
39 * FUNCTION : Initialize the estimated navigation data master
43 ******************************************************************************/
44 void DeadReckoningInitDataMaster(void) { // LCOV_EXCL_START 8: dead code.
45 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
46 /* Vehicle sensor data master initialization */
47 DeadReckoningInitLongitudeDr();
48 DeadReckoningInitLatitudeDr();
49 DeadReckoningInitAltitudeDr();
50 DeadReckoningInitSpeedDr();
51 DeadReckoningInitHeadingDr();
52 DeadReckoningInitSnsCounterDr();
53 DeadReckoningInitGyroOffsetDr();
54 DeadReckoningInitGyroScaleFactorDr();
55 DeadReckoningInitGyroScaleFactorLevelDr();
56 DeadReckoningInitSpeedPulseScaleFactorDr();
57 DeadReckoningInitSpeedPulseScaleFactorLevelDr();
60 /*******************************************************************************
61 * MODULE : DeadReckoning_SetDataMaster_Sub
62 * ABSTRACT : Estimated Navigational Data Master SW Data Set Processing
63 * FUNCTION : Set estimated navigation data
64 * ARGUMENT : *p_data : SW vehicle signal notification data
65 * : p_datamaster_set_n : Data Master Set Notification(Callback function)
68 ******************************************************************************/
69 void DeadReckoningSetDataMaster(const DEADRECKONING_DATA_MASTER *p_data,
70 PFUNC_DR_DMASTER_SET_N p_datamaster_set_n) {
71 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
74 static u_int8 gyro_parameter_chg_type = 0;
75 static u_int8 speedpulse_parameter_chg_type = 0;
77 /*------------------------------------------------------*/
78 /* Call the data set processing associated with the DID */
79 /* Call the data master set notification process */
80 /*------------------------------------------------------*/
81 switch (p_data->ul_did) {
82 case VEHICLE_DID_DR_LONGITUDE:
84 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
85 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
86 p_data->ul_did, p_data->us_size);
88 chg_type = DeadReckoningSetLongitudeDr(p_data);
89 /* Implementation of delivery process at LATITUDE updating timings */
90 /* Since the order of transmission (updating) at the main receiver is fixed, there is no problem. */
93 case VEHICLE_DID_DR_LATITUDE:
95 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
96 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
97 p_data->ul_did, p_data->us_size);
99 chg_type = DeadReckoningSetLatitudeDr(p_data);
100 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
103 case VEHICLE_DID_DR_ALTITUDE:
105 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
106 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
107 p_data->ul_did, p_data->us_size);
109 chg_type = DeadReckoningSetAltitudeDr(p_data);
110 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
113 case VEHICLE_DID_DR_SPEED:
115 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
116 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
117 p_data->ul_did, p_data->us_size);
119 chg_type = DeadReckoningSetSpeedDr(p_data);
120 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
123 case VEHICLE_DID_DR_HEADING:
125 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
126 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
127 p_data->ul_did, p_data->us_size);
129 chg_type = DeadReckoningSetHeadingDr(p_data);
130 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
133 case VEHICLE_DID_DR_SNS_COUNTER:
135 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
136 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
137 p_data->ul_did, p_data->us_size);
139 chg_type = DeadReckoningSetSnsCounterDr(p_data);
140 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
143 case VEHICLE_DID_DR_GYRO_OFFSET:
145 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
146 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
147 p_data->ul_did, p_data->us_size);
149 chg_type = DeadReckoningSetGyroOffsetDr(p_data);
150 /* Distribution processing not performed in this DID */
151 /* Delivery processing is executed when VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL is updated. */
152 /* The GyroParameter order is defined by DeadReckoning_RcvMsg(). */
153 if (chg_type == DEADRECKONING_NEQ) {
154 gyro_parameter_chg_type = DEADRECKONING_NEQ;
158 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR:
160 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
161 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
162 p_data->ul_did, p_data->us_size);
164 chg_type = DeadReckoningSetGyroScaleFactorDr(p_data);
165 /* Distribution processing not performed in this DID */
166 /* Delivery processing is executed when VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL is updated. */
167 /* The GyroParameter order is defined by DeadReckoning_RcvMsg(). */
168 if (chg_type == DEADRECKONING_NEQ) {
169 gyro_parameter_chg_type = DEADRECKONING_NEQ;
173 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
175 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
176 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
177 p_data->ul_did, p_data->us_size);
179 chg_type = DeadReckoningSetGyroScaleFactorLevelDr(p_data);
180 if (gyro_parameter_chg_type == DEADRECKONING_NEQ) {
181 chg_type = DEADRECKONING_NEQ;
182 gyro_parameter_chg_type = DEADRECKONING_EQ;
184 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
187 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR:
189 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
190 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
191 p_data->ul_did, p_data->us_size);
193 chg_type = DeadReckoningSetSpeedPulseScaleFactorDr(p_data);
194 /* Distribution processing not performed in this DID */
195 /* Delivery processing is executed when VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL is updated. */
196 /* The SpeedPulseParameter order is defined by DeadReckoning_RcvMsg(). */
197 if (chg_type == DEADRECKONING_NEQ) {
198 speedpulse_parameter_chg_type = DEADRECKONING_NEQ;
202 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
204 #if (DR_DEBUG == 1) /* PastModel002_DR_VEHICLE */
205 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
206 p_data->ul_did, p_data->us_size);
208 chg_type = DeadReckoningSetSpeedPulseScaleFactorLevelDr(p_data);
209 if (speedpulse_parameter_chg_type == DEADRECKONING_NEQ) {
210 chg_type = DEADRECKONING_NEQ;
211 speedpulse_parameter_chg_type = DEADRECKONING_EQ;
213 (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
221 /*******************************************************************************
222 * MODULE : DeadReckoningGetDataMaster
223 * ABSTRACT : Estimated Navigational Data Master Get Processing
224 * FUNCTION : Provide an estimated navigation data master
225 * ARGUMENT : ul_did : Data ID corresponding to the vehicle information
226 * : *p_data : Pointer to the data master provider
229 ******************************************************************************/
230 void DeadReckoningGetDataMaster(DID ul_did, DEADRECKONING_DATA_MASTER *p_data) {
231 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
232 /*------------------------------------------------------*/
233 /* Call the data Get processing associated with the DID */
234 /*------------------------------------------------------*/
236 /*------------------------------------------------------*/
237 /* Vehicle sensor data group */
238 /*------------------------------------------------------*/
239 case VEHICLE_DID_DR_LONGITUDE:
241 DeadReckoningGetLongitudeDr(p_data);
244 case VEHICLE_DID_DR_LATITUDE:
246 DeadReckoningGetLatitudeDr(p_data);
249 case VEHICLE_DID_DR_ALTITUDE:
251 DeadReckoningGetAltitudeDr(p_data);
254 case VEHICLE_DID_DR_SPEED:
256 DeadReckoningGetSpeedDr(p_data);
259 case VEHICLE_DID_DR_HEADING:
261 DeadReckoningGetHeadingDr(p_data);
264 case VEHICLE_DID_DR_SNS_COUNTER:
266 DeadReckoningGetSnsCounterDr(p_data);
269 case VEHICLE_DID_DR_GYRO_OFFSET:
271 DeadReckoningGetGyroOffsetDr(p_data);
274 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR:
276 DeadReckoningGetGyroScaleFactorDr(p_data);
279 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
281 DeadReckoningGetGyroScaleFactorLevelDr(p_data);
284 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR:
286 DeadReckoningGetSpeedPulseScaleFactorDr(p_data);
289 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
291 DeadReckoningGetSpeedPulseScaleFactorLevelDr(p_data);