ItsRSUsSimulator_TestCases.ttcn 11.5 KB
Newer Older
garciay's avatar
garciay committed
1
2
3
4
5
6
module ItsRSUsSimulator_TestCases {
    
    // Libcommon
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    
garciay's avatar
garciay committed
7
8
9
10
    // LibIts
    import from ITS_Container language "ASN.1:1997" all;
    import from CAM_PDU_Descriptions language "ASN.1:1997" all;
    
garciay's avatar
garciay committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    // LibItsCommon
    import from LibItsCommon_Functions all;
    
    // LibItsGeoNetworking
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Templates all;
    
    // LibItsDenm
    import from LibItsDenm_Templates all;
    
    // AtsRSUsSimulator
    import from ItsRSUsSimulator_TypesAndValues all;
    import from ItsRSUsSimulator_Templates all;
    import from ItsRSUsSimulator_TestSystem all;
    import from ItsRSUsSimulator_Functions all;
garciay's avatar
garciay committed
27
    import from ItsRSUsSimulator_Pics all;
garciay's avatar
garciay committed
28
29
    import from ItsRSUsSimulator_Pixits all;
    
30
    testcase TC_RSUSIMU_BV_01() runs on ItsRSUsSimulator system ItsRSUsSimulatorSystem {
garciay's avatar
garciay committed
31
32
33
        // Local variables
        var template (value) Payload v_payload;
        var GeoNetworkingInd v_gnInd;
34
        var CfEvent v_cfEvent;
garciay's avatar
garciay committed
35
36
37
38
        
        // Test control
        
        // Test component configuration
39
        ItsRSUsSimulator_Functions.f_cf01Up();
garciay's avatar
garciay committed
40
41
42
43
44
45
46
            
        // Test adapter configuration
        
        // Preamble
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
47
48
49
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].beacon)) {
            tc_beacon.start;
        }
50
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].cam)) {
garciay's avatar
garciay committed
51
52
            tc_cam.start;
        }
53
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].denms)) {
garciay's avatar
garciay committed
54
55
            tc_denm.start;
        }
56
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].mapem)) {
garciay's avatar
garciay committed
57
58
            tc_mapem.start;
        }
59
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].spatems)) {
garciay's avatar
garciay committed
60
61
            tc_spatem.start;
        }
62
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].ivim)) {
garciay's avatar
garciay committed
63
64
            tc_ivim.start;
        }
garciay's avatar
garciay committed
65

garciay's avatar
garciay committed
66
67
68
69
        alt {
            [] geoNetworkingPort.receive(
                mw_geoNwInd(
                    mw_geoNwPdu(
garciay's avatar
garciay committed
70
                        mw_geoNwTsbPacketWithNextHeader_srem(
garciay's avatar
garciay committed
71
72
73
74
                            ?,
                            ?,
                            e_btpB
            )))) -> value v_gnInd { // Receive a SREM message
garciay's avatar
garciay committed
75
                //log("*** " & testcasename() & ": DEBUG: Processing SREM ***");
garciay's avatar
garciay committed
76
77
78
                f_processSrem(v_gnInd.msgIn);
                repeat;
            }
garciay's avatar
garciay committed
79
            /*[] geoNetworkingPort.receive(
80
81
82
83
84
85
86
                mw_geoNwInd(
                    mw_geoNwPdu(
                        mw_geoNwTsbPacketWithNextHeader_denm(
                            ?,
                            ?,
                            e_btpB // TODO Refined to exclude RSU StationID
            )))) -> value v_gnInd { // Receive a DENM message
garciay's avatar
garciay committed
87
                //log("*** " & testcasename() & ": DEBUG: Processing DENM ***");
88
89
                // Nothing to do, just for logging purposes
                repeat;
garciay's avatar
garciay committed
90
            }*/
garciay's avatar
garciay committed
91
            [] geoNetworkingPort.receive(mw_geoNwInd(?)) -> value v_gnInd { // Receive a message
garciay's avatar
garciay committed
92
                //log("*** " & testcasename() & ": DEBUG: Recieving unsollicited message ***");
garciay's avatar
garciay committed
93
94
95
                // Nothing to do, just for logging purposes
                repeat;
            }
96
            [] cfPort.receive(CfEvent:?) -> value v_cfEvent {
garciay's avatar
garciay committed
97
                //log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***");
98
99
100
101
                if (f_process_cf_event(v_cfEvent) == true) {
                    repeat;
                }
            }
102
            [vc_beacon == true] tc_beacon.timeout {
garciay's avatar
garciay committed
103
                //log("*** " & testcasename() & ": DEBUG: Processing BEACON ***");
104
105
106
107
108
                f_prepare_beacon(v_payload);
                f_send(v_payload, PICS_CAM_ITS_AID);
                tc_beacon.start;
                repeat;
            }
109
            [vc_cam == true] tc_cam.timeout {
garciay's avatar
garciay committed
110
                //log("*** " & testcasename() & ": DEBUG: Processing CAM ***");
garciay's avatar
garciay committed
111
                f_prepare_cam(v_payload);
112
                f_send(v_payload, PICS_CAM_ITS_AID);
garciay's avatar
garciay committed
113
114
115
                tc_cam.start;
                repeat;
            }
116
            [vc_denm == true] tc_denm.timeout {
garciay's avatar
garciay committed
117
                //log("*** " & testcasename() & ": DEBUG: Processing DENM ***");
118
119
120
121
                for (var integer v_i := 0; v_i < lengthof(vc_rsuMessagesValueList[vc_rsu_id].denms); v_i := v_i + 1) {
                    f_prepare_denm(v_payload);
                    f_send(v_payload, PICS_DENM_ITS_AID);
                } // End of 'for' 
garciay's avatar
garciay committed
122
                tc_denm.start;
garciay's avatar
garciay committed
123
124
                repeat;
            }
125
            [vc_mapem == true] tc_mapem.timeout {
garciay's avatar
garciay committed
126
                log("*** " & testcasename() & ": DEBUG: Processing MAPEM ***");
garciay's avatar
garciay committed
127
                f_prepare_mapem(v_payload);
128
                f_send(v_payload, PICS_MAPEM_ITS_AID);
garciay's avatar
garciay committed
129
130
131
                tc_mapem.start;
                repeat;
            }
132
            [vc_spatem == true] tc_spatem.timeout {
garciay's avatar
garciay committed
133
                log("*** " & testcasename() & ": DEBUG: Processing SPATEM ***");
134
135
                for (var integer v_counter := 0; v_counter < lengthof(vc_rsuMessagesValueList[PX_RSU_ID - 1].spatems); v_counter := v_counter + 1) {
                    f_prepare_spatem(vc_rsuMessagesValueList[PX_RSU_ID - 1].spatems[v_counter], v_payload);
136
                    f_send(v_payload, PICS_SPATEM_ITS_AID);
137
                }
garciay's avatar
garciay committed
138
139
140
                tc_spatem.start;
                repeat;
            }
141
            [vc_ivim == true] tc_ivim.timeout {
garciay's avatar
garciay committed
142
                //log("*** " & testcasename() & ": DEBUG: Processing IVIM ***");
garciay's avatar
garciay committed
143
                f_prepare_ivim(v_payload);
144
                f_send(v_payload, PICS_IVIM_ITS_AID);
garciay's avatar
garciay committed
145
146
147
                tc_ivim.start;
                repeat;
            }
garciay's avatar
garciay committed
148
149
150
151
        } // End of 'alt' statement
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        
        // Postamble
152
153
154
155
156
157
        if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].denms)) {
            for (var integer v_i := 0; v_i < lengthof(vc_rsuMessagesValueList[vc_rsu_id].denms); v_i := v_i + 1) {
                f_prepare_denm(v_payload, true);
                f_send(v_payload, PICS_DENM_ITS_AID);
            } // End of 'for' statement
        }
158
        ItsRSUsSimulator_Functions.f_cf01Down();
garciay's avatar
garciay committed
159
        
garciay's avatar
garciay committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    } // End of TC_RSUSIMU_BV_01
    
    /**
     * @remark: All PICS_GENERATE_xxx = false
     *          PICS_CAM_FREQUENCY = 0.1
     */
    testcase TC_RSUSIMU_BV_02() runs on ItsRSUsSimulator system ItsRSUsSimulatorSystem {
        // Local variables
        var VehiclesSimulator v_vehicles := {};
        var integer v_vehiclesIdx := 0;
        var charstring v_stationIDs := "";
        var charstring v_stationID;
        var GeoNetworkingInd v_gnInd;
        var CfEvent v_cfEvent;
        
        // Test control
        
        // Test component configuration
178
        ItsRSUsSimulator_Functions.f_cf01Up();
garciay's avatar
garciay committed
179
180
181
182
183
184
185
186
            
        // Test adapter configuration
        
        // Preamble
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        tc_ac.start;
187
        geoNetworkingPort.clear;
garciay's avatar
garciay committed
188
189
190
191
192
        alt {
            [] geoNetworkingPort.receive(
                mw_geoNwInd(
                    mw_geoNwPdu(
                        mw_geoNwShbPacketWithNextHeader_cam(
193
194
195
196
                            -,
                            -,
                            e_btpB
            )))) -> value v_gnInd { // Receive a CAM message
garciay's avatar
garciay committed
197
                tc_ac.stop;
garciay's avatar
garciay committed
198
                // Check if it already processed
garciay's avatar
garciay committed
199
                v_stationID := int2str(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.header.stationID);
garciay's avatar
garciay committed
200
201
202
203
204
205
                if (regexp(v_stationIDs, charstring:"(" & v_stationID & ",)", 0) == "") { // Vehicle not processed yet
                    v_vehicles[v_vehiclesIdx] := ItsRSUsSimulator.create("Node" & int2char(v_vehiclesIdx + 65)) alive;
                    v_vehicles[v_vehiclesIdx].start(f_startVehicleSimulator(v_vehicles[v_vehiclesIdx], v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket));
                    v_vehiclesIdx := v_vehiclesIdx + 1;
                    v_stationIDs := v_stationIDs & v_stationID & ",";
                    log("*** " & testcasename() & ": DEBUG: New v_stationIDs: " & v_stationIDs & " ***");
garciay's avatar
garciay committed
206
207
                } else {
                    // Nothing to do
garciay's avatar
garciay committed
208
                    log("*** " & testcasename() & ": DEBUG: StationID: " & v_stationID & " already processed ***");
garciay's avatar
garciay committed
209
210
211
212
213
                }
                tc_ac.start;
                repeat;
            }
            [] cfPort.receive(CfEvent:?) -> value v_cfEvent {
garciay's avatar
garciay committed
214
                //log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***");
garciay's avatar
garciay committed
215
216
217
218
219
220
                if (f_process_cf_event(v_cfEvent) == true) {
                    repeat;
                }
                all component.stop;
            }
            [] tc_ac.timeout {
garciay's avatar
garciay committed
221
                log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
garciay's avatar
garciay committed
222
223
224
225
226
227
228
229
230
                all component.stop;
            }
        } // End of 'alt' statement
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        
        // Postamble
        for (var integer v_idx := 0; v_idx < lengthof(v_vehicles); v_idx := v_idx + 1) {
            v_vehicles[v_idx].done;
        } // End of 'for' statement
231
        ItsRSUsSimulator_Functions.f_cf01Down();
garciay's avatar
garciay committed
232
233
234
235
236
237
238
        
    } // End of TC_RSUSIMU_BV_02
    
    group tc_RSUSIMU_BV_02 {
        
        function f_startVehicleSimulator(
                                         in ItsRSUsSimulator p_component,
garciay's avatar
garciay committed
239
                                         in CAM p_camVehicle
garciay's avatar
garciay committed
240
241
242
        ) runs on ItsRSUsSimulator {
            
            // Local variables
garciay's avatar
garciay committed
243
244
            var GeoNetworkingInd v_gnInd;
            var template (value) CAM v_camSimu;
garciay's avatar
garciay committed
245
            
garciay's avatar
garciay committed
246
247
            log("*** " & testcasename() & ": DEBUG: >>> f_startVehicleSimulator: " & int2str(p_camVehicle.header.stationID) & " ***");
            f_initialiseVehicleSimulatorComponent(p_component, v_camSimu);
garciay's avatar
garciay committed
248
            
garciay's avatar
garciay committed
249
            tc_cam.start;
garciay's avatar
garciay committed
250
            alt {
garciay's avatar
garciay committed
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwPdu(
                            mw_geoNwShbPacketWithNextHeader_cam(
                                -,
                                -,
                                e_btpB,
                                mw_cam_stationID(
                                    -,
                                    p_camVehicle.header.stationID
                ))))) -> value v_gnInd { // Receive a CAM message from the processed vehicle
                    log("*** " & testcasename() & ": DEBUG: Processing CAM #" & int2str(p_camVehicle.header.stationID) & " ***");
                    tc_cam.stop;
                    f_send_vehicle_cam(v_camSimu, v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket);
                    tc_cam.start;
                }
267
268
269
                /*[] cfPort.receive {
                    repeat;
                }*/
garciay's avatar
garciay committed
270
271
                [] tc_cam.timeout {
                    log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
garciay's avatar
garciay committed
272
273
274
275
276
277
278
279
                }
            } // End of 'altstep' statement
            
            f_uninitialiseVehicleSimulatorComponent(p_component);
            
        } // End of f_startVehicleSimulator
        
    } // End of group tc_RSUSIMU_BV_02 
garciay's avatar
garciay committed
280
281
    
} // End of module ItsRSUsSimulator_TestCases