필터 지우기
필터 지우기

How to get enumerations defined by Simulink.IntEnumType to appear in data assistant?

조회 수: 7 (최근 30일)
Hi,
I have various classdef EMyEnum < Simulink.IntEnumType m-files which all work fine except that they do not autopopulate in the data assisstant drop down. If I enter Enum: EMyEnum it comes in fine, but the drop down doesn't list the enums that are defined in my m-files only the enums defined in a data dictionary. Is there a way to get the ModelExplorer and Simulink to display enumerations defined like this?
For instance EDriveState is defined in an M-file (see below). This comes in fine when typed but its not suggested as an option by the data type assistant. The 2 Enums which do show up are in the data dictionary.
classdef EDriveState < Simulink.IntEnumType
enumeration
STOPPED (1) % The drive is not running, but is ready to start.
PRE_START (2) % The drive is not yet running, but actions are being taken to prepare to start.
STARTING (3) % The drive is starting.
WARM_UP (4) % The drive is operating at reduced speed or load to allow correct operating temperature to be reached.
RUNNING (5) % The drive is running in steady state operation and can be loaded.
COOL_DOWN (6) % The drive is operating at reduced speed or load to allow the operating temperature to drop before stopping.
STOPPING (7) % The drive is stopping.
POST_RUN (8) % The drive is not turning, but actions are being taken to complete the shutdown sequence.
ERROR (9) % An error has occurred and the drive is unavailable.
end
methods (Static)
function retVal = getDescription()
retVal = 'Abstract super states, possible Drive States. Specific drive states can be mapped to these states.';
end
function retVal = getDefaultValue()
retVal = EDriveState.STOPPED;
end
end
end

채택된 답변

Manoj Mirge
Manoj Mirge 2023년 4월 21일
Hi Brent,
If you want the Model Explorer and Simulink to display enumerated data types defined by you, you will need to store them in Simulink data dictionary.
You can refer below link for storing your custom enumerated data types into Simulink data dictionary:
Hope this helps.
  댓글 수: 1
Brent Jarvis
Brent Jarvis 2023년 4월 21일
Daaang ok, I liked the m-files since it makes diff-ing for source control a little easier as well as running tests on subsystem references. I'll just deal with this inconvience for now, maybe we'll switch to data dictionaries.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by