Bus Creator: Import signals list from bus object

5 vues (au cours des 30 derniers jours)
marco abbondanza
marco abbondanza le 8 Oct 2019
Modifié(e) : Aabha le 27 Fév 2025
Hello everyone,
is there a way to import the signal list from a bus object into the Bus Creator block from a predefined Bus Object in a Data Dictionary?
I found the Bus Object Bus Creator in the file exhange (https://uk.mathworks.com/matlabcentral/fileexchange/50601-bus-object-bus-creator) wich does the trick for me, but unfortunately it cannot read bus objects from Data Dictionaries (fondamental feature).
I find this problem a huge missing in the simulink base libraries.
Without a feature like this bus objects become useless, programming becomes hard and mainance impossible if you have a huge control application with hundreds of subsytems/submodels with thousands of variables and hundreds of buses.
Marco.

Réponses (1)

Aabha
Aabha le 27 Fév 2025
Modifié(e) : Aabha le 27 Fév 2025
I faced a similar difficulty, while reading bus objects from the data dictionary. However, there is a workaround to this problem, where data dictionary elements can be programmatically accessed and modified. The following code can be run in the MATLAB Command Window, to create a bus object in a data dictionary linked to a Simulink model and subsequently link its elements to a Bus Creator block.
dataDictionary = Simulink.data.dictionary.open('myDictionary.sldd');
section = getSection(dataDictionary, 'Design Data')
Assuming there is a Simulink bus object titled “myBus”, it can be linked to the dictionary as follows:
addEntry(section, 'MyBus', myBus);
busObj = getEntry(section,'MyBus')
busValue = getValue(busObj)
open_system('yourModel')
busCreator = add_block('simulink/Signal Routing/Bus Creator', 'yourModel/BusCreator');
set(busCreator, 'Inputs', num2str(length(busValue.Elements)));
This adds a bus creator block, where the signal list is imported from a bus object in the corresponding data dictionary.
I hope this helps.

Catégories

En savoir plus sur Composite Interfaces 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!

Translated by