#include <uaserver_config.h>
#include <opcua_statuscodes.h>
#include <uaserver_basenode.h>
#include <uaserver_utilities.h>
#include <uaserver_p_atomic.h>
#include <uaserver_historyread.h>
#include "uaprovider_demo_helper.h"
#include "uaprovider_demo_simulation.h"
#if HAVE_DATA_LOGGER
#include <uaserver_datalogger.h>
#endif
OPCUA_BEGIN_EXTERN_C
{
OpcUa_Int32 i;
OpcUa_BaseNode *pNode = OpcUa_Null;
OpcUa_NodeId *pNodeId;
OpcUa_HistoryReadValueId *pNodeToRead;
OpcUa_ReturnErrorIfArgumentNull(a_pHistoryReadRawModifiedCtx);
for (i = 0; i < a_pHistoryReadRawModifiedCtx->NoOfNodesToRead; i++)
{
pNodeToRead = &a_pHistoryReadRawModifiedCtx->pNodesToRead[i];
pNodeId = &pNodeToRead->NodeId;
if (pNodeId->NamespaceIndex == g_UaProviderDemo_uNamespaceIndex1)
{
if (pNode)
{
if (OpcUa_BaseNode_GetClass(pNode) == OpcUa_NodeClass_Variable
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
continue;
}
#if UASERVER_SUPPORT_AUTHORIZATION
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
continue;
}
#endif
#if HAVE_DATA_LOGGER && UASERVER_DATALOGGER_SUPPORT_DATA
{
OpcUa_StatusCode ret;
OpcUa_HistoryReadResult *pHistoryResult = &a_pHistoryReadRawModifiedCtx->pResponse->Results[i];
if (pUserData && pUserData->Type == UserDataHistoryDataLogger)
{
HistoryDataLogger *pLoggerData = (HistoryDataLogger*)pUserData;
ret = UaServer_DataLogger_ReadValues(
pLoggerData->DataLogger,
pLoggerData->DataLogItem,
a_pHistoryReadRawModifiedCtx->pHistoryReadRawModifiedDetails,
a_pHistoryReadRawModifiedCtx->TimestampsToReturn,
a_pHistoryReadRawModifiedCtx->ReleaseContinuationPoints,
&a_pHistoryReadRawModifiedCtx->pNodesToRead[i],
pHistoryResult);
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = ret;
}
else
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
}
}
#endif
}
}
}
return OpcUa_Good;
}
OPCUA_END_EXTERN_C