Hi anyone explain me about GENERATE and GENERATE_TYPE Functions in tlc file?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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....
2 comentarios
Respuestas (1)
Valmir Sadiku
el 23 de Mayo de 2013
here you can show example how to use GENERATE : http://www.weizmann.ac.il/matlab/toolbox/rtw/tlc_ref/cp_lan17.html
3 comentarios
Valmir Sadiku
el 24 de Mayo de 2013
Editada: Valmir Sadiku
el 24 de Mayo de 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
el 4 de Jun. de 2013
Please mark this question as answered or close it, if you don't need further support.
Ver también
Categorías
Más información sobre Target Language Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!