Loading LibIot/LibIot_Functions.ttcn +68 −44 Original line number Diff line number Diff line module LibIot_Functions { import from LibIot_PICS {modulepar PX_CONFOMANCE_CHECK;} import from LibIot_TypesAndValues {type IOTVerdict;} Loading @@ -8,46 +7,71 @@ module LibIot_Functions { type TestCoordinator, TestMonitor, TestOracle; } function f_setConformanceVerdict(in verdicttype p_verdict, in charstring p_reason) runs on TestMonitor { /** * @desc sets the conformance verdict and send it to the test oracle * @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 TestMonitor { log("Conformance verdict set to: ", p_verdict); log(p_reason); var IOTVerdict v_verdict := {conformance := p_verdict}; vPort.send(v_verdict); } function f_setE2EVerdict(in verdicttype p_verdict, in charstring p_reason) runs on TestMonitor { /** * @desc sets the end-to-end verdict and send it to the test oracle * @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 TestMonitor { log("E2E verdict set to: ", p_verdict); log(p_reason); var IOTVerdict v_verdict := {e2e := p_verdict}; vPort.send(v_verdict); } /** * @desc evaluate the test verdict and sets it correspondingly * @param p_verdict the verdict received */ function f_setVerdict(in IOTVerdict p_verdict) runs on TestOracle { if (ischosen(p_verdict.e2e)) { setverdict(p_verdict.e2e); } else if(PX_CONFOMANCE_CHECK) { } else if (PX_CONFOMANCE_CHECK) { setverdict(p_verdict.conformance); } } /** * @desc listens continously on the port for receiving verdict * @param p_idx index of the port */ altstep a_receiveIOTVerdict(in integer p_idx) runs on TestOracle { var IOTVerdict v_verdict; [] vPort[p_idx].receive(IOTVerdict:?) -> value v_verdict { f_setVerdict(v_verdict); repeat; } } function f_getMonitorIdx(in charstring p_name) runs on TestCoordinator return integer { /** * @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 := sizeof(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; } } No newline at end of file LibIot/LibIot_TestConfiguration.ttcn +34 −4 Original line number Diff line number Diff line Loading @@ -6,16 +6,34 @@ module LibIot_TestConfiguration { type TestCoordinator, TestMonitor, TestOracle; } /** * @desc connects the port of the monitor component to the * port of the test oracle and activates the default * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_oracle_up(in TestMonitor p_monitor, in integer p_idx) runs on TestOracle { connect(self:vPort[p_idx], p_monitor:vPort); vc_monitorDefaults[p_idx] := activate(a_receiveIOTVerdict(p_idx)); } /** * @desc deactivates the default and disconnects the port of the monitor * component * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_oracle_down(in TestMonitor p_monitor, in integer p_idx) runs on TestOracle { deactivate(vc_monitorDefaults[p_idx]); disconnect(self:vPort[p_idx], p_monitor:vPort); } /** * @desc configures monitor component: connects to the synchronnization * port, maps to the TSI port and connects to the oracle * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_monitor_up(in TestMonitor p_monitor, in integer p_idx) runs on TestCoordinator { // connect sync ports connect(p_monitor:syncPort, self:syncPort); Loading @@ -25,6 +43,12 @@ module LibIot_TestConfiguration { f_cf_oracle_up(p_monitor, p_idx); } /** * @desc frees monitor component: disconnects the synchronnization * port, unmaps from the TSI port and disconnects from the oracle * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_monitor_down(in TestMonitor p_monitor, in integer p_idx) runs on TestCoordinator { // connect sync ports disconnect(p_monitor:syncPort, self:syncPort); Loading @@ -34,6 +58,12 @@ module LibIot_TestConfiguration { f_cf_oracle_down(p_monitor, p_idx); } /** * @desc creates a monitor component and store its name and id in * an array * @param p_name name of the monitor component * @return the created monitor component */ function f_cf_create_monitor(in charstring p_name) runs on TestCoordinator return TestMonitor { var TestMonitor v_monitor := TestMonitor.create(p_name); var integer v_size := sizeof(vc_compIds); Loading LibIot/LibIot_TestInterface.ttcn +5 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,16 @@ module LibIot_TestInterface { const all; } /** * @desc interfaces to the SUT */ type component SystemInterface { port MonitorPort mPort[c_NUM_OF_MONITORS]; port DeviceControllPort dcPort[c_NUM_OF_DEVICES]; port TriggerPort tPort[c_NUM_OF_TRIGGER_POINTS]; } type port MonitorPort message { in all; } Loading Loading
LibIot/LibIot_Functions.ttcn +68 −44 Original line number Diff line number Diff line module LibIot_Functions { import from LibIot_PICS {modulepar PX_CONFOMANCE_CHECK;} import from LibIot_TypesAndValues {type IOTVerdict;} Loading @@ -8,46 +7,71 @@ module LibIot_Functions { type TestCoordinator, TestMonitor, TestOracle; } function f_setConformanceVerdict(in verdicttype p_verdict, in charstring p_reason) runs on TestMonitor { /** * @desc sets the conformance verdict and send it to the test oracle * @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 TestMonitor { log("Conformance verdict set to: ", p_verdict); log(p_reason); var IOTVerdict v_verdict := {conformance := p_verdict}; vPort.send(v_verdict); } function f_setE2EVerdict(in verdicttype p_verdict, in charstring p_reason) runs on TestMonitor { /** * @desc sets the end-to-end verdict and send it to the test oracle * @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 TestMonitor { log("E2E verdict set to: ", p_verdict); log(p_reason); var IOTVerdict v_verdict := {e2e := p_verdict}; vPort.send(v_verdict); } /** * @desc evaluate the test verdict and sets it correspondingly * @param p_verdict the verdict received */ function f_setVerdict(in IOTVerdict p_verdict) runs on TestOracle { if (ischosen(p_verdict.e2e)) { setverdict(p_verdict.e2e); } else if(PX_CONFOMANCE_CHECK) { } else if (PX_CONFOMANCE_CHECK) { setverdict(p_verdict.conformance); } } /** * @desc listens continously on the port for receiving verdict * @param p_idx index of the port */ altstep a_receiveIOTVerdict(in integer p_idx) runs on TestOracle { var IOTVerdict v_verdict; [] vPort[p_idx].receive(IOTVerdict:?) -> value v_verdict { f_setVerdict(v_verdict); repeat; } } function f_getMonitorIdx(in charstring p_name) runs on TestCoordinator return integer { /** * @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 := sizeof(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; } } No newline at end of file
LibIot/LibIot_TestConfiguration.ttcn +34 −4 Original line number Diff line number Diff line Loading @@ -6,16 +6,34 @@ module LibIot_TestConfiguration { type TestCoordinator, TestMonitor, TestOracle; } /** * @desc connects the port of the monitor component to the * port of the test oracle and activates the default * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_oracle_up(in TestMonitor p_monitor, in integer p_idx) runs on TestOracle { connect(self:vPort[p_idx], p_monitor:vPort); vc_monitorDefaults[p_idx] := activate(a_receiveIOTVerdict(p_idx)); } /** * @desc deactivates the default and disconnects the port of the monitor * component * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_oracle_down(in TestMonitor p_monitor, in integer p_idx) runs on TestOracle { deactivate(vc_monitorDefaults[p_idx]); disconnect(self:vPort[p_idx], p_monitor:vPort); } /** * @desc configures monitor component: connects to the synchronnization * port, maps to the TSI port and connects to the oracle * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_monitor_up(in TestMonitor p_monitor, in integer p_idx) runs on TestCoordinator { // connect sync ports connect(p_monitor:syncPort, self:syncPort); Loading @@ -25,6 +43,12 @@ module LibIot_TestConfiguration { f_cf_oracle_up(p_monitor, p_idx); } /** * @desc frees monitor component: disconnects the synchronnization * port, unmaps from the TSI port and disconnects from the oracle * @param p_monitor monitor component * @param p_idx index of the monitor component */ function f_cf_monitor_down(in TestMonitor p_monitor, in integer p_idx) runs on TestCoordinator { // connect sync ports disconnect(p_monitor:syncPort, self:syncPort); Loading @@ -34,6 +58,12 @@ module LibIot_TestConfiguration { f_cf_oracle_down(p_monitor, p_idx); } /** * @desc creates a monitor component and store its name and id in * an array * @param p_name name of the monitor component * @return the created monitor component */ function f_cf_create_monitor(in charstring p_name) runs on TestCoordinator return TestMonitor { var TestMonitor v_monitor := TestMonitor.create(p_name); var integer v_size := sizeof(vc_compIds); Loading
LibIot/LibIot_TestInterface.ttcn +5 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,16 @@ module LibIot_TestInterface { const all; } /** * @desc interfaces to the SUT */ type component SystemInterface { port MonitorPort mPort[c_NUM_OF_MONITORS]; port DeviceControllPort dcPort[c_NUM_OF_DEVICES]; port TriggerPort tPort[c_NUM_OF_TRIGGER_POINTS]; } type port MonitorPort message { in all; } Loading