How to reset/empty OPCUA server data field?

Hello,
I would like to know if it is possible thanks logics/code running in a PLC (AXC F 2152) to withdraw values from opcua server ?
When PLC restart, all opcua server data fields are empty.. kind of #undef values.
But after fields start to be filled with values, I wonder if there is a possibility for plc to erase the current data inside opcua field (in case for instance data is no longer accurate since it is a data that has not been refreshed for a long time or something). The interest would be for opcua customers not to visualize incorrect values but more to find at the moment no data accurate data are available.
If yes, please detail instruction or something I shiould use to allow it ?
Thanks

Hello antoinebourricat,
This is an application-relevant question. In general, you need to define the “#undef values” in your application. If you measure the room temperature and know the sensor limitation, you can define the limits for valid values, e.g. -100..+100 degrees. If the sensor temperature is not measured, e.g. because the program is not started, you can initialize the value in the GDS with e.g. 255, then you know that the value is invalid.
In general, the OPC UA server only provides to the OPC UA client the values ​​of the OPC UA variable in the GDS (Global Data Space), if the OPC UA session has been established.
I hope it helps, if not, please let me know.
BR Eduard

One way to implement this functionality is like this:

IF OPC_UA = OK THEN
udt_OPCUA_Values = Structure_of_valid_opcua_values;
ELSE
udt_OPCUA_Values = Another_Structure_Of_similar_type_with_predefines_error_values; // e.g. NAN, #undef, 0.0 etc
END_IF

Thanks for answers.
OPC_UA = OK with what variable or node should we supervise to make this test to consider opc ua is ok ?

Hello antoinebourricat,
the OPC UA “Status -Connection” variable is not implemented on PLCnext target, but you can subscribe the Notification on the OPC UA Client, please find the information/examples under following links:
Notifications with C++ (plcnext.help)CppExamples/Examples/NotificationExample at master · PLCnext/CppExamples · GitHub

E.g. in case of OPC UA Server reboot the Client will generate following Notifications (the program have to react in this case, see answer from fluxmodel):
18.09.24 12:17:01.514 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession INFO - ConnectionStatusChanged - Monitoring connection: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, ServerState=’ ServerShutdown’18.09.24 12:17:06.523 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession INFO - ConnectionStatusChanged - Monitoring connection: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, ServerState=’ ConnectionErrorApiReconnect’18.09.24 12:17:06.538 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession ERROR - ConnectFailed - Connecting session: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, Service=‘Open secure channel’, Status=’ BadCommunicationError’18.09.24 12:17:22.076 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession ERROR - ConnectFailed - Connecting session: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, Service=‘Activate session’, Status=’ BadSessionIdInvalid’18.09.24 12:17:22.190 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession INFO - ConnectionStatusChanged - Monitoring connection: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, ServerState=’ NewSessionCreated’18.09.24 12:17:22.195 Arp.Services.Modules.OpcUAServer.Client.Internal.RemoteSession INFO - ConnectionStatusChanged - Monitoring connection: ConnectionId=‘1’, EndpointUrl=‘opc.tcp://192.168.1.11:4840’, ServerState=’ ConnectedNewSession’

BR Eduard