Attention

IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.

P2006

Code

P2006

Message

Enumeration uses value that is not defined in the enumeration

This error occurs when an enumeration uses a value that is not defined in the enumeration.

Example

The following code will generate error P2006:

TYPE
    LogLevel : (CRITICAL, WARNING, INFO, DEBUG) := INFO;
END_TYPE

FUNCTION_BLOCK Logger
  VAR_INPUT
    Trigger : BOOL;
    Message : STRING;
    Level : LogLevel := BLAH;  (* Error: BLAH is not defined in LogLevel *)
  END_VAR
END_FUNCTION_BLOCK

The variable Level is assigned the value BLAH, but BLAH is not one of the defined values in the LogLevel enumeration.

To fix this error, use a value that is defined in the enumeration:

TYPE
    LogLevel : (CRITICAL, WARNING, INFO, DEBUG) := INFO;
END_TYPE

FUNCTION_BLOCK Logger
  VAR_INPUT
    Trigger : BOOL;
    Message : STRING;
    Level : LogLevel := INFO;  (* Correct: INFO is defined in LogLevel *)
  END_VAR
END_FUNCTION_BLOCK