#include <uaserver_config.h>
#include <opcua_statuscodes.h>
#include <uaserver_write.h>
#include <uaserver_basenode.h>
#include <uaserver_utilities.h>
#include <uaserver_p_atomic.h>
#include "custom_provider_helper.h"
OPCUA_BEGIN_EXTERN_C
{
OpcUa_WriteRequest *pReq;
OpcUa_WriteResponse *pRes;
OpcUa_Int32 i;
OpcUa_BaseNode *pNode;
OpcUa_InitializeStatus(OpcUa_Module_Server, "CustomProvider_WriteAsync");
OpcUa_ReturnErrorIfArgumentNull(a_pWriteCtx);
pReq = a_pWriteCtx->pRequest;
pRes = a_pWriteCtx->pResponse;
for (i = 0; i < pReq->NoOfNodesToWrite; i++)
{
if (pReq->NodesToWrite[i].NodeId.NamespaceIndex == g_uCustomProvider_NamespaceIndex)
{
if (pNode)
{
if ( (a_pWriteCtx->pRequest->NodesToWrite[i].AttributeId == OpcUa_Attributes_Value &&
OpcUa_BaseNode_GetType(pNode) == eVariable &&
{
pRes->Results[i] = OpcUa_BadNotWritable;
continue;
}
if ( (a_pWriteCtx->pRequest->NodesToWrite[i].AttributeId == OpcUa_Attributes_Value &&
a_pWriteCtx->pSession->UserIdentityData)) ||
(a_pWriteCtx->pRequest->NodesToWrite[i].AttributeId != OpcUa_Attributes_Value &&
a_pWriteCtx->pSession->UserIdentityData)))
{
pRes->Results[i] = OpcUa_BadNotWritable;
continue;
}
}
else
{
pRes->Results[i] = OpcUa_BadNodeIdUnknown;
}
}
}
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
OPCUA_END_EXTERN_C