Generated reference › String To Enum — Control Systems/Strings
kind: generated#block#control-systems-strings

String To Enum — Control Systems/Strings

"Red" enum

Control_Systems/Strings/String_To_Enum · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

String to Enum

Control Systems / Strings

Turns text into the member of an enumerated type whose name it is: with a type Hue of members Red = 10, Green = 20 and Blue = 30, the text Green gives Green, whose value is 20. The match is exact and case-sensitive, as in Simulink: green,  Green, Green , an empty text and the value 20 written as text all name no member. Text that names no member stops the run.

Ports

  • Input – the text u (str, ICoreString), one value.
  • Output – the member (enum, ICoreEnum) of the type below, carried as the member's own value, one value [1,1].

Parameters

  • Output data type – Enum: Name, where Name is an enumerated type the project defines with defineEnum. Nothing else is accepted, as in Simulink. The default, Enum: SlDemoSign, is Simulink’s own, and names a type a project must define before the block runs.
  • Sampling Time (s) – zero or less inherits the solver's rate. It does not cross to Simulink, whose block has no rate parameter.

When a run is refused

A type the project does not define; an output data type that is not an enumeration; and, while the model runs, text that names no member, in Simulink’s words: Input string 'Purple' of block '…' does not match any enumerated value in enumerated data type 'Hue'.

Code export

Python, MATLAB, Java, Rust, C and C++: the text is matched against the member names written into the code, and the output is the member’s value as a 32-bit integer, which is how every target carries an enumeration. Generated code cannot stop a run: text that names no member gives the type’s default member there. The HDL targets and PLC Structured Text do not carry text, so an export to one stops and names the block.

Simulink bridge

Import and export, mapped to simulink/String/String to Enum. Output data type crosses as OutDataTypeStr, and the type itself as the Simulink.defineIntEnumType line every exported enumeration gets. The rate does not cross.

Notes

  • To turn text into a plain integer code by a list instead, use Machine Learning / Preprocessing / Label Encoder, which answers a code of its own for text it does not know rather than stopping.

Code facts#

FactValue
registered typeControl_Systems/Strings/String_To_Enum
familyControl_Systems/Strings
solver environment classICoreBlock_0_Control_Systems_1_Strings_2_String_To_Enum
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Strings/String_To_Enum/ICoreBlock_0_Control_Systems_1_Strings_2_String_To_Enum.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Strings/String_To_Enum/ICoreBlock_0_Control_Systems_1_Strings_2_String_To_Enum.h
default size on canvas90 × 60 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++

Ports#

#DirectionSignal typeDescription label
1inICoreString—
2outICoreEnum—

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Output data typeEnum: SlDemoSignOutDataTypeStr

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::Both
Simulink pathsimulink/String/String to Enum
port-count rulePortsParam::
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
ICore configSimulink parameterValue translation
Output data typeOutDataTypeStrpasses through

Caveat (shown to the user): OutDataTypeStr is Enum: <type> on both sides, and the type crosses as the

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 no sample under docs/generated/samples/ — nothing to cross-check (P8.1)

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

String to Enum -- text in, the enumeration member of that name out Measured on R2026a (2026-09-11): BlockType=StringToEnum, 1 in / 1 out, ONE parameter, OutDataTypeStr, default Enum: SlDemoSign, taking nothing but Enum: <class> (int32 and Inherit: auto are refused); no SampleTime. The match is EXACT and case-sensitive against the member NAMES: "Red" gives Red, while "red", " Red", "Red ", "" and the member's value "10" are refused. Text that names no member STOPS the run, mid-run as at constant folding: "Input string 'Purple' of block ... does not match any enumerated value in enumerated data type 'zb6Hue'". The output carries the members' OWN values (10/20/30), not their positions.

The enumeration is BF19.3's ICoreEnum: the port matrix holds the member's value and the type's name rides on the side carrier, which this block sets as Data Type Conversion does.

Sample results#

No sample run is committed for this block. Samples come from the headless harness (DOCS_PLAN.md P8.1) into docs/generated/samples/; until one exists this block's behaviour is witnessed by the parity and export-verification suites, not by a plot here.