Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / DeadReckoning_DeliveryCtrl.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 name    :DeadReckoning_DeliveryCtrl.cpp
19  *  System name    :GPF
20  *  Subsystem name  :Vehicle sensor process
21  *  Program name  :Vehicle Sensor Destination Management(
22  *  Module configuration  DeadReckoningInitDeliveryCtrlTbl()        Vehicle sensor delivery destination management table initialization function
23  *          DeadReckoningInitDeliveryCtrlTblMng()      Vehicle sensor delivery destination management table management area initialization function
24  *          DeadReckoningEntryDeliveryCtrl()        Vehicle sensor delivery destination management registration function
25  *          :DeadReckoningAddDeliveryCtrlTbl()        Vehicle sensor delivery destination management table addition function
26  *          :DeadReckoningUpdateDeliveryCtrlTbl()      Vehicle sensor delivery destination management table update function
27  *          :DeadReckoning_DeliveryEntry_Delete()      Vehicle sensor delivery destination management table deletion function
28  *          :DeadReckoningAddDeliveryCtrlTblMng()      Vehicle sensor delivery destination management table management addition function
29  *          :DeadReckoningUpdateDeliveryCtrlTblMng()    Vehicle sensor delivery destination management table management update function
30  *          :DeadReckoning_DeleteDeliveryCtrlTblMng_Touch()  Vehicle sensor delivery destination management table management deletion (touch panel) function
31  *          DeadReckoningMakeDeliveryPnoTbl()        Vehicle Sensor Destination PNO Table Creation Function
32  *          :DeadReckoningAddPnoTbl()            Vehicle Sensor Destination PNO Table Addition Function
33  *          :DeadReckoningDeliveryProc()          Vehicle Sensor Data Delivery Process
34  ******************************************************************************/
35
36 #include <vehicle_service/positioning_base_library.h>
37 #include "DeadReckoning_DeliveryCtrl.h"
38 #include "Vehicle_API.h"
39 #include "Vehicle_API_Dummy.h"
40 #include "Dead_Reckoning_Local_Api.h"
41
42 /*************************************************/
43 /*       Global variable            */
44 /*************************************************/
45 static  DEADRECKONING_DELIVERY_CTRL_TBL    g_delivery_dr_ctrltbl;
46 static  DEADRECKONING_DELIVERY_CTRL_TBL_MNG  g_delivery_dr_ctrltbl_mng;
47 static  DEADRECKONING_DELIVERY_PNO_TBL    g_delivery_dr_pnotbl;
48
49 /* Stored data count */
50 int32 g_delivery_dr_ctrl_num = 0;
51
52 /* PastModel002 support DR */
53 /*******************************************************************************
54 * MODULE   : DeadReckoningInitDeliveryCtrlTbl
55 * ABSTRACT  : Vehicle sensor delivery destination management table initialization function
56 * FUNCTION  : Delivery destination management table initialization processing
57 * ARGUMENT  : void
58 * NOTE    :
59 * RETURN   : void
60 ******************************************************************************/
61 void DeadReckoningInitDeliveryCtrlTbl(void) {  // LCOV_EXCL_START 8: dead code.
62     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
63     memset(&g_delivery_dr_ctrltbl, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL));
64 }
65
66 /*******************************************************************************
67 * MODULE   : DeadReckoningInitDeliveryCtrlTblMng
68 * ABSTRACT  : Vehicle sensor delivery destination management table management area initialization function
69 * FUNCTION  : Delivery destination management table management area initialization processing
70 * ARGUMENT  : void
71 * NOTE    :
72 * RETURN   : void
73 ******************************************************************************/
74 void DeadReckoningInitDeliveryCtrlTblMng(void) {
75     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
76     memset(&g_delivery_dr_ctrltbl_mng, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL_MNG));
77 }
78
79 /*******************************************************************************
80 * MODULE   : DeadReckoningEntryDeliveryCtrl
81 * ABSTRACT  : Vehicle sensor delivery destination management registration function
82 * FUNCTION  : Shipping management table,Update the shipping management table management.
83 * ARGUMENT  : p_st_delivery_entry  : Pointer to the delivery registration information
84 * NOTE    :
85 * RETURN   : VEHICLE_RET_NORMAL  :Successful registration
86 ******************************************************************************/
87 DEAD_RECKONING_RET_API DeadReckoningEntryDeliveryCtrl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
88     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
89     int32 i;
90     u_int8 uc_action_type  = DEADRECKONING_ACTION_TYPE_ADD;
91     int32 uc_did_flag;
92     DID ul_entry_did    = p_st_delivery_entry->data.did;
93     DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA  *p_st_existing_mng_data = NULL;
94     /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
95     DEAD_RECKONING_RET_API ret = DEAD_RECKONING_RET_NORMAL;
96
97     /* Check if the data ID exists. */
98     uc_did_flag = DeadReckoningCheckDid(ul_entry_did);
99     if (uc_did_flag == 0) {
100         ret =  DEADRECKONING_RET_ERROR_DID;  /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
101     }
102
103     /* Check the number of registered shipments. */
104     if ((ret == DEAD_RECKONING_RET_NORMAL) &&/* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
105             (g_delivery_dr_ctrltbl.us_num >= DEADRECKONING_DELIVERY_INFO_MAX)) {
106         /* Return the FULL of delivery registrations*/
107         ret =  DEADRECKONING_RET_ERROR_BUFFULL;  /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
108     }
109     /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
110     if (ret == DEAD_RECKONING_RET_NORMAL) {
111         /* By searching for the delivery registration of the relevant DID,Hold the address. */
112         for (i = 0; i < g_delivery_dr_ctrltbl_mng.us_num; i++) {
113             if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_entry_did) {
114                 uc_action_type = DEADRECKONING_ACTION_TYPE_UPDATE;
115                 p_st_existing_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i];
116             }
117         }
118
119         /* Add to the shipping management table.*/
120         DeadReckoningAddDeliveryCtrlTbl(p_st_delivery_entry);
121
122         /* Processing when updating existing data*/
123         if (uc_action_type == DEADRECKONING_ACTION_TYPE_UPDATE) {
124             /* Update the shipping management table.*/
125             DeadReckoningUpdateDeliveryCtrlTbl(p_st_existing_mng_data);
126
127             /* Update the shipping destination management table management information.*/
128             DeadReckoningUpdateDeliveryCtrlTblMng(p_st_existing_mng_data);
129         } else { /* Newly added processing*/
130             /* Add to the shipping management table management information.*/
131             DeadReckoningAddDeliveryCtrlTblMng(p_st_delivery_entry);
132         }
133     }
134     return ret; /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
135 }
136
137 /*******************************************************************************
138 * MODULE   : DeadReckoningAddDeliveryCtrlTbl
139 * ABSTRACT  : Vehicle sensor delivery destination management table addition function
140 * FUNCTION  : Add to the shipping management table.
141 * ARGUMENT  : *p_st_delivery_entry  : Pointer to the delivery registration information
142 * NOTE    :
143 * RETURN   : void
144 ******************************************************************************/
145 void DeadReckoningAddDeliveryCtrlTbl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
146     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
147     DEADRECKONING_DELIVERY_CTRL_TBL_DATA *p_st_ctrl_data;
148
149     p_st_ctrl_data = &g_delivery_dr_ctrltbl.st_ctrl_data[g_delivery_dr_ctrltbl.us_num];
150     p_st_ctrl_data->ul_did          = p_st_delivery_entry->data.did;
151     p_st_ctrl_data->us_pno          = p_st_delivery_entry->data.pno;
152     p_st_ctrl_data->uc_chg_type        = p_st_delivery_entry->data.delivery_timing;
153     p_st_ctrl_data->uc_ctrl_flg        = p_st_delivery_entry->data.ctrl_flg;
154     p_st_ctrl_data->us_link_idx        = DEADRECKONING_LINK_INDEX_END;
155     p_st_ctrl_data->uc_method        = DEADRECKONING_DELIVERY_METHOD_NORMAL;
156
157     g_delivery_dr_ctrltbl.us_num = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num + 1);
158 }
159
160 /*******************************************************************************
161 * MODULE   : DeadReckoningUpdateDeliveryCtrlTbl
162 * ABSTRACT  : Vehicle sensor delivery destination management table update function
163 * FUNCTION  : Update the shipping management table.
164 * ARGUMENT  : *p_st_existing_mng_data  : Pointer to the previous data information with the same data ID
165 * NOTE    :
166 * RETURN   : void
167 ******************************************************************************/
168 void DeadReckoningUpdateDeliveryCtrlTbl(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
169     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
170     /* Update Link Index Only.
171        For the index of the value of us_end_idx that matches the data ID of the distribution target management table management information
172        Make us_link_idx a registered index */
173     g_delivery_dr_ctrltbl.st_ctrl_data[p_st_existing_mng_data->us_end_idx].us_link_idx =
174         static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
175 }
176
177 /*******************************************************************************
178 * MODULE   : DeadReckoningAddDeliveryCtrlTblMng
179 * ABSTRACT  : Vehicle sensor delivery destination management table management addition function
180 * FUNCTION  : Add to the shipping management table management.
181 * ARGUMENT  : *p_st_delivery_entry  : Pointer to the delivery registration information
182 * NOTE    :
183 * RETURN   : void
184 ******************************************************************************/
185 void DeadReckoningAddDeliveryCtrlTblMng(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
186     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
187     DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_ctr_mng_data;
188
189     p_st_ctr_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[g_delivery_dr_ctrltbl_mng.us_num];
190     p_st_ctr_mng_data->ul_did    = p_st_delivery_entry->data.did;
191     p_st_ctr_mng_data->us_start_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
192     p_st_ctr_mng_data->us_end_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
193     p_st_ctr_mng_data->us_dlvry_entry_num++;
194     g_delivery_dr_ctrltbl_mng.us_num++;
195     g_delivery_dr_ctrl_num++;
196 }
197
198 /*******************************************************************************
199 * MODULE   : DeadReckoningUpdateDeliveryCtrlTblMng
200 * ABSTRACT  : Vehicle sensor delivery destination management table management update function
201 * FUNCTION  : Update the shipping management table management.
202 * ARGUMENT  : *p_st_existing_mng_data  : Pointer to the previous data information with the same data ID
203 * NOTE    :
204 * RETURN   : void
205 ******************************************************************************/
206 void DeadReckoningUpdateDeliveryCtrlTblMng(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
207     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
208     /*  Update only the end index and the number of registered shipping destinations. */
209     p_st_existing_mng_data->us_end_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
210     p_st_existing_mng_data->us_dlvry_entry_num++;
211 }
212
213 /*******************************************************************************
214 * MODULE   : DeadReckoningMakeDeliveryPnoTbl
215 * ABSTRACT  : Vehicle sensor delivery destination PNO table creation function
216 * FUNCTION  : Create the shipping destination PNO table
217 * ARGUMENT  : ul_did    Data ID
218 *         Change_type Delivery Trigger
219 * NOTE    :
220 * RETURN   : DEADRECKONING_DELIVERY_PNO_TBL* Pointer to the shipping PNO table
221 ******************************************************************************/
222 DEADRECKONING_DELIVERY_PNO_TBL* DeadReckoningMakeDeliveryPnoTbl(DID ul_did, u_int8 change_type) {
223     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
224     int32 i;
225     u_int16 us_index = 0;
226     u_int16 us_num = 0;
227
228     /* Get the start index and count of the corresponding data ID. */
229     for (i = 0; i < g_delivery_dr_ctrl_num; i++) {
230         /* Stores the information of the corresponding DID.. */
231         if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_did) {
232             us_index  = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_start_idx;
233             us_num  = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_dlvry_entry_num;
234             break;
235         }
236     }
237
238     /* Create a PNO list */
239     g_delivery_dr_pnotbl.us_num = 0;
240     if (change_type == DEADRECKONING_CHGTYPE_CHG) {
241         /* Processing when delivery timing is changed*/
242         for (i = 0; i < us_num; i++) {
243             /* Functionalization by Increasing Structure Members */
244             DeadReckoningAddPnoTbl(us_index);
245
246             us_index  = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
247         }
248     } else {
249         /* Processing when delivery timing is update */
250         for (i = 0; i < us_num; i++) {
251             if (DEADRECKONING_DELIVERY_TIMING_UPDATE  == g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_chg_type) {
252                 /* Functionalization by Increasing Structure Members */
253                 DeadReckoningAddPnoTbl(us_index);
254             }
255             us_index  = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
256         }
257     }
258     return (&g_delivery_dr_pnotbl);
259 }
260
261 /*******************************************************************************
262 * MODULE   : DeadReckoningAddPnoTbl
263 * ABSTRACT  : Vehicle Sensor Destination PNO Table Addition Function
264 * FUNCTION  : Add to the shipping PNO table.
265 * ARGUMENT  : us_index  : Index of the referenced destination management table
266 * NOTE    :
267 * RETURN   : void
268 ******************************************************************************/
269 void DeadReckoningAddPnoTbl(u_int16 us_index) {
270     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
271     u_int16  us_pno_tbl_idx;
272
273     us_pno_tbl_idx = g_delivery_dr_pnotbl.us_num;
274     g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_pno    = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_pno;
275     /* Save the relevant INDEX in the delivery control table */
276     g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_index    = us_index;
277     g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].uc_method =
278     g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_method;
279     g_delivery_dr_pnotbl.us_num++;
280 }
281
282 /*******************************************************************************
283 * MODULE   : DeadReckoningDeliveryProc
284 * ABSTRACT  : Vehicle Sensor Data Delivery Process
285 * FUNCTION  : Deliver data to a destination.
286 * ARGUMENT  : ul_did    :Data ID
287 *         uc_chg_type  :Delivery timing
288 *         uc_get_method  :Acquisition method
289 * NOTE    :
290 * RETURN   : void
291 ******************************************************************************/
292 void DeadReckoningDeliveryProc(DID ul_did, u_int8 uc_chg_type, u_int8 uc_get_method) {
293     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
294     int32                i;          /* Generic counters           */
295     DEADRECKONING_DATA_MASTER      st_master;      /* Data master of normal data      */
296
297
298     /* Defines the data master for each API. */
299     SENSORLOCATION_MSG_LONLATINFO_DAT  st_msg_lonlat_info;
300     SENSORLOCATION_MSG_ALTITUDEINFO_DAT  st_msg_altitude_info;
301     SENSORMOTION_MSG_SPEEDINFO_DAT    st_msg_speed_info;
302     SENSORMOTION_MSG_HEADINGINFO_DAT  st_msg_heading_info;
303
304
305     const DEADRECKONING_DELIVERY_PNO_TBL  *p_st_pno_tbl;          /* Vehicle Sensor Destination PNO Table Pointer  */
306
307     /* Initialization */
308     st_msg_lonlat_info.reserve[0]   = 0;
309     st_msg_lonlat_info.reserve[1]   = 0;
310     st_msg_lonlat_info.reserve[2]   = 0;
311     st_msg_altitude_info.reserve[0] = 0;
312     st_msg_altitude_info.reserve[1] = 0;
313     st_msg_altitude_info.reserve[2] = 0;
314     st_msg_speed_info.reserve       = 0;
315     st_msg_heading_info.reserve     = 0;
316
317     /* Obtain the shipping destination PNO */
318     p_st_pno_tbl =
319     reinterpret_cast<DEADRECKONING_DELIVERY_PNO_TBL*>(DeadReckoningMakeDeliveryPnoTbl(ul_did, uc_chg_type));
320
321     if ((p_st_pno_tbl->us_num) > 0) {
322         /* When there is a shipping destination PNO registration */
323         /* Vehicle sensor information notification transmission process */
324         for (i = 0; i < (p_st_pno_tbl->us_num); i++) {
325             /* Acquire the applicable data information from the data master..*/
326             DeadReckoningGetDataMaster(ul_did, &st_master);
327
328             /* Align data from the data master for API I/F */
329             switch (ul_did) {
330                     /* Describes the process for each DID. */
331                 case VEHICLE_DID_DR_LATITUDE:
332                 {
333                     /* Size storage(LONLAT)  */
334                     st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);
335
336                     /* DR status setting */
337                     st_msg_lonlat_info.dr_status = st_master.dr_status;
338
339                     /* The DR enable flag is set to enabled. */
340                     st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
341
342                     /* Set the Latitude */
343                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.latitude)),
344                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
345
346                     /* Obtain the data master Longitude */
347                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);
348
349                     /* Set the Longitude */
350                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.longitude)),
351                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
352
353                     /* Acquire data master SensorCnt */
354                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
355
356                     /* Set the SensorCnt */
357                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.sensor_cnt)),
358                         (const void *)(&( st_master.uc_data[0])), (size_t)(st_master.us_size));
359
360                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
361                                             p_st_pno_tbl->st_pno_data[i].us_pno,
362                                             CID_VEHICLE_SENSORLOCATION_LONLAT,
363                                             sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
364                                             (const void *)&st_msg_lonlat_info);
365                     break;
366                 }
367                 case VEHICLE_DID_DR_ALTITUDE:
368                 {
369                     /* Size storage(ALTITUDE)  */
370                     st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);
371
372                     /* The DR enable flag is set to enabled. */
373                     st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
374
375                     /* DR status setting */
376                     st_msg_altitude_info.dr_status = st_master.dr_status;
377
378
379                     /* Set the Altitude */
380                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.altitude)),
381                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
382
383                     /* Acquire data master SensorCnt */
384                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
385
386                     /* Set the SensorCnt */
387                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.sensor_cnt)),
388                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
389
390                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
391                                             p_st_pno_tbl->st_pno_data[i].us_pno,
392                                             CID_VEHICLE_SENSORLOCATION_ALTITUDE,
393                                             sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
394                                             (const void *)&st_msg_altitude_info);
395
396                     break;
397                 }
398                 case VEHICLE_DID_DR_SPEED:
399                 {
400                     /* Size storage(SPEED)  */
401                     st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);
402
403                     /* The DR enable flag is set to enabled. */
404                     st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
405
406                     /* DR status setting */
407                     st_msg_speed_info.dr_status = st_master.dr_status;
408
409
410                     /* Set the Speed */
411                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.speed)),
412                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
413
414                     /* Acquire data master SensorCnt */
415                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
416                     /* Set the SensorCnt */
417                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.sensor_cnt)),
418                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
419
420                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
421                                             p_st_pno_tbl->st_pno_data[i].us_pno,
422                                             CID_VEHICLE_SENSORMOTION_SPEED,
423                                             sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
424                                             (const void *)&st_msg_speed_info);
425                     break;
426                 }
427                 case VEHICLE_DID_DR_HEADING:
428                 {
429                     /* Size storage(HEADING)  */
430                     st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);
431
432                     /* The DR enable flag is set to enabled. */
433                     st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
434
435                     /* DR status setting */
436                     st_msg_heading_info.dr_status = st_master.dr_status;
437
438                     /* Set the Heading */
439                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
440                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
441
442                     /* Acquire data master SensorCnt */
443                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
444                     /* Set the SensorCnt */
445                     (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
446                         (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
447
448                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
449                                             p_st_pno_tbl->st_pno_data[i].us_pno,
450                                             CID_VEHICLE_SENSORMOTION_HEADING,
451                                             sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
452                                             (const void *)&st_msg_heading_info);
453                     break;
454                 }
455                 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
456                 {
457                     SENSORMOTION_MSG_GYROPARAMETERINFO_DAT  stMsgGyroParameterInfo;
458                     /* Initialization */
459                     stMsgGyroParameterInfo.reserve[0] = 0;
460                     stMsgGyroParameterInfo.reserve[1] = 0;
461
462                     /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master  */
463                     /* setup must be completed before data delivery of this DID         */
464                     /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing              */
465
466                     /* Size storage(GYROPARAMETER) */
467                     stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);
468
469                     /* GyroOffset acuisition/setting */
470                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);
471
472                     (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
473                                         reinterpret_cast<void *>(&(st_master.uc_data[0])),
474                                         sizeof(stMsgGyroParameterInfo.gyro_offset));
475
476                     /* GyroScaleFactor acuisition/setting */
477                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);
478
479                     (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
480                                         reinterpret_cast<void *>(&(st_master.uc_data[0])),
481                                         sizeof(stMsgGyroParameterInfo.gyro_scale_factor));
482
483                     /* GyroScaleFactorLevel acuisition/setting */
484                     DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);
485
486                     (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
487                                         reinterpret_cast<void *>(&(st_master.uc_data[0])),
488                                         sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));
489
490                     /* Data transmission */
491                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
492                                             p_st_pno_tbl->st_pno_data[i].us_pno,
493                                             CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
494                                             sizeof(stMsgGyroParameterInfo),
495                                             (const void *)&stMsgGyroParameterInfo);
496                 }
497                 break;
498                 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
499                 {
500                   SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT  stMsgSpeedPulseParameterInfo;
501
502                   /* Initialization */
503                   stMsgSpeedPulseParameterInfo.reserve[0] = 0;
504                   stMsgSpeedPulseParameterInfo.reserve[1] = 0;
505                   stMsgSpeedPulseParameterInfo.reserve[2] = 0;
506
507                   /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master  */
508                   /* setup must be completed before data delivery of this DID     */
509                   /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing              */
510
511                   /* Size storage(SPEEDPULSEPARAMETER) */
512                   stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);
513
514                   /* SpeedPulseScaleFactor acuisition/setting */
515                   DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);
516
517                   (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
518                                       reinterpret_cast<void *>(&(st_master.uc_data[0])),
519                                       sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));
520
521                   /* SpeedPulseScaleFactorLevel acuisition/setting */
522                   DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);
523
524                   (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
525                                       reinterpret_cast<void *>(&(st_master.uc_data[0])),
526                                       sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));
527
528                     /* Data transmission */
529                     (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
530                                             p_st_pno_tbl->st_pno_data[i].us_pno,
531                                             CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
532                                             sizeof(stMsgSpeedPulseParameterInfo),
533                                             (const void *)&stMsgSpeedPulseParameterInfo);
534                 }
535                 break;
536                 /* Other than the above */
537                 default:
538                     /* Do not edit. */
539                     break;
540             }
541         }
542     }
543 }
544
545 /*******************************************************************************
546  * MODULE    : DRManagerSndMsg
547  * ABSTRACT  : Message transmission processing
548  * FUNCTION  : Send a message to the specified PNO
549  * ARGUMENT  : us_pno_src      : Source PNO
550  *           : us_pno_dest    : Destination PNO
551  *           : us_cid      : Command ID
552  *           : us_msg_len      : Message data body length
553  *           : *p_msg_data    : Pointer to message data
554  * NOTE      :
555  * RETURN    : RET_NORMAL    : Normal completion
556  *           : RET_ERRNOTRDY  : Destination process is not wakeup
557  *           : RET_ERRMSGFULL  : Message queue overflows
558  *           : RET_ERRPARAM    : Buffer size error
559  ******************************************************************************/
560 RET_API  DRManagerSndMsg(PNO us_pno_src, PNO us_pno_dest, CID us_cid, u_int16 us_msg_len, const void *p_msg_data) {
561     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
562     DEADRECKONING_MSG_BUF    st_msg_buf;    /* message buffer */
563     T_APIMSG_MSGBUF_HEADER  *p_st_msg_hdr;    /* Pointer to the message header */
564     RET_API          l_ret_api;    /* Return value */
565
566     /* Message buffer initialization */
567     memset(reinterpret_cast<void *>(&st_msg_buf), 0, sizeof(DEADRECKONING_MSG_BUF));
568
569     /* Get pointer to send buffer */
570     p_st_msg_hdr = reinterpret_cast<T_APIMSG_MSGBUF_HEADER *>(reinterpret_cast<void *>(&st_msg_buf));
571
572     /*--------------------------------------------------------------*
573      *  Create message headers                  *
574      *--------------------------------------------------------------*/
575     p_st_msg_hdr->hdr.sndpno    = us_pno_src;    /* Source PNO */
576     p_st_msg_hdr->hdr.cid      = us_cid;    /* Command ID */
577     p_st_msg_hdr->hdr.msgbodysize  = us_msg_len;    /* Message data body length */
578
579     /*--------------------------------------------------------------*
580      *  Create message data                  *
581      *--------------------------------------------------------------*/
582     if ((0 != p_msg_data) && (0 != us_msg_len)) {
583         /* Set the message data */
584         memcpy(reinterpret_cast<void *>(st_msg_buf.data), p_msg_data, (size_t)us_msg_len);
585     }
586     /*--------------------------------------------------------------*
587      * Send messages                      *
588      *--------------------------------------------------------------*/
589     l_ret_api = _pb_SndMsg(us_pno_dest,
590                             (u_int16)(sizeof(T_APIMSG_MSGBUF_HEADER) + us_msg_len),
591                             reinterpret_cast<void *>(&st_msg_buf),
592                             0);
593     return (l_ret_api);
594 }
595
596
597 /*******************************************************************************
598 * MODULE    : DeadReckoningFirstDelivery
599 * ABSTRACT  : Vehicle Sensor Initial Data Delivery Process
600 * FUNCTION  : Deliver the initial data to the destination.
601 * ARGUMENT  : us_pno  :Addresses for delivery NO
602 *             ul_did  :Data ID
603 * NOTE      :
604 * RETURN    : void
605 ******************************************************************************/
606 void DeadReckoningFirstDelivery(PNO us_pno, DID ul_did) {
607     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
608     DEADRECKONING_DATA_MASTER      st_master;      /* Data master of normal data      */
609
610     /* Defines the data master for each API. */
611     SENSORLOCATION_MSG_LONLATINFO_DAT  st_msg_lonlat_info;
612     SENSORLOCATION_MSG_ALTITUDEINFO_DAT  st_msg_altitude_info;
613     SENSORMOTION_MSG_SPEEDINFO_DAT    st_msg_speed_info;
614     SENSORMOTION_MSG_HEADINGINFO_DAT  st_msg_heading_info;
615
616     /* Initialization */
617     st_msg_lonlat_info.reserve[0] = 0;
618     st_msg_lonlat_info.reserve[1] = 0;
619     st_msg_lonlat_info.reserve[2] = 0;
620     st_msg_altitude_info.reserve[0] = 0;
621     st_msg_altitude_info.reserve[1] = 0;
622     st_msg_altitude_info.reserve[2] = 0;
623     st_msg_speed_info.reserve = 0;
624     st_msg_heading_info.reserve = 0;
625
626     /* Align data from the data master for API I/F */
627     switch (ul_did) {
628             /* Describes the process for each DID. */
629         case VEHICLE_DID_DR_LATITUDE:
630         {
631             DeadReckoningGetDataMaster(ul_did, &st_master);
632
633             /* Size storage(LONLAT)  */
634             st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);
635
636             /* DR status setting */
637             st_msg_lonlat_info.dr_status = st_master.dr_status;
638
639             /* The DR enable flag is set to enabled. */
640             st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
641
642             /* Set the Latitude */
643             memcpy(&(st_msg_lonlat_info.latitude), &(st_master.uc_data[0]), st_master.us_size);
644
645             /* Obtain the data master Longitude */
646             DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);
647
648             /* Set the Longitude */
649             memcpy(&(st_msg_lonlat_info.longitude), &(st_master.uc_data[0]), st_master.us_size);
650
651             /* Acquire data master SensorCnt */
652             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
653
654             /* Set the SensorCnt */
655             memcpy(&(st_msg_lonlat_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
656
657             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
658                                     us_pno,
659                                     CID_VEHICLE_SENSORLOCATION_LONLAT,
660                                     sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
661                                     (const void *)&st_msg_lonlat_info);
662             break;
663         }
664         case VEHICLE_DID_DR_ALTITUDE:
665         {
666             DeadReckoningGetDataMaster(ul_did, &st_master);
667
668             /* Size storage(ALTITUDE)  */
669             st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);
670
671             /* The DR enable flag is set to enabled. */
672             st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
673
674             /* DR status setting */
675             st_msg_altitude_info.dr_status = st_master.dr_status;
676
677
678             /* Set the Altitude */
679             memcpy(&(st_msg_altitude_info.altitude), &(st_master.uc_data[0]), st_master.us_size);
680
681             /* Acquire data master SensorCnt */
682             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
683
684             /* Set the SensorCnt */
685             memcpy(&(st_msg_altitude_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
686
687             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
688                                     us_pno,
689                                     CID_VEHICLE_SENSORLOCATION_ALTITUDE,
690                                     sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
691                                     (const void *)&st_msg_altitude_info);
692
693             break;
694         }
695         case VEHICLE_DID_DR_SPEED:
696         {
697             DeadReckoningGetDataMaster(ul_did, &st_master);
698
699             /* Size storage(SPEED)  */
700             st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);
701
702             /* The DR enable flag is set to enabled. */
703             st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
704
705             /* DR status setting */
706             st_msg_speed_info.dr_status = st_master.dr_status;
707
708
709             /* Set the Speed */
710             memcpy(&(st_msg_speed_info.speed), &(st_master.uc_data[0]), st_master.us_size);
711
712             /* Acquire data master SensorCnt */
713             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
714             /* Set the SensorCnt */
715             memcpy(&(st_msg_speed_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
716
717             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
718                                     us_pno,
719                                     CID_VEHICLE_SENSORMOTION_SPEED,
720                                     sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
721                                     (const void *)&st_msg_speed_info);
722             break;
723         }
724         case VEHICLE_DID_DR_HEADING:
725         {
726             DeadReckoningGetDataMaster(ul_did, &st_master);
727
728             /* Size storage(HEADING)  */
729             st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);
730
731             /* The DR enable flag is set to enabled. */
732             st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
733
734             /* DR status setting */
735             st_msg_heading_info.dr_status = st_master.dr_status;
736
737
738             /* Set the Heading */
739             (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
740              (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
741
742             /* Acquire data master SensorCnt */
743             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
744             /* Set the SensorCnt */
745             (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
746                 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
747
748             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
749                                     us_pno,
750                                     CID_VEHICLE_SENSORMOTION_HEADING,
751                                     sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
752                                     (const void *)&st_msg_heading_info);
753             break;
754         }
755         case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
756         {
757             SENSORMOTION_MSG_GYROPARAMETERINFO_DAT  stMsgGyroParameterInfo;
758
759             /* Initialization */
760             stMsgGyroParameterInfo.reserve[0] = 0;
761             stMsgGyroParameterInfo.reserve[1] = 0;
762
763             /* Size storage(GYROPARAMETER) */
764             stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);
765
766             /* GyroOffset acuisition/setting */
767             DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);
768
769             (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
770                                 reinterpret_cast<void *>(&(st_master.uc_data[0])),
771                                 sizeof( stMsgGyroParameterInfo.gyro_offset));
772
773             /* GyroScaleFactor acuisition/setting */
774             DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);
775
776             (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
777                                 reinterpret_cast<void *>(&(st_master.uc_data[0])),
778                                 sizeof(stMsgGyroParameterInfo.gyro_scale_factor));
779
780             /* GyroScaleFactorLevel acuisition/setting */
781             DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);
782
783             (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
784                                 reinterpret_cast<void *>(&(st_master.uc_data[0])),
785                                 sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));
786
787             /* Data transmission */
788             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
789                                     us_pno,
790                                     CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
791                                     sizeof(stMsgGyroParameterInfo),
792                                     (const void *)&stMsgGyroParameterInfo);
793         }
794         break;
795         case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
796         {
797             SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT  stMsgSpeedPulseParameterInfo;
798
799             /* Initialization */
800             stMsgSpeedPulseParameterInfo.reserve[0] = 0;
801             stMsgSpeedPulseParameterInfo.reserve[1] = 0;
802             stMsgSpeedPulseParameterInfo.reserve[2] = 0;
803
804             /* Size storage(SPEEDPULSEPARAMETER) */
805             stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);
806
807             /* SpeedPulseScaleFactor acuisition/setting */
808             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);
809
810             (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
811                                 reinterpret_cast<void *>(&(st_master.uc_data[0])),
812                                 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));
813
814             /* SpeedPulseScaleFactorLevel acuisition/setting */
815             DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);
816
817             (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
818                                 reinterpret_cast<void *>(&(st_master.uc_data[0])),
819                                 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));
820
821             /* Data transmission */
822             (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
823                                     us_pno,
824                                     CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
825                                     sizeof(stMsgSpeedPulseParameterInfo),
826                                     (const void *)&stMsgSpeedPulseParameterInfo);
827         }
828         break;
829         /* Other than the above */
830         default:
831             /* Do not edit. */
832             break;
833     }
834 }
835 // LCOV_EXCL_STOP