Programmatically get bus data type of In Bus Element block
Ältere Kommentare anzeigen
I'm looking to get the bus data type used in 'In bus element' blocks in Matlab environment, e.g. using the 'get_param()' function or similar. The In Bus Element selects 1 element from the bus, but I'm not interested in the type of the element, but I need the bus type (name) of the associated parent bus.
What I'm trying to do is to list the root level ports and associated bus data types of a given model that uses only In Bus Element and Out Bus Element blocks with specified bus data types.
The bus element ports are mapped to an Autosar interface, I'm not sure if that changes anything.
Akzeptierte Antwort
Weitere Antworten (1)
Raghava S N
am 14 Jul. 2023
0 Stimmen
To obtain the bus data type (name) of the associated parent bus from an 'In Bus Element' block in MATLAB, you can use the following approach:
- Identify the 'In Bus Element' blocks in your model: You can use the find_system function to find all the 'In Bus Element' blocks in your model. For example:
inBusElementBlocks = find_system('YourModelName', 'BlockType', 'Inport');
2. Get the parent bus object of each 'In Bus Element' block: Iterate through the 'In Bus Element' blocks and use the get_param function to retrieve the parent bus object. For example:
for i = 1:numel(inBusElementBlocks)
parentBusObject = get_param(inBusElementBlocks{i}, 'Parent');
% Perform further operations with the parentBusObject
end
3. Extract the bus data type (name) from the parent bus object: Use the get function to access the properties of the parent bus object and retrieve the bus data type (name). For example:
busDataType = get(parentBusObject, 'Name');
By following these steps, you can obtain the bus data type (name) of the associated parent bus for each 'In Bus Element' block in your model.
3 Kommentare
Gergely
am 14 Jul. 2023
Admasu Shewangizaw
am 19 Jul. 2023
I also needed to do this and no joy so far. The above method didn't work as stated by Gergely.
Arne
am 7 Okt. 2024
I also need an answer to this the information is hidden the datatype of the signak is some 'Bus: value_typ' in my case I don't get this construct is there please some more documentation about this somewehre.
Kategorien
Mehr zu Simulink Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
