FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
05-24-2024 02:06 PM - edited 05-24-2024 02:16 PM
Hi
We tried upgrading our project from 2.4 to 2.6 and noticed that our hmi stoped working.
After a short investigation we realized it's due to the fact that enum values are now printed as json text instead of numbers in the datalayer.
Is there any way in the plc to get the enums back as numbers? because this causes quite a lot of issues within our application
2.4:
2.6:
enum:
Solved! Go to Solution.
05-27-2024 11:05 AM
A possible workaround:
05-27-2024 01:10 PM - edited 05-27-2024 01:11 PM
Hi,
pls, never create such a workaround. This is a system error which has to be solved on OS level.
Nobody is willing to do so because no system works like that.
Thx.
05-27-2024 01:59 PM
Which HMI system are you using? In WebIQ we face the same problem, because ENUMs are currently not supported there.
Maybe we can request a switch in PLC, where you can define how ENUM's are exported.
05-27-2024 02:24 PM - edited 05-27-2024 02:25 PM
We're using an own developed hmi. Its implemented using golang and svelte and reads directly from the datalayer nodes. But it would be a nice feature to have a switch so it could be toggled how enums are represented in the datalayer
05-28-2024 11:37 AM
I created a request that customer gets the possibility how ENUM are exported. As INT datatypes or ENUM datatype.
05-28-2024 03:41 PM
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.
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) |
|
|
Unzip attached PLC example project "enum-workaround.zip" to test it.
05-29-2024 08:08 AM
Thank you for the suggestion, i think i will stay with 2.4 until we have the switch or the change is reverted (as i dont see much benefits to present enum values as json, i would understand if the enum was a subnode to the value so you could see what it represents but for using it it kind of takes away the point of an enum when presenting it as json)
09-09-2024 03:45 PM
As an update:
In version 2.6.2 there are now "switches" available as data layer nodes to chooses the behavior:
As the default settings changed, you must set the following data layer variables path: plc/admin/runtime-settings/symbol-settings and save change afterwards by executing plc/admin/cfg/save.
{
"enumRepresentation": "BASETYPE",
"arrayDisplayName": "OFF"
}