Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Datalayer Enums difference between 2.4 and 2.6

Datalayer Enums difference between 2.4 and 2.6

ham1hel
Established Member

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:
Old_datalayer.png

2.6:

ham1hel_0-1716552265141.png

enum:

ham1hel_0-1716552907600.png

 

 

8 REPLIES 8

zhenhui
Established Member

A possible workaround:

  1. remove //{attribute 'strict'}  when define ENUM RobotMode, declare variable robotMode as Enum type
  2. Define varaible Mode  as LINT type (map as int on datalayer)
  3. In your program replace Mode with  robotMode 
  4. Write code RobotMode := Mode at beginning of the main program to write to RobotMode when Mode are modifed from datalayer
  5. Write Mode := RoboteMode at the end of main program to make right Mode value show on datalayer

PADE
Established Member

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.

HmiGuide
Community Moderator
Community Moderator

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.

ham1hel
Established Member

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

HmiGuide
Community Moderator
Community Moderator

I created a request that customer gets the possibility how ENUM are exported. As INT datatypes or ENUM datatype.

HmiGuide
Community Moderator
Community Moderator

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.

ham1hel
Established Member

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)

CodeShepherd
Community Moderator
Community Moderator

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"
}

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist