summaryrefslogtreecommitdiffstats
path: root/positioning/server/src/Sensor/DeadReckoning_DataMasterMain.cpp
blob: 93adda0d68ee832c78ee6f3058b4f0640d13a77b (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
/*
 * @copyright Copyright (c) 2016-2020 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_DataMasterMain.cpp
 *  System name    :GPF
 *  Subsystem name  :Vehicle sensor process
 *  Program name  :Vehicle SW Data Master
 *  Module configuration  :DeadReckoningInitDataMaster()    Guess Navigation Data Master Initialization Function
 *          :DeadReckoningSetDataMaster()      Estimated Navigational Data Master SW Data Set Processing
 *          :DeadReckoningGetDataMaster()      Estimated Navigational Data Master Get Processing
 ******************************************************************************/

#include <vehicle_service/positioning_base_library.h>
#include "DeadReckoning_DataMaster.h"

/*************************************************/
/*       Global variable                           */
/*************************************************/

#define DR_DEBUG 0

/*******************************************************************************
* MODULE   : DeadReckoningInitDataMaster
* ABSTRACT  : Initialization of Guess Navigation Data Master
* FUNCTION  : Initialize the estimated navigation data master
* ARGUMENT  : void
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningInitDataMaster(void) {  // LCOV_EXCL_START 8: dead code.
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    /* Vehicle sensor data master initialization */
    DeadReckoningInitLongitudeDr();
    DeadReckoningInitLatitudeDr();
    DeadReckoningInitAltitudeDr();
    DeadReckoningInitSpeedDr();
    DeadReckoningInitHeadingDr();
    DeadReckoningInitSnsCounterDr();
    DeadReckoningInitGyroOffsetDr();
    DeadReckoningInitGyroScaleFactorDr();
    DeadReckoningInitGyroScaleFactorLevelDr();
    DeadReckoningInitSpeedPulseScaleFactorDr();
    DeadReckoningInitSpeedPulseScaleFactorLevelDr();
}

/*******************************************************************************
* MODULE   : DeadReckoning_SetDataMaster_Sub
* ABSTRACT  : Estimated Navigational Data Master SW Data Set Processing
* FUNCTION  : Set estimated navigation data
* ARGUMENT  : *p_data      : SW vehicle signal notification data
*       : p_datamaster_set_n  : Data Master Set Notification(Callback function)
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningSetDataMaster(const DEADRECKONING_DATA_MASTER *p_data,
                                PFUNC_DR_DMASTER_SET_N p_datamaster_set_n) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    u_int8  chg_type;

    static u_int8  gyro_parameter_chg_type      = 0;
    static u_int8  speedpulse_parameter_chg_type  = 0;

    /*------------------------------------------------------*/
    /*  Call the data set processing associated with the DID      */
    /*  Call the data master set notification process      */
    /*------------------------------------------------------*/
    switch (p_data->ul_did) {
        case VEHICLE_DID_DR_LONGITUDE:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetLongitudeDr(p_data);
            /* Implementation of delivery process at LATITUDE updating timings */
            /* Since the order of transmission (updating) at the main receiver is fixed, there is no problem. */
            break;
        }
        case VEHICLE_DID_DR_LATITUDE:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetLatitudeDr(p_data);
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_ALTITUDE:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetAltitudeDr(p_data);
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_SPEED:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                           p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetSpeedDr(p_data);
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_HEADING:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetHeadingDr(p_data);
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_SNS_COUNTER:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetSnsCounterDr(p_data);
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_GYRO_OFFSET:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetGyroOffsetDr(p_data);
            /* Distribution processing not performed in this DID                                */
            /* Delivery processing is executed when VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL is updated.        */
            /* The GyroParameter order is defined by DeadReckoning_RcvMsg().              */
            if (chg_type == DEADRECKONING_NEQ) {
                gyro_parameter_chg_type = DEADRECKONING_NEQ;
            }
            break;
        }
        case VEHICLE_DID_DR_GYRO_SCALE_FACTOR:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetGyroScaleFactorDr(p_data);
            /* Distribution processing not performed in this DID                                */
            /* Delivery processing is executed when VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL is updated.        */
            /* The GyroParameter order is defined by DeadReckoning_RcvMsg().              */
            if (chg_type == DEADRECKONING_NEQ) {
                gyro_parameter_chg_type = DEADRECKONING_NEQ;
            }
            break;
        }
        case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetGyroScaleFactorLevelDr(p_data);
            if (gyro_parameter_chg_type == DEADRECKONING_NEQ) {
                chg_type        = DEADRECKONING_NEQ;
                gyro_parameter_chg_type  = DEADRECKONING_EQ;
            }
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetSpeedPulseScaleFactorDr(p_data);
            /* Distribution processing not performed in this DID                                */
            /* Delivery processing is executed when VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL is updated.    */
            /* The SpeedPulseParameter order is defined by DeadReckoning_RcvMsg().          */
            if (chg_type == DEADRECKONING_NEQ) {
                speedpulse_parameter_chg_type = DEADRECKONING_NEQ;
            }
            break;
        }
        case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
        {
#if (DR_DEBUG == 1)  /* PastModel002_DR_VEHICLE  */
            FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DeadReckoningSetDataMaster DID=[0x%08X] DSIZE=[%d] \r\n",
                          p_data->ul_did, p_data->us_size);
#endif
            chg_type = DeadReckoningSetSpeedPulseScaleFactorLevelDr(p_data);
            if (speedpulse_parameter_chg_type == DEADRECKONING_NEQ) {
                chg_type            = DEADRECKONING_NEQ;
                speedpulse_parameter_chg_type  = DEADRECKONING_EQ;
            }
            (*p_datamaster_set_n)(p_data->ul_did, chg_type, DEADRECKONING_GETMETHOD_DR);
            break;
        }
        default:
            break;
    }
}

/*******************************************************************************
* MODULE   : DeadReckoningGetDataMaster
* ABSTRACT  : Estimated Navigational Data Master Get Processing
* FUNCTION  : Provide an estimated navigation data master
* ARGUMENT  : ul_did    : Data ID corresponding to the vehicle information
*       : *p_data    : Pointer to the data master provider
* NOTE    :
* RETURN   : void
******************************************************************************/
void DeadReckoningGetDataMaster(DID ul_did, DEADRECKONING_DATA_MASTER *p_data) {
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    /*------------------------------------------------------*/
    /*  Call the data Get processing associated with the DID        */
    /*------------------------------------------------------*/
    switch (ul_did) {
        /*------------------------------------------------------*/
        /*  Vehicle sensor data group                                   */
        /*------------------------------------------------------*/
        case VEHICLE_DID_DR_LONGITUDE:
        {
            DeadReckoningGetLongitudeDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_LATITUDE:
        {
            DeadReckoningGetLatitudeDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_ALTITUDE:
        {
            DeadReckoningGetAltitudeDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_SPEED:
        {
            DeadReckoningGetSpeedDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_HEADING:
        {
            DeadReckoningGetHeadingDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_SNS_COUNTER:
        {
            DeadReckoningGetSnsCounterDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_GYRO_OFFSET:
        {
            DeadReckoningGetGyroOffsetDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_GYRO_SCALE_FACTOR:
        {
            DeadReckoningGetGyroScaleFactorDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
        {
            DeadReckoningGetGyroScaleFactorLevelDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR:
        {
            DeadReckoningGetSpeedPulseScaleFactorDr(p_data);
            break;
        }
        case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
        {
            DeadReckoningGetSpeedPulseScaleFactorLevelDr(p_data);
            break;
        }
        default:
            break;
    }
}
// LCOV_EXCL_STOP