Can not save enumeration created by Stateflow

34 visualizaciones (últimos 30 días)
Andy
Andy el 11 de Nov. de 2024 a las 16:38
Respondida: Ashok el 19 de Nov. de 2024 a las 3:12
StateFlow can create an enumeration when outputing a monitor port, but can also use a manually created enumeration that match the state names. What I would really like to do is save the StateFlow-created enumeration, and then for future model runs select "Define enumeration type manually". This would a) avoid having to type the enumeration from scratch, and then b) eliminate all the red block highlighting when the model opens (before it builds). Is there a way to do this?

Respuestas (1)

Ashok
Ashok el 19 de Nov. de 2024 a las 3:12
Hey @Andy,
Stateflow does not have a direct feature to output the enumeration definition. here's a workaround that might be useful. In a Stateflow chart where the Enum type 'ModeLogicModeType' is created, the output of the 'Child activity' monitor can be logged using an 'Outport' as shown below.
To gather the enumeration class name, members, and their corresponding numeric values, the following lines of code can be used:
[enumMembers, memberNames] = enumeration(out.yout{1}.Values.Data);
memberValues = double(enumMembers);
enumName = class(out.yout{1}.Values.Data);
This data can then be used to define an enumeration type using the ‘Simulink.defineIntEnumType’ function. More information on this function can be found here:
To list all custom enumerations, present in the current MATLAB session, refer to this MATLAB Answer:
I believe this will assist you!

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by