Why Does get_param(​gcb,Compil​edPort*) Return Weird Results for Several Object Parameters ?

4 views (last 30 days)
I have the following very simple model that has been compiled and simulated in Normal mode
Verify the Constant block is selected
>> gcb
ans =
'mymodel/Constant'
Now try to access several Common Block Properties of the Constant block:
This looks incorrect.
>> get_param(gcb,'CompiledPortComplexSignals')
ans =
0×0 empty struct array with fields:
Inport
Outport
Enable
Trigger
State
LConn
RConn
Ifaction
Reset
Event
According to the linked doc page above, these parameters should be "properties common to all Simulink® blocks."
>> get_param(gcb,'CompiledPortDesignMin')
Constant block does not have a parameter named 'CompiledPortDesignMin'
>> get_param(gcb,'CompiledPortDesignMin')
Constant block does not have a parameter named 'CompiledPortDesignMin'
This looks incorrect.
>> get_param(gcb,'CompiledPortDimensions')
ans =
0×0 empty struct array with fields:
Inport
Outport
Enable
Trigger
State
LConn
RConn
Ifaction
Reset
Event
According to the linked doc page above, this parameter should be "properties common to all Simulink® blocks."
>> get_param(gcb,'CompiledPortDimensionsMode')
Constant block does not have a parameter named 'CompiledPortDimensionsMode'
This looks incorrect.
>> get_param(gcb,'CompiledPortFrameData')
ans =
0×0 empty struct array with fields:
Inport
Outport
Enable
Trigger
State
LConn
RConn
Ifaction
Reset
Event
This looks incorrect
>> get_param(gcb,'CompiledPortWidths')
ans =
0×0 empty struct array with fields:
Inport
Outport
Enable
Trigger
State
LConn
RConn
Ifaction
Reset
Event
Can anyone explain these results?

Accepted Answer

Paul
Paul on 8 Jul 2023
Thanks to @Andy Bartlett discussion in this thread, and further review the doc, the model has to be put into compile mode before accessing the Compiled* block parameters. But there still seems to be inconsistency for some parameters between what's actually returned and what the doc says should be returned.
Here is the model:
Verify the Integrator is the current block
gcb
ans = 'test/Integrator'
Compile the model. The use of feval in the workflow for accessing Compiled* is block properties is shown on the Common Block Properties doc page, but only for some Compiled* properties.
feval(gcs, [],[],[],'compile');
Now try to access several Common Block Properties of the Integrator block.
According to the Common Block Properties doc page linked above, these parameters should be "properties common to all Simulink® blocks." But they are not.
try
DesignMin = get_param(gcb,'CompiledPortDesignMin')
catch
disp('Invalid block parameter: CompiledPortDesignMin');
end
Invalid block parameter: CompiledPortDesignMin
try
DimensionsMode = get_param(gcb,'CompiledPortDimensionsMode')
catch
disp('Invalid block parameter: CompiledPortDimensionsMode');
end
Invalid block parameter: CompiledPortDimensionsMode
These properties are really properties of the ports of the block, not the block itself. This approach to getting these port properties is documented on the linked doc page, but I'm not sure why they are shown as block properties.
ports = get_param(gcb,'PortHandles');
DesignMin = get_param(ports.Outport, 'CompiledPortDesignMin')
DesignMin =
[]
But, DesignMin is supposed to be returned as a structure.
DimensionsMode = get_param(ports.Outport, 'CompiledPortDimensionsMode')
DimensionsMode =
0
ComplexSignals = get_param(gcb,'CompiledPortComplexSignals')
ComplexSignals = struct with fields:
Inport: 0
Outport: 0
Enable: []
Trigger: []
State: []
LConn: []
RConn: []
Ifaction: []
Reset: []
Event: []
PortDimensions = get_param(gcb,'CompiledPortDimensions')
PortDimensions = struct with fields:
Inport: [1 1]
Outport: [1 1]
Enable: []
Trigger: []
State: []
LConn: []
RConn: []
Ifaction: []
Reset: []
Event: []
However, PortDimensions is supposed to be returned as a numeric array.
FrameData = get_param(gcb,'CompiledPortFrameData')
FrameData = struct with fields:
Inport: 0
Outport: 0
Enable: []
Trigger: []
State: []
LConn: []
RConn: []
Ifaction: []
Reset: []
Event: []
PortWidths = get_param(gcb,'CompiledPortWidths')
PortWidths = struct with fields:
Inport: 1
Outport: 1
Enable: []
Trigger: []
State: []
LConn: []
RConn: []
Ifaction: []
Reset: []
Event: []
Set the model to term
feval(gcs, [],[],[],'term');
Is the use of the model name as a function documented anywhere? I can't find it.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!