Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

SimEvent Resource local to a subsystem

2 visualizaciones (últimos 30 días)
Caroline Brandberg
Caroline Brandberg el 25 de En. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi,
I would like to create a reusable subsystem which contains a SimEvent Resource which it acquires and releases locally to that subsystem.
If I copy and paste such subsystem, I will get an error telling me that I have two resources with the same name.
I tried to create a mask for the subsystem, and thereafter create an attribute to be used to separate the different resources. But, I couldn't acquire a resource identified by a name specified in the mask for the subsystem...
All suggestions are appreciated!
Thanks

Respuestas (1)

Gaurav Phatnani
Gaurav Phatnani el 2 de Feb. de 2018
You can implement the desired behavior in the 'CopyFcn' callback (Right click> Properties> Callbacks) of the original subsystem. Here, you will need a script which checks the number of existing Resource Pools in your model and then generates a new name and assigns it to the 'Resource Pool' inside the newly created subsystem. For ex, if 3 'Resource Pool' blocks exist, the new name will be 'Name4'.
The script inside the 'CopyFcn' callback should look like this: 1. Use 'find_system' to return a list of all existing 'Resource Pool' blocks.
>> l = find_system(gcs,'SearchDepth',2,'LookUnderMasks','all','BlockType','EntityResourcePool');
2. The length of the list represents the number of 'Resource Pool' blocks in your system. If the 'Resource Name' is 'Name' for the original block, the subsequent copies will have resource names 'Name1', 'Name2', 'Name3' etc. Use 'set_param' to set the desired name
>> set_param([gcb '/Resource Pool'], 'ResourceName',['Name' num2str(length(l))]);
Set the above callback in the original subsystem and delete any pre-existing copies. Now if you make copies from the original subsystem you will find that the 'Resource Names' are 'Name2',' Name3', 'Name4' etc. Making a copy from a copy will also produce a unique name.

La pregunta está cerrada.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by