Hi anyone explain me about GENERATE and GENERATE_TYPE Functions in tlc file?

2 views (last 30 days)
Hello Matlab users,
Anyone pls explain me about GENERATE and GENERATE_TYPE Functions in tlc file writing?
GENERATE_TYPE(block, "Output", "dp_read")
In this structure (Output = "Function name which we want to call", What about block, dp_read. Am using Level 2 M file S Function am not getting any information related to this.
Please help me in resolving this issue.
Thanks in Advance....

Answers (1)

Valmir Sadiku
Valmir Sadiku on 23 May 2013
here you can show example how to use GENERATE : http://www.weizmann.ac.il/matlab/toolbox/rtw/tlc_ref/cp_lan17.html
  3 Comments
Valmir Sadiku
Valmir Sadiku on 24 May 2013
Edited: Valmir Sadiku on 24 May 2013
are you able to get the following example to work? if not, tell which error you get?
The following listing is polymorph.tlc.
%%polymorph.tlc
%language "C"
%%create records used as scopes within the dispatched functions
%createrecord MyRecord { Type "MyBlock"; data 123 }
%createrecord YourRecord { Type "YourBlock"; theStuff 666 }
%%dispatch the functions thru the GENERATE call.
%%dispatch to MyBlock implementation
%<GENERATE(MyRecord, "aFunc")>
%%dispatch to YourBlock implementation
%<GENERATE(YourRecord, "aFunc")>
%%end of polymorph.tlc
The following listing is MyBlock.tlc.
%%MyBlock.tlc
%implements "MyBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%MyRecord is in generate scope in this function.
%%Therefore, fields of MyRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of MyRecord.data is: %<data>
%closefile STDOUT
%endfunction
%%end of MyBlock.tlc
The following listing is YourBlock.tlc.
%%YourBlock.tlc
%implements "YourBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%YourRecord is in generate scope in this function.
%%Therefore, fields of YourRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of YourRecord.theStuff is: %<theStuff>
%closefile STDOUT
%endfunction
%%end of YourBlock.tlc
The invocation and output of polymorph.tlc, as displayed on the MATLAB console, are shown below:
tlc -v polymorph.tlc
The value of MyRecord.data is: 123
The value of YourRecord.theStuff is: 666
We use in this case STDOUT file to print values to the matlab window.
Which error you got?
Valmir Sadiku
Valmir Sadiku on 4 Jun 2013
Please mark this question as answered or close it, if you don't need further support.

Sign in to comment.

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!