public String escapeEnumValue(TypeReference typeReference, String valueString) {
        // Currently the only case in which here complex type references are used are when referencing enum constants.
        if (typeReference != null && typeReference.isNonSimpleTypeReference()) {
            // C doesn't like NULL values for enums, so we have to return something else (we'll treat -1 as NULL)
            if ("null".equals(valueString) || valueString == null) {
                return "0";
            }
            if (valueString.contains(".")) {
                // If the value string contains a dot, it's assumed to be a string
                // representation of an enum constant with a name in the form:
                // "typeName_constantName" (e.g. "MyEnum_MY_CONSTANT")
                String typeName = valueString.substring(0, valueString.indexOf('.'));
                String constantName = valueString.substring(valueString.indexOf('.') + 1);
                return typeName + "_" + constantName;
            }
            // Otherwise, return the value string as is.
            return valueString;
        } else {
            // For simple types, just use the {@link #escapeValue(TypeReference, String)}
            // method.
            return escapeValue(typeReference, valueString);
        }
    }
Escapes a string value according to the type reference given.
<p>
This method is used by the generated Python code to properly handle string values when
writing data to a PLC device.

@param typeReference the type reference of the field the value is being written to.
@param valueString the string value to be escaped.
@return an escaped string value.
code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java