如何让一个街区的端口类型和尺寸吗

90(30天)
我们是通过一个脚本生成代码使用环球套票。我想收集端口尺寸和数据类型。参数名称将是伟大的,但不是必需的。
我目前能得到的港口名称

接受的答案

Fangjun江
Fangjun江 2011年6月3日
有时很难找到帮助文档中。很多时候我只是闲逛,让一个受过教育的猜测。我做了一个简单的模型和运行下面的代码。似乎能够得到维数和数据类型。希望这将帮助。
clc;
acModelName = bdroot;
lcInportHandles = find_system (acModelName,“FindAll”,“上”,“SearchDepth”,1“BlockType”,“尺寸”);
i = 1:长度(lcInportHandles)
lcInputDimensions = get_param (lcInportHandles(我),“CompiledPortDimensions”);
lcInputDimensions = lcInputDimensions.Outport
lcInputDataTypes = get_param (lcInportHandles(我),“CompiledPortDataTypes”);
lcInputDataTypes = lcInputDataTypes.Outport
结束
输出是这样的:
lcInputDimensions =
1 2
lcInputDataTypes =
“单一”
lcInputDimensions =
1
lcInputDataTypes =
“int8”
4评论
凯文
凯文 2011年6月3日
我的下一部分搬到以下:
//www.tatmou.com/matlabcentral/answers/8749-how-to-iterate-through-a-bus-object-intil-i-have-a-struct-of-primitives-which-match-rtw-output-with

登录置评。

更多的答案(4)

“Gunaseelan
“Gunaseelan 2011年6月2日
你可以得到一个块的尺寸和数据类型的港口后,你把模型转换为一个“编译”的状态。的
模型([]、[][],“编译”)
模型是你的名字会让你在那里。之后,一个get_param块感兴趣的选项
CompiledPortDimensions
CompiledPortDataTypes
会让你你想要的信息。
3评论
“Gunaseelan
“Gunaseelan 2011年6月3日
“模型”在上面的代码片段的名称加载模型。我喜欢把它作为一种与模型交互,仿佛一个函数签名。
我一直在使用这个片段很长一段时间了,我认为这是早在R14。

登录置评。


凯文
凯文 2011年6月2日
@Nirmal Gunaseelan——因此,我怎么得到一个指针指向我的模型才能执行这个?做find_system时,我不知道如何限制结果我顶层模型,建筑吗?

Fangjun江
Fangjun江 2011年6月2日
一些属性,如尺寸和数据类型不符合日期模型加载。这些属性依赖于其他信息。他们还需要反复核对,以避免任何不重合。你需要“更新”模型或进一步力模型“编译”去通过这些传播和反复核对。命令模式([]、[][],“编译”)是迫使这一过程。模型不是一个处理。它的名字是你的模型。模型需要加载。一旦命令模式([]、[][],“编译”)。您可以使用find_system()和“SearchDepth”找到所有root尺寸模块和输出模块。 And then you can get the dimension and data type property of all those Inport/Outport blocks.
5个评论
凯文
凯文 2011年6月2日
@Walter——是的,名字向量有两个输入和一个输出的名字名字,他们根据这个模型是正确的。

登录置评。


凯文
凯文 2011年6月2日
好吧,这就是我现在…
lcInterfaceSpec = RTW.getEncapsulationInterfaceSpecification (acModelName);
%得到处理我们的尺寸/输出港
lcInportHandles = find_system (acModelName,“FindAll”,“上”,“SearchDepth”,1“BlockType”,“尺寸”);
lcOutportHandles = find_system (acModelName,“FindAll”,“上”,“SearchDepth”,1“BlockType”,“输出港”);
lcInportNames =得到(lcInportHandles,“名字”);
lcOutportNames =得到(lcOutportHandles,“名字”);
lcPortNames = vertcat (lcInportNames lcOutportNames);
%,得到每个端口的尺寸
% code_blocks = find_system (getfullname (acModelName),‘LookUnderMasks’,‘所有’,‘BlockType’,“子系统”、“名称”、“代码”);
% lcModelHandle = find_system (acModelName‘FindAll’,‘上’,‘SearchDepth’, 1,“BlockType”,“子系统”);
%以下命令需要一个编译模型…
eval ([acModelName,”([]、[][],“编译”);“]);
q = get_param (gcb,“PortHandles”);
lcInputDimensions = get_param (lcInportHandles,“CompiledPortDimensions”);
lcInputDimensions2 = get_param (q.Inport,“CompiledPortDimensions”);
lcInputDataTypes = get_param (lcInportHandles,“CompiledPortDataTypes”);
lcInputDataTypes2 = get_param (q.Inport,“CompiledPortDataType”);
lcInputPortWidths = get_param (lcInportHandles,“CompiledPortWidths”);
lcInputPortWidths2 = get_param (q.Inport,“CompiledPortWidth”);
lcOutputDimensions = get_param (lcOutportHandles,“CompiledPortDimensions”);
lcOutputDataTypes = get_param (lcOutportHandles,“CompiledPortDataTypes”);
lcOutputPortWidths = get_param (lcOutportHandles,“CompiledPortWidths”);
%第一,得到参数的数量
lnArguments = lcInterfaceSpec.getNumArgs;
%循环参数,检查类型和遍历任何复杂类型
i = 1:长度(lcPortNames)% lnArguments应该是一样的
% todo /修复-如何检查类型? ? ? ?ARRRGHHHHH ! ! ! !
lcArgName = getArgName (lcInterfaceSpec lcPortNames{我});
lcQualifier = getArgQualifier (lcInterfaceSpec lcPortNames{我});%常量
lcCategory = getArgCategory (lcInterfaceSpec lcPortNames{我});%的指针
lnPosition = getArgPosition (lcInterfaceSpec lcPortNames{我})
结束
所以,我发现 //www.tatmou.com/help/toolbox/ecoder/ref/rtw.modelcppargsclass.getargqualifier.html 前一段时间,现在知道如何得到结果。但是没有办法得到的数据类型。我还发现,get_param (lcInportHandles CompiledPortDataTypes)返回总线的名称,而不是一个真正的类型。我希望得到一个类型模型。金宝appBusElement从 //www.tatmou.com/matlabcentral/fileexchange/13399-embedded-coder-robot-nxt-demo/content/ecrobotNXT/nxtracer/param.m ,或者从这里: //www.tatmou.com/help/toolbox/金宝appsimulink/ug/f14 - 90479. - html
所以,我如何告诉如果我有一辆公共汽车,或原始的,还是别的?
谢谢,
凯文
3评论
法比安Jeanneteau赛
法比安Jeanneteau赛 2022年5月11日
你好,
如果你卡住了(像我一样),你应该:
模型([]、[][],“术语”)
我发现回答以下页面:https://fr.mathworks.com/matlabcentral/answers/29764-turn-off-compile-mode
问候,
法比安

登录置评。

类别

找到更多的在事件函数帮助中心文件交换

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!