My project has a restriction that bus elements need to be all lowercase. The architecture has bus objects stored in data dictionaries, and the model uses these in BusCreator objects.
In order to enforce compliance with this restriction, I'd like to programmatically inspect all the buses used in a model, and/or bus objects stored in the data dictionaries. When an offending element is found, I might
- just print an error message,
- provide a dialog to help the user edit the name, or
- do some kind of automatic name change.
But the first issue is to identify the uppercase and camelcase bus elements.
So far, here's what has not worked for me:
1. Inspecting the BusCreator
I've tried selecting a BusCreator block which has elements that need to be corrected, then using the command
get_param(gcb,'DialogParameters')
but the result doesn't contain the bus name, much less the element names.
2. Finding Bus Definitions used by the model
This gets me a little closer; I can use
modelVariables = Simulink.findVars(bdroot,'SourceType','data dictionary')
then check each of the modelVariables.Users to see if that user block is a BusCreator; in which case the variable is probably the name of a bus object. But once I have the bus names, I still need to find the element names, and I'm stumped there.
3. Finding Bus Definitions in the SLDD
I've tried using the Simulink.data.Dictionary class methods to find bus objects' elements names, but haven't found a way to actually find the bus element names, much less edit them.
4. Model Advisor Checks
I took a brief look, but didn't see a way to customize mathworks.maab.jc_0221 Check character usage in signal labels to flag uppercase characters. I don't necessarily want to exclude uppercase on ALL signals, although doing that would probably end up helping achieve all lowercase bus elements.
Best Answer