[22] | 1 | /*
|
---|
| 2 | * @author STF 370
|
---|
| 3 | * @version $Id: LibIot_Functions.ttcn 16 2009-06-16 15:06:42Z pintar $
|
---|
| 4 | * @desc This module provides the functions used by the test component
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | module LibIot_Functions {
|
---|
| 8 | import from LibCommon_VerdictControl {type FncRetCode;}
|
---|
| 9 |
|
---|
| 10 | import from LibUpperTester {
|
---|
| 11 | template mw_EO_Response;
|
---|
| 12 | type EquipmentOperationReq, EquipmentOperationRsp;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | import from LibIot_TypesAndValues {
|
---|
| 16 | type IotVerdict, IotVerdictType, Status, VerdictType;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | import from LibIot_PIXITS {
|
---|
| 20 | modulepar PX_EUT_TRIGGER_RESPONSE, PX_TTCN3_VERDICT;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | import from LibIot_TestInterface {
|
---|
| 24 | type IotEquipmentUser, OracleClient, OracleServer, TestCoordinator, EquipmentUser;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | group oracleFunctions {
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * @desc Sets the conformance verdict on the oracle client and sends it to the oracle server
|
---|
| 32 | * @param p_verdict conformance verdict set by the monitor
|
---|
| 33 | * @param p_reason reason why the verdict has been set
|
---|
| 34 | */
|
---|
| 35 | function f_setConformanceVerdict(in verdicttype p_verdict,
|
---|
| 36 | in charstring p_reason)
|
---|
| 37 | runs on OracleClient {
|
---|
| 38 | var IotVerdict v_verdict := {conformance := {p_verdict, p_reason}};
|
---|
| 39 | log("Conformance verdict set to: ", p_verdict, p_reason);
|
---|
| 40 | vPort.send(v_verdict);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * @desc Sets the end-to-end verdict on the oracle client and sends it to the oracle server
|
---|
| 45 | * @param p_verdict e2e verdict set by the monitor
|
---|
| 46 | * @param p_reason reason why the verdict has been set
|
---|
| 47 | */
|
---|
| 48 | function f_setE2EVerdict(in verdicttype p_verdict, in charstring p_reason)
|
---|
| 49 | runs on OracleClient {
|
---|
| 50 | var IotVerdict v_verdict := {e2e := {p_verdict, p_reason}};
|
---|
| 51 | log("E2E verdict set to: ", p_verdict, p_reason);
|
---|
| 52 | vPort.send(v_verdict);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * @desc Gets the conformance verdict on the oracle client
|
---|
| 57 | * @return conformance verdict of oracle server
|
---|
| 58 | */
|
---|
| 59 | function f_getConformanceVerdict()
|
---|
| 60 | runs on OracleServer
|
---|
| 61 | return verdicttype {
|
---|
| 62 | return vc_conf_verdict.verdict;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | /**
|
---|
| 66 | * @desc Gets the end-to-end verdict on the oracle client
|
---|
| 67 | * @return end-to-end verdict of oracle server
|
---|
| 68 | */
|
---|
| 69 | function f_getE2EVerdict()
|
---|
| 70 | runs on OracleServer
|
---|
| 71 | return verdicttype {
|
---|
| 72 | return pass; //vc_e3e_verdict.verdict;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /**
|
---|
| 76 | * @desc Computes and logs overall verdict for end-to-end and conformance separately on oracle server
|
---|
| 77 | * @param p_verdict the verdict received
|
---|
| 78 | */
|
---|
| 79 | function f_setIotVerdict(in IotVerdict p_verdict) runs on OracleServer {
|
---|
| 80 | f_logIotVerdict(p_verdict);
|
---|
| 81 | if (ischosen(p_verdict.e2e) and PX_TTCN3_VERDICT == e_e2e) {
|
---|
| 82 | setverdict(p_verdict.e2e.verdict, p_verdict.e2e.reason);
|
---|
| 83 | } else if (ischosen(p_verdict.conformance) and PX_TTCN3_VERDICT == e_conformance) {
|
---|
| 84 | setverdict(p_verdict.conformance.verdict, p_verdict.conformance.reason);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | /**
|
---|
| 89 | * @desc Set verdict PASS on main component (to be used, e.g on TestCoordinator)
|
---|
| 90 | */
|
---|
| 91 | function f_setIotVerdictPASS(in charstring p_reason) runs on OracleServer {
|
---|
| 92 | var IotVerdict p_verdict := {
|
---|
| 93 | conformance := {verdict := pass, reason := p_reason}
|
---|
| 94 | };
|
---|
| 95 | f_setIotVerdict(p_verdict);
|
---|
| 96 | }
|
---|
| 97 | /**
|
---|
| 98 | * @desc Set verdict PASS on main component (to be used, e.g on TestCoordinator)
|
---|
| 99 | */
|
---|
| 100 | function f_setIotVerdictFAIL(in charstring p_reason) runs on OracleServer {
|
---|
| 101 | var IotVerdict p_verdict := {
|
---|
| 102 | conformance := {verdict := fail, reason := p_reason}
|
---|
| 103 | };
|
---|
| 104 | f_setIotVerdict(p_verdict);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | *
|
---|
| 110 | * @desc logs the received IOT verdict
|
---|
| 111 | * @param p_verdict The verdict to set
|
---|
| 112 | */
|
---|
| 113 | function f_logIotVerdict(in IotVerdict p_verdict) runs on OracleServer {
|
---|
| 114 | if (ischosen(p_verdict.e2e)) {
|
---|
| 115 | vc_e3e_verdict := f_getWorseVerdict(vc_e3e_verdict, p_verdict.e2e);
|
---|
| 116 | log("E2E verdict set to: ", p_verdict.e2e.verdict, "Reason: " & p_verdict.e2e.reason);
|
---|
| 117 | } else {
|
---|
| 118 | vc_conf_verdict := f_getWorseVerdict(vc_conf_verdict, p_verdict.conformance);
|
---|
| 119 | log("Conformance verdict set to: ", p_verdict.conformance.verdict, "Reason: " & p_verdict.conformance.reason);
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
| 124 | *
|
---|
| 125 | * @desc returns the worse verdict
|
---|
| 126 | * @param p_org the original verdict
|
---|
| 127 | * @param p_new the new verdict
|
---|
| 128 | * @return the worse verdict
|
---|
| 129 | */
|
---|
| 130 | function f_getWorseVerdict(in VerdictType p_org, in VerdictType p_new) return VerdictType {
|
---|
| 131 | if(p_org.verdict == pass) {
|
---|
| 132 |
|
---|
| 133 | if(p_new.verdict != pass) {
|
---|
| 134 | return p_new;
|
---|
| 135 | }
|
---|
| 136 | else {
|
---|
| 137 | return p_org;
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | else if (p_org.verdict == inconc) {
|
---|
| 141 |
|
---|
| 142 | if(p_new.verdict != pass) {
|
---|
| 143 | return p_new;
|
---|
| 144 | }
|
---|
| 145 | else {
|
---|
| 146 | return p_org;
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 | else if (p_org.verdict == fail) {
|
---|
| 150 | if(p_new.verdict == pass) {
|
---|
| 151 | return p_org;
|
---|
| 152 | }
|
---|
| 153 | else if(p_new.verdict == inconc) {
|
---|
| 154 | return p_org;
|
---|
| 155 | }
|
---|
| 156 | else {
|
---|
| 157 | return p_new;
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 | else if (p_org.verdict == error) {
|
---|
| 161 | return p_org;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | return p_org;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | /**
|
---|
| 168 | * @desc Altstep to be used for listening continously on the verdict port of the oracle server for receiving verdicts from oracle clients
|
---|
| 169 | */
|
---|
| 170 | altstep a_receiveIOTVerdict() runs on OracleServer {
|
---|
| 171 | var IotVerdict v_verdict;
|
---|
| 172 | [] vPort.receive(IotVerdict:?) -> value v_verdict {
|
---|
| 173 | f_setIotVerdict(v_verdict);
|
---|
| 174 | repeat;
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | group equipmentOperationFunctions { // TODO Update!
|
---|
| 180 | function f_sendEquipmentCmd(in EquipmentOperationReq p_req) runs on EquipmentUser {
|
---|
| 181 | var EquipmentOperationRsp v_response;
|
---|
| 182 | var charstring v_reason := "";
|
---|
| 183 |
|
---|
| 184 | T_Equipment.start(PX_EUT_TRIGGER_RESPONSE);
|
---|
| 185 | eaPort.send(p_req);
|
---|
| 186 |
|
---|
| 187 | alt{
|
---|
| 188 | [] eaPort.receive(mw_EO_Response(e_success)) -> value v_response {
|
---|
| 189 | if(ispresent(v_response.status.reason)) {
|
---|
| 190 | v_reason := v_response.status.reason;
|
---|
| 191 | f_setE2EVerdict(pass, "Equipment command """ & p_req.cmd & """successful: " & v_reason);
|
---|
| 192 | }else {
|
---|
| 193 | f_setE2EVerdict(pass, "Equipment command successful");
|
---|
| 194 | }
|
---|
| 195 | }
|
---|
| 196 | [] eaPort.receive(mw_EO_Response(?)) -> value v_response {
|
---|
| 197 | if(ispresent(v_response.status.reason)) {
|
---|
| 198 | v_reason := v_response.status.reason;
|
---|
| 199 | f_setE2EVerdict(fail, "Equipment command """ & p_req.cmd & """unsuccessful: " & v_reason);
|
---|
| 200 | }else {
|
---|
| 201 | f_setE2EVerdict(fail, "Equipment command unsuccessful: no reason given");
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 | [] T_Equipment.timeout {
|
---|
| 205 | f_setE2EVerdict(inconc, "Timer expired while waiting for reponse of Trigger command """ & p_req.cmd & """");
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 | }
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | group miscFunctions {
|
---|
| 212 | /**
|
---|
| 213 | * @desc searches the array for a given name and returns
|
---|
| 214 | * the corresponding index
|
---|
| 215 | * @param p_idx index of the port
|
---|
| 216 | * @return the index
|
---|
| 217 | */
|
---|
| 218 | function f_getMonitorIdx(in charstring p_name)
|
---|
| 219 | runs on TestCoordinator return integer {
|
---|
| 220 | var integer v_size := sizeof(vc_compIds);
|
---|
| 221 | for (var integer i := 0; i < v_size; i := i + 1) {
|
---|
| 222 | if (vc_compIds[i].name == p_name) {
|
---|
| 223 | return vc_compIds[i].index;
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 | return - 1;
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 | } |
---|