• 大小: 456KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: Opc  Server  

资源简介

OPC 基金组织公开的最新OPC Server 4.0 for .NET,是开发OPC难得的开源项目

资源截图

代码片段和文件信息

/**********************************************************************
 * Copyright © 2009 2010 2011 2012 OPC Foundation Inc. 
 *
 * The source code and all binaries built with the OPC .NET 3.0 source
 * code are subject to the terms of the Express Interface Public
 * License (Xi-PL).  See http://www.opcfoundation.org/License/Xi-PL/
 *
 * The source code may be distributed from an OPC member company in
 * its original or modified form to its customers and to any others who
 * have software that needs to interoperate with the OPC member‘s OPC
* .NET 3.0 products. No other redistribution is permitted.
 *
 * You must not remove this notice or any other from this software.
 *
 *********************************************************************/

using System;
using System.ServiceModel;

namespace Xi.Common.Support
{
/// 
/// This class is used to properly close a WCF client proxy.  It aborts or closes
/// the proxy based on the channel status and whether an exception is encountered.
/// It has two calling methods one where the proxy has a short life and the other
/// to be used when the proxy is held over the life of a single method.
/// 

/// 
/// Usage 1: Short lived proxy
/// void SomeMethod()
/// {
///     SomeWcfProxy proxy = new SomeWcfProxy();
///     using (new ChannelCloser(proxy))
///     {
///        proxy.MakeCall();
///         ...
///     }
/// }
/// 
/// Usage 2: Long lived proxy
/// void CreateProxy()
/// {
///     SomeWcfProxy proxy = new SomeWcfProxy();
///     ...
/// }
/// void DestroyProxy()
/// {
///    ChannelCloser.Close(proxy);
/// }
/// 

public class ChannelCloser : IDisposable
{
private readonly ICommunicationobject _channel;

/// 
/// Constructs a WCF channel closer object
/// 

/// WCF proxy object
public ChannelCloser(object channelObj)
{
if (!(channelObj is ICommunicationobject))
throw new ArgumentException(“Channel object must implement ICommunicationobject“);
_channel = (ICommunicationobject)channelObj;
}

/// 
/// Properly releases and closes the held WCF proxy
/// 

public void Dispose()
{
Close(_channel);
}

/// 
/// This method closes the passed proxy object
/// 

/// 
public static void Close(object obj)
{
if (obj != null)
{
var channelObj = obj as ICommunicationobject;
if (channelObj == null)
throw new ArgumentException(“Channel object must implement ICommunicationobject“ “obj“);

// if the channel faults you cannot Close/Dispose it - instead you have to Abort it
if (channelObj.State == CommunicationState.Faulted)
channelObj.Abort();
else if (channelObj.State != CommunicationState.Closed)
{
try
{
channelObj.Close();
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-09-06 15:02  Xi Contracts\Data\
     文件        2551  2012-09-06 11:33  Xi Contracts\Data\AddDataobjectResult.cs
     文件        3106  2012-09-06 11:33  Xi Contracts\Data\AlarmCondition.cs
     文件        2444  2012-09-06 11:33  Xi Contracts\Data\AlarmDescription.cs
     文件        1479  2012-09-06 11:33  Xi Contracts\Data\AlarmEnabledState.cs
     文件        2377  2012-09-06 11:33  Xi Contracts\Data\AlarmMessageData.cs
     文件        2245  2012-09-06 11:33  Xi Contracts\Data\AlarmState.cs
     文件        4931  2012-09-06 11:33  Xi Contracts\Data\AlarmSummary.cs
     文件        1410  2012-09-06 11:33  Xi Contracts\Data\AliasAndCalculation.cs
     文件        2115  2012-09-06 11:33  Xi Contracts\Data\AliasResult.cs
     文件        1957  2012-09-06 11:33  Xi Contracts\Data\AliasUpdate.cs
     文件        3374  2012-09-06 11:33  Xi Contracts\Data\CategoryConfiguration.cs
     文件        1924  2012-09-06 11:33  Xi Contracts\Data\DataJournalOptions.cs
     文件        1402  2012-09-06 11:33  Xi Contracts\Data\DataJournalWriteResult.cs
     文件       16674  2012-09-06 11:33  Xi Contracts\Data\DataValueArrays.cs
     文件       11523  2012-09-06 11:33  Xi Contracts\Data\DataValueArraysWithAlias.cs
     文件        4455  2012-09-06 11:33  Xi Contracts\Data\EndpointConfiguration.cs
     文件        2419  2012-09-06 11:33  Xi Contracts\Data\EndpointConfigurationEx.cs
     文件        3071  2012-09-06 11:33  Xi Contracts\Data\EndpointDefinition.cs
     文件        6029  2012-09-06 11:33  Xi Contracts\Data\ErrorInfo.cs
     文件        2870  2012-09-06 11:33  Xi Contracts\Data\EventId.cs
     文件        1436  2012-09-06 11:33  Xi Contracts\Data\EventIdResult.cs
     文件        4744  2012-09-06 11:33  Xi Contracts\Data\EventMessage.cs
     文件        2206  2012-09-06 11:33  Xi Contracts\Data\EventMessageField.cs
     文件        3677  2012-09-06 11:33  Xi Contracts\Data\EventType.cs
     文件        4774  2012-09-06 11:33  Xi Contracts\Data\FilterCriterion.cs
     文件        3792  2012-09-06 11:33  Xi Contracts\Data\FilterSet.cs
     文件        3201  2012-09-06 11:33  Xi Contracts\Data\FindCriteria.cs
     文件       14513  2012-09-06 11:33  Xi Contracts\Data\InstanceId.cs
     文件        2378  2012-09-06 11:33  Xi Contracts\Data\JournalDataChangedValues.cs
     文件        1799  2012-09-06 11:33  Xi Contracts\Data\JournalDataPropertyValue.cs
............此处省略164个文件信息

评论

共有 条评论