summaryrefslogtreecommitdiffstats
path: root/positioning/server/src/Sensor/DeadReckoning_DeliveryCtrl.cpp
blob: 781c11d64a9025c2aabfe8fd1c29486e8d43cf94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
/*
 * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*******************************************************************************
 *  File name    :DeadReckoning_DeliveryCtrl.cpp
 *  System name    :GPF
 *  Subsystem name  :Vehicle sensor process
 *  Program name  :Vehicle Sensor Destination Management(
 *  Module configuration  DeadReckoningInitDeliveryCtrlTbl()        Vehicle sensor delivery destination management table initialization function
 *          DeadReckoningInitDeliveryCtrlTblMng()      Vehicle sensor delivery destination management table management area initialization function
 *          DeadReckoningEntryDeliveryCtrl()        Vehicle sensor delivery destination management registration function
 *          :DeadReckoningAddDeliveryCtrlTbl()        Vehicle sensor delivery destination management table addition function
 *          :DeadReckoningUpdateDeliveryCtrlTbl()      Vehicle sensor delivery destination management table update function
 *          :DeadReckoning_DeliveryEntry_Delete()      Vehicle sensor delivery destination management table deletion function
 *          :DeadReckoningAddDeliveryCtrlTblMng()      Vehicle sensor delivery destination management table management addition function
 *          :DeadReckoningUpdateDeliveryCtrlTblMng()    Vehicle sensor delivery destination management table management update function
 *          :DeadReckoning_DeleteDeliveryCtrlTblMng_Touch()  Vehicle sensor delivery destination management table management deletion (touch panel) function
 *          DeadReckoningMakeDeliveryPnoTbl()        Vehicle Sensor Destination PNO Table Creation Function
 *          :DeadReckoningAddPnoTbl()            Vehicle Sensor Destination PNO Table Addition Function
 *          :DeadReckoningDeliveryProc()          Vehicle Sensor Data Delivery Process
 ******************************************************************************/

#include <vehicle_service/positioning_base_library.h>
#include "DeadReckoning_DeliveryCtrl.h"
#include "Vehicle_API.h"
#include "Vehicle_API_Dummy.h"
#include "Dead_Reckoning_Local_Api.h"

/*************************************************/
/*       Global variable            */
/*************************************************/
static  DEADRECKONING_DELIVERY_CTRL_TBL    g_delivery_dr_ctrltbl;
static  DEADRECKONING_DELIVERY_CTRL_TBL_MNG  g_delivery_dr_ctrltbl_mng;
static  DEADRECKONING_DELIVERY_PNO_TBL    g_delivery_dr_pnotbl;

/* Stored data count */
int32 g_delivery_dr_ctrl_num = 0;

/* PastModel002 support DR */
/*******************************************************************************
* MODULE   : DeadReckoningInitDeliveryCtrlTbl
* ABSTRACT  : Vehicle sensor delivery destination management table initialization function
* FUNCTION  : Delivery destination management table initialization processing
* ARGUMENT  : void
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningInitDeliveryCtrlTbl(void) {  // LCOV_EXCL_START 8: dead code.
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    memset(&g_delivery_dr_ctrltbl, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL));
}

/*******************************************************************************
* MODULE   : DeadReckoningInitDeliveryCtrlTblMng
* ABSTRACT  : Vehicle sensor delivery destination management table management area initialization function
* FUNCTION  : Delivery destination management table management area initialization processing
* ARGUMENT  : void
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningInitDeliveryCtrlTblMng(void) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    memset(&g_delivery_dr_ctrltbl_mng, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL_MNG));
}

/*******************************************************************************
* MODULE   : DeadReckoningEntryDeliveryCtrl
* ABSTRACT  : Vehicle sensor delivery destination management registration function
* FUNCTION  : Shipping management table,Update the shipping management table management.
* ARGUMENT  : p_st_delivery_entry  : Pointer to the delivery registration information
* NOTE    :
* RETURN   : VEHICLE_RET_NORMAL  :Successful registration
******************************************************************************/
DEAD_RECKONING_RET_API DeadReckoningEntryDeliveryCtrl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    int32 i;
    u_int8 uc_action_type  = DEADRECKONING_ACTION_TYPE_ADD;
    int32 uc_did_flag;
    DID ul_entry_did    = p_st_delivery_entry->data.did;
    DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA  *p_st_existing_mng_data = NULL;
    /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
    DEAD_RECKONING_RET_API ret = DEAD_RECKONING_RET_NORMAL;

    /* Check if the data ID exists. */
    uc_did_flag = DeadReckoningCheckDid(ul_entry_did);
    if (uc_did_flag == 0) {
        ret =  DEADRECKONING_RET_ERROR_DID;  /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
    }

    /* Check the number of registered shipments. */
    if ((ret == DEAD_RECKONING_RET_NORMAL) &&/* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
            (g_delivery_dr_ctrltbl.us_num >= DEADRECKONING_DELIVERY_INFO_MAX)) {
        /* Return the FULL of delivery registrations*/
        ret =  DEADRECKONING_RET_ERROR_BUFFULL;  /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
    }
    /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
    if (ret == DEAD_RECKONING_RET_NORMAL) {
        /* By searching for the delivery registration of the relevant DID,Hold the address. */
        for (i = 0; i < g_delivery_dr_ctrltbl_mng.us_num; i++) {
            if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_entry_did) {
                uc_action_type = DEADRECKONING_ACTION_TYPE_UPDATE;
                p_st_existing_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i];
            }
        }

        /* Add to the shipping management table.*/
        DeadReckoningAddDeliveryCtrlTbl(p_st_delivery_entry);

        /* Processing when updating existing data*/
        if (uc_action_type == DEADRECKONING_ACTION_TYPE_UPDATE) {
            /* Update the shipping management table.*/
            DeadReckoningUpdateDeliveryCtrlTbl(p_st_existing_mng_data);

            /* Update the shipping destination management table management information.*/
            DeadReckoningUpdateDeliveryCtrlTblMng(p_st_existing_mng_data);
        } else { /* Newly added processing*/
            /* Add to the shipping management table management information.*/
            DeadReckoningAddDeliveryCtrlTblMng(p_st_delivery_entry);
        }
    }
    return ret; /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
}

/*******************************************************************************
* MODULE   : DeadReckoningAddDeliveryCtrlTbl
* ABSTRACT  : Vehicle sensor delivery destination management table addition function
* FUNCTION  : Add to the shipping management table.
* ARGUMENT  : *p_st_delivery_entry  : Pointer to the delivery registration information
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningAddDeliveryCtrlTbl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    DEADRECKONING_DELIVERY_CTRL_TBL_DATA *p_st_ctrl_data;

    p_st_ctrl_data = &g_delivery_dr_ctrltbl.st_ctrl_data[g_delivery_dr_ctrltbl.us_num];
    p_st_ctrl_data->ul_did          = p_st_delivery_entry->data.did;
    p_st_ctrl_data->us_pno          = p_st_delivery_entry->data.pno;
    p_st_ctrl_data->uc_chg_type        = p_st_delivery_entry->data.delivery_timing;
    p_st_ctrl_data->uc_ctrl_flg        = p_st_delivery_entry->data.ctrl_flg;
    p_st_ctrl_data->us_link_idx        = DEADRECKONING_LINK_INDEX_END;
    p_st_ctrl_data->uc_method        = DEADRECKONING_DELIVERY_METHOD_NORMAL;

    g_delivery_dr_ctrltbl.us_num = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num + 1);
}

/*******************************************************************************
* MODULE   : DeadReckoningUpdateDeliveryCtrlTbl
* ABSTRACT  : Vehicle sensor delivery destination management table update function
* FUNCTION  : Update the shipping management table.
* ARGUMENT  : *p_st_existing_mng_data  : Pointer to the previous data information with the same data ID
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningUpdateDeliveryCtrlTbl(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    /* Update Link Index Only.
       For the index of the value of us_end_idx that matches the data ID of the distribution target management table management information
       Make us_link_idx a registered index */
    g_delivery_dr_ctrltbl.st_ctrl_data[p_st_existing_mng_data->us_end_idx].us_link_idx =
        static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
}

/*******************************************************************************
* MODULE   : DeadReckoningAddDeliveryCtrlTblMng
* ABSTRACT  : Vehicle sensor delivery destination management table management addition function
* FUNCTION  : Add to the shipping management table management.
* ARGUMENT  : *p_st_delivery_entry  : Pointer to the delivery registration information
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningAddDeliveryCtrlTblMng(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_ctr_mng_data;

    p_st_ctr_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[g_delivery_dr_ctrltbl_mng.us_num];
    p_st_ctr_mng_data->ul_did    = p_st_delivery_entry->data.did;
    p_st_ctr_mng_data->us_start_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
    p_st_ctr_mng_data->us_end_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
    p_st_ctr_mng_data->us_dlvry_entry_num++;
    g_delivery_dr_ctrltbl_mng.us_num++;
    g_delivery_dr_ctrl_num++;
}

/*******************************************************************************
* MODULE   : DeadReckoningUpdateDeliveryCtrlTblMng
* ABSTRACT  : Vehicle sensor delivery destination management table management update function
* FUNCTION  : Update the shipping management table management.
* ARGUMENT  : *p_st_existing_mng_data  : Pointer to the previous data information with the same data ID
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningUpdateDeliveryCtrlTblMng(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    /*  Update only the end index and the number of registered shipping destinations. */
    p_st_existing_mng_data->us_end_idx  = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
    p_st_existing_mng_data->us_dlvry_entry_num++;
}

/*******************************************************************************
* MODULE   : DeadReckoningMakeDeliveryPnoTbl
* ABSTRACT  : Vehicle sensor delivery destination PNO table creation function
* FUNCTION  : Create the shipping destination PNO table
* ARGUMENT  : ul_did    Data ID
*         Change_type Delivery Trigger
* NOTE    :
* RETURN   : DEADRECKONING_DELIVERY_PNO_TBL* Pointer to the shipping PNO table
******************************************************************************/
DEADRECKONING_DELIVERY_PNO_TBL* DeadReckoningMakeDeliveryPnoTbl(DID ul_did, u_int8 change_type) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    int32 i;
    u_int16 us_index = 0;
    u_int16 us_num = 0;

    /* Get the start index and count of the corresponding data ID. */
    for (i = 0; i < g_delivery_dr_ctrl_num; i++) {
        /* Stores the information of the corresponding DID.. */
        if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_did) {
            us_index  = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_start_idx;
            us_num  = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_dlvry_entry_num;
            break;
        }
    }

    /* Create a PNO list */
    g_delivery_dr_pnotbl.us_num = 0;
    if (change_type == DEADRECKONING_CHGTYPE_CHG) {
        /* Processing when delivery timing is changed*/
        for (i = 0; i < us_num; i++) {
            /* Functionalization by Increasing Structure Members */
            DeadReckoningAddPnoTbl(us_index);

            us_index  = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
        }
    } else {
        /* Processing when delivery timing is update */
        for (i = 0; i < us_num; i++) {
            if (DEADRECKONING_DELIVERY_TIMING_UPDATE  == g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_chg_type) {
                /* Functionalization by Increasing Structure Members */
                DeadReckoningAddPnoTbl(us_index);
            }
            us_index  = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
        }
    }
    return (&g_delivery_dr_pnotbl);
}

/*******************************************************************************
* MODULE   : DeadReckoningAddPnoTbl
* ABSTRACT  : Vehicle Sensor Destination PNO Table Addition Function
* FUNCTION  : Add to the shipping PNO table.
* ARGUMENT  : us_index  : Index of the referenced destination management table
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningAddPnoTbl(u_int16 us_index) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    u_int16  us_pno_tbl_idx;

    us_pno_tbl_idx = g_delivery_dr_pnotbl.us_num;
    g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_pno    = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_pno;
    /* Save the relevant INDEX in the delivery control table */
    g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_index    = us_index;
    g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].uc_method =
    g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_method;
    g_delivery_dr_pnotbl.us_num++;
}

/*******************************************************************************
* MODULE   : DeadReckoningDeliveryProc
* ABSTRACT  : Vehicle Sensor Data Delivery Process
* FUNCTION  : Deliver data to a destination.
* ARGUMENT  : ul_did    :Data ID
*         uc_chg_type  :Delivery timing
*         uc_get_method  :Acquisition method
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningDeliveryProc(DID ul_did, u_int8 uc_chg_type, u_int8 uc_get_method) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    int32                i;          /* Generic counters           */
    DEADRECKONING_DATA_MASTER      st_master;      /* Data master of normal data      */


    /* Defines the data master for each API. */
    SENSORLOCATION_MSG_LONLATINFO_DAT  st_msg_lonlat_info;
    SENSORLOCATION_MSG_ALTITUDEINFO_DAT  st_msg_altitude_info;
    SENSORMOTION_MSG_SPEEDINFO_DAT    st_msg_speed_info;
    SENSORMOTION_MSG_HEADINGINFO_DAT  st_msg_heading_info;


    const DEADRECKONING_DELIVERY_PNO_TBL  *p_st_pno_tbl;          /* Vehicle Sensor Destination PNO Table Pointer  */

    /* Initialization */
    st_msg_lonlat_info.reserve[0]   = 0;
    st_msg_lonlat_info.reserve[1]   = 0;
    st_msg_lonlat_info.reserve[2]   = 0;
    st_msg_altitude_info.reserve[0] = 0;
    st_msg_altitude_info.reserve[1] = 0;
    st_msg_altitude_info.reserve[2] = 0;
    st_msg_speed_info.reserve       = 0;
    st_msg_heading_info.reserve     = 0;

    /* Obtain the shipping destination PNO */
    p_st_pno_tbl =
    reinterpret_cast<DEADRECKONING_DELIVERY_PNO_TBL*>(DeadReckoningMakeDeliveryPnoTbl(ul_did, uc_chg_type));

    if ((p_st_pno_tbl->us_num) > 0) {
        /* When there is a shipping destination PNO registration */
        /* Vehicle sensor information notification transmission process */
        for (i = 0; i < (p_st_pno_tbl->us_num); i++) {
            /* Acquire the applicable data information from the data master..*/
            DeadReckoningGetDataMaster(ul_did, &st_master);

            /* Align data from the data master for API I/F */
            switch (ul_did) {
                    /* Describes the process for each DID. */
                case VEHICLE_DID_DR_LATITUDE:
                {
                    /* Size storage(LONLAT)  */
                    st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);

                    /* DR status setting */
                    st_msg_lonlat_info.dr_status = st_master.dr_status;

                    /* The DR enable flag is set to enabled. */
                    st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;

                    /* Set the Latitude */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.latitude)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    /* Obtain the data master Longitude */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);

                    /* Set the Longitude */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.longitude)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    /* Acquire data master SensorCnt */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);

                    /* Set the SensorCnt */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.sensor_cnt)),
                        (const void *)(&( st_master.uc_data[0])), (size_t)(st_master.us_size));

                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORLOCATION_LONLAT,
                                            sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
                                            (const void *)&st_msg_lonlat_info);
                    break;
                }
                case VEHICLE_DID_DR_ALTITUDE:
                {
                    /* Size storage(ALTITUDE)  */
                    st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);

                    /* The DR enable flag is set to enabled. */
                    st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;

                    /* DR status setting */
                    st_msg_altitude_info.dr_status = st_master.dr_status;


                    /* Set the Altitude */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.altitude)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    /* Acquire data master SensorCnt */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);

                    /* Set the SensorCnt */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.sensor_cnt)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORLOCATION_ALTITUDE,
                                            sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
                                            (const void *)&st_msg_altitude_info);

                    break;
                }
                case VEHICLE_DID_DR_SPEED:
                {
                    /* Size storage(SPEED)  */
                    st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);

                    /* The DR enable flag is set to enabled. */
                    st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;

                    /* DR status setting */
                    st_msg_speed_info.dr_status = st_master.dr_status;


                    /* Set the Speed */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.speed)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    /* Acquire data master SensorCnt */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
                    /* Set the SensorCnt */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.sensor_cnt)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORMOTION_SPEED,
                                            sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
                                            (const void *)&st_msg_speed_info);
                    break;
                }
                case VEHICLE_DID_DR_HEADING:
                {
                    /* Size storage(HEADING)  */
                    st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);

                    /* The DR enable flag is set to enabled. */
                    st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;

                    /* DR status setting */
                    st_msg_heading_info.dr_status = st_master.dr_status;

                    /* Set the Heading */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    /* Acquire data master SensorCnt */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
                    /* Set the SensorCnt */
                    (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
                        (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORMOTION_HEADING,
                                            sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
                                            (const void *)&st_msg_heading_info);
                    break;
                }
                case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
                {
                    SENSORMOTION_MSG_GYROPARAMETERINFO_DAT  stMsgGyroParameterInfo;
                    /* Initialization */
                    stMsgGyroParameterInfo.reserve[0] = 0;
                    stMsgGyroParameterInfo.reserve[1] = 0;

                    /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master  */
                    /* setup must be completed before data delivery of this DID         */
                    /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing              */

                    /* Size storage(GYROPARAMETER) */
                    stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);

                    /* GyroOffset acuisition/setting */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);

                    (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
                                        reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                        sizeof(stMsgGyroParameterInfo.gyro_offset));

                    /* GyroScaleFactor acuisition/setting */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);

                    (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
                                        reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                        sizeof(stMsgGyroParameterInfo.gyro_scale_factor));

                    /* GyroScaleFactorLevel acuisition/setting */
                    DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);

                    (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
                                        reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                        sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));

                    /* Data transmission */
                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
                                            sizeof(stMsgGyroParameterInfo),
                                            (const void *)&stMsgGyroParameterInfo);
                }
                break;
                case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
                {
                  SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT  stMsgSpeedPulseParameterInfo;

                  /* Initialization */
                  stMsgSpeedPulseParameterInfo.reserve[0] = 0;
                  stMsgSpeedPulseParameterInfo.reserve[1] = 0;
                  stMsgSpeedPulseParameterInfo.reserve[2] = 0;

                  /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master  */
                  /* setup must be completed before data delivery of this DID     */
                  /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing              */

                  /* Size storage(SPEEDPULSEPARAMETER) */
                  stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);

                  /* SpeedPulseScaleFactor acuisition/setting */
                  DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);

                  (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
                                      reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                      sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));

                  /* SpeedPulseScaleFactorLevel acuisition/setting */
                  DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);

                  (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
                                      reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                      sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));

                    /* Data transmission */
                    (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                            p_st_pno_tbl->st_pno_data[i].us_pno,
                                            CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
                                            sizeof(stMsgSpeedPulseParameterInfo),
                                            (const void *)&stMsgSpeedPulseParameterInfo);
                }
                break;
                /* Other than the above */
                default:
                    /* Do not edit. */
                    break;
            }
        }
    }
}

/*******************************************************************************
 * MODULE    : DRManagerSndMsg
 * ABSTRACT  : Message transmission processing
 * FUNCTION  : Send a message to the specified PNO
 * ARGUMENT  : us_pno_src      : Source PNO
 *           : us_pno_dest    : Destination PNO
 *           : us_cid      : Command ID
 *           : us_msg_len      : Message data body length
 *           : *p_msg_data    : Pointer to message data
 * NOTE      :
 * RETURN    : RET_NORMAL    : Normal completion
 *           : RET_ERRNOTRDY  : Destination process is not wakeup
 *           : RET_ERRMSGFULL  : Message queue overflows
 *           : RET_ERRPARAM    : Buffer size error
 ******************************************************************************/
RET_API  DRManagerSndMsg(PNO us_pno_src, PNO us_pno_dest, CID us_cid, u_int16 us_msg_len, const void *p_msg_data) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    DEADRECKONING_MSG_BUF    st_msg_buf;    /* message buffer */
    T_APIMSG_MSGBUF_HEADER  *p_st_msg_hdr;    /* Pointer to the message header */
    RET_API          l_ret_api;    /* Return value */

    /* Message buffer initialization */
    memset(reinterpret_cast<void *>(&st_msg_buf), 0, sizeof(DEADRECKONING_MSG_BUF));

    /* Get pointer to send buffer */
    p_st_msg_hdr = reinterpret_cast<T_APIMSG_MSGBUF_HEADER *>(reinterpret_cast<void *>(&st_msg_buf));

    /*--------------------------------------------------------------*
     *  Create message headers                  *
     *--------------------------------------------------------------*/
    p_st_msg_hdr->hdr.sndpno    = us_pno_src;    /* Source PNO */
    p_st_msg_hdr->hdr.cid      = us_cid;    /* Command ID */
    p_st_msg_hdr->hdr.msgbodysize  = us_msg_len;    /* Message data body length */

    /*--------------------------------------------------------------*
     *  Create message data                  *
     *--------------------------------------------------------------*/
    if ((0 != p_msg_data) && (0 != us_msg_len)) {
        /* Set the message data */
        memcpy(reinterpret_cast<void *>(st_msg_buf.data), p_msg_data, (size_t)us_msg_len);
    }
    /*--------------------------------------------------------------*
     * Send messages                      *
     *--------------------------------------------------------------*/
    l_ret_api = _pb_SndMsg(us_pno_dest,
                            (u_int16)(sizeof(T_APIMSG_MSGBUF_HEADER) + us_msg_len),
                            reinterpret_cast<void *>(&st_msg_buf),
                            0);
    return (l_ret_api);
}


/*******************************************************************************
* MODULE    : DeadReckoningFirstDelivery
* ABSTRACT  : Vehicle Sensor Initial Data Delivery Process
* FUNCTION  : Deliver the initial data to the destination.
* ARGUMENT  : us_pno  :Addresses for delivery NO
*             ul_did  :Data ID
* NOTE      :
* RETURN    : void
******************************************************************************/
void DeadReckoningFirstDelivery(PNO us_pno, DID ul_did) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    DEADRECKONING_DATA_MASTER      st_master;      /* Data master of normal data      */

    /* Defines the data master for each API. */
    SENSORLOCATION_MSG_LONLATINFO_DAT  st_msg_lonlat_info;
    SENSORLOCATION_MSG_ALTITUDEINFO_DAT  st_msg_altitude_info;
    SENSORMOTION_MSG_SPEEDINFO_DAT    st_msg_speed_info;
    SENSORMOTION_MSG_HEADINGINFO_DAT  st_msg_heading_info;

    /* Initialization */
    st_msg_lonlat_info.reserve[0] = 0;
    st_msg_lonlat_info.reserve[1] = 0;
    st_msg_lonlat_info.reserve[2] = 0;
    st_msg_altitude_info.reserve[0] = 0;
    st_msg_altitude_info.reserve[1] = 0;
    st_msg_altitude_info.reserve[2] = 0;
    st_msg_speed_info.reserve = 0;
    st_msg_heading_info.reserve = 0;

    /* Align data from the data master for API I/F */
    switch (ul_did) {
            /* Describes the process for each DID. */
        case VEHICLE_DID_DR_LATITUDE:
        {
            DeadReckoningGetDataMaster(ul_did, &st_master);

            /* Size storage(LONLAT)  */
            st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);

            /* DR status setting */
            st_msg_lonlat_info.dr_status = st_master.dr_status;

            /* The DR enable flag is set to enabled. */
            st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;

            /* Set the Latitude */
            memcpy(&(st_msg_lonlat_info.latitude), &(st_master.uc_data[0]), st_master.us_size);

            /* Obtain the data master Longitude */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);

            /* Set the Longitude */
            memcpy(&(st_msg_lonlat_info.longitude), &(st_master.uc_data[0]), st_master.us_size);

            /* Acquire data master SensorCnt */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);

            /* Set the SensorCnt */
            memcpy(&(st_msg_lonlat_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);

            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORLOCATION_LONLAT,
                                    sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
                                    (const void *)&st_msg_lonlat_info);
            break;
        }
        case VEHICLE_DID_DR_ALTITUDE:
        {
            DeadReckoningGetDataMaster(ul_did, &st_master);

            /* Size storage(ALTITUDE)  */
            st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);

            /* The DR enable flag is set to enabled. */
            st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;

            /* DR status setting */
            st_msg_altitude_info.dr_status = st_master.dr_status;


            /* Set the Altitude */
            memcpy(&(st_msg_altitude_info.altitude), &(st_master.uc_data[0]), st_master.us_size);

            /* Acquire data master SensorCnt */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);

            /* Set the SensorCnt */
            memcpy(&(st_msg_altitude_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);

            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORLOCATION_ALTITUDE,
                                    sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
                                    (const void *)&st_msg_altitude_info);

            break;
        }
        case VEHICLE_DID_DR_SPEED:
        {
            DeadReckoningGetDataMaster(ul_did, &st_master);

            /* Size storage(SPEED)  */
            st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);

            /* The DR enable flag is set to enabled. */
            st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;

            /* DR status setting */
            st_msg_speed_info.dr_status = st_master.dr_status;


            /* Set the Speed */
            memcpy(&(st_msg_speed_info.speed), &(st_master.uc_data[0]), st_master.us_size);

            /* Acquire data master SensorCnt */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
            /* Set the SensorCnt */
            memcpy(&(st_msg_speed_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);

            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORMOTION_SPEED,
                                    sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
                                    (const void *)&st_msg_speed_info);
            break;
        }
        case VEHICLE_DID_DR_HEADING:
        {
            DeadReckoningGetDataMaster(ul_did, &st_master);

            /* Size storage(HEADING)  */
            st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);

            /* The DR enable flag is set to enabled. */
            st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;

            /* DR status setting */
            st_msg_heading_info.dr_status = st_master.dr_status;


            /* Set the Heading */
            (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
             (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

            /* Acquire data master SensorCnt */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
            /* Set the SensorCnt */
            (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
                (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));

            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORMOTION_HEADING,
                                    sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
                                    (const void *)&st_msg_heading_info);
            break;
        }
        case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
        {
            SENSORMOTION_MSG_GYROPARAMETERINFO_DAT  stMsgGyroParameterInfo;

            /* Initialization */
            stMsgGyroParameterInfo.reserve[0] = 0;
            stMsgGyroParameterInfo.reserve[1] = 0;

            /* Size storage(GYROPARAMETER) */
            stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);

            /* GyroOffset acuisition/setting */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);

            (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
                                reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                sizeof( stMsgGyroParameterInfo.gyro_offset));

            /* GyroScaleFactor acuisition/setting */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);

            (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
                                reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                sizeof(stMsgGyroParameterInfo.gyro_scale_factor));

            /* GyroScaleFactorLevel acuisition/setting */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);

            (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
                                reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));

            /* Data transmission */
            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
                                    sizeof(stMsgGyroParameterInfo),
                                    (const void *)&stMsgGyroParameterInfo);
        }
        break;
        case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
        {
            SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT  stMsgSpeedPulseParameterInfo;

            /* Initialization */
            stMsgSpeedPulseParameterInfo.reserve[0] = 0;
            stMsgSpeedPulseParameterInfo.reserve[1] = 0;
            stMsgSpeedPulseParameterInfo.reserve[2] = 0;

            /* Size storage(SPEEDPULSEPARAMETER) */
            stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);

            /* SpeedPulseScaleFactor acuisition/setting */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);

            (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
                                reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));

            /* SpeedPulseScaleFactorLevel acuisition/setting */
            DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);

            (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
                                reinterpret_cast<void *>(&(st_master.uc_data[0])),
                                sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));

            /* Data transmission */
            (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
                                    us_pno,
                                    CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
                                    sizeof(stMsgSpeedPulseParameterInfo),
                                    (const void *)&stMsgSpeedPulseParameterInfo);
        }
        break;
        /* Other than the above */
        default:
            /* Do not edit. */
            break;
    }
}
// LCOV_EXCL_STOP