Author Topic: Questions About The Code Templates  (Read 4380 times)

chiweis

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Questions About The Code Templates
« on: March 01, 2007, 11:13:47 pm »
Hello. :)
I am using the Code Templates to customize the way of code generation. But there is several problem that confused me a lot:
1. How to access embedded elements??
For example, the class elements can contain ports as embedded elements. The ports thus become member variables of the class element. If I want to write code templates for it, how can I do? ???

2. How to connect the state machine element with member functions of a class element?
I want to use the state machine diagram to depict the operations of member funcions of a class element. But the state machine and the class are two different elements, how can I make them know each other? ???

3. Is there any language reference manual for the Code Template Framework??
What I've got is the section of Code Template Framework in EA User Guide. I was wondering if there is another manual about it. :-/

If anybody has any suggestion, please reply to me.
Thanks a lot!! :D

Best Regards.
chiweis

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Questions About The Code Templates
« Reply #1 on: March 02, 2007, 07:00:57 am »
Have you looked at the Sparx Resources page? In particular, how about http://www.sparxsystems.com.au/resources/mda/writing_transformations.html?
No, you can't have it!

chiweis

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Questions About The Code Templates
« Reply #2 on: March 03, 2007, 05:29:07 am »
Dear Midnight:

 Thx for your suggestion. I have read the sections of transformations. The purpose of that is to convert a PIM to different PSMs. It may not what I need..   :-[

 What I want to do is to write a set of Code Template for generating source code. Take the picture in the link below for example, the class object has an embedded element "port". There is also a element of state machine inside the class object, but it is not an embedded element. The hierarchy of the elements can is shown in the Project Browser. What I want to do is to make the port as a member variabe of the class object, and use the state machine to present the actions of the member function "computation()".

http://www.pbase.com/ewchay/image/75116793

 I guess the key point is "how to access the embedded element?" and "how to connect the inside element?" I really need more suggestions. Thx a lot. :)

Best Regards.
chiweis

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Questions About The Code Templates
« Reply #3 on: March 04, 2007, 02:29:45 am »
chiweis,

I am a bit confused here, what exactly are you meaning by a "port on a class"?  What are you trying to get the classifier  to do by giving it a behavioural embedded component?

Try this.  Express a simple example of your desired code generation result in a simple "playground" piece of code and see how EA reverse engineers it.

regards
bruce  
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Questions About The Code Templates
« Reply #4 on: March 04, 2007, 01:09:32 pm »
If the key to your question is about accessing the port and state machine, then code generation by itself can't do this.  Code generation ignores any elements except for classes and interfaces.

However, a transform can access all elements and generate a member variable.  To generate the actions of a method using a state machine is somewhat more complicated.  Firstly, you need some way of identifying what state machine to use.  (eg. A tagged value on the method)  From there, I would expect to use an addin using the %EXEC_ADD_IN()% function macro.

chiweis

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Questions About The Code Templates
« Reply #5 on: March 05, 2007, 11:54:46 pm »
Hi. Thanks for the replies.. :)

Have you heard about SystemC? It's a system level designing language which is based on C++. What I want to do is using EA to make up an UML profile for SystemC, and do code generating works.

I have made an UML profile for SystemC as follows:
http://www.pbase.com/image/75268660
and used the profile to model an adder:
ftp://http://www.pbase.com/image/75268668

The code of the adder written in SystemC should be:
http://www.pbase.com/ewchay/image/75269392

Now I can use the Code Template to produce the skeleton of the SC_CODULE(adder), but I don't know how to insert the variabes that reprent ports, and how to connect the state machine to the specific operation.

Is there anyone that know how to obtain the expected code??
The problem has confused me for a long time.  ???

BTW, the file I can generate is just the adder.h, how can I move the implementation codes into the file "adder.cpp"? Moreover, is there more manuals about EXEC_ADD_IN macro? The EA User Guide just has little information.

Thanks for your suggestions!!   :)

Best Regards.
chiweis