/* ========================================================================
* Copyright (c) 2005-2011 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
#include "StdAfx.h"
#include "OpcUaComProxyServer.h"
#include "COpcUaHdaProxyServer.h"
#include "COpcUaProxyUtils.h"
#include "COpcUaHdaProxyBrowser.h"
#include "COpcUaHdaProxyDataCallback.h"
using namespace System;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Collections::Generic;
using namespace System::Security::Cryptography::X509Certificates;
using namespace Opc::Ua;
using namespace Opc::Ua::Com;
using namespace Opc::Ua::Com::Server;
//==============================================================================
// Static Functions
/// <summary>
/// Writes a trace message.
/// </summary>
static void TraceState(String^ context, ... array<Object^>^ args)
{
#ifdef TRACESTATE
COpcUaProxyUtils::TraceState("COpcUaHdaProxyServer", context, args);
#endif
}
struct OpcHdaAttributeDesc
{
DWORD dwID;
VARTYPE vtDataType;
LPCWSTR szName;
LPCWSTR szDescription;
};
OpcHdaAttributeDesc g_AttributeTable[] =
{
{ OPCHDA_DATA_TYPE, VT_I2, OPCHDA_ATTRNAME_DATA_TYPE, L"Specifies the data type for the item." },
{ OPCHDA_DESCRIPTION, VT_BSTR, OPCHDA_ATTRNAME_DESCRIPTION, L"Describes the item." },
{ OPCHDA_ENG_UNITS, VT_BSTR, OPCHDA_ATTRNAME_ENG_UNITS, L"The label to use in displays to define the units for the item (e.g., kg/sec)." },
{ OPCHDA_STEPPED, VT_BOOL, OPCHDA_ATTRNAME_STEPPED, L"Whether data from the history repository should be displayed as interpolated or stepped." },
{ OPCHDA_ARCHIVING, VT_BOOL, OPCHDA_ATTRNAME_ARCHIVING, L"Indicates whether historian is recording data for this item." },
{ OPCHDA_DERIVE_EQUATION, VT_BSTR, OPCHDA_ATTRNAME_DERIVE_EQUATION, L"Specifies the equation to be used by a derived item to calculate its value." },
{ OPCHDA_NORMAL_MAXIMUM, VT_R8, OPCHDA_ATTRNAME_NORMAL_MAXIMUM, L"Specifies the upper limit for the normal value range for the item." },
{ OPCHDA_NORMAL_MINIMUM, VT_R8, OPCHDA_ATTRNAME_NORMAL_MINIMUM, L"Specifies the lower limit for the normal value range for the item." },
{ OPCHDA_ITEMID, VT_BSTR, OPCHDA_ATTRNAME_ITEMID, L"Specifies the leaf name portion the item id." },
{ OPCHDA_MAX_TIME_INT, VT_CY, OPCHDA_ATTRNAME_MAX_TIME_INT, L"Specifies the maximum interval between data points in the history repository." },
{ OPCHDA_MIN_TIME_INT, VT_CY, OPCHDA_ATTRNAME_MIN_TIME_INT, L"Specifies the minimum interval between data points in the history repository." },
{ OPCHDA_EXCEPTION_DEV, VT_R8, OPCHDA_ATTRNAME_EXCEPTION_DEV, L"Specifies the minimum amount that the data for the item must change in order for the change to be reported to the history database." },
{ OPCHDA_EXCEPTION_DEV_TYPE, VT_I2, OPCHDA_ATTRNAME_EXCEPTION_DEV_TYPE, L"Specifies whether the exception deviation is given as an absolute value, percent of span, or percent of value." },
{ OPCHDA_HIGH_ENTRY_LIMIT, VT_R8, OPCHDA_ATTRNAME_HIGH_ENTRY_LIMIT, L"Specifies the highest valid value for the item." },
{ OPCHDA_LOW_ENTRY_LIMIT, VT_R8, OPCHDA_ATTRNAME_LOW_ENTRY_LIMIT, L"Specifies the lowest valid value for the item." },
{ 0, VT_EMPTY, NULL, NULL }
};
static void* AllocArray(int size, int count)
{
// allocate return array.
void* pValues = CoTaskMemAlloc(size*count);
// check allocations.
if (pValues == NULL)
{
throw gcnew System::OutOfMemoryException();
}
// initialize results.
memset(pValues, 0, size*count);
return pValues;
}
#define ALLOC_ARRAY(xType, xCount) (xType*)AllocArray(sizeof(xType),xCount)
// Copy(HRESULT)
HRESULT Copy(
array<int>^ results,
DWORD dwNumItems,
HRESULT* pErrors)
{
HRESULT hResult = S_OK;
for (DWORD ii = 0; ii < dwNumItems; ii++)
{
pErrors[ii] = results[ii];
if (pErrors[ii] != S_OK)
{
hResult = S_FALSE;
}
}
return hResult;
}
// Copy(HdaUpdateRequest)
HRESULT Copy(
List<HdaUpdateRequest^>^ results,
DWORD dwNumItems,
OPCHANDLE* phClient,
HRESULT* pErrors)
{
HRESULT hResult = S_OK;
for (DWORD ii = 0; ii < dwNumItems; ii++)
{
phClient[ii] = results[ii]->ClientHandle;
pErrors[ii] = results[ii]->Error;
if (pErrors[ii] != S_OK)
{
hResult = S_FALSE;
}
}
return hResult;
}
// MarshalRequests
static HRESULT MarshalRequests(
array<DaValue^>^ values,
VARIANT* pvValues,
DWORD* pdwQualities,
::FILETIME* pftTimeStamps)
{
// check arguments.
if (pvValues == NULL || pdwQualities == NULL || pftTimeStamps == NULL)
{
return E_INVALIDARG;
}
DWORD dwCount = values->Length;
try
{
// fix any marshalling issues.
COpcUaProxyUtils::FixupInputVariants(dwCount, pvValues);
// copy data.
for (int ii = 0; ii < values->Length; ii++)
{
values[ii] = gcnew DaValue();
values[ii]->Value = Marshal::GetObjectForNativeVariant((IntPtr)&(pvValues[ii]));
values[ii]->Timestamp = COpcUaProxyUtils::ResolveTime(&(pftTimeStamps[ii]));
values[ii]->HdaQuality = pdwQualities[ii];
}
return S_OK;
}
catch (Exception^ e)
{
// extract unexpected error.
return Marshal::GetHRForException(e);
}
}
// MarshalRequests
static HRESULT MarshalRequests(
array<int>^ serverHandles,
array<DateTime>^ timestamps,
array<array<Annotation^>^>^ annotations,
OPCHANDLE* phServer,
::FILETIME* ftTimeStamps,
OPCHDA_ANNOTATION* pAnnotationValues)
{
// check arguments.
if (pAnnotationValues == NULL || ftTimeStamps == NULL)
{
return E_INVALIDARG;
}
DWORD dwCount = serverHandles->Length;
try
{
for (int ii = 0; ii < serverHandles->Length; ii++)
{
// marshal handle/timestamps.
serverHandles[ii] = phServer[ii];
timestamps[ii] = COpcUaProxyUtils::ResolveTime(&(ftTimeStamps[ii]));
if (pAnnotationValues[ii].dwNumValues == 0)
{
continue;
}
// marhsal annotations.
List<Annotation^>^ list = gcnew List<Annotation
没有合适的资源?快使用搜索试试~ 我知道了~
opc UA .net 源码 2016年的1.33版本
共2000个文件
cs:1511个
resx:325个
htm:280个
需积分: 19 28 下载量 56 浏览量
2017-02-18
21:33:50
上传
评论 2
收藏 30.12MB ZIP 举报
温馨提示
企业数据软硬集成国际/国内标准推荐的数据处理方案---OPC UA。
资源推荐
资源详情
资源评论
收起资源包目录
opc UA .net 源码 2016年的1.33版本 (2000个子文件)
Archtecture.aml 6KB
Overview.aml 3KB
Overview.aml 3KB
Archtecture.aml 977B
BuildDesign.bat 1007B
BuildDesign.bat 551B
BuildSchema.bat 482B
BuildDesign.bat 340B
BuildDesign.bat 309B
BuildDesign.bat 308B
BuildDesign.bat 308B
BuildDesign.bat 308B
BuildDesign.bat 304B
BuildDesign.bat 291B
BuildDesign.bat 243B
BuildDesign.bat 237B
BuildDesign.bat 168B
Variable.bmp 822B
Object.bmp 822B
ByteString.bmp 822B
Method.bmp 822B
Value.bmp 822B
String.bmp 822B
Attribute.bmp 822B
View.bmp 822B
Number.bmp 822B
OpenFolder.bmp 822B
InputArgument.bmp 822B
Constant.bmp 822B
Structure.bmp 822B
Property.bmp 822B
Array.bmp 822B
Varible.bmp 822B
ClosedFolder.bmp 822B
ObjectType.bmp 822B
Object2.bmp 822B
Reference.bmp 822B
OutputArgument.bmp 822B
Opc.Ua.Types.bsd 141KB
TestData.Types.bsd 13KB
BuiltInTypes.bsd 12KB
Opc.Ua.Sample.Types.bsd 6KB
StandardTypes.bsd 5KB
Quickstarts.DataTypes.Instances.Types.bsd 1KB
Quickstarts.DataTypes.Types.Types.bsd 1KB
Quickstarts.DataTypes.Instances.Types.bsd 954B
Quickstarts.Views.Types.bsd 873B
Quickstarts.Boiler.Types.bsd 736B
Quickstarts.SimpleEvents.Types.bsd 674B
Quickstarts.SimpleEvents.Types.bsd 674B
TutorialModel.Types.bsd 650B
Boiler.Types.bsd 578B
MemoryBuffer.Types.bsd 576B
FileSystem.Types.bsd 574B
Quickstarts.HistoricalEvents.Types.bsd 494B
Quickstarts.HistoricalEvents.Types.bsd 494B
Quickstarts.Engineering.Types.bsd 490B
Quickstarts.Operations.Types.bsd 488B
Quickstarts.BoilerServer.Types.bsd 474B
Opc.Ua.Com.Types.bsd 472B
AggregationModel.Types.bsd 466B
opcda_i.c 5KB
opcda_i.c 5KB
opchda_i.c 4KB
opchda_i.c 4KB
opc_ae_i.c 4KB
opc_ae_i.c 4KB
opcbc_i.c 4KB
opcbc_i.c 4KB
opccomn_i.c 3KB
OpcCmd_i.c 3KB
opccomn_i.c 3KB
OpcCmd_i.c 3KB
OpcDx_i.c 3KB
OpcDx_i.c 3KB
opcSec_i.c 3KB
opcSec_i.c 3KB
OpcEnum_i.c 3KB
OpcEnum_i.c 3KB
ClassDiagram1.cd 1B
OPCUASDKHelp.chm 10MB
OPC UA Alarms and Conditions Quickstart.chm 1.04MB
OPC UA Data Access Quickstart.chm 723KB
Web.config 4KB
Opc.Ua.SampleServer.exe.config 3KB
App.config 3KB
Quickstarts.UserAuthenticationServer.exe.config 3KB
App.config 3KB
Quickstarts.ReferenceServer.exe.config 3KB
Quickstarts.HistoricalEventsServer.exe.config 3KB
Quickstarts.HistoricalAccessServer.exe.config 3KB
Quickstarts.MethodsServer.exe.config 3KB
Quickstarts.AlarmConditionServer.exe.config 3KB
Quickstarts.EmptyServer.exe.config 3KB
Quickstarts.ViewsServer.exe.config 3KB
Quickstarts.SimpleEventsServer.exe.config 3KB
Quickstarts.DataAccessServer.exe.config 3KB
Opc.Ua.SampleClient.exe.config 3KB
AggregationServer.exe.config 3KB
DataTypesServer.exe.config 3KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
qianrushi110
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功