Issue with variables in recursive altsteps
Altstep-level variables don't function correctly, if the altstep calls itself recursively.
Example:
module Altsteps001 {
type record ComplexStruct {
integer int1,
charstring chr,
integer int2
}
type port MSG message {
inout ComplexStruct;
} with {extension "internal"}
type component CT {
port MSG MSGport1;
}
altstep as_default_MSGport1() runs on CT {
var ComplexStruct vl_recv;
[] MSGport1.receive(?) -> value vl_recv {
log("@100 MSGport1-on jott egy ", vl_recv);
timer t_wait := 0.1; t_wait.start; t_wait.timeout; // recursive call
log("@105 vl_recv most: ", vl_recv); // incorrect output
repeat;
}
}
function f_ct1() runs on CT {
MSGport1.send({1, "1", 1});
MSGport1.send({2, "22", 2});
MSGport1.send({3, "333", 3});
timer t_wait := 2.0; t_wait.start; t_wait.timeout;
}
function f_ct2() runs on CT {
activate(as_default_MSGport1());
timer t_wait := 2.0; t_wait.start; t_wait.timeout;
}
testcase tc_001() runs on CT {
var CT ct1, ct2;
ct1 := CT.create("CT1");
ct2 := CT.create("CT2");
connect(ct1:MSGport1, ct2:MSGport1);
ct2.start(f_ct2());
ct1.start(f_ct1());
all component.done;
}
}
The received messages are stored in the activated altstep variable 'vl_recv', before the altstep is re-called (through the standalone timeout operation), and are logged after the recursive call finishes. This should log them in the opposite order they were received in, but instead the 3rd message is logged 3 times.
/cc @aknappqwt @mmagyari