Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Template evaluation time(When templates are evaluated: at initialization or when they are used?)
Template evaluation time [message #1837789] Sat, 06 February 2021 13:12 Go to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 80
Registered: November 2018
Member
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 #1837791 is a reply to message #1837789] Sat, 06 February 2021 16:29 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 86
Registered: December 2015
Member
The TITAN supports the @fuzzy only for the function/altstep/testcase parameters.

So the @fuzzy template behaves as the normal one.

"Both global and local templates are initialized at the place of their declaration. This means, all template fields which are not affected by parameterization shall receive a value or matching mechanism. Template fields affected by parameterization are initialized at the time of template use."

Currently you can use parametrized templates if you need to update the template.
Re: Template evaluation time [message #1837806 is a reply to message #1837791] Sun, 07 February 2021 16:15 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 80
Registered: November 2018
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 #1837831 is a reply to message #1837789] Mon, 08 February 2021 12:02 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 36
Registered: February 2016
Member
Hi,

As Gabor said, @fuzzy in TITAN only works for parameters. The @fuzzy modifier is ignored when applied to variables or templates.

I.e.
var @fuzzy charstring  v_ts_fuzzy := v_ts;

does the exact same thing as
var charstring  v_ts_fuzzy := v_ts;


The variables in the code you posted are reinitialized every time because they are declared in an altstep that keeps repeating itself. After every 'repeat' instruction the entire altstep is executed again. This means the variables are destroyed, then recreated and initialized after every 'repeat'.

Best regards,
Botond Baranyi
Re: Template evaluation time [message #1837836 is a reply to message #1837831] Mon, 08 February 2021 12:47 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 80
Registered: November 2018
Member
Thanks, Botond!

I undserstand now that all variables in a altstep are re-initialized each time the altstep is executed again, e-g. via a repeat.


I still would like to find a way to select which variables in a altstep (which may be very complex templates) are initialized only once. We have in our 3GPP/ETSI ATSs ( in https://www.3gpp.org/ftp/tsg_ran/WG5_Test_ex-T1/TTCN/Deliveries/TTCN3) complex altsteps which result in critical runtime situation: race conditions and cpu intensive computations, which could be solved by stateing in the altstep that a particular variable is initialized once only .

I still do not understand the use of fuzzy. Could you send/post a meaningful example of its use?

Thanks and regards,
Olaf
Re: Template evaluation time [message #1837842 is a reply to message #1837836] Mon, 08 February 2021 13:54 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 36
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
Re: Template evaluation time [message #1837853 is a reply to message #1837842] Mon, 08 February 2021 16:16 Go to previous message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 80
Registered: November 2018
Member
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
Previous Topic:use of select() and file-descriptor limit
Next Topic:TTCN-3 Language Server
Goto Forum:
  


Current Time: Mon Jun 14 14:29:01 GMT 2021

Powered by FUDForum. Page generated in 0.02731 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top