LibItsIicp_Functions.ttcn3 15 KB
Newer Older
1
2
/**
 *  @author     ETSI / STF422_EETS
filatov's avatar
filatov committed
3
4
 *  @version    $URL$
 *              $Id$
5
6
7
8
9
 *  @desc       Inter-ITS-SCU communications (ISO 24102-4) functions
 */
module LibItsIicp_Functions {
    
    // LibCommon
garciay's avatar
garciay committed
10
11
12
13
    import from LibCommon_Sync all;
    import from LibCommon_Time {
        function f_sleepIgnoreDef
    };
14
15
16
17
18
19
20
21
22
23
24
    import from LibCommon_BasicTypesAndValues {
        const 
            c_uInt8Max;
    };
    import from LibCommon_Sync {
        function
            f_selfOrClientSyncAndVerdict, f_selfOrClientSyncAndVerdictPreamble
    };
    import from LibCommon_VerdictControl all;
    
    // LibIts
garciay's avatar
garciay committed
25
26
27
28
29
30
    import from CALMllsap language "ASN.1:1997" {
        type 
            Link_ID 
    };
    import from CALMmsap language "ASN.1:1997" {
        type 
31
            MF_Command, MN_Command, MI_Command, 
32
33
            MF_Request, MN_Request, MI_Request, 
            MF_Request_confirm 
garciay's avatar
garciay committed
34
    };
35
36
    import from CALMmanagement language "ASN.1:1997" {
        type 
garciay's avatar
garciay committed
37
            ITS_scuId, Talive
38
39
40
    };
    import from CALMiitsscu language "ASN.1:1997" {
        type 
41
            IIC_Request, IIC_Response, 
garciay's avatar
garciay committed
42
43
            ITS_SCUtype, 
            VCI_Info, VCI_info_res, VCI_update_req 
44
    };
garciay's avatar
garciay committed
45
    import from LibItsMgt_TypesAndValues {
garciay's avatar
garciay committed
46
        type IParamNoList, IParamList, ErrorsList 
garciay's avatar
garciay committed
47
    };
48
49
50
    import from LibItsIicp_Templates all;
    import from LibItsIicp_Pics all;
    import from LibItsIicp_Pixits all;
reinaortega's avatar
reinaortega committed
51
    import from LibItsCalm_Interface {
52
        type 
53
            IicpResp, IicpResp, 
reinaortega's avatar
reinaortega committed
54
55
56
            ItsMgt;
        function
		      f_utInitializeIut 
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    };
    
    group iicpConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are combined (see ISO/WD 29281-2 - Figure 1 - Implementation architecture I)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is used if specified</li>
         */
        function f_cf01Up() runs on ItsMgt {
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
71
72
            map(self:iicpPort, system:iicpPort);
            map(self:iicpPort, system:iicpPort);
73
            map(self:mgtMfSapPort, system:mgtMfSapPort);
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
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf01Down());
            
            // Initialize the component
            f_initialiseComponent("cf01Up");

            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf01Up
        
        /**
         * @desc    Deletes configuration cf01
         */
        function f_cf01Down() runs on ItsMgt {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
99
            unmap(self:iicpPort, system:iicpPort);
100
            unmap(self:mgtMfSapPort, system:mgtMfSapPort);
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
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // End of f_cf01Down
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         * @param   p_iicpMGM Set to true if IISC port shall be used
         */
        function f_initialiseComponent(in charstring p_componentName) runs on ItsMgt {
            
            // Initialize variables
            
            // Set defaults
            activate(a_iicpDefault()); 
            
        } // end f_initialiseComponent
        
    } // End of group iicpConfigurationFunctions
    
    group functions {
        
    } // End of group functions
    
    group iicpFunctions {
        
        /**
         * @desc    Triggers a request command event in the test system adaptation.
         * @param   p_rCmd The remote commad to trigger
         * @return  FncRetCode
         */
        function f_iicpTriggerRequest(
            in template (value) IIC_Request p_rCmd
        ) runs on ItsMgt return FncRetCode {
            var FncRetCode v_ret := e_success;
            
139
            iicpPort.send(m_iicpReq(p_rCmd));
140
141
142
143
            
            return v_ret;
        }
        
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        /**
         * @desc    Triggers a response command event in the test system adaptation.
         * @param   p_rCmd The remote commad to trigger
         * @return  FncRetCode
         */
        function f_iicpTriggerResponse(
            in template (value) IIC_Response p_rCmd
        ) runs on ItsMgt return FncRetCode {
            var FncRetCode v_ret := e_success;
            
            iicpPort.send(m_iicpResp(p_rCmd));
            
            return v_ret;
        }
        
159
160
161
162
163
164
165
166
167
168
169
    } // End of group iicpFunctions
    
    
    
    group iicpAltsteps {
        
        /**
         * @desc Trap for not processed IICP message.
         * @verdict Set to fail on unknown message
         */
        altstep a_iicpDefault() runs on ItsMgt {
garciay's avatar
garciay committed
170
171
172
173
174
            [] iicpPort.receive(mw_iicpRequest(mw_iicpRequest_any)) { // Receive any IIC-Request message
                log("*** a_iicpDefault: INFO: Remote IIC-Request command service primitive received in default ***");
                repeat;
            }
            [] iicpPort.receive(mw_iicpResponse(mw_iicpResponse_any)) { // Receive any IIC-Response message
175
176
177
                log("*** a_iicpDefault: INFO: Remote IIC-Response command service primitive received in default ***");
                repeat;
            }
178
            [] iicpPort.receive { // Receive unknown message
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
                log("*** a_iicpDefault: ERROR: event received on IISC port in default ***");
                f_selfOrClientSyncAndVerdict("error", e_error);
            }
            [] tc_wait.timeout {
                log("*** a_iicpDefault: ERROR: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] tc_ac.timeout {
                log("*** a_iicpDefault: ERROR: Timeout while awaiting the reception of a message ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] any timer.timeout {
                log("*** a_iicpDefault: INCONC: An unknown timer has expired in default ***"); 
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] a_shutdown() {
                f_poDefault();
                log("*** a_iicpDefault: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                if(self == mtc) {
                    f_cf01Down();
                }
                stop;
            }
        } // End of altstep a_iicpDefault
        
        /**
         * @desc Default handling cf01 de-initialisation.
         */
        altstep a_cf01Down() runs on ItsMgt {
            [] a_shutdown() {
                f_poDefault();
                f_cf01Down();
                log("*** a_cf01Down: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;
            }
        } // End of altstep a_cf01Down()
        
    } // End of group iicpAltsteps
    
reinaortega's avatar
reinaortega committed
218
    group preamble {
219
220
221
222
        
        /**
         * @desc Brings the IUT into an initial state.
         */
garciay's avatar
garciay committed
223
        function f_initialState() runs on ItsMgt {
224
225
226
227
            f_utInitializeIut(m_iicpInitialize);
            f_sleepIgnoreDef(PX_WAIT_FOR_IUT_READY); // Wait until the IUT is in a stable situation (beaconing...)
        } // End of function f_initialState
        
reinaortega's avatar
reinaortega committed
228
    } // End of group preamble
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsMgt {
            // Nothing to do
        } // End of function f_poDefault
        
    } // End of group postambles
    
    group adapterControl {
        
    } // End of group adapterControl
    
    group testerFunctions {
        
garciay's avatar
garciay committed
247
248
249
250
251
252
253
254
        /**
         * @desc matches a record of values if, and only if, the record of values contains at least all of the elements defined within the SuperSet, and may contain more.
         * @param p_vciInfoRes      Received datas to be checked
         * @param p_baseTemplate    Template to be matched
         * @return true on matching, false otherwise
         * @verdict Unchanged
         * @see ETSI ES 201 873-1 V4.3.1 (2011-06)
         */
garciay's avatar
garciay committed
255
        function f_superset_VCI_Info(in VCI_info_res p_vciInfoRes, in template (present) VCI_Info p_baseTemplate) return boolean { 
garciay's avatar
garciay committed
256
257
            var integer v_counter;
            
garciay's avatar
garciay committed
258
            for (v_counter := 0; v_counter < lengthof(p_vciInfoRes); v_counter := v_counter + 1) { 
garciay's avatar
garciay committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
                if (match(p_vciInfoRes[v_counter], p_baseTemplate)) { 
                    return true;
                }
            } // End of 'for' statement
            
            return false;
        }
        
        /**
         * @desc matches a record of values if, and only if, the record of values contains at least all of the elements defined within the SuperSet, and may contain more.
         * @param p_vciInfoRes      Received datas to be checked
         * @param p_baseTemplate    Template to be matched
         * @return true on matching, false otherwise
         * @verdict Unchanged
         * @see ETSI ES 201 873-1 V4.3.1 (2011-06)
         */
garciay's avatar
garciay committed
275
        function f_superset_VCI_Update(in VCI_update_req p_vciUpdate, in template (present) VCI_Info p_baseTemplate) return boolean { 
garciay's avatar
garciay committed
276
277
            var integer v_counter;
            
garciay's avatar
garciay committed
278
            for (v_counter := 0; v_counter < lengthof(p_vciUpdate); v_counter := v_counter + 1) { 
garciay's avatar
garciay committed
279
280
281
282
283
284
285
286
                if (match(p_vciUpdate[v_counter], p_baseTemplate)) { 
                    return true;
                }
            } // End of 'for' statement
            
            return false;
        }
        
287
288
289
290
    } // End of group testerFunctions
    
    group iutFunctions {
        
garciay's avatar
garciay committed
291
292
293
294
295
        /**
         * @desc Get the active VCI link identifier
         * @return The active VCI link identifier
         * @see PX_ACTIVE_VCI_LINK_ID
         */
296
        function f_getIutCiLinkId() return Link_ID {
garciay's avatar
garciay committed
297
298
299
            return PX_ACTIVE_VCI_LINK_ID;
        }
        
300
301
302
303
304
305
        /**
         * @desc Gets the Local/source ITS scuID 
         * @return  The Local/source ITS scuID 
         * @see PX_LOCAL_ITS_SCU_ID 
         * @see ISO/WD 24102-4 - Table 2 — ITS-SCU-ID value assignment
         */
reinaortega's avatar
reinaortega committed
306
        function f_getIutLocalItsScuId() return ITS_scuId {
307
308
309
310
            return PX_LOCAL_ITS_SCU_ID;
        }
        
        /**
garciay's avatar
garciay committed
311
312
         * @desc    Get the type of ITS-SCU in the "Data" element
         * @return  The type of ITS-SCU in the "Data" element
313
314
         * @see     PX_SRC_ITS_SCU_TYPE
         */
reinaortega's avatar
reinaortega committed
315
        function f_getIutSourceItsScuType() return ITS_SCUtype {
316
317
318
319
320
            return PX_SRC_ITS_SCU_TYPE;
        }
        
        
        /**
garciay's avatar
garciay committed
321
         * @desc    Gets the type ITS scuID
322
323
324
325
         * @return  The type ITS scuID
         * @see PX_LOCAL_ITS_TYPE 
         * @see ISO/WD 24102-4 - Table 2 — ITS-SCU-ID value assignment
         */
reinaortega's avatar
reinaortega committed
326
        function f_getIutLocalItsType() return ITS_SCUtype {
327
328
329
            return PX_LOCAL_ITS_TYPE;
        }
        
garciay's avatar
garciay committed
330
331
332
333
334
        /**
         * @desc    Gets the Alive timer
         * @return  The Alive timer
         * @see PX_TALIVE 
         */
reinaortega's avatar
reinaortega committed
335
        function f_getIutTalive() return Talive {
garciay's avatar
garciay committed
336
337
338
            return PX_TALIVE;
        }
        
garciay's avatar
garciay committed
339
        /**
340
341
         * @desc    Get the MI-Command value used for remote command
         * @return  The MI-Command value used for remote command
garciay's avatar
garciay committed
342
343
         * @see     PX_MI_RCMD_STATECINOTIFY
         */
reinaortega's avatar
reinaortega committed
344
        function f_getIutRemoteCmdForMiCommand() return MI_Command {
garciay's avatar
garciay committed
345
346
347
348
            return PX_MI_RCMD_STATECINOTIFY;
        }
        
        /**
349
350
351
352
         * @desc    Get the MI-Request value used for remote command
         * @return  The MI-Request value used for remote command
         * @see     PX_MI_RCMD_REGTYPE
         */
reinaortega's avatar
reinaortega committed
353
        function f_getIutRemoteCmdForMiRequest() return MI_Request {
354
355
356
357
358
359
            return PX_MI_RCMD_REGTYPE;
        }
        
        /**
         * @desc    Get the MM-Command value used for remote command
         * @return  The MM-Command value used for remote command
garciay's avatar
garciay committed
360
361
         * @see     PX_MN_RCMD_STATECINOTIFY
         */
reinaortega's avatar
reinaortega committed
362
        function f_getIutRemoteCmdForMnCommand() return MN_Command {
garciay's avatar
garciay committed
363
364
365
366
            return PX_MN_RCMD_STATECINOTIFY;
        }
        
        /**
367
368
369
370
         * @desc    Get the MM-Request value used for remote command
         * @return  The MN-Request value used for remote command
         * @see     PX_MN_RCMD_FWYSETNOTIFY
         */
reinaortega's avatar
reinaortega committed
371
        function f_getIutRemoteCmdForMnRequest() return MN_Request {
372
373
374
375
376
377
            return PX_MN_RCMD_FWYSETNOTIFY;
        }
        
        /**
         * @desc    Get the MF-Command value used for remote command
         * @return  The MF-Command value used for remote command
garciay's avatar
garciay committed
378
379
         * @see     PX_MF_RCMD_STATECINOTIFY
         */
reinaortega's avatar
reinaortega committed
380
        function f_getIutRemoteCmdForMfCommand() return MF_Command {
garciay's avatar
garciay committed
381
382
383
            return PX_MF_RCMD_STATECINOTIFY;
        }
        
garciay's avatar
garciay committed
384
        /**
385
386
387
388
         * @desc    Get the MF-Request value used for remote command
         * @return  The MF-Request value used for remote command
         * @see     PX_MF_RCMD_LDM_REGISTER
         */
reinaortega's avatar
reinaortega committed
389
        function f_getIutRemoteCmdForMfRequest() return MF_Request {
390
391
392
393
394
395
            return PX_MF_RCMD_LDM_REGISTER;
        }
        
        /**
         * @desc    Get the List of reference number of parameter to be monitored
         * @return  The List of reference number of parameter to be monitored
garciay's avatar
garciay committed
396
397
         * @see     PX_MI_IPARAMNOLIST
         */
reinaortega's avatar
reinaortega committed
398
        function f_getIutIparamNoList() return IParamNoList {
garciay's avatar
garciay committed
399
400
401
402
            return PX_MI_IPARAMNOLIST;
        }
        
        /**
403
404
         * @desc    Get the list of error status for each parameter to be monitored
         * @return  The list of error status for each parameter to be monitored
garciay's avatar
garciay committed
405
406
         * @see     PX_MI_IPARAMNOLIST
         */
reinaortega's avatar
reinaortega committed
407
        function f_getIutIparamList() return IParamList {
garciay's avatar
garciay committed
408
409
410
            return PX_MI_IPARAMLIST;
        }
        
garciay's avatar
garciay committed
411
        /**
412
413
         * @desc    Get the list of error status for each parameter to be monitored
         * @return  The list of error status for each parameter to be monitored
garciay's avatar
garciay committed
414
415
416
417
418
419
         * @see     PX_MI_ERRORSLIST
         */
        function f_getIutErrorsList() return ErrorsList { 
            return PX_MI_ERRORSLIST;
        }
        
420
421
422
423
424
425
426
427
428
        /**
         * @desc    Get a IIC-Response value
         * @return  The IIC-Response value
         * @see     PX_IIC_RESPONSE
         */
        function f_getIutIicResponse() return MF_Request_confirm { 
            return PX_IIC_RESPONSE;
        }
        
429
430
431
    } // End of group iutFunctions
    
} // End of module LibItsIicp_Functions