Resource acquire block programmatic use
1 view (last 30 days)
Show older comments
Marco Fanti
on 1 Apr 2019
Answered: Krishna Akella
on 4 Apr 2019
Hello,
I'm building a SimEvents model programmaticaly and I have the following problems regarding the "Resource Acquire", "Resource Release" and "Resource Pool" blocks:
- 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.
- 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.
0 Comments
Accepted Answer
Krishna Akella
on 4 Apr 2019
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 Comments
More Answers (0)
See Also
Categories
Find more on Discrete-Event Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!