#include <uaserver_config.h>
#include <opcua_identifiers.h>
#include <opcua_memory.h>
#include <opcua_string.h>
#include <opcua_errorhandling.h>
#include <uaserver_events.h>
#include <uaserver_utilities.h>
#include "custom_provider_helper.h"
OPCUA_BEGIN_EXTERN_C
OpcUa_UInt32 g_HeaterSwitchedEventTypeId;
OpcUa_Int32 g_HeaterSwitchedEventType_IndexSwitchPosition;
OpcUa_Int32 g_HeaterSwitchedEventType_IndexCurrentTemperature;
{
OpcUa_BaseNode *pBaseNode = OpcUa_Null;
OpcUa_ObjectType *pEventType = OpcUa_Null;
OpcUa_Property *pProperty = OpcUa_Null;
OpcUa_InitializeStatus(OpcUa_Module_Server, "CustomProvider_RegisterEventTypes");
OpcUa_ReturnErrorIfArgumentNull(a_pStartingNodeId);
OpcUa_NodeId_Initialize(&parentEventTypeId);
OpcUa_NodeId_Initialize(&nodeId);
a_pStartingNodeId->Identifier.Numeric++;
g_HeaterSwitchedEventTypeId = a_pStartingNodeId->Identifier.Numeric;
parentEventTypeId.Identifier.Numeric = OpcUaId_BaseEventType;
OpcUa_GotoErrorIfBad(uStatus);
OpcUa_String_FromCString("SwitchPosition"),
OPCUA_STRING_LENDONTCARE);
&eventField);
OpcUa_String_FromCString("CurrentTemperature"),
OPCUA_STRING_LENDONTCARE);
&eventField);
nodeId.Identifier.Numeric = OpcUaId_BaseEventType;
&pEventType,
(OpcUa_BaseNode*)pBaseNode,
a_pStartingNodeId->Identifier.Numeric,
g_uCustomProvider_NamespaceIndex,
"HeaterSwitchedEventType");
OpcUa_GotoErrorIfBad(uStatus);
a_pStartingNodeId->Identifier.Numeric++;
&pProperty,
(OpcUa_BaseNode*)pEventType,
a_pStartingNodeId->Identifier.Numeric,
g_uCustomProvider_NamespaceIndex,
"SwitchPosition");
OpcUa_GotoErrorIfBad(uStatus);
a_pStartingNodeId->Identifier.Numeric++;
&pProperty,
(OpcUa_BaseNode*)pEventType,
a_pStartingNodeId->Identifier.Numeric,
g_uCustomProvider_NamespaceIndex,
"CurrentTemperature");
OpcUa_GotoErrorIfBad(uStatus);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
{
OpcUa_InitializeStatus(OpcUa_Module_Server, "CustomProvider_UnregisterEventTypes");
OpcUa_NodeId_Initialize(&eventTypeId);
eventTypeId.Identifier.Numeric = g_HeaterSwitchedEventTypeId;
OpcUa_GotoErrorIfBad(uStatus);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
{
OpcUa_InitializeStatus(OpcUa_Module_Server, "CustomProvider_FireHeaterSwitchedEvent");
OpcUa_ReturnErrorIfArgumentNull(a_pMachine);
OpcUa_NodeId_Initialize(&eventTypeId);
OpcUa_ByteString_Initialize(&bsEventId);
OpcUa_Variant_Initialize(&value);
eventTypeId.Identifier.Numeric = g_HeaterSwitchedEventTypeId;
if (*a_pMachine->pHeaterSwitch->pValue == OpcUa_False)
{
}
else
{
}
value.
Value.Boolean = *a_pMachine->pHeaterSwitch->pValue;
value.
Value.Double = *a_pMachine->pTemperatureSensor->pValue;
OpcUa_ByteString_Clear(&bsEventId);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
OPCUA_END_EXTERN_C