Would 'AliasType' be the solution to refer a signal which belongs a struct inside Stateflow?

314 Views Asked by At

In a chart I have several States that read and write accesses to some objetcs but insteand of using the full-address of each element (like 'BusOut.CPTIO.CH_PT.Dr'), I'd like to have a shorter name to be used only inside the chart (like just 'Dr').

How should I make it done inside stateflow? It seems be through 'Simulink.AliasType', but I am not sure if that is the way and how it would be implemented.

i.e: Actually it's used such approach:

entry: BusOut.CPTIO.CH_PT.Dr = 0;
exit: BusOut.Vehicle_CPTIO.CH_PT.Dr = 1;

but I'd like to simplify the notation like that:

entry: Dr = 0;
exit: Dr = 1;
1

There are 1 best solutions below

0
On

It is somewhat hacky, but one way to do it would be to create an atomic subchart inside the chart, move all your logic into the newly created atomic subchart, and then use atomic subchart mappings to map the bus fields to shorter names inside the atomic subchart. See https://www.mathworks.com/help/stateflow/ug/mapping-variables-for-atomic-subcharts.html#mw_09590422-fbaf-4e2c-a7fb-d68a91ed3f64 for an example.