Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Component's variable

Component's variable 19 Sep 2007 09:33 #7241

Hello!

I have a question and i would like to ask your help is it's possible.
I would like to define default values to my component's variables.
e.g.: type component AComponent
{
var request_id_list_type request_id_list;
}

In this case i would like to define default starting value to the
request_id_list which is an array from octetstrings.

If this is not possible is there any way for creating a function
which is called when the component is created (like a constructor in
the C++).

Thanks for your help in advance,
Csaba
The administrator has disabled public write access.

Component's variable 19 Sep 2007 09:50 #7242

  • G
  • G's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Karma: 0
Hi,

That is quite possible. You must use "constant" values for initialization, however. That is, use either module parameters, constants, or literal values. For example:

//put your initial value in
modulepar request_id_list_type tsp_initialIdList;
modulepar request_id_list_type tsp_initialIdList2 := {''O};
const request_id_list_type c_fixedInitialIdList := {'00112233'O, '33221100'O);
type component AComponent
{
var request_id_list_type request_id_list := tsp_initialIdList,
request_id_list2 := tsp_initialIdList2,
request_id_list3 := c_fixedInitialIdList,
request_id_list4 := {};
}

BR,


Gábor Ziegler M.Sc.E.E., dr.univ
Test System Engineer
Test Competence Center

Ericsson Hungary Ltd.

Research & Development
Budapest, XI. Irinyi. J. u. 4-20.
www.ericsson.com

Office: +36 1 437 7361
Fax: +36 1 439 5176
Mobile: +30 30 219 9805
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Ericsson Magyarország Kft., Székhely: Budapest, Laborc u.1. Nyilvántartó cégbíróság: Fővárosi Bíróság. Cégjegyzékszám: 01-09-070937

This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interception, unauthorized amendment, tampering and viruses, and we only send and receive emails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.




>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Csaba Bejan
> Sent: 2007. September 19, Wednesday 11:33
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Component's variable
>
> Hello!
>
> I have a question and i would like to ask your help is it's
> possible.
> I would like to define default values to my component's variables.
> e.g.: type component AComponent
> {
> var request_id_list_type
> request_id_list;
> }
>
> In this case i would like to define default starting value
> to the request_id_list which is an array from octetstrings.
>
> If this is not possible is there any way for creating a
> function which is called when the component is created (like
> a constructor in the C++).
>
> Thanks for your help in advance,
> Csaba
>
The administrator has disabled public write access.

Component's variable 19 Sep 2007 10:22 #7243

Dear Csaba,

why should it not be possible?

There are two ways on how to handle an array type of thing:

record/set of octetstring
or the array notation

Examples:
type record of octetstring myList ;
type octetstring O[2] ;

type component C {
var octetstring o[2] := { 'AA'O, 'BB'O } ; // 1
var myList l := { 'AA'O, 'BB'O } ; // 2
var O o2 := { 'AA'O, 'BB'O } ; // 3
}

Initialization by:
(1) make use of the array notation without an explicit type
(2) using a record of octetstring type
(3) using an array type of octetstring


Gruss, Theo


Csaba Bejan schrieb:
> Hello!
>
> I have a question and i would like to ask your help is it's possible.
> I would like to define default values to my component's variables.
> e.g.: type component AComponent
> {
> var request_id_list_type request_id_list;
> }
>
> In this case i would like to define default starting value to the
> request_id_list which is an array from octetstrings.
>
> If this is not possible is there any way for creating a function
> which is called when the component is created (like a constructor in
> the C++).
>
> Thanks for your help in advance,
> Csaba
>
The administrator has disabled public write access.

Component's variable 19 Sep 2007 11:37 #7244

Hi

There are plenty of ways. You may use references to constants, module
parameters and other component variables as well as function return values
to initialize the variable.
The another choice is to pass your variable as 'out' parameter to a function
that initializes dummy variable located on the next line.

type octetstring ARR[2]

type component CT
{
var ARR v1 := {INIT('00'O), INIT('11'O)} // use return value
var ARR v2
var boolean dummy := INIT_HELPER(v2) // use 'out' parameter
}

function INIT(octetstring u) return octetstring
{
return u;
}

function INIT_HELPER(out ARR u) return boolean
{
u[0] := '00'O;
u[1] := '11'O;
return true;
}

Best regards,
Pavel Yakovenko

Original Message
From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Csaba Bejan
Sent: Wednesday, September 19, 2007 1:33 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Component's variable

Hello!

I have a question and i would like to ask your help is it's possible.
I would like to define default values to my component's variables.
e.g.: type component AComponent
{
var request_id_list_type
request_id_list;
}

In this case i would like to define default starting value to the
request_id_list which is an array from octetstrings.

If this is not possible is there any way for creating a function
which is called when the component is created (like a constructor in
the C++).

Thanks for your help in advance,
Csaba
The administrator has disabled public write access.

Component's variable 19 Sep 2007 11:58 #7245

Hello!

Thanks for all of you for the quick help. Now i see how it should
work:), i tried it and it's working fine.

Thanks again,
Csaba

On 9/19/07, Pavel Yakovenko <This email address is being protected from spambots. You need JavaScript enabled to view it.> wrote:
> Hi
>
> There are plenty of ways. You may use references to constants, module
> parameters and other component variables as well as function return values
> to initialize the variable.
> The another choice is to pass your variable as 'out' parameter to a function
> that initializes dummy variable located on the next line.
>
> type octetstring ARR[2]
>
> type component CT
> {
> var ARR v1 := {INIT('00'O), INIT('11'O)} // use return value
> var ARR v2
> var boolean dummy := INIT_HELPER(v2) // use 'out' parameter
> }
>
> function INIT(octetstring u) return octetstring
> {
> return u;
> }
>
> function INIT_HELPER(out ARR u) return boolean
> {
> u[0] := '00'O;
> u[1] := '11'O;
> return true;
> }
>
> Best regards,
> Pavel Yakovenko
>
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Csaba Bejan
> Sent: Wednesday, September 19, 2007 1:33 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Component's variable
>
> Hello!
>
> I have a question and i would like to ask your help is it's possible.
> I would like to define default values to my component's variables.
> e.g.: type component AComponent
> {
> var request_id_list_type
> request_id_list;
> }
>
> In this case i would like to define default starting value to the
> request_id_list which is an array from octetstrings.
>
> If this is not possible is there any way for creating a function
> which is called when the component is created (like a constructor in
> the C++).
>
> Thanks for your help in advance,
> Csaba
>
The administrator has disabled public write access.

Component's variable 19 Sep 2007 12:23 #7246

  • G
  • G's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Karma: 0
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Pavel Yakovenko
> Sent: 2007. September 19, Wednesday 13:38
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Component's variable
>
> Hi
>
> There are plenty of ways. You may use references to
> constants, module parameters and other component variables as
> well as function return values to initialize the variable.
> The another choice is to pass your variable as 'out'
> parameter to a function that initializes dummy variable
> located on the next line.
>
Just one note: using functions could result in nasty race-conditions, since a.f.a.i.k. the TTCN-3 semantics does not define any particular order of executing the variable instantiations of a component...

So, IMHO, wise people would just use "constant values" here (i.e., constants, module pars and literals), and write additional initialization functions to be explicitly invoked from the behavioral specification of the component. That is, that are explicitly invoked from either the test case body in case of the MTC; or from the function(s) bodi(es) that is (are) used as argument(s) to the start() operation(s) of the other PTC(s)

BR,
Gabor


Gábor Ziegler M.Sc.E.E., dr.univ
Test System Engineer
Test Competence Center

Ericsson Hungary Ltd.

Research & Development
Budapest, XI. Irinyi. J. u. 4-20.
www.ericsson.com

Office: +36 1 437 7361
Fax: +36 1 439 5176
Mobile: +30 30 219 9805
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Ericsson Magyarország Kft., Székhely: Budapest, Laborc u.1. Nyilvántartó cégbíróság: Fővárosi Bíróság. Cégjegyzékszám: 01-09-070937

This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interception, unauthorized amendment, tampering and viruses, and we only send and receive emails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.

> type octetstring ARR[2]
>
> type component CT
> {
> var ARR v1 := {INIT('00'O), INIT('11'O)} // use return value
> var ARR v2
> var boolean dummy := INIT_HELPER(v2) // use 'out' parameter }
>
> function INIT(octetstring u) return octetstring {
> return u;
> }
>
> function INIT_HELPER(out ARR u) return boolean {
> u[0] := '00'O;
> u[1] := '11'O;
> return true;
> }
>
> Best regards,
> Pavel Yakovenko
>
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Csaba Bejan
> Sent: Wednesday, September 19, 2007 1:33 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Component's variable
>
> Hello!
>
> I have a question and i would like to ask your help is it's
> possible.
> I would like to define default values to my component's variables.
> e.g.: type component AComponent
> {
> var request_id_list_type
> request_id_list;
> }
>
> In this case i would like to define default starting value
> to the request_id_list which is an array from octetstrings.
>
> If this is not possible is there any way for creating a
> function which is called when the component is created (like
> a constructor in the C++).
>
> Thanks for your help in advance,
> Csaba
>
The administrator has disabled public write access.

Component's variable 20 Sep 2007 07:20 #7247

Hi,

Gabor's comment is a good topic to provide a CR to ETSI!

BR, Gyorgy

Original Message
From: active_ttcn3 : mts stf133 ttcn version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Gábor Ziegler
Sent: Wednesday, 19 September, 2007 2:23 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Component's variable



>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Pavel Yakovenko
> Sent: 2007. September 19, Wednesday 13:38
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Component's variable
>
> Hi
>
> There are plenty of ways. You may use references to constants, module
> parameters and other component variables as well as function return
> values to initialize the variable.
> The another choice is to pass your variable as 'out'
> parameter to a function that initializes dummy variable located on the
> next line.
>
Just one note: using functions could result in nasty race-conditions, since a.f.a.i.k. the TTCN-3 semantics does not define any particular order of executing the variable instantiations of a component...

So, IMHO, wise people would just use "constant values" here (i.e., constants, module pars and literals), and write additional initialization functions to be explicitly invoked from the behavioral specification of the component. That is, that are explicitly invoked from either the test case body in case of the MTC; or from the function(s) bodi(es) that is (are) used as argument(s) to the start() operation(s) of the other PTC(s)

BR,
Gabor


Gábor Ziegler M.Sc.E.E., dr.univ
Test System Engineer
Test Competence Center

Ericsson Hungary Ltd.

Research & Development
Budapest, XI. Irinyi. J. u. 4-20.
www.ericsson.com

Office: +36 1 437 7361
Fax: +36 1 439 5176
Mobile: +30 30 219 9805
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Ericsson Magyarország Kft., Székhely: Budapest, Laborc u.1. Nyilvántartó cégbíróság: Fővárosi Bíróság. Cégjegyzékszám: 01-09-070937

This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interception, unauthorized amendment, tampering and viruses, and we only send and receive emails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.

> type octetstring ARR[2]
>
> type component CT
> {
> var ARR v1 := {INIT('00'O), INIT('11'O)} // use return value
> var ARR v2
> var boolean dummy := INIT_HELPER(v2) // use 'out' parameter }
>
> function INIT(octetstring u) return octetstring {
> return u;
> }
>
> function INIT_HELPER(out ARR u) return boolean {
> u[0] := '00'O;
> u[1] := '11'O;
> return true;
> }
>
> Best regards,
> Pavel Yakovenko
>
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Csaba Bejan
> Sent: Wednesday, September 19, 2007 1:33 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Component's variable
>
> Hello!
>
> I have a question and i would like to ask your help is it's
> possible.
> I would like to define default values to my component's variables.
> e.g.: type component AComponent
> {
> var request_id_list_type
> request_id_list;
> }
>
> In this case i would like to define default starting value to the
> request_id_list which is an array from octetstrings.
>
> If this is not possible is there any way for creating a function
> which is called when the component is created (like a constructor in
> the C++).
>
> Thanks for your help in advance,
> Csaba
>
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin