High Performance OPC UA Server SDK  1.2.0.193
custom_provider.c
/*****************************************************************************
* *
* Copyright (c) 2006-2016 Unified Automation GmbH. All rights reserved. *
* *
* Software License Agreement ("SLA") Version 2.6 *
* *
* 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.6, 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. *
* *
* The complete license agreement can be found here: *
* http://unifiedautomation.com/License/SLA/2.6/ *
* *
*****************************************************************************/
#include <uaserver/addressspace/addressspace.h>
#include <memory/memory.h>
#include <uaserver/provider/provider.h>
#include <uaserver/valuestore/valuestore.h>
#include <trace/trace.h>
#include <uaserver/server_config.h>
#ifdef UA_AUTHORIZATION_SUPPORT
# include <uaserver/session/authorization/authorization.h>
#endif
#ifdef ENABLE_SERVICE_READ
# include "custom_provider_read.h"
#endif
#ifdef ENABLE_SERVICE_WRITE
# include "custom_provider_write.h"
#endif
#ifdef ENABLE_SERVICE_SUBSCRIPTION
# include "custom_provider_subscription.h"
#endif
#include "custom_provider_nodes.h"
#include "custom_provider.h"
uint16_t g_custom_provider_nsidx;
static struct ua_variant g_memorystore_values[3];
struct ua_memorystore g_memorystore;
uint32_t g_custom_provider_values[3];
/* cleanup resources allocated by the custom provider */
static void custom_provider_cleanup(struct uaprovider *ctx)
{
UA_UNUSED(ctx);
ua_memorystore_clear(&g_memorystore);
return;
}
int custom_provider_init(struct uaprovider *ctx)
{
struct ua_addressspace_config config;
int ret;
ua_memset(&config, 0, sizeof(config));
config.nsidx = UA_NSIDX_INVALID; /* assign auto index */
config.max_variables = 10;
config.max_references = 20;
config.max_strings = 10;
/* register new namespace */
"http://www.unifiedautomation.com/CustomServer/",
&config,
if (ret < 0) return ret;
g_custom_provider_nsidx = (uint16_t) ret;
ret = uaprovider_register_nsindex(ctx, g_custom_provider_nsidx);
if (ret != 0) return ret;
/* initialize memorystore context */
ret = ua_memorystore_init(&g_memorystore, 0, g_memorystore_values, countof(g_memorystore_values));
if (ret != 0) return ret;
ret = custom_provider_create_nodes();
if (ret != 0) return ret;
#ifdef ENABLE_SERVICE_READ
ctx->read = custom_provider_read;
#endif
#ifdef ENABLE_SERVICE_WRITE
ctx->write = custom_provider_write;
#endif
#ifdef ENABLE_SERVICE_SUBSCRIPTION
ctx->add_item = custom_provider_add_item;
ctx->remove_item = custom_provider_remove_item;
ctx->modify_item = custom_provider_modify_item;
ctx->subscribe = custom_provider_subscribe;
#endif
#ifdef ENABLE_SERVICE_READ
ctx->read = custom_provider_read;
#endif
#ifdef ENABLE_SERVICE_WRITE
ctx->write = custom_provider_write;
#endif
#ifdef ENABLE_SERVICE_SUBSCRIPTION
ctx->add_item = custom_provider_add_item;
ctx->remove_item = custom_provider_remove_item;
ctx->modify_item = custom_provider_modify_item;
ctx->subscribe = custom_provider_subscribe;
#endif
ctx->cleanup = custom_provider_cleanup;
return ret;
}