UA ANSI C Server Professional  1.4.0.285
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
uaprovider_demo_historyread.c
/******************************************************************************
**
** **************************** auto-generated ****************************
** This code was generated by a tool: UaModeler
** Runtime Version: 1.2.0, using ANSI C DemoProvider 1.4.0 template
**
** This is a template file that was generated for your convenience.
** This file will not be overwritten when generating code again.
** ADD YOUR IMPLEMTATION HERE!
** **************************** auto-generated ****************************
** Copyright (c) 2006-2014 Unified Automation GmbH All rights reserved.
** Web: http://www.unifiedautomation.com
**
** Software License Agreement ("SLA") Version 2.3
**
** Unless explicitly acquired and licensed from Licensor under another
** license, the contents of this file are subject to the Software License
** Agreement ("SLA") Version 2.3, or subsequent versions
** as allowed by the SLA, and You may not copy or use this file in either
** source code or executable form, except in compliance with the terms and
** conditions of the SLA.
**
** All software distributed under the SLA is provided strictly on an
** "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
** AND LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
** LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
** PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the SLA for specific
** language governing rights and limitations under the SLA.
**
** Project: OPC Ansi C DemoProvider for namespace http://www.unifiedautomation.com/DemoServer/
**
** Description: OPC Unified Architecture Software Development Kit.
**
** The complete license agreement can be found here:
** http://unifiedautomation/License/SLA/2.3/
**
** Created: 30.01.2014
**
******************************************************************************/
#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 /* HAVE_DATA_LOGGER */
OPCUA_BEGIN_EXTERN_C
IFMETHODIMP(UaProvider_Demo_HistoryReadRawModifiedAsync)(UaServer_ProviderHistoryReadRawModifiedContext* a_pHistoryReadRawModifiedCtx)
{
OpcUa_Int32 i;
OpcUa_BaseNode *pNode = OpcUa_Null;
OpcUa_NodeId *pNodeId;
OpcUa_HistoryReadValueId *pNodeToRead;
UaServer_AddressSpace *pAddressSpace = &(g_pDemoProvider->AddressSpace);
OpcUa_ReturnErrorIfArgumentNull(a_pHistoryReadRawModifiedCtx);
/* we will send exactly one callback */
UaServer_Atomic_Increment(&a_pHistoryReadRawModifiedCtx->nOutstandingCbs);
/* process nodes */
for (i = 0; i < a_pHistoryReadRawModifiedCtx->NoOfNodesToRead; i++)
{
pNodeToRead = &a_pHistoryReadRawModifiedCtx->pNodesToRead[i];
pNodeId = &pNodeToRead->NodeId;
if (pNodeId->NamespaceIndex == g_UaProviderDemo_uNamespaceIndex1)
{
UaServer_GetNode(pAddressSpace, pNodeId, &pNode);
if (pNode)
{
if (OpcUa_BaseNode_GetClass(pNode) == OpcUa_NodeClass_Variable
&& (OpcUa_Variable_GetAccessLevel(pNode) & OpcUa_AccessLevels_HistoryRead) == 0)
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
continue;
}
#if UASERVER_SUPPORT_AUTHORIZATION
/* Check if the user has the necessary permission to read the history */
if (!UaServer_UserMgt_IsHistoryReadable(OpcUa_BaseNode_GetINode(pNode), a_pHistoryReadRawModifiedCtx->pSession->UserIdentityData))
{
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode = OpcUa_BadNotReadable;
continue;
}
#endif
#if HAVE_DATA_LOGGER && UASERVER_DATALOGGER_SUPPORT_DATA
if (OpcUa_BaseNode_GetId(pNode)->IdentifierType == OpcUa_IdentifierType_Numeric
|| OpcUa_BaseNode_GetId(pNode)->IdentifierType == OpcUa_IdentifierType_String)
{
OpcUa_StatusCode ret;
OpcUa_HistoryReadResult *pHistoryResult = &a_pHistoryReadRawModifiedCtx->pResponse->Results[i];
UserDataCommon *pUserData = (UserDataCommon*)OpcUa_BaseNode_GetUserData(pNode);
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 /* HAVE_DATA_LOGGER && UASERVER_DATALOGGER_SUPPORT_DATA */
}
}
}
/* send callback */
UaServer_HistoryReadRawModifiedComplete(a_pHistoryReadRawModifiedCtx);
return OpcUa_Good;
}
OPCUA_END_EXTERN_C