Newer
Older
* @author ETSI / STF405
* @version $URL$
* $Id$
* @desc Module containing common functions for ITS
// LibCommon
import from LibCommon_Sync all;
import from LibCommon_VerdictControl all;
// LibIts
import from DENM_PDU_Descriptions language "ASN.1:1997" all;
import from LibItsCommon_Pixits all;
import from LibIts_Interface all;
import from LibItsCommon_TypesAndValues all;
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
group upperTester {
/**
* @desc Requests to bring the IUT in an initial state
* @param p_init The initialisation to trigger.
*/
function f_utInitializeIut(template (value) UtInitialize p_init) runs on ItsAdapterComponent {
utPort.send(p_init);
tc_wait.start;
alt {
[] utPort.receive(UtResult:true) {
tc_wait.stop;
log("*** f_utInitializeIut: INFO: IUT initialized ***");
}
[] utPort.receive {
tc_wait.stop;
f_selfOrClientSyncAndVerdict("error", e_error, "*** IUT could not be initialized ***");
}
[] tc_wait.timeout {
f_selfOrClientSyncAndVerdict("error", e_timeout, "*** IUT could not be initialized in time ***");
}
}
}
/**
* @desc Triggers event from the application layer
* @param p_event The event to trigger.
* @return
*/
function f_utTriggerEvent(template (value) UtEvent p_event) runs on ItsAdapterComponent {
var template (value) UtTrigger v_utMsg := { p_event };
utPort.send(v_utMsg);
}
/**
* @desc Checks that the event was indicated at the application layer
* @param p_event The event to check.
* @param p_discard The event should not appear. Default value: FALSE.
* @return
*/
function f_utCheckEvent(template (value) UtEvent p_event, boolean p_discard := false) runs on ItsAdapterComponent {
var template (value) UtCheck v_utMsg := { p_event };
utPort.send(v_utMsg);
tc_wait.start;
alt {
[] utPort.receive(UtResult:true) {
tc_wait.stop;
if (p_discard == false) {
log("*** f_utCheckEvent: Event correctly indicated at application layer ***");
}
else {
f_selfOrClientSyncAndVerdict("error", e_error, "*** f_utCheckEvent: Event indicated at application layer where it should be discarded ***");
}
}
[] utPort.receive {
tc_wait.stop;
if (p_discard == false) {
f_selfOrClientSyncAndVerdict("error", e_error, "*** f_utCheckEvent: Event not correctly indicated at application layer ***");
}
else {
log("*** f_utCheckEvent: Another event indicated at application layer, repeating check ***");
repeat;
}
}
[] tc_wait.timeout {
if (p_discard == false) {
f_selfOrClientSyncAndVerdict("error", e_timeout, "*** f_utCheckEvent: Timeout while waiting for event check result ***");
}
else {
log("*** f_utCheckEvent: Event not indicated at application layer ***");
}
}
}
}
} // end of group upper tester
group generalFunctions {
/**
* @desc function to generate integer random values
*
* @see ttcn-3 - rnd()
* @param p_lowerbound lowest number in range
* @param p_upperbound highest number in range
* @return random integer
*
*/
function f_random( in integer p_lowerbound,
in integer p_upperbound )
return integer {
//Variables
var integer v_random := 0;
v_random := float2int(int2float(p_upperbound - p_lowerbound +1)*rnd()) + p_lowerbound;
log("*** f_random: INFO: OK - random value = " & int2str(v_random) & " ***");
return v_random;
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
/**
* @desc Gets the current time
* @return Timestamp - current time in Epoch format
*/
function f_getCurrentTime() return TimeStamp {
var TimeStamp v_timeStamp := 0;
v_timeStamp := fx_getCurrentTime();
return v_timeStamp;
}
} // end generalFunctions
group itsFunctions {
/**
* @desc Gets the station identifier of test system
* @return Test system's station ID
* @see PX_TESTER_STATION_ID
*/
function f_getTsStationId()
return StationID {
return PX_TESTER_STATION_ID;
} // end f_getTsStationId
/**
* @desc Gets the current position of test system
* @return Test system's position
*/
function f_getTsCurrentPosition() return ReferencePosition {
// TODO: correct values required
var ReferencePosition v_referencePosition := {
longitude := {hemisphere := east, degree := 0},
latitude := {hemisphere := north, degree := 0},
elevation := 0,
heading := omit,
streetName := omit,
positionConfidence := omit,
elevationConfidence := omit,
roadSegmentID :=0
}
return v_referencePosition;
} // end f_getTsCurrentPosition
} // end itsFunctions
group externalFunctions {
/**
* @desc Gets the current time
* @return Timestamp - current time in Epoch format
*/
external function fx_getCurrentTime() return TimeStamp;
} // end externalFunctions