As workaround until we hopefully get the switch to define how a enum is exported, you can define a INT variable, which is a reference to the enum.
In PLC program you use the Enum variable
In HMI program you use the REFERENCE TO INT variable
While you have now 2 different variable names:
Use PLC refactoring to rename the PLC internal used ENUM variable
Use original name of enum variable as INT variable for HMI, to avoid adapting of variable names in HMI program.
VAR_GLOBAL
// ENUM variables used in PLC program
_enTest: EN_Test;
_stTest: ST_Enums;
END_VAR
VAR_GLOBAL
// INT variables used in HMI program
enTest: REFERENCE TO INT;
stTest: REFERENCE TO ST_Enums_HMI;
END_VAR
PROGRAM PLC_PRG
VAR
ptrTest: POINTER TO INT;
ptrStruct: POINTER TO ST_Enums_HMI;
END_VAR
// Set referencet to single variable
ptrTest := ADR(_enTest);
enTest REF= ptrTest^;
// Set reference to struct variable
ptrStruct := ADR(_stTest);
stTest REF= ptrStruct^;
When the Enums are members of a struct, you can do the same, by duplicating the structure and replacing the ENUM type by INT type. Keep in mind, that both structures MUST be 100% identical (order & data type of elements)
STRUCT with ENUM (for PLC)
STRUCT with INT instead of ENUM (for HMI)
TYPE ST_Enums :
STRUCT
strText: STRING(10):='Hallo';
enTestA: EN_Test;
enTestB: EN_Test;
enTestC: EN_Test;
bEnd: BOOL;
END_STRUCT
END_TYPE
TYPE ST_Enums_HMI :
STRUCT
strText: STRING(10):='Hallo';
enTestA: INT;
enTestB: INT;
enTestC: INT;
bEnd: BOOL;
END_STRUCT
END_TYPE
Unzip attached PLC example project "enum-workaround.zip" to test it.
... View more