Newer
Older
/*
* @author STF 370
* @version $Id: LibIot_Functions.ttcn 16 2009-06-16 15:06:42Z pintar $
* @desc This module provides the functions used by the test component
*/
module LibIot_Functions {
import from LibCommon_VerdictControl all;
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
import from LibUpperTester {
template mw_EO_Response;
type EquipmentOperationReq, EquipmentOperationRsp;
}
import from LibIot_TypesAndValues {
type IotVerdict, IotVerdictType, Status, VerdictType;
}
import from LibIot_PIXITS {
modulepar PX_EUT_TRIGGER_RESPONSE, PX_TTCN3_VERDICT;
}
import from LibIot_TestInterface {
type IotEquipmentUser, OracleClient, OracleServer, TestCoordinator, EquipmentUser;
}
group oracleFunctions {
/**
* @desc Sets the conformance verdict on the oracle client and sends it to the oracle server
* @param p_verdict conformance verdict set by the monitor
* @param p_reason reason why the verdict has been set
*/
function f_setConformanceVerdict(in verdicttype p_verdict,
in charstring p_reason)
runs on OracleClient {
var IotVerdict v_verdict := {conformance := {p_verdict, p_reason}};
log("Conformance verdict set to: ", p_verdict, p_reason);
vPort.send(v_verdict);
}
/**
* @desc Sets the end-to-end verdict on the oracle client and sends it to the oracle server
* @param p_verdict e2e verdict set by the monitor
* @param p_reason reason why the verdict has been set
*/
function f_setE2EVerdict(in verdicttype p_verdict, in charstring p_reason)
runs on OracleClient {
var IotVerdict v_verdict := {e2e := {p_verdict, p_reason}};
log("E2E verdict set to: ", p_verdict, p_reason);
vPort.send(v_verdict);
}
/**
* @desc Gets the conformance verdict on the oracle client
* @return conformance verdict of oracle server
*/
function f_getConformanceVerdict()
runs on OracleServer
return verdicttype {
return vc_conf_verdict.verdict;
}
/**
* @desc Gets the end-to-end verdict on the oracle client
* @return end-to-end verdict of oracle server
*/
function f_getE2EVerdict()
runs on OracleServer
return verdicttype {
return vc_e3e_verdict.verdict;
}
/**
* @desc Computes and logs overall verdict for end-to-end and conformance separately on oracle server
* @param p_verdict the verdict received
*/
function f_setIotVerdict(in IotVerdict p_verdict) runs on OracleServer {
f_logIotVerdict(p_verdict);
if (ischosen(p_verdict.e2e) and PX_TTCN3_VERDICT == e_e2e) {
setverdict(p_verdict.e2e.verdict, p_verdict.e2e.reason);
} else if (ischosen(p_verdict.conformance) and PX_TTCN3_VERDICT == e_conformance) {
setverdict(p_verdict.conformance.verdict, p_verdict.conformance.reason);
}
}
/**
* @desc Set verdict PASS on main component (to be used, e.g on TestCoordinator)
*/
function f_setIotVerdictPASS(in charstring p_reason) runs on OracleServer {
var IotVerdict p_verdict := {
conformance := {verdict := pass, reason := p_reason}
};
f_setIotVerdict(p_verdict);
}
/**
* @desc Set verdict PASS on main component (to be used, e.g on TestCoordinator)
*/
function f_setIotVerdictFAIL(in charstring p_reason) runs on OracleServer {
var IotVerdict p_verdict := {
conformance := {verdict := fail, reason := p_reason}
};
f_setIotVerdict(p_verdict);
}
/**
*
* @desc logs the received IOT verdict
* @param p_verdict The verdict to set
*/
function f_logIotVerdict(in IotVerdict p_verdict) runs on OracleServer {
if (ischosen(p_verdict.e2e)) {
vc_e3e_verdict := f_getWorseVerdict(vc_e3e_verdict, p_verdict.e2e);
log("E2E verdict set to: ", p_verdict.e2e.verdict, "Reason: " & p_verdict.e2e.reason);
} else {
vc_conf_verdict := f_getWorseVerdict(vc_conf_verdict, p_verdict.conformance);
log("Conformance verdict set to: ", p_verdict.conformance.verdict, "Reason: " & p_verdict.conformance.reason);
}
}
/**
*
* @desc returns the worse verdict
* @param p_org the original verdict
* @param p_new the new verdict
* @return the worse verdict
*/
function f_getWorseVerdict(in VerdictType p_org, in VerdictType p_new) return VerdictType {
if(p_org.verdict == pass) {
if(p_new.verdict != pass) {
return p_new;
}
else {
return p_org;
}
}
else if (p_org.verdict == inconc) {
if(p_new.verdict != pass) {
return p_new;
}
else {
return p_org;
}
}
else if (p_org.verdict == fail) {
if(p_new.verdict == pass) {
return p_org;
}
else if(p_new.verdict == inconc) {
return p_org;
}
else {
return p_new;
}
}
else if (p_org.verdict == error) {
return p_org;
}
return p_org;
}
/**
* @desc Altstep to be used for listening continously on the verdict port of the oracle server for receiving verdicts from oracle clients
*/
altstep a_receiveIOTVerdict() runs on OracleServer {
var IotVerdict v_verdict;
[] vPort.receive(IotVerdict:?) -> value v_verdict {
f_setIotVerdict(v_verdict);
repeat;
}
}
}
group equipmentOperationFunctions { // TODO Update!
function f_sendEquipmentCmd(in EquipmentOperationReq p_req) runs on EquipmentUser {
var EquipmentOperationRsp v_response;
var charstring v_reason := "";
T_Equipment.start(PX_EUT_TRIGGER_RESPONSE);
eaPort.send(p_req);
alt{
[] eaPort.receive(mw_EO_Response(e_success)) -> value v_response {
T_Equipment.stop;
if(ispresent(v_response.status.reason)) {
v_reason := v_response.status.reason;
f_setE2EVerdict(pass, "Equipment command """ & p_req.cmd & """successful: " & v_reason);
}else {
f_setE2EVerdict(pass, "Equipment command successful");
}
}
[] eaPort.receive(mw_EO_Response(?)) -> value v_response {
T_Equipment.stop;
if(ispresent(v_response.status.reason)) {
v_reason := v_response.status.reason;
f_setE2EVerdict(fail, "Equipment command """ & p_req.cmd & """unsuccessful: " & v_reason);
}else {
f_setE2EVerdict(fail, "Equipment command unsuccessful: no reason given");
}
}
[] T_Equipment.timeout {
f_setE2EVerdict(inconc, "Timer expired while waiting for reponse of Trigger command """ & p_req.cmd & """");
}
}
}
}
group miscFunctions {
/**
* @desc searches the array for a given name and returns
* the corresponding index
* @param p_idx index of the port
* @return the index
*/
function f_getMonitorIdx(in charstring p_name)
runs on TestCoordinator return integer {
var integer v_size := lengthof(vc_compIds);
for (var integer i := 0; i < v_size; i := i + 1) {
if (vc_compIds[i].name == p_name) {
return vc_compIds[i].index;
}
}
return - 1;
}
}
}