accessing port data types during Complilation

1 回表示 (過去 30 日間)
Rakesh Chandrashekar
Rakesh Chandrashekar 2012 年 2 月 29 日
Hi,
I am masking addition block, i need to access the port datatypes of the Addition block.
I have written the code in initialization tab of the mask system, to access the port datatypes i used the below code
IportBlks = find_system(mdlName, 'LookUnderMasks', 'on','BlockType', 'Inport')
InportDTs = cell(numel(IportBlks))
modelname([],[],[],'compile')
for i = 1:numel(IportBlks)
IportBlk = IportBlks{i}
q=get_param(IportBlk,'PortHandles')
InportDTs{i} = get_param(q.Outport,'CompiledPortDataType')
end
modelname([],[],[],'term');
Its not working, but if i run the same code on Command window it will work.
let me know do i need to change the code or any alternative way is there.

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 2 月 29 日
You cannot run this code during mask initialization, because mask initialization is actually one of the stages of the model compilation process (the command "modelname([],[],[],'compile')"). Is there a reason you want to get the CompiledPortDataTypes for all Inport blocks in your model? Perhaps there is a better solution.
  2 件のコメント
Rakesh Chandrashekar
Rakesh Chandrashekar 2012 年 3 月 1 日
My main question is whether my mask code can appear in C Code when we generate the code by using E-coder.
for your question:
I am creating generic libraries for my application. my libs need to access the data types when the model is running.
for EG: if i am masking Addition block, suppose i am getting Uint16 and int16 as my port data types, my mask block should replace the code with add_U16_S16(). its a function call for my application.
Kaustubha Govind
Kaustubha Govind 2012 年 3 月 6 日
Mask initialization code is not generated into the code generated by Simulink/Embedded Coder.
I would recommend post-processing the generated code using the after_tlc in STF_make_rtw_hook.m - you need to create a custom target that inherits from ert.tlc for this. See http://www.mathworks.com/help/releases/R2011b/toolbox/rtw/ug/bse3c7m-1.html and http://www.mathworks.com/help/releases/R2011b/toolbox/rtw/ug/f10435.html#f10760

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

製品


Translated by