#include <uaserver_config.h>
#include <opcua_statuscodes.h>
#include <uaserver_historyread.h>
#include <uaserver_basenode.h>
#include <uaserver_utilities.h>
#include <uabase_p_atomic.h>
#include "custom_provider_helper.h"
#if HAVE_DATA_LOGGER
#include <uaserver_datalogger.h>
#endif
OPCUA_BEGIN_EXTERN_C
IFMETHODIMP(CustomProvider_HistoryReadRawModifiedAsync)(UaServer_ProviderHistoryReadRawModifiedContext* a_pHistoryReadRawModifiedCtx)
{
OpcUa_Int32 i;
OpcUa_BaseNode *pNode = OpcUa_Null;
OpcUa_ReturnErrorIfArgumentNull(a_pHistoryReadRawModifiedCtx);
for (i = 0; i < a_pHistoryReadRawModifiedCtx->NoOfNodesToRead; i++)
{
if (a_pHistoryReadRawModifiedCtx->pNodesToRead[i].NodeId.NamespaceIndex == g_uCustomProvider_NamespaceIndex)
{
UaServer_GetNode(pAddressSpace, &a_pHistoryReadRawModifiedCtx->pNodesToRead[i].NodeId, &pNode);
if (pNode)
{
#if UASERVER_SUPPORT_AUTHORIZATION
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
continue;
}
#endif
#if HAVE_DATA_LOGGER && UASERVER_DATALOGGER_SUPPORT_DATA
{
if (pUserData && pUserData->Type == UserDataTemperature)
{
TemperatureSensor *pTemperatureSensorData = (TemperatureSensor*)pUserData;
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = UaServer_DataLogger_ReadValues(
g_hDataLogger,
pTemperatureSensorData->hDataLogItemTemperatureValue,
a_pHistoryReadRawModifiedCtx->pHistoryReadRawModifiedDetails,
a_pHistoryReadRawModifiedCtx->TimestampsToReturn,
a_pHistoryReadRawModifiedCtx->ReleaseContinuationPoints,
&a_pHistoryReadRawModifiedCtx->pNodesToRead[i],
pHistoryResult,
a_pHistoryReadRawModifiedCtx->RequestHeader.TimeoutHint);
}
else
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
}
}
#endif
}
}
}
return OpcUa_Good;
}
OPCUA_END_EXTERN_C