Home » Eclipse Projects » Eclipse Titan » Template evaluation time(When templates are evaluated: at initialization or when they are used?)
| |
Re: Template evaluation time [message #1837806 is a reply to message #1837791] |
Sun, 07 February 2021 16:15 |
Olaf Bergengruen Messages: 127 Registered: November 2018 |
Senior Member |
|
|
Thanks, Gábor!
- OK, that templates, except for the parameters, are setup at initialization time, and not at use time.
- Not OK with the use of @fuzzy. I could not manage to use it in any meaningful way. In the example below, my focus was to intitialize 'fuzzy' variable v_ts_fuzzy only once and not each time a time even occurs. But this does not work
Could you correct my code or send me any example which shows the usage of @fuzzy and works with TITAN?
external function fx_Timestamp() return charstring;
altstep a_TestFuzzy(timer p_tt, timer p_TMax)
{
var charstring v_ts := fx_Timestamp(); // 'normal' variable is evaluated at each timout event
var @fuzzy charstring v_ts_fuzzy := v_ts; // 'fuzzy' variable should be evaluated only once
[] p_tt.timeout {
log(v_ts);
log(v_ts_fuzzy);
p_tt.start(1.0);
repeat;
}
[] p_TMax.timeout {
log("altstep done - Final timestamp " & v_ts);
}
}
function f_TestFuzzy()
{
timer tt;
timer TMax;
tt.start(1.0);
TMax.start(5.0);
a_TestFuzzy(tt, TMax);
setverdict(pass);
}
Thanks and regards,
Olaf
|
|
| | |
Re: Template evaluation time [message #1837842 is a reply to message #1837836] |
Mon, 08 February 2021 13:54 |
Botond Baranyi Messages: 55 Registered: February 2016 |
Member |
|
|
Hi,
Here's an example from the TTCN-3 standard about how @fuzzy parameters work:
type record MyMessage { integer id, float number }
type port MyPortType message { inout MyMessage }
type component MyMTC {
var integer vc_id;
port MyPortType p;
}
...
function f_sendFuzzy(@fuzzy MyMessage p_pdu) runs on MyMTC {
for (vc_id := 1; vc_id<9; vc_id:=vc_id+1){
p.send(p_pdu); // the actual parameter passed to the formal parameter p_pdu is evaluated in each
// loop; let say rnd() returns 0.924946, 0.680497, 0.630836, 0.648681, 0.428501,
// 0.262539, 0.646990, 0.265262 in subsequent calls; the messages { 1, 0.924946 },
// { 2, 0.680497 }, { 3, 0.630836 }, { 4, 0.648681 }, { 5, 0.428501 },
// { 6, 0.262539 }, { 7, 0.646990 } and { 8, 0.265262 } are sent out in sequence
}
setverdict(pass,"messages have been sent out")
}
I'm not sure how to get altstep variables to only be initialized once... Perhaps changing them into global variables or component variables (of the altstep's 'runs on' component) would work?
Best regards,
Botond Baranyi
|
|
| |
Goto Forum:
Current Time: Thu Oct 10 16:34:26 GMT 2024
Powered by FUDForum. Page generated in 0.04303 seconds
|