Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / server / include / Sensor / VehicleSens_DeliveryCtrl.h
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 #ifndef POSITIONING_SERVER_INCLUDE_SENSOR_VEHICLESENS_DELIVERYCTRL_H_
18 #define POSITIONING_SERVER_INCLUDE_SENSOR_VEHICLESENS_DELIVERYCTRL_H_
19 /******************************************************************************
20  * File name        :VehicleSens_DeliveryCtrl.h
21  * System name        :_CWORD107_
22  * Subsystem name    :
23  ******************************************************************************/
24
25 #include "Vehicle_API_Dummy.h"
26 #include "Sensor_API.h"
27 #include "Vehicle_API_private.h"
28 #include "Sensor_API_private.h"
29 #include "VehicleSens_SelectionItemList.h"
30 #include "VehicleSens_DataMaster.h"
31 #include "Dead_Reckoning_Local_Api.h"
32
33 /************************************************************************
34 *            Macro definitions                                                    *
35 ************************************************************************/
36 #define    VEHICLESENS_CANID_EFFECTIVE        29        /* CAN ID Effective number   */
37 #define    VEHICLESENS_CANID_RESERVE        11        /* CAN ID Reserved number  */
38 #define    VEHICLESENS_SIGNAL                VEHICLESENS_SELECTION_ITEM_LIST_LEN    /* Number of vehicle signals  */
39 #define    VEHICLESENS_DELIVERY            10        /* Number of delivery destinations                */
40 /* CAN ID Maximum number            */
41 #define    VEHICLESENS_CANID_MAX            (VEHICLESENS_CANID_EFFECTIVE + VEHICLESENS_CANID_RESERVE)
42 /* Vehicle sensor information            */
43 #define    VEHICLESENS_DELIVERY_INFO        (VEHICLESENS_CANID_MAX + VEHICLESENS_SIGNAL)
44 /* Maximum number of vehicle sensor information    */
45 #define    VEHICLESENS_DELIVERY_INFO_MAX    (VEHICLESENS_DELIVERY_INFO * VEHICLESENS_DELIVERY)
46 /* Vehicle Sensor Information Valid Number    */
47 #define    VEHICLESENS_DID_EFFECTIVE        (VEHICLESENS_CANID_EFFECTIVE + VEHICLESENS_SIGNAL)
48 #define    VEHICLESENS_ACTION_TYPE_ADD        0        /* Vehicle sensor addition processing        */
49 #define    VEHICLESENS_ACTION_TYPE_UPDATE    1        /* Vehicle sensor update processing        */
50 #define    VEHICLESENS_LINK_INDEX_END        0xFFFF    /* End of the link index    */
51
52
53 #define    VEHICLESENS_PKG_DELIVERY_INFO_MAX    2560    /* Maximum number of vehicle sensor information  */
54 #define    VEHICLESENS_DELIVERY_METHOD_NORMAL    0        /* Delivery system normal delivery    */
55 #define    VEHICLESENS_DELIVERY_METHOD_PACKAGE    1        /* Delivery system package delivery */
56 #define    VEHICLESENS_PKG_EXT_SEND_MAX        10        /* Number of data master transmissions/onece  */
57 #define    VEHICLESENS_PKG_EXT_SEND_MAX_10DATA    100        /* Number of data masters transmitted (GYRO),SPEED)/once */
58
59 #define    VEHICLESENS_DELIVERY_MAX_SIZE            SENSOR_MSG_VSINFO_DSIZE        /* Maximum Size of Delivery       */
60 #define    VEHICLESENS_DELIVERY_FSTSNS_HDR_SIZE    8        /* Initial Sensor Data Delivery Data Header Size    */
61
62 /************************************************************************
63 *            Struct definitions                                                    *
64 ************************************************************************/
65 /*********************************************************************
66 * TAG       : VEHICLESENS_DELIVERY_LIST_CANID
67 * ABSTRACT  : CAN data delivery registration request information
68 ***********************************************************************/
69 typedef struct {
70     u_int8    uc_can_num;                            /* CANID delivery registrations */
71     u_int8    uc_reserve[3];
72     u_int32    ul_can_id[VEHICLESENS_CANID_MAX];        /* Delivery registrationCANID */ /* CANIF_API deletion */
73 } VEHICLESENS_DELIVERY_LIST_CANID;
74
75 /*********************************************************************
76 * TAG       :VEHICLESENS_DELIVERY_CTRL_TBL_DATA
77 * ABSTRACT  : Structure of each data of the vehicle sensor delivery destination management table
78 ***********************************************************************/
79 typedef struct {
80     DID        ul_did;                /* Data ID                */
81     PNO        us_pno;                /* Shipping PID            */
82     u_int8    uc_chg_type;            /* Delivery timing            */
83     u_int8    uc_ctrl_flg;            /* Delivery operation                */
84     u_int16    us_link_idx;            /* Link index    */
85     u_int16    us_pkg_start_idx;        /* Package Delivery Start Index    */
86     u_int16    us_pkg_end_idx;        /* Package delivery end index        */
87     u_int8    uc_method;            /* Delivery system                */
88     u_int8    uc_reserve;            /* reserve                */
89     /* Modify to store the destination service name TODO */
90     /* Add handles as needed TODO */
91 } VEHICLESENS_DELIVERY_CTRL_TBL_DATA;
92
93 /*********************************************************************
94 * TAG       : VEHICLESENS_DELIVERY_CTRL_TBL
95 * ABSTRACT  : Vehicle Sensor Delivery Destination Management Table Structure
96 ***********************************************************************/
97 typedef struct {
98     u_int16        us_dnum;            /* Number of delivery destination management data items    */
99     u_int8        uc_reserve[2];    /* Reserved                */
100     /* Array of each data        */
101     VEHICLESENS_DELIVERY_CTRL_TBL_DATA    st_ctrl_data[VEHICLESENS_DELIVERY_INFO_MAX];
102 } VEHICLESENS_DELIVERY_CTRL_TBL;
103
104 /*********************************************************************
105 * TAG       : VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA
106 * ABSTRACT  : Structure of each data of Vehicle Sensor Destination Management Table Management
107 ***********************************************************************/
108 typedef struct {
109     DID        ul_did;                    /* Data ID                */
110     u_int16    us_start_idx;                /* Start index    */
111     u_int16    us_end_idx;                /* End index    */
112     u_int16    usdlvry_entry_num;        /* Number of registered shipping addresses        */
113     u_int8    uc_reserve[2];            /* Reserved                */
114 } VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA;
115
116 /*********************************************************************
117 * TAG       : VEHICLESENS_DELIVERY_CTRL_TBL_MNG
118 * ABSTRACT  : Structure of Vehicle Sensor Delivery Destination Management Table Management
119 ***********************************************************************/
120 typedef struct {
121     u_int16        us_dnum;            /* Number of data items            */
122     u_int8        uc_reserve[2];    /* Reserved                */
123     /* Array of each data        */
124     VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA     st_ctrl_tbl_mng_data[VEHICLESENS_DELIVERY_INFO];
125 } VEHICLESENS_DELIVERY_CTRL_TBL_MNG;
126
127 /*********************************************************************
128 * TAG       : VEHICLESENS_PKG_DELIVERY_TBL_MNG_DATA
129 * ABSTRACT  : Structure of each data of the vehicle sensor package delivery management table
130 ***********************************************************************/
131 typedef struct {
132     DID        ul_did;                    /* Data ID                    */
133     u_int16    usdlvry_idx;                /* Delivery data index    */
134     u_int8    uc_reserve[2];            /* Reserved                    */
135 } VEHICLESENS_PKG_DELIVERY_TBL_MNG_DATA;
136
137
138 /*********************************************************************
139 * TAG       : VEHICLESENS_PKG_DELIVERY_TBL_MNG
140 * ABSTRACT  : Structure of Vehicle Sensor Package Delivery Management Table
141 ***********************************************************************/
142 typedef struct {
143     u_int16        us_dnum;            /* Number of data items            */
144     u_int8        uc_reserve[2];    /* Reserved                */
145     /* Array of each data        */
146     VEHICLESENS_PKG_DELIVERY_TBL_MNG_DATA     st_pkg_data[VEHICLESENS_PKG_DELIVERY_INFO_MAX];
147 } VEHICLESENS_PKG_DELIVERY_TBL_MNG;
148
149 /*********************************************************************
150 * TAG       : VEHICLESENS_DELIVERY_PNO_TBL
151 * ABSTRACT  : Vehicle Sensor Destination PNO Table
152 ***********************************************************************/
153 typedef struct {
154     PNO        us_pno;                /* Thread ID    */
155     u_int16    us_pkg_start_idx;        /* Package Delivery Start Index    */
156     u_int16    us_pkg_end_idx;        /* Package delivery end index        */
157     u_int8    uc_method;            /* Delivery system                                */
158     u_int8    uc_reserve;            /* reserve                                */
159 } VEHICLESENS_DELIVERY_PNO_TBL_DAT;
160
161 typedef struct {
162     u_int16    us_dnum;                /* Number of data items    */
163     u_int8    uc_reserve[2];        /* reserve        */
164     VEHICLESENS_DELIVERY_PNO_TBL_DAT    st_pno_data[VEHICLESENS_DELIVERY_INFO_MAX];
165 } VEHICLESENS_DELIVERY_PNO_TBL;
166
167 /*********************************************************************
168 * TAG       : VEHICLESENS_DELIVERY_HEADER
169 * ABSTRACT  : Delivery data header
170 ***********************************************************************/
171 typedef struct {
172     DID        did;                                        /* Data ID            */
173     u_int16    size;                                        /* Size of the data    */
174     u_int8    rcv_flag;                                    /* Receive flag        */
175     u_int8    sensor_cnt;                                    /* Sensor Counter    */
176 } VEHICLESENS_DELIVERY_HEADER;
177
178 /*********************************************************************
179 * TAG       : VEHICLESENS_DELIVERY_FORMAT
180 * ABSTRACT  : Delivery data format
181 ***********************************************************************/
182 typedef struct {
183     VEHICLESENS_DELIVERY_HEADER        header;                                    /* Header            */
184     u_int8                            data[VEHICLESENS_DELIVERY_MAX_SIZE];    /* Data            */
185 } VEHICLESENS_DELIVERY_FORMAT;
186
187 /************************************************************************
188 *            Function prototype                                              *
189 ************************************************************************/
190 void VehicleSensInitDeliveryCtrlTbl(void);
191 void VehicleSensInitDeliveryCtrlTblMng(void);
192 void VehicleSensInitPkgDeliveryTblMng(void);
193 VEHICLE_RET_API VehicleSensEntryDeliveryCtrl(const VEHICLE_MSG_DELIVERY_ENTRY *);
194 void VehicleSensAddDeliveryCtrlTbl(const VEHICLE_MSG_DELIVERY_ENTRY *);
195 void VehicleSensUpdateDeliveryCtrlTbl(VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA *);
196 void VehicleSensUpdatePkgDeliveryCtrlTbl(u_int16, u_int16);
197 void VehicleSensAddDeliveryCtrlTblMng(const VEHICLE_MSG_DELIVERY_ENTRY *);
198 void VehicleSensUpdateDeliveryCtrlTblMng(VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA *);
199 void VehicleSensAddPkgDeliveryTblMng(const SENSOR_MSG_DELIVERY_ENTRY *);
200 VEHICLE_RET_API VehicleSensEntryPkgDeliveryCtrl(const SENSOR_MSG_DELIVERY_ENTRY *, u_int8 uc_ext_chk);
201 VEHICLESENS_DELIVERY_PNO_TBL* VehicleSensMakeDeliveryPnoTbl(DID ul_did, u_int8 change_type);
202 void VehicleSensAddPnoTbl(u_int16);
203 u_int8 VehicleSensDeliveryGPS(DID ul_did, u_int8 uc_get_method, u_int8 uc_current_get_method, int32 pno_index,
204                             u_int32* cid, VEHICLESENS_DATA_MASTER* stmaster,
205                             const VEHICLESENS_DELIVERY_PNO_TBL *pst_pno_tbl);
206 u_int8 VehicleSensDeliveryFst(DID ul_did, u_int8 uc_get_method, int32 pno_index,
207                             const VEHICLESENS_DELIVERY_PNO_TBL *pst_pno_tbl);
208 u_int8 VehicleSensDeliveryGyro(DID ul_did, u_int8 uc_current_get_method, int32 pno_index,
209                             const VEHICLESENS_DELIVERY_PNO_TBL *pst_pno_tbl);
210 void VehicleSensDeliveryAntenna(DID ul_did, u_int8 uc_current_get_method, int32 pno_index,
211                             const VEHICLESENS_DELIVERY_PNO_TBL *pst_pno_tbl);
212 u_int8 VehicleSensDeliveryOther(DID ul_did, u_int8 uc_current_get_method, int32 pno_index,
213                             u_int32* cid,
214                             VEHICLESENS_DATA_MASTER* stmaster,
215                             const VEHICLESENS_DELIVERY_PNO_TBL *pst_pno_tbl);
216 void VehicleSensDeliveryProc(DID ul_did, u_int8 uc_chg_type, u_int8 uc_get_method);
217 u_int8 VehicleSensFirstDeliverySens(PNO us_pno, DID ul_did, u_int8 uc_get_method,
218                                     VEHICLESENS_DATA_MASTER_FST* stmaster_fst,
219                                     VEHICLESENS_DATA_MASTER_FST* stmaster_fst_temp);
220 u_int8 VehicleSensFirstDeliveryOther(PNO us_pno, DID ul_did, u_int8 uc_get_method,
221                                     u_int32* cid,
222                                     VEHICLESENS_DATA_MASTER* stmaster);
223 void VehicleSensFirstDelivery(PNO us_pno, DID ul_did);
224 void VehicleSensFirstPkgDelivery(const SENSOR_MSG_DELIVERY_ENTRY_DAT *);
225 RET_API    VehicleSensCanDeliveryEntry(void);
226 void VehicleSensFirstPkgDelivery(const SENSOR_MSG_DELIVERY_ENTRY_DAT *);
227
228 #if CONFIG_SENSOR_EXT_VALID                /* Initial Sensor Support */
229 void VehicleSensFirstPkgDeliveryExt(const SENSOR_MSG_DELIVERY_ENTRY_DAT *pst_data);
230 #endif
231
232 #if CONFIG_HW_PORTSET_TYPE_C
233 void VehicleSensInitSeqNum(void);
234 void VehicleSensDivideDeliveryProc(PNO, const void *);
235 #endif
236
237 /* ++ PastModel002 support DR */
238 void VehicleSensInitDeliveryCtrlTblDR(void);
239 void VehicleSensInitDeliveryCtrlTblMngDR(void);
240 VEHICLE_RET_API VehicleSensEntryDeliveryCtrlDR(const DEADRECKONING_MSG_DELIVERY_ENTRY *);
241 void VehicleSensAddDeliveryCtrlTblDR(const DEADRECKONING_MSG_DELIVERY_ENTRY *);
242 void VehicleSensAddDeliveryCtrlTblMngDR(const DEADRECKONING_MSG_DELIVERY_ENTRY *);
243 void VehicleSensUpdateDeliveryCtrlTblDR(VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA *);
244 void VehicleSensUpdateDeliveryCtrlTblMngDR(VEHICLESENS_DELIVERY_CTRL_TBL_MNG_DATA *);
245 void VehicleSensDeliveryProcDR(DID ul_did, u_int8 uc_chg_type, u_int8 uc_get_method);
246 VEHICLESENS_DELIVERY_PNO_TBL* VehicleSensMakeDeliveryPnoTblDR(DID ul_did, u_int8 change_type);
247 void VehicleSensAddPnoTblDR(u_int16 us_index);
248 void VehicleSensGetDebugDeliveryCtrlTbl(void* pbuf);
249 void VehicleSensGetDebugDeliveryCtrlTblMng(void* pbuf);
250 void VehicleSensGetDebugPkgDeliveryTblMng(void* pbuf);
251 void VehicleSensGetDebugDeliveryPnoTbl(void* pbuf);
252 /* -- PastModel002 supprt DR */
253 #endif  // POSITIONING_SERVER_INCLUDE_SENSOR_VEHICLESENS_DELIVERYCTRL_H_