Resource acquire block programmatic use
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Marco Fanti
le 1 Avr 2019
Réponse apportée : Krishna Akella
le 4 Avr 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 commentaires
Réponse acceptée
Krishna Akella
le 4 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Discrete-Event Simulation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!