Commit b7779022 authored by stancakapost's avatar stancakapost
Browse files

changed to use ptc-loopback to avoid dependence on loopback port test

adaptation implementation
parent ce6baf91
...@@ -14,54 +14,73 @@ ...@@ -14,54 +14,73 @@
module Sem_060210_ReuseofComponentTypes_002 { module Sem_060210_ReuseofComponentTypes_002 {
//MyCompA has a port pt_myPortA //MyCompA has a port pt_myPortA
type component MyCompA { type component MyCompA {
port loopbackPort pt_myPortA; port loopbackPort pt_myPortA;
} }
//MyComp has a port pt_myPortB //MyComp has a port pt_myPortB
type component MyCompB { type component MyCompB {
port loopbackPort pt_myPortB; port loopbackPort pt_myPortB;
} }
//Component GeneralComp has a timer and inherit two ports from MyCompA and MyCompB //Component GeneralComp has a timer and inherit two ports from MyCompA and MyCompB
type component GeneralComp extends MyCompA, MyCompB { type component GeneralComp extends MyCompA, MyCompB {
timer t; timer t;
} }
type port loopbackPort message { type port loopbackPort message {
inout integer; inout integer;
inout float; inout float;
} }
function loopback() runs on GeneralComp system GeneralComp {
var integer v_i;
var float v_f;
while (true) {
alt {
[] pt_myPortA.receive(integer:?) -> value v_i { pt_myPortA.send(v_i); }
[] pt_myPortA.receive(float:?) -> value v_f { pt_myPortA.send(v_f); }
[] pt_myPortB.receive(integer:?) -> value v_i { pt_myPortB.send(v_i); }
[] pt_myPortB.receive(float:?) -> value v_f { pt_myPortB.send(v_f); }
}
}
}
testcase TC_Sem_060210_ReuseofComponentTypes_002() runs on GeneralComp { testcase TC_Sem_060210_ReuseofComponentTypes_002() runs on GeneralComp {
//Send an integer from pt_myPortA: var GeneralComp v_server := GeneralComp.create;
pt_myPortA.send(2);
connect(mtc:pt_myPortA, v_server:pt_myPortA);
connect(mtc:pt_myPortB, v_server:pt_myPortB);
v_server.start(loopback());
//Send an integer from pt_myPortA:
pt_myPortA.send(2);
alt { alt {
[] pt_myPortA.receive(2) { [] pt_myPortA.receive(2) {
setverdict(pass,"Receive successful"); setverdict(pass,"Receive successful");
} }
[] pt_myPortA.receive { [] pt_myPortA.receive {
setverdict(fail,"Unexpected result"); setverdict(fail,"Unexpected result");
} }
} }
//Send an integer from pt_myPortB: //Send an integer from pt_myPortB:
pt_myPortB.send(1.0); pt_myPortB.send(1.0);
alt { alt {
[] pt_myPortB.receive(1.0) { [] pt_myPortB.receive(1.0) {
setverdict(pass,"Receive successful"); setverdict(pass,"Receive successful");
} }
[] pt_myPortB.receive { [] pt_myPortB.receive {
setverdict(fail,"Unexpected result"); setverdict(fail,"Unexpected result");
} }
} }
} }
control{ control{
execute(TC_Sem_060210_ReuseofComponentTypes_002()); execute(TC_Sem_060210_ReuseofComponentTypes_002());
} }
} }
\ No newline at end of file
...@@ -11,60 +11,80 @@ ...@@ -11,60 +11,80 @@
* Any of the parent types may also be defined by means of extension. * Any of the parent types may also be defined by means of extension.
*/ */
module Sem_060210_ReuseofComponentTypes_003 { module Sem_060210_ReuseofComponentTypes_003 {
//MyCompA has a port pt_myPortA //MyCompA has a port pt_myPortA
type component MyCompA { type component MyCompA {
port loopbackPort pt_myPortA; port loopbackPort pt_myPortA;
var integer MyInt; var integer MyInt;
} }
//MyComp has a port pt_myPortB and inherit a port (pt_myPortA) form MyCompA //MyComp has a port pt_myPortB and inherit a port (pt_myPortA) form MyCompA
type component MyCompB extends MyCompA { type component MyCompB extends MyCompA {
port loopbackPort pt_myPortB; port loopbackPort pt_myPortB;
} }
//Component GeneralComp has a timer and inherit two ports from MyCompB (pt_myPortA and pt_myPortB) //Component GeneralComp has a timer and inherit two ports from MyCompB (pt_myPortA and pt_myPortB)
type component GeneralComp extends MyCompB { type component GeneralComp extends MyCompB {
timer t; timer t;
} }
type port loopbackPort message { type port loopbackPort message {
inout integer; inout integer;
inout float; inout float;
} }
testcase TC_Sem_060210_ReuseofComponentTypes_003() runs on GeneralComp { function loopback() runs on GeneralComp {
var integer v_i;
var float v_f;
while (true) {
alt {
[] pt_myPortA.receive(integer:?) -> value v_i { pt_myPortA.send(v_i); }
[] pt_myPortA.receive(float:?) -> value v_f { pt_myPortA.send(v_f); }
[] pt_myPortB.receive(integer:?) -> value v_i { pt_myPortB.send(v_i); }
[] pt_myPortB.receive(float:?) -> value v_f { pt_myPortB.send(v_f); }
}
}
}
testcase TC_Sem_060210_ReuseofComponentTypes_003() runs on GeneralComp system GeneralComp {
var GeneralComp v_server := GeneralComp.create;
connect(mtc:pt_myPortA, v_server:pt_myPortA);
connect(mtc:pt_myPortB, v_server:pt_myPortB);
v_server.start(loopback());
//Set a value to MyInt: //Set a value to MyInt:
MyInt := 10; MyInt := 10;
//Send an integer from pt_myPortA: //Send an integer from pt_myPortA:
pt_myPortA.send(2); pt_myPortA.send(2);
alt { alt {
[] pt_myPortA.receive(2) { [] pt_myPortA.receive(2) {
setverdict(pass,"Receive successful"); setverdict(pass,"Receive successful");
} }
[] pt_myPortA.receive { [] pt_myPortA.receive {
setverdict(fail,"Unexpected result"); setverdict(fail,"Unexpected result");
} }
} }
//Send an integer from pt_myPortB: //Send an integer from pt_myPortB:
pt_myPortB.send(1.0); pt_myPortB.send(1.0);
alt { alt {
[] pt_myPortB.receive(1.0) { [] pt_myPortB.receive(1.0) {
setverdict(pass,"Receive successful"); setverdict(pass,"Receive successful");
} }
[] pt_myPortB.receive { [] pt_myPortB.receive {
setverdict(fail,"Unexpected result"); setverdict(fail,"Unexpected result");
} }
} }
} }
control{ control{
execute(TC_Sem_060210_ReuseofComponentTypes_003()); execute(TC_Sem_060210_ReuseofComponentTypes_003());
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment