Resource acquire block programmatic use

1 次查看(过去 30 天)
Hello,
I'm building a SimEvents model programmaticaly and I have the following problems regarding the "Resource Acquire", "Resource Release" and "Resource Pool" blocks:
  1. I am not able to find the using the "add_block" command. An error comes out saying there is no such a block in the library.
  2. I partially solved the problem by manually creating the blocks in a different model and then programmaticaly pasting them on a new model. The problem is still that I would like to be able to change block paramters directly from code. The parameters that i would like to change are:
  • For Resource Acquire block: resource to be acquired and amount.
  • For Resource Release block: resource to be released
  • For Resource Pool block: resource name and relative amount.
Thanks.

采纳的回答

Krishna Akella
Krishna Akella 2019-4-4
Hi Marco,
To know the BlockType of any block, add the block to a model and select it. Then in MATLAB window, type the following:
>> h = get_param(gcb, 'Handle');
>> get(h, 'BlockType')
ans =
'EntityResourceAcquirer'
>>
To add a EntityResourceAcquirer to a model, you can type:
>> add_block('built-in/EntityResourceAcquirer', [gcs '/R1'], 'MakeNameUnique', 'on')
Similarly to know the block parameters for a block, you can select the block in the model and use:
>> get_param(gcb, 'DialogParameters')
ans =
struct with fields:
ResourceName: [1×1 struct]
ResourceAmountSource: [1×1 struct]
ResourceAmount: [1×1 struct]
...
Then use the following to set the block's values:
>> set_param(gcb, 'ResourceName', 'Resource1', 'ResourceAmountSource', 'Dialog', 'ResourceAmount', '1')
Hope that helps!
Regards,
Krishna

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete-Event Simulation 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by