Template evaluation time [message #1837789] |
Sat, 06 February 2021 08:12  |
Eclipse User |
|
|
|
Hi TTCN/ Titan experts,
We are not sure whether the point in time when templates are evaluated (i.e. produced) is inline with the latest TTCN spec 4.12.1, and whether it is possible to force Titan to evaluate a template anew when it is used. This is important when a template depends on external function getting data from the outside world, or depends on global variables which have been changed during execution.
Attached a simple example executed with Titan 7.1.1.
The execution output is shown below and marked with ??? are the places where we expect a different output, i.e. the current timestamp, not the initial one.
"cs_Testcasename1: "
"testcasename(): TC_Template_Test"
"cs_Testcasename2: "
"Test 0"
"cs_Time1: 2021-01-25T17:43:53+01:00"
"fx_Timestamp(): 2021-01-25T17:43:54+01:00"
"cs_Time2: 2021-01-25T17:43:53+01:00"
"Test 1"
"cs_Time1: 2021-01-25T17:43:53+01:00" <--???
"fx_Timestamp(): 2021-01-25T17:43:55+01:00"
"cs_Time2: 2021-01-25T17:43:53+01:00" <--???
"Test 2"
"cs_Time1: 2021-01-25T17:43:53+01:00" <--???
"fx_Timestamp(): 2021-01-25T17:43:56+01:00"
"cs_Time2: 2021-01-25T17:43:53+01:00" <--???
"Test 3"
"cs_Time1: 2021-01-25T17:43:53+01:00" <--???
"fx_Timestamp(): 2021-01-25T17:43:57+01:00"
"cs_Time2: 2021-01-25T17:43:53+01:00" <--???
"Test 4"
"cs_Time1: 2021-01-25T17:43:53+01:00" <--???
"fx_Timestamp(): 2021-01-25T17:43:58+01:00"
"cs_Time2: 2021-01-25T17:43:53+01:00" <--???
Any comments are welcome,
Olaf @ ETSI -TF160
|
|
|
|
Re: Template evaluation time [message #1837806 is a reply to message #1837791] |
Sun, 07 February 2021 11:15   |
Eclipse User |
|
|
|
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 08:54   |
Eclipse User |
|
|
|
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
|
|
|
Re: Template evaluation time [message #1837853 is a reply to message #1837842] |
Mon, 08 February 2021 11:16  |
Eclipse User |
|
|
|
Thanks, Botond! You got my question !
Yes, a PTC global variable for accessing it inside the altstep could be a solution to the problem of 'disabling' re-evaluation of some of the critical altstep variables.
Regards,
Olaf
|
|
|
Powered by
FUDForum. Page generated in 0.05234 seconds