This commit is contained in:
luosheng
2023-07-16 08:17:03 +08:00
parent 6d655b24d1
commit 2055c10c59
127 changed files with 7414 additions and 7470 deletions

View File

@@ -40,11 +40,11 @@ namespace Modbus.Net
{ {
Array.Reverse(data, pos, 4); Array.Reverse(data, pos, 4);
byte temp; byte temp;
temp = data[pos]; data[pos] = data[pos+2]; data[pos+2] = temp; temp = data[pos]; data[pos] = data[pos + 2]; data[pos + 2] = temp;
temp = data[pos+1]; data[pos+1] = data[pos+3]; data[pos+3] = temp; temp = data[pos + 1]; data[pos + 1] = data[pos + 3]; data[pos + 3] = temp;
var t = BitConverter.ToSingle(data, pos); var t = BitConverter.ToSingle(data, pos);
temp = data[pos]; data[pos] = data[pos+2]; data[pos+2] = temp; temp = data[pos]; data[pos] = data[pos + 2]; data[pos + 2] = temp;
temp = data[pos+1]; data[pos+1] = data[pos+3]; data[pos+3] = temp; temp = data[pos + 1]; data[pos + 1] = data[pos + 3]; data[pos + 3] = temp;
Array.Reverse(data, pos, 4); Array.Reverse(data, pos, 4);
pos += 4; pos += 4;
return t; return t;

View File

@@ -21,7 +21,7 @@ namespace Modbus.Net.Modbus
/// <param name="masterAddress">主站号</param> /// <param name="masterAddress">主站号</param>
/// <param name="endian">端格式</param> /// <param name="endian">端格式</param>
public ModbusMachine(TKey id, ModbusType connectionType, string connectionString, public ModbusMachine(TKey id, ModbusType connectionType, string connectionString,
IEnumerable<AddressUnit<TUnitKey, int ,int>> getAddresses, bool keepConnect, byte slaveAddress, byte masterAddress, IEnumerable<AddressUnit<TUnitKey, int, int>> getAddresses, bool keepConnect, byte slaveAddress, byte masterAddress,
Endian endian) Endian endian)
: base(id, getAddresses, keepConnect, slaveAddress, masterAddress) : base(id, getAddresses, keepConnect, slaveAddress, masterAddress)
{ {

View File

@@ -130,7 +130,7 @@ namespace Modbus.Net.Opc
{ {
Success = false, Success = false,
Value = Encoding.ASCII.GetBytes("NoData") Value = Encoding.ASCII.GetBytes("NoData")
}; };
} }
else else
{ {

View File

@@ -136,7 +136,7 @@ namespace Modbus.Net
else if (length == 0) return null; else if (length == 0) return null;
else else
{ {
duplicatedMessages = new List<(byte[],bool)>(); duplicatedMessages = new List<(byte[], bool)>();
var skipLength = 0; var skipLength = 0;
while (receiveMessageCopy.Length >= length) while (receiveMessageCopy.Length >= length)
{ {
@@ -160,7 +160,7 @@ namespace Modbus.Net
if (length == 0) return null; if (length == 0) return null;
} }
if (skipLength > 0) if (skipLength > 0)
{ {
lock (WaitingMessages) lock (WaitingMessages)
{ {
var def = GetMessageFromWaitingList(null); var def = GetMessageFromWaitingList(null);
@@ -175,7 +175,7 @@ namespace Modbus.Net
} }
def.ReceiveMutex.Set(); def.ReceiveMutex.Set();
} }
} }
return null; return null;
} }
} }

View File

@@ -1,9 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Modbus.Net namespace Modbus.Net
{ {

View File

@@ -1,10 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Modbus.Net namespace Modbus.Net
{ {

View File

@@ -1,8 +1,4 @@
using System; namespace Modbus.Net
using System.Collections.Generic;
using System.Linq;
namespace Modbus.Net
{ {
#if NET462 #if NET462
#pragma warning disable 1591 #pragma warning disable 1591

View File

@@ -313,13 +313,13 @@ namespace Modbus.Net
} }
foreach (var assembly in AssemblyHelper.GetAllLibraryAssemblies()) foreach (var assembly in AssemblyHelper.GetAllLibraryAssemblies())
{ {
var valueHelper = assembly.GetType("Modbus.Net."+endian.ToString() + "ValueHelper")?.GetProperty("Instance")?.GetValue(null, null) as ValueHelper; var valueHelper = assembly.GetType("Modbus.Net." + endian.ToString() + "ValueHelper")?.GetProperty("Instance")?.GetValue(null, null) as ValueHelper;
if (valueHelper != null) if (valueHelper != null)
{ {
EndianInstanceCache[endian.ToString()] = valueHelper; EndianInstanceCache[endian.ToString()] = valueHelper;
return valueHelper; return valueHelper;
} }
} }
throw new NotImplementedException("ValueHelper " + endian.ToString() + " doesn't exist."); throw new NotImplementedException("ValueHelper " + endian.ToString() + " doesn't exist.");
} }

View File

@@ -1,8 +1,6 @@
using Quartz; using Quartz;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -41,7 +39,7 @@ namespace Modbus.Net
if (sj == null) if (sj == null)
{ {
var chainRoot = context.JobDetail.Key; var chainRoot = context.JobDetail.Key;
var chainParent = ChainLinks.FirstOrDefault(p => p.Value == context.JobDetail.Key).Key; var chainParent = ChainLinks.FirstOrDefault(p => p.Value == context.JobDetail.Key).Key;
while (chainParent != null) while (chainParent != null)
{ {
chainRoot = chainParent; chainRoot = chainParent;

View File

@@ -90,7 +90,7 @@ namespace Modbus.Net
var jobKeys = await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("Modbus.Net.DataQuery.Group." + triggerKey)); var jobKeys = await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("Modbus.Net.DataQuery.Group." + triggerKey));
await scheduler.DeleteJobs(jobKeys); await scheduler.DeleteJobs(jobKeys);
return new MachineGetJobScheduler<TMachineMethod, TMachineKey, TReturnUnit>(scheduler, trigger); return new MachineGetJobScheduler<TMachineMethod, TMachineKey, TReturnUnit>(scheduler, trigger);
} }
/// <summary> /// <summary>

View File

@@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Quartz.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -646,7 +645,7 @@ namespace Modbus.Net
ErrorMsg = "Data length mismatch" ErrorMsg = "Data length mismatch"
}; };
} }
//字节坐标的主地址位置 //字节坐标的主地址位置
var localMainPos = 0; var localMainPos = 0;
//字节坐标的子地址位置 //字节坐标的子地址位置
@@ -720,7 +719,7 @@ namespace Modbus.Net
}; };
} }
} }
//如果不保持连接,断开连接 //如果不保持连接,断开连接
if (!KeepConnect) if (!KeepConnect)
BaseUtility.Disconnect(); BaseUtility.Disconnect();
@@ -873,7 +872,7 @@ namespace Modbus.Net
} }
//将要写入的值加入队列 //将要写入的值加入队列
var data = Convert.ChangeType(value.Value / addressUnit.Zoom, dataType); var data = Convert.ChangeType(value.Value / addressUnit.Zoom, dataType);
//写入数据 //写入数据
await await
BaseUtility.GetUtilityMethods<IUtilityMethodDatas>().SetDatasAsync(address, BaseUtility.GetUtilityMethods<IUtilityMethodDatas>().SetDatasAsync(address,

View File

@@ -3,9 +3,9 @@ using Microsoft.AspNetCore.Mvc;
using Modbus.Net; using Modbus.Net;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
using System.Diagnostics; using System.Diagnostics;
using AddressUnit = Modbus.Net.AddressUnit<string, int, int>;
using MachineJobSchedulerCreator = Modbus.Net.MachineJobSchedulerCreator<Modbus.Net.IMachineMethodDatas, string, double>; using MachineJobSchedulerCreator = Modbus.Net.MachineJobSchedulerCreator<Modbus.Net.IMachineMethodDatas, string, double>;
using ModbusMachine = Modbus.Net.Modbus.ModbusMachine<string, string>; using ModbusMachine = Modbus.Net.Modbus.ModbusMachine<string, string>;
using AddressUnit = Modbus.Net.AddressUnit<string, int, int>;
namespace AnyType.Controllers namespace AnyType.Controllers
{ {

View File

@@ -1,5 +1,4 @@
using Quartz.Logging; using Quartz.Logging;
using System.Configuration;
namespace MachineJob namespace MachineJob
{ {

View File

@@ -30,22 +30,22 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// Defines all well known COM AE HRESULT codes. /// Defines all well known COM AE HRESULT codes.
/// </summary> /// </summary>
internal struct Result internal struct Result
{ {
/// <remarks/> /// <remarks/>
public const int S_ALREADYACKED = +0x00040200; // 0x00040200 public const int S_ALREADYACKED = +0x00040200; // 0x00040200
/// <remarks/> /// <remarks/>
public const int S_INVALIDBUFFERTIME = +0x00040201; // 0x00040201 public const int S_INVALIDBUFFERTIME = +0x00040201; // 0x00040201
/// <remarks/> /// <remarks/>
public const int S_INVALIDMAXSIZE = +0x00040202; // 0x00040202 public const int S_INVALIDMAXSIZE = +0x00040202; // 0x00040202
/// <remarks/> /// <remarks/>
public const int S_INVALIDKEEPALIVETIME = +0x00040203; // 0x00040203 public const int S_INVALIDKEEPALIVETIME = +0x00040203; // 0x00040203
/// <remarks/> /// <remarks/>
public const int E_INVALIDBRANCHNAME = -0x3FFBFDFD; // 0xC0040203 public const int E_INVALIDBRANCHNAME = -0x3FFBFDFD; // 0xC0040203
/// <remarks/> /// <remarks/>
public const int E_INVALIDTIME = -0x3FFBFDFC; // 0xC0040204 public const int E_INVALIDTIME = -0x3FFBFDFC; // 0xC0040204
/// <remarks/> /// <remarks/>
public const int E_BUSY = -0x3FFBFDFB; // 0xC0040205 public const int E_BUSY = -0x3FFBFDFB; // 0xC0040205
/// <remarks/> /// <remarks/>
public const int E_NOINFO = -0x3FFBFDFA; // 0xC0040206 public const int E_NOINFO = -0x3FFBFDFA; // 0xC0040206
} }
} }

View File

@@ -24,10 +24,9 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Ae; using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Ae; using Technosoftware.OpcRcw.Ae;
using Technosoftware.OpcRcw.Comn;
#endregion #endregion
#pragma warning disable 0618 #pragma warning disable 0618
@@ -44,7 +43,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// <summary> /// <summary>
/// Initializes the object with the specified OpcUrl and COM server. /// Initializes the object with the specified OpcUrl and COM server.
/// </summary> /// </summary>
internal Server(OpcUrl url, object server) : base(url, server) internal Server(OpcUrl url, object server) : base(url, server)
{ {
m_supportsAE11 = true; m_supportsAE11 = true;
@@ -177,41 +176,41 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
// verify state and arguments. // verify state and arguments.
if (server_ == null) throw new NotConnectedException(); if (server_ == null) throw new NotConnectedException();
if (state == null) throw new ArgumentNullException(nameof(state)); if (state == null) throw new ArgumentNullException(nameof(state));
// initialize arguments. // initialize arguments.
object unknown = null; object unknown = null;
var riid = typeof(IOPCEventSubscriptionMgt).GUID; var riid = typeof(IOPCEventSubscriptionMgt).GUID;
var bufferTime = 0; var bufferTime = 0;
var maxSize = 0; var maxSize = 0;
// invoke COM method. // invoke COM method.
try try
{ {
((IOPCEventServer)server_).CreateEventSubscription( ((IOPCEventServer)server_).CreateEventSubscription(
(state.Active)?1:0, (state.Active) ? 1 : 0,
state.BufferTime, state.BufferTime,
state.MaxSize, state.MaxSize,
++m_handles, ++m_handles,
ref riid, ref riid,
out unknown, out unknown,
out bufferTime, out bufferTime,
out maxSize); out maxSize);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.CreateEventSubscription", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.CreateEventSubscription", e);
} }
// save actual values. // save actual values.
state.BufferTime = bufferTime; state.BufferTime = bufferTime;
state.MaxSize = maxSize; state.MaxSize = maxSize;
var subscription = new Subscription(state, unknown); var subscription = new Subscription(state, unknown);
// set keep alive. // set keep alive.
subscription.ModifyState((int)TsCAeStateMask.KeepAlive, state); subscription.ModifyState((int)TsCAeStateMask.KeepAlive, state);
// save subscription. // save subscription.
m_subscriptions.Add(m_handles, subscription); m_subscriptions.Add(m_handles, subscription);
@@ -245,8 +244,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryAvailableFilters", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryAvailableFilters", e);
} }
// return results. // return results.
return filters; return filters;
} }
@@ -270,23 +269,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// initialize arguments. // initialize arguments.
var count = 0; var count = 0;
var ppdwEventCategories = IntPtr.Zero; var ppdwEventCategories = IntPtr.Zero;
var ppszEventCategoryDescs = IntPtr.Zero; var ppszEventCategoryDescs = IntPtr.Zero;
// invoke COM method. // invoke COM method.
try try
{ {
((IOPCEventServer)server_).QueryEventCategories( ((IOPCEventServer)server_).QueryEventCategories(
eventType, eventType,
out count, out count,
out ppdwEventCategories, out ppdwEventCategories,
out ppszEventCategoryDescs); out ppszEventCategoryDescs);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventCategories", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventCategories", e);
} }
// check for empty list. // check for empty list.
if (count == 0) if (count == 0)
{ {
@@ -294,7 +293,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
} }
// unmarshal arguments. // unmarshal arguments.
var ids = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppdwEventCategories, count, true); var ids = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppdwEventCategories, count, true);
var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszEventCategoryDescs, count, true); var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszEventCategoryDescs, count, true);
// build results. // build results.
@@ -304,7 +303,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
categories[ii] = new TsCAeCategory(); categories[ii] = new TsCAeCategory();
categories[ii].ID = ids[ii]; categories[ii].ID = ids[ii];
categories[ii].Name = names[ii]; categories[ii].Name = names[ii];
} }
@@ -336,15 +335,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).QueryConditionNames( ((IOPCEventServer)server_).QueryConditionNames(
eventCategory, eventCategory,
out count, out count,
out ppszConditionNames); out ppszConditionNames);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryConditionNames", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryConditionNames", e);
} }
// check for empty list. // check for empty list.
if (count == 0) if (count == 0)
{ {
@@ -382,21 +381,21 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).QuerySubConditionNames( ((IOPCEventServer)server_).QuerySubConditionNames(
conditionName, conditionName,
out count, out count,
out ppszSubConditionNames); out ppszSubConditionNames);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySubConditionNames", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySubConditionNames", e);
} }
// check for empty list. // check for empty list.
if (count == 0) if (count == 0)
{ {
return new string[0]; return new string[0];
} }
// unmarshal arguments. // unmarshal arguments.
var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszSubConditionNames, count, true); var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszSubConditionNames, count, true);
@@ -428,15 +427,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).QuerySourceConditions( ((IOPCEventServer)server_).QuerySourceConditions(
sourceName, sourceName,
out count, out count,
out ppszConditionNames); out ppszConditionNames);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySourceConditions", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySourceConditions", e);
} }
// check for empty list. // check for empty list.
if (count == 0) if (count == 0)
{ {
@@ -476,7 +475,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).QueryEventAttributes( ((IOPCEventServer)server_).QueryEventAttributes(
eventCategory, eventCategory,
out count, out count,
out ppdwAttrIDs, out ppdwAttrIDs,
out ppszAttrDescs, out ppszAttrDescs,
@@ -485,8 +484,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventAttributes", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventAttributes", e);
} }
// check for empty list. // check for empty list.
if (count == 0) if (count == 0)
{ {
@@ -494,9 +493,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
} }
// unmarshal arguments. // unmarshal arguments.
var ids = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppdwAttrIDs, count, true); var ids = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppdwAttrIDs, count, true);
var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszAttrDescs, count, true); var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszAttrDescs, count, true);
var types = Technosoftware.DaAeHdaClient.Com.Interop.GetInt16s(ref ppvtAttrTypes, count, true); var types = Technosoftware.DaAeHdaClient.Com.Interop.GetInt16s(ref ppvtAttrTypes, count, true);
// build results. // build results.
var attributes = new TsCAeAttribute[count]; var attributes = new TsCAeAttribute[count];
@@ -505,8 +504,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
attributes[ii] = new TsCAeAttribute(); attributes[ii] = new TsCAeAttribute();
attributes[ii].ID = ids[ii]; attributes[ii].ID = ids[ii];
attributes[ii].Name = names[ii]; attributes[ii].Name = names[ii];
attributes[ii].DataType = Technosoftware.DaAeHdaClient.Com.Interop.GetType((VarEnum)types[ii]); attributes[ii].DataType = Technosoftware.DaAeHdaClient.Com.Interop.GetType((VarEnum)types[ii]);
} }
@@ -529,12 +528,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// <returns>A list of item urls for each specified attribute.</returns> /// <returns>A list of item urls for each specified attribute.</returns>
public TsCAeItemUrl[] TranslateToItemIDs( public TsCAeItemUrl[] TranslateToItemIDs(
string sourceName, string sourceName,
int eventCategory, int eventCategory,
string conditionName, string conditionName,
string subConditionName, string subConditionName,
int[] attributeIDs) int[] attributeIDs)
{ {
lock (this) lock (this)
{ {
// verify state and arguments. // verify state and arguments.
if (server_ == null) throw new NotConnectedException(); if (server_ == null) throw new NotConnectedException();
@@ -543,19 +542,19 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var ppszAttrItemIDs = IntPtr.Zero; var ppszAttrItemIDs = IntPtr.Zero;
var ppszNodeNames = IntPtr.Zero; var ppszNodeNames = IntPtr.Zero;
var ppCLSIDs = IntPtr.Zero; var ppCLSIDs = IntPtr.Zero;
var count = (attributeIDs != null)?attributeIDs.Length:0; var count = (attributeIDs != null) ? attributeIDs.Length : 0;
// call server. // call server.
try try
{ {
((IOPCEventServer)server_).TranslateToItemIDs( ((IOPCEventServer)server_).TranslateToItemIDs(
(sourceName != null)?sourceName:"", (sourceName != null) ? sourceName : "",
eventCategory, eventCategory,
(conditionName != null)?conditionName:"", (conditionName != null) ? conditionName : "",
(subConditionName != null)?subConditionName:"", (subConditionName != null) ? subConditionName : "",
count, count,
(count > 0)?attributeIDs:new int[0], (count > 0) ? attributeIDs : new int[0],
out ppszAttrItemIDs, out ppszAttrItemIDs,
out ppszNodeNames, out ppszNodeNames,
out ppCLSIDs); out ppCLSIDs);
@@ -563,15 +562,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.TranslateToItemIDs", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.TranslateToItemIDs", e);
} }
// unmarshal results. // unmarshal results.
var itemIDs = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszAttrItemIDs, count, true); var itemIDs = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszAttrItemIDs, count, true);
var nodeNames = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszNodeNames, count, true); var nodeNames = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszNodeNames, count, true);
var clsids = Technosoftware.DaAeHdaClient.Com.Interop.GetGUIDs(ref ppCLSIDs, count, true); var clsids = Technosoftware.DaAeHdaClient.Com.Interop.GetGUIDs(ref ppCLSIDs, count, true);
var itemUrls = new TsCAeItemUrl[count]; var itemUrls = new TsCAeItemUrl[count];
// fill in item urls. // fill in item urls.
for (var ii = 0; ii < count; ii++) for (var ii = 0; ii < count; ii++)
{ {
@@ -579,9 +578,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
itemUrls[ii].ItemName = itemIDs[ii]; itemUrls[ii].ItemName = itemIDs[ii];
itemUrls[ii].ItemPath = null; itemUrls[ii].ItemPath = null;
itemUrls[ii].Url.Scheme = OpcUrlScheme.DA; itemUrls[ii].Url.Scheme = OpcUrlScheme.DA;
itemUrls[ii].Url.HostName = nodeNames[ii]; itemUrls[ii].Url.HostName = nodeNames[ii];
itemUrls[ii].Url.Path = string.Format("{{{0}}}", clsids[ii]); itemUrls[ii].Url.Path = string.Format("{{{0}}}", clsids[ii]);
} }
// return results. // return results.
@@ -602,7 +601,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
public TsCAeCondition GetConditionState( public TsCAeCondition GetConditionState(
string sourceName, string sourceName,
string conditionName, string conditionName,
int[] attributeIDs) int[] attributeIDs)
{ {
lock (this) lock (this)
{ {
@@ -616,20 +615,20 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).GetConditionState( ((IOPCEventServer)server_).GetConditionState(
(sourceName != null)?sourceName:"", (sourceName != null) ? sourceName : "",
(conditionName != null)?conditionName:"", (conditionName != null) ? conditionName : "",
(attributeIDs != null)?attributeIDs.Length:0, (attributeIDs != null) ? attributeIDs.Length : 0,
(attributeIDs != null)?attributeIDs:new int[0], (attributeIDs != null) ? attributeIDs : new int[0],
out ppConditionState); out ppConditionState);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.GetConditionState", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.GetConditionState", e);
} }
// unmarshal results. // unmarshal results.
var conditions = Interop.GetConditions(ref ppConditionState, 1, true); var conditions = Interop.GetConditions(ref ppConditionState, 1, true);
// fill in attribute ids. // fill in attribute ids.
for (var ii = 0; ii < conditions[0].Attributes.Count; ii++) for (var ii = 0; ii < conditions[0].Attributes.Count; ii++)
{ {
@@ -672,15 +671,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer2)server_).EnableConditionByArea2( ((IOPCEventServer2)server_).EnableConditionByArea2(
areas.Length, areas.Length,
areas, areas,
out ppErrors); out ppErrors);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionByArea2", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionByArea2", e);
} }
// unmarshal arguments. // unmarshal arguments.
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true); errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
} }
@@ -689,18 +688,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).EnableConditionByArea( ((IOPCEventServer)server_).EnableConditionByArea(
areas.Length, areas.Length,
areas); areas);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionByArea", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionByArea", e);
} }
// create dummy error array (0 == S_OK). // create dummy error array (0 == S_OK).
errors = new int[areas.Length]; errors = new int[areas.Length];
} }
// build results. // build results.
var results = new OpcResult[errors.Length]; var results = new OpcResult[errors.Length];
@@ -713,7 +712,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
return results; return results;
} }
} }
//====================================================================== //======================================================================
// DisableConditionByArea // DisableConditionByArea
@@ -745,15 +744,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer2)server_).DisableConditionByArea2( ((IOPCEventServer2)server_).DisableConditionByArea2(
areas.Length, areas.Length,
areas, areas,
out ppErrors); out ppErrors);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionByArea2", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionByArea2", e);
} }
// unmarshal arguments. // unmarshal arguments.
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true); errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
} }
@@ -762,18 +761,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).DisableConditionByArea( ((IOPCEventServer)server_).DisableConditionByArea(
areas.Length, areas.Length,
areas); areas);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionByArea", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionByArea", e);
} }
// create dummy error array (0 == S_OK). // create dummy error array (0 == S_OK).
errors = new int[areas.Length]; errors = new int[areas.Length];
} }
// build results. // build results.
var results = new OpcResult[errors.Length]; var results = new OpcResult[errors.Length];
@@ -818,15 +817,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer2)server_).EnableConditionBySource2( ((IOPCEventServer2)server_).EnableConditionBySource2(
sources.Length, sources.Length,
sources, sources,
out ppErrors); out ppErrors);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionBySource2", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionBySource2", e);
} }
// unmarshal arguments. // unmarshal arguments.
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true); errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
} }
@@ -835,18 +834,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).EnableConditionBySource( ((IOPCEventServer)server_).EnableConditionBySource(
sources.Length, sources.Length,
sources); sources);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionBySource", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionBySource", e);
} }
// create dummy error array (0 == S_OK). // create dummy error array (0 == S_OK).
errors = new int[sources.Length]; errors = new int[sources.Length];
} }
// build results. // build results.
var results = new OpcResult[errors.Length]; var results = new OpcResult[errors.Length];
@@ -891,15 +890,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer2)server_).DisableConditionBySource2( ((IOPCEventServer2)server_).DisableConditionBySource2(
sources.Length, sources.Length,
sources, sources,
out ppErrors); out ppErrors);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionBySource2", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionBySource2", e);
} }
// unmarshal arguments. // unmarshal arguments.
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true); errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
} }
@@ -908,18 +907,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try try
{ {
((IOPCEventServer)server_).DisableConditionBySource( ((IOPCEventServer)server_).DisableConditionBySource(
sources.Length, sources.Length,
sources); sources);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionBySource", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionBySource", e);
} }
// create dummy error array (0 == S_OK). // create dummy error array (0 == S_OK).
errors = new int[sources.Length]; errors = new int[sources.Length];
} }
// build results. // build results.
var results = new OpcResult[errors.Length]; var results = new OpcResult[errors.Length];
@@ -962,23 +961,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
failures[ii] = new TsCAeEnabledStateResult(); failures[ii] = new TsCAeEnabledStateResult();
failures[ii].Enabled = false; failures[ii].Enabled = false;
failures[ii].EffectivelyEnabled = false; failures[ii].EffectivelyEnabled = false;
failures[ii].Result = OpcResult.E_FAIL; failures[ii].Result = OpcResult.E_FAIL;
} }
return failures; return failures;
} }
// initialize arguments. // initialize arguments.
var pbEnabled = IntPtr.Zero; var pbEnabled = IntPtr.Zero;
var pbEffectivelyEnabled = IntPtr.Zero; var pbEffectivelyEnabled = IntPtr.Zero;
var ppErrors = IntPtr.Zero; var ppErrors = IntPtr.Zero;
try try
{ {
((IOPCEventServer2)server_).GetEnableStateByArea( ((IOPCEventServer2)server_).GetEnableStateByArea(
areas.Length, areas.Length,
areas, areas,
out pbEnabled, out pbEnabled,
out pbEffectivelyEnabled, out pbEffectivelyEnabled,
@@ -987,14 +986,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateByArea", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateByArea", e);
} }
// unmarshal arguments. // unmarshal arguments.
var enabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEnabled, areas.Length, true); var enabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEnabled, areas.Length, true);
var effectivelyEnabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEffectivelyEnabled, areas.Length, true); var effectivelyEnabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEffectivelyEnabled, areas.Length, true);
var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true); var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
// build results. // build results.
var results = new TsCAeEnabledStateResult[errors.Length]; var results = new TsCAeEnabledStateResult[errors.Length];
@@ -1002,9 +1001,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
results[ii] = new TsCAeEnabledStateResult(); results[ii] = new TsCAeEnabledStateResult();
results[ii].Enabled = enabled[ii] != 0; results[ii].Enabled = enabled[ii] != 0;
results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0; results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0;
results[ii].Result = Interop.GetResultID(errors[ii]); results[ii].Result = Interop.GetResultID(errors[ii]);
} }
// return results // return results
@@ -1041,23 +1040,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
failures[ii] = new TsCAeEnabledStateResult(); failures[ii] = new TsCAeEnabledStateResult();
failures[ii].Enabled = false; failures[ii].Enabled = false;
failures[ii].EffectivelyEnabled = false; failures[ii].EffectivelyEnabled = false;
failures[ii].Result = OpcResult.E_FAIL; failures[ii].Result = OpcResult.E_FAIL;
} }
return failures; return failures;
} }
// initialize arguments. // initialize arguments.
var pbEnabled = IntPtr.Zero; var pbEnabled = IntPtr.Zero;
var pbEffectivelyEnabled = IntPtr.Zero; var pbEffectivelyEnabled = IntPtr.Zero;
var ppErrors = IntPtr.Zero; var ppErrors = IntPtr.Zero;
try try
{ {
((IOPCEventServer2)server_).GetEnableStateBySource( ((IOPCEventServer2)server_).GetEnableStateBySource(
sources.Length, sources.Length,
sources, sources,
out pbEnabled, out pbEnabled,
out pbEffectivelyEnabled, out pbEffectivelyEnabled,
@@ -1066,14 +1065,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateBySource", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateBySource", e);
} }
// unmarshal arguments. // unmarshal arguments.
var enabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEnabled, sources.Length, true); var enabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEnabled, sources.Length, true);
var effectivelyEnabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEffectivelyEnabled, sources.Length, true); var effectivelyEnabled = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref pbEffectivelyEnabled, sources.Length, true);
var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true); var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
// build results. // build results.
var results = new TsCAeEnabledStateResult[errors.Length]; var results = new TsCAeEnabledStateResult[errors.Length];
@@ -1081,9 +1080,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
results[ii] = new TsCAeEnabledStateResult(); results[ii] = new TsCAeEnabledStateResult();
results[ii].Enabled = enabled[ii] != 0; results[ii].Enabled = enabled[ii] != 0;
results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0; results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0;
results[ii].Result = Interop.GetResultID(errors[ii]); results[ii].Result = Interop.GetResultID(errors[ii]);
} }
// return results // return results
@@ -1102,10 +1101,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// <param name="conditions">The conditions being acknowledged.</param> /// <param name="conditions">The conditions being acknowledged.</param>
/// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns> /// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns>
public OpcResult[] AcknowledgeCondition( public OpcResult[] AcknowledgeCondition(
string acknowledgerID, string acknowledgerID,
string comment, string comment,
TsCAeEventAcknowledgement[] conditions) TsCAeEventAcknowledgement[] conditions)
{ {
lock (this) lock (this)
{ {
// verify state and arguments. // verify state and arguments.
@@ -1120,17 +1119,17 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// initialize arguments. // initialize arguments.
var count = conditions.Length; var count = conditions.Length;
var pszSource = new string[count]; var pszSource = new string[count];
var pszConditionName = new string[count]; var pszConditionName = new string[count];
var pftActiveTime = new OpcRcw.Ae.FILETIME[count]; var pftActiveTime = new OpcRcw.Ae.FILETIME[count];
var pdwCookie = new int[count]; var pdwCookie = new int[count];
for (var ii = 0; ii < count; ii ++) for (var ii = 0; ii < count; ii++)
{ {
pszSource[ii] = conditions[ii].SourceName; pszSource[ii] = conditions[ii].SourceName;
pszConditionName[ii] = conditions[ii].ConditionName; pszConditionName[ii] = conditions[ii].ConditionName;
pftActiveTime[ii] = Interop.Convert(Com.Interop.GetFILETIME(conditions[ii].ActiveTime)); pftActiveTime[ii] = Interop.Convert(Com.Interop.GetFILETIME(conditions[ii].ActiveTime));
pdwCookie[ii] = conditions[ii].Cookie; pdwCookie[ii] = conditions[ii].Cookie;
} }
var ppErrors = IntPtr.Zero; var ppErrors = IntPtr.Zero;
@@ -1151,11 +1150,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.AckCondition", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.AckCondition", e);
} }
// unmarshal results. // unmarshal results.
var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, count, true); var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, count, true);
// build results. // build results.
var results = new OpcResult[count]; var results = new OpcResult[count];
@@ -1180,9 +1179,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// <param name="browseFilter">The expression used to filter the names of children returned.</param> /// <param name="browseFilter">The expression used to filter the names of children returned.</param>
/// <returns>The set of elements that meet the filter criteria.</returns> /// <returns>The set of elements that meet the filter criteria.</returns>
public TsCAeBrowseElement[] Browse( public TsCAeBrowseElement[] Browse(
string areaID, string areaID,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter) string browseFilter)
{ {
lock (this) lock (this)
{ {
@@ -1213,10 +1212,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param> /// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param>
/// <returns>The set of elements that meet the filter criteria.</returns> /// <returns>The set of elements that meet the filter criteria.</returns>
public TsCAeBrowseElement[] Browse( public TsCAeBrowseElement[] Browse(
string areaID, string areaID,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter, string browseFilter,
int maxElements, int maxElements,
out IOpcBrowsePosition position) out IOpcBrowsePosition position)
{ {
position = null; position = null;
@@ -1239,7 +1238,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var elements = new ArrayList(); var elements = new ArrayList();
var result = FetchElements(browseType, maxElements, enumerator, elements); var result = FetchElements(browseType, maxElements, enumerator, elements);
// dispose of enumerator if all done. // dispose of enumerator if all done.
if (result != 0) if (result != 0)
{ {
@@ -1256,7 +1255,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement)); return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement));
} }
} }
//====================================================================== //======================================================================
// BrowseNext // BrowseNext
@@ -1282,12 +1281,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// fetch enumerator from position object. // fetch enumerator from position object.
var enumerator = ((BrowsePosition)position).Enumerator; var enumerator = ((BrowsePosition)position).Enumerator;
// fetch elements. // fetch elements.
var elements = new ArrayList(); var elements = new ArrayList();
var result = FetchElements(((BrowsePosition)position).BrowseType, maxElements, enumerator, elements); var result = FetchElements(((BrowsePosition)position).BrowseType, maxElements, enumerator, elements);
// dispose of position object if all done. // dispose of position object if all done.
if (result != 0) if (result != 0)
{ {
@@ -1298,7 +1297,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// return results. // return results.
return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement)); return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement));
} }
} }
#endregion #endregion
#region Private Methods #region Private Methods
@@ -1333,19 +1332,19 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// verify object. // verify object.
if (unknown == null) if (unknown == null)
{ {
throw new OpcResultException(new OpcResult( (int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null ),"The response from the server was invalid or incomplete"); throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The response from the server was invalid or incomplete");
} }
// save object. // save object.
m_browser = unknown; m_browser = unknown;
} }
/// <summary> /// <summary>
/// Moves the browse position prior to executing a browse operation. /// Moves the browse position prior to executing a browse operation.
/// </summary> /// </summary>
private void ChangeBrowsePosition(string areaID) private void ChangeBrowsePosition(string areaID)
{ {
var targetID = (areaID != null)?areaID:""; var targetID = (areaID != null) ? areaID : "";
// invoke COM method. // invoke COM method.
try try
@@ -1357,9 +1356,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.ChangeBrowsePosition", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.ChangeBrowsePosition", e);
} }
} }
/// <summary> /// <summary>
/// Creates an enumerator for the names at the current position. /// Creates an enumerator for the names at the current position.
/// </summary> /// </summary>
@@ -1374,22 +1373,22 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{ {
((IOPCEventAreaBrowser)m_browser).BrowseOPCAreas( ((IOPCEventAreaBrowser)m_browser).BrowseOPCAreas(
dwBrowseFilterType, dwBrowseFilterType,
(browseFilter != null)?browseFilter:"", (browseFilter != null) ? browseFilter : "",
out enumerator); out enumerator);
} }
catch (Exception e) catch (Exception e)
{ {
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.BrowseOPCAreas", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.BrowseOPCAreas", e);
} }
// verify object. // verify object.
if (enumerator == null) if (enumerator == null)
{ {
throw new OpcResultException(new OpcResult( (int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null ),"The response from the server was invalid or incomplete"); throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The response from the server was invalid or incomplete");
} }
// return result. // return result.
return (System.Runtime.InteropServices.ComTypes.IEnumString)enumerator; return (System.Runtime.InteropServices.ComTypes.IEnumString)enumerator;
} }
/// <summary> /// <summary>
@@ -1412,7 +1411,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.GetQualifiedAreaName", e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.GetQualifiedAreaName", e);
} }
} }
// fetch source qualified name. // fetch source qualified name.
else else
{ {
@@ -1438,47 +1437,47 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var buffer = new string[1]; var buffer = new string[1];
// re-calculate buffer length. // re-calculate buffer length.
var bufferLength = (maxElements > 0 && maxElements-elements.Count < buffer.Length)?maxElements-elements.Count:buffer.Length; var bufferLength = (maxElements > 0 && maxElements - elements.Count < buffer.Length) ? maxElements - elements.Count : buffer.Length;
// fetch first batch of names. // fetch first batch of names.
var pFetched = Marshal.AllocCoTaskMem(sizeof(int)); var pFetched = Marshal.AllocCoTaskMem(sizeof(int));
try try
{ {
var result = enumerator.Next(bufferLength, buffer, pFetched); var result = enumerator.Next(bufferLength, buffer, pFetched);
while (result == 0) while (result == 0)
{ {
var fetched = Marshal.ReadInt32(pFetched); var fetched = Marshal.ReadInt32(pFetched);
// create elements. // create elements.
for (var ii = 0; ii < fetched; ii++) for (var ii = 0; ii < fetched; ii++)
{ {
var element = new TsCAeBrowseElement(); var element = new TsCAeBrowseElement();
element.Name = buffer[ii]; element.Name = buffer[ii];
element.QualifiedName = GetQualifiedName(buffer[ii], browseType); element.QualifiedName = GetQualifiedName(buffer[ii], browseType);
element.NodeType = browseType; element.NodeType = browseType;
elements.Add(element);
}
// check for halt. elements.Add(element);
if (maxElements > 0 && elements.Count >= maxElements) }
{
break;
}
// re-calculate buffer length. // check for halt.
bufferLength = (maxElements > 0 && maxElements-elements.Count < buffer.Length)?maxElements-elements.Count:buffer.Length; if (maxElements > 0 && elements.Count >= maxElements)
{
// fetch next block. break;
}
// re-calculate buffer length.
bufferLength = (maxElements > 0 && maxElements - elements.Count < buffer.Length) ? maxElements - elements.Count : buffer.Length;
// fetch next block.
result = enumerator.Next(bufferLength, buffer, pFetched); result = enumerator.Next(bufferLength, buffer, pFetched);
} }
// return final result. // return final result.
return result; return result;
} }
finally finally
{ {
if (pFetched != IntPtr.Zero) if (pFetched != IntPtr.Zero)
@@ -1486,7 +1485,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
Marshal.FreeCoTaskMem(pFetched); Marshal.FreeCoTaskMem(pFetched);
} }
} }
} }
#endregion #endregion
#region Private Members #region Private Members
@@ -1496,7 +1495,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
private Hashtable m_subscriptions = new Hashtable(); private Hashtable m_subscriptions = new Hashtable();
#endregion #endregion
} }
#region BrowsePosition Class #region BrowsePosition Class
/// <summary> /// <summary>
/// Stores the state of a browse operation. /// Stores the state of a browse operation.
@@ -1509,14 +1508,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// Saves the parameters for an incomplete browse information. /// Saves the parameters for an incomplete browse information.
/// </summary> /// </summary>
public BrowsePosition( public BrowsePosition(
string areaID, string areaID,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter, string browseFilter,
System.Runtime.InteropServices.ComTypes.IEnumString enumerator) System.Runtime.InteropServices.ComTypes.IEnumString enumerator)
: :
base (areaID, browseType, browseFilter) base(areaID, browseType, browseFilter)
{ {
m_enumerator = enumerator; m_enumerator = enumerator;
} }
#endregion #endregion
@@ -1543,11 +1542,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// Release unmanaged resources. // Release unmanaged resources.
// Set large fields to null. // Set large fields to null.
if (m_enumerator != null) if (m_enumerator != null)
{ {
Technosoftware.DaAeHdaClient.Com.Interop.ReleaseServer(m_enumerator); Technosoftware.DaAeHdaClient.Com.Interop.ReleaseServer(m_enumerator);
m_enumerator = null; m_enumerator = null;
} }
// Call Dispose on your base class. // Call Dispose on your base class.
m_disposed = true; m_disposed = true;
@@ -1568,7 +1567,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
#endregion #endregion
#region Private Members #region Private Members
System.Runtime.InteropServices.ComTypes.IEnumString m_enumerator = null; System.Runtime.InteropServices.ComTypes.IEnumString m_enumerator = null;
#endregion #endregion
} }
#endregion #endregion

View File

@@ -23,11 +23,9 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Ae; using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.OpcRcw.Ae;
using Technosoftware.DaAeHdaClient.Utilities; using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Ae;
#endregion #endregion
@@ -333,7 +331,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// build results. // build results.
var filters = new TsCAeSubscriptionFilters var filters = new TsCAeSubscriptionFilters
{ {
EventTypes = pdwEventType, LowSeverity = pdwLowSeverity, HighSeverity = pdwHighSeverity EventTypes = pdwEventType,
LowSeverity = pdwLowSeverity,
HighSeverity = pdwHighSeverity
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -41,12 +41,12 @@ namespace Technosoftware.DaAeHdaClient.Com
/// The id assigned to the connection by the COM server. /// The id assigned to the connection by the COM server.
/// </summary> /// </summary>
private int cookie_; private int cookie_;
/// <summary> /// <summary>
/// The number of times Advise() has been called without a matching Unadvise(). /// The number of times Advise() has been called without a matching Unadvise().
/// </summary> /// </summary>
private int refs_; private int refs_;
/// <summary> /// <summary>
/// Initializes the object by finding the specified connection point. /// Initializes the object by finding the specified connection point.
/// </summary> /// </summary>

View File

@@ -32,7 +32,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
/// Implements an object that handles multi-step browse operations. /// Implements an object that handles multi-step browse operations.
/// </summary> /// </summary>
[Serializable] [Serializable]
internal class BrowsePosition : TsCDaBrowsePosition internal class BrowsePosition : TsCDaBrowsePosition
{ {
/// <summary> /// <summary>
/// The continuation point for a browse operation. /// The continuation point for a browse operation.
@@ -48,13 +48,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
/// Initializes a browse position /// Initializes a browse position
/// </summary> /// </summary>
internal BrowsePosition( internal BrowsePosition(
OpcItem itemID, OpcItem itemID,
TsCDaBrowseFilters filters, TsCDaBrowseFilters filters,
string continuationPoint) string continuationPoint)
: :
base(itemID, filters) base(itemID, filters)
{ {
ContinuationPoint = continuationPoint; ContinuationPoint = continuationPoint;
} }
} }
} }

View File

@@ -23,9 +23,8 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da; using Technosoftware.DaAeHdaClient.Da;
#endregion #endregion
@@ -134,9 +133,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
output.ProductVersion = string.Format("{0}.{1}.{2}", status.wMajorVersion, status.wMinorVersion, status.wBuildNumber); output.ProductVersion = string.Format("{0}.{1}.{2}", status.wMajorVersion, status.wMinorVersion, status.wBuildNumber);
output.ServerState = (OpcServerState)status.dwServerState; output.ServerState = (OpcServerState)status.dwServerState;
output.StatusInfo = null; output.StatusInfo = null;
output.StartTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftStartTime)); output.StartTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftStartTime));
output.CurrentTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftCurrentTime)); output.CurrentTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftCurrentTime));
output.LastUpdateTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftLastUpdateTime)); output.LastUpdateTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftLastUpdateTime));
if (deallocate) if (deallocate)
{ {
@@ -622,9 +621,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
case OpcRcw.Da.Constants.OPC_WRITEABLE: return TsDaAccessRights.Writable; case OpcRcw.Da.Constants.OPC_WRITEABLE: return TsDaAccessRights.Writable;
case OpcRcw.Da.Constants.OPC_READABLE | OpcRcw.Da.Constants.OPC_WRITEABLE: case OpcRcw.Da.Constants.OPC_READABLE | OpcRcw.Da.Constants.OPC_WRITEABLE:
{ {
return TsDaAccessRights.ReadWritable; return TsDaAccessRights.ReadWritable;
} }
} }
return null; return null;

View File

@@ -32,77 +32,77 @@ namespace Technosoftware.DaAeHdaClient.Com
/// Defines all well known COM DA HRESULT codes. /// Defines all well known COM DA HRESULT codes.
/// </summary> /// </summary>
internal struct Result internal struct Result
{ {
/// <remarks/> /// <remarks/>
public const int S_OK = +0x00000000; // 0x00000000 public const int S_OK = +0x00000000; // 0x00000000
/// <remarks/> /// <remarks/>
public const int S_FALSE = +0x00000001; // 0x00000001 public const int S_FALSE = +0x00000001; // 0x00000001
/// <remarks/> /// <remarks/>
public const int E_NOTIMPL = -0x7FFFBFFF; // 0x80004001 public const int E_NOTIMPL = -0x7FFFBFFF; // 0x80004001
/// <remarks/> /// <remarks/>
public const int E_OUTOFMEMORY = -0x7FF8FFF2; // 0x8007000E public const int E_OUTOFMEMORY = -0x7FF8FFF2; // 0x8007000E
/// <remarks/> /// <remarks/>
public const int E_INVALIDARG = -0x7FF8FFA9; // 0x80070057 public const int E_INVALIDARG = -0x7FF8FFA9; // 0x80070057
/// <remarks/> /// <remarks/>
public const int E_NOINTERFACE = -0x7FFFBFFE; // 0x80004002 public const int E_NOINTERFACE = -0x7FFFBFFE; // 0x80004002
/// <remarks/> /// <remarks/>
public const int E_POINTER = -0x7FFFBFFD; // 0x80004003 public const int E_POINTER = -0x7FFFBFFD; // 0x80004003
/// <remarks/> /// <remarks/>
public const int E_FAIL = -0x7FFFBFFB; // 0x80004005 public const int E_FAIL = -0x7FFFBFFB; // 0x80004005
/// <remarks/> /// <remarks/>
public const int CONNECT_E_NOCONNECTION = -0x7FFBFE00; // 0x80040200 public const int CONNECT_E_NOCONNECTION = -0x7FFBFE00; // 0x80040200
/// <remarks/> /// <remarks/>
public const int CONNECT_E_ADVISELIMIT = -0x7FFBFDFF; // 0x80040201 public const int CONNECT_E_ADVISELIMIT = -0x7FFBFDFF; // 0x80040201
/// <remarks/> /// <remarks/>
public const int DISP_E_TYPEMISMATCH = -0x7FFDFFFB; // 0x80020005 public const int DISP_E_TYPEMISMATCH = -0x7FFDFFFB; // 0x80020005
/// <remarks/> /// <remarks/>
public const int DISP_E_OVERFLOW = -0x7FFDFFF6; // 0x8002000A public const int DISP_E_OVERFLOW = -0x7FFDFFF6; // 0x8002000A
/// <remarks/> /// <remarks/>
public const int E_INVALIDHANDLE = -0x3FFBFFFF; // 0xC0040001 public const int E_INVALIDHANDLE = -0x3FFBFFFF; // 0xC0040001
/// <remarks/> /// <remarks/>
public const int E_BADTYPE = -0x3FFBFFFC; // 0xC0040004 public const int E_BADTYPE = -0x3FFBFFFC; // 0xC0040004
/// <remarks/> /// <remarks/>
public const int E_PUBLIC = -0x3FFBFFFB; // 0xC0040005 public const int E_PUBLIC = -0x3FFBFFFB; // 0xC0040005
/// <remarks/> /// <remarks/>
public const int E_BADRIGHTS = -0x3FFBFFFA; // 0xC0040006 public const int E_BADRIGHTS = -0x3FFBFFFA; // 0xC0040006
/// <remarks/> /// <remarks/>
public const int E_UNKNOWNITEMID = -0x3FFBFFF9; // 0xC0040007 public const int E_UNKNOWNITEMID = -0x3FFBFFF9; // 0xC0040007
/// <remarks/> /// <remarks/>
public const int E_INVALIDITEMID = -0x3FFBFFF8; // 0xC0040008 public const int E_INVALIDITEMID = -0x3FFBFFF8; // 0xC0040008
/// <remarks/> /// <remarks/>
public const int E_INVALIDFILTER = -0x3FFBFFF7; // 0xC0040009 public const int E_INVALIDFILTER = -0x3FFBFFF7; // 0xC0040009
/// <remarks/> /// <remarks/>
public const int E_UNKNOWNPATH = -0x3FFBFFF6; // 0xC004000A public const int E_UNKNOWNPATH = -0x3FFBFFF6; // 0xC004000A
/// <remarks/> /// <remarks/>
public const int E_RANGE = -0x3FFBFFF5; // 0xC004000B public const int E_RANGE = -0x3FFBFFF5; // 0xC004000B
/// <remarks/> /// <remarks/>
public const int E_DUPLICATENAME = -0x3FFBFFF4; // 0xC004000C public const int E_DUPLICATENAME = -0x3FFBFFF4; // 0xC004000C
/// <remarks/> /// <remarks/>
public const int S_UNSUPPORTEDRATE = +0x0004000D; // 0x0004000D public const int S_UNSUPPORTEDRATE = +0x0004000D; // 0x0004000D
/// <remarks/> /// <remarks/>
public const int S_CLAMP = +0x0004000E; // 0x0004000E public const int S_CLAMP = +0x0004000E; // 0x0004000E
/// <remarks/> /// <remarks/>
public const int S_INUSE = +0x0004000F; // 0x0004000F public const int S_INUSE = +0x0004000F; // 0x0004000F
/// <remarks/> /// <remarks/>
public const int E_INVALIDCONFIGFILE = -0x3FFBFFF0; // 0xC0040010 public const int E_INVALIDCONFIGFILE = -0x3FFBFFF0; // 0xC0040010
/// <remarks/> /// <remarks/>
public const int E_NOTFOUND = -0x3FFBFFEF; // 0xC0040011 public const int E_NOTFOUND = -0x3FFBFFEF; // 0xC0040011
/// <remarks/> /// <remarks/>
public const int E_INVALID_PID = -0x3FFBFDFD; // 0xC0040203 public const int E_INVALID_PID = -0x3FFBFDFD; // 0xC0040203
/// <remarks/> /// <remarks/>
public const int E_DEADBANDNOTSET = -0x3FFBFC00; // 0xC0040400 public const int E_DEADBANDNOTSET = -0x3FFBFC00; // 0xC0040400
/// <remarks/> /// <remarks/>
public const int E_DEADBANDNOTSUPPORTED = -0x3FFBFBFF; // 0xC0040401 public const int E_DEADBANDNOTSUPPORTED = -0x3FFBFBFF; // 0xC0040401
/// <remarks/> /// <remarks/>
public const int E_NOBUFFERING = -0x3FFBFBFE; // 0xC0040402 public const int E_NOBUFFERING = -0x3FFBFBFE; // 0xC0040402
/// <remarks/> /// <remarks/>
public const int E_INVALIDCONTINUATIONPOINT = -0x3FFBFBFD; // 0xC0040403 public const int E_INVALIDCONTINUATIONPOINT = -0x3FFBFBFD; // 0xC0040403
/// <remarks/> /// <remarks/>
public const int S_DATAQUEUEOVERFLOW = +0x00040404; // 0x00040404 public const int S_DATAQUEUEOVERFLOW = +0x00040404; // 0x00040404
/// <remarks/> /// <remarks/>
public const int E_RATENOTSET = -0x3FFBFBFB; // 0xC0040405 public const int E_RATENOTSET = -0x3FFBFBFB; // 0xC0040405
/// <remarks/> /// <remarks/>
public const int E_NOTSUPPORTED = -0x3FFBFBFA; // 0xC0040406 public const int E_NOTSUPPORTED = -0x3FFBFBFA; // 0xC0040406
} }
} }
@@ -114,15 +114,15 @@ namespace Technosoftware.DaAeHdaClient.Com
internal struct Result internal struct Result
{ {
/// <remarks/> /// <remarks/>
public const int E_TYPE_CHANGED = -0x3FFBFBF9; // 0xC0040407 public const int E_TYPE_CHANGED = -0x3FFBFBF9; // 0xC0040407
/// <remarks/> /// <remarks/>
public const int E_FILTER_DUPLICATE = -0x3FFBFBF8; // 0xC0040408 public const int E_FILTER_DUPLICATE = -0x3FFBFBF8; // 0xC0040408
/// <remarks/> /// <remarks/>
public const int E_FILTER_INVALID = -0x3FFBFBF7; // 0xC0040409 public const int E_FILTER_INVALID = -0x3FFBFBF7; // 0xC0040409
/// <remarks/> /// <remarks/>
public const int E_FILTER_ERROR = -0x3FFBFBF6; // 0xC004040A public const int E_FILTER_ERROR = -0x3FFBFBF6; // 0xC004040A
/// <remarks/> /// <remarks/>
public const int S_FILTER_NO_DATA = +0x0004040B; // 0xC004040B public const int S_FILTER_NO_DATA = +0x0004040B; // 0xC004040B
} }
} }
} }

View File

@@ -22,16 +22,13 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Threading;
using System.Collections; using System.Collections;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using Technosoftware.DaAeHdaClient.Com.Utilities; using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.OpcRcw.Da;
#endregion #endregion
@@ -100,7 +97,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// release all groups. // release all groups.
foreach (Subscription subscription in subscriptions_.Values) foreach (Subscription subscription in subscriptions_.Values)
{ {
var methodName = "IOPCServer.RemoveGroup"; var methodName = "IOPCServer.RemoveGroup";
// remove subscription from server. // remove subscription from server.
try try
@@ -166,7 +163,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCServer>(methodName, true); var server = BeginComCall<IOPCServer>(methodName, true);
(server).GetErrorString( (server).GetErrorString(
@@ -188,7 +185,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
} }
} }
@@ -237,7 +234,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCServer>(methodName, true); var server = BeginComCall<IOPCServer>(methodName, true);
(server).GetStatus(out pStatus); (server).GetStatus(out pStatus);
@@ -292,10 +289,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
var pQualities = IntPtr.Zero; var pQualities = IntPtr.Zero;
var pTimestamps = IntPtr.Zero; var pTimestamps = IntPtr.Zero;
var pErrors = IntPtr.Zero; var pErrors = IntPtr.Zero;
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCItemIO>(methodName, true); var server = BeginComCall<IOPCItemIO>(methodName, true);
server.Read( server.Read(
count, count,
@@ -424,7 +421,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCItemIO>(methodName, true); var server = BeginComCall<IOPCItemIO>(methodName, true);
server.WriteVQT( server.WriteVQT(
count, count,
@@ -500,7 +497,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
var revisedUpdateRate = 0; var revisedUpdateRate = 0;
var hDeadband = GCHandle.Alloc(result.Deadband, GCHandleType.Pinned); var hDeadband = GCHandle.Alloc(result.Deadband, GCHandleType.Pinned);
// invoke COM method. // invoke COM method.
try try
{ {
@@ -538,12 +535,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
if (group == null) throw new OpcResultException(OpcResult.E_FAIL, "The subscription was not created."); if (group == null) throw new OpcResultException(OpcResult.E_FAIL, "The subscription was not created.");
methodName = "IOPCGroupStateMgt2.SetKeepAlive"; methodName = "IOPCGroupStateMgt2.SetKeepAlive";
// set the keep alive rate if requested. // set the keep alive rate if requested.
try try
{ {
var keepAlive = 0; var keepAlive = 0;
var comObject = BeginComCall<IOPCGroupStateMgt2>(group, methodName, true); var comObject = BeginComCall<IOPCGroupStateMgt2>(group, methodName, true);
comObject.SetKeepAlive(result.KeepAlive, out keepAlive); comObject.SetKeepAlive(result.KeepAlive, out keepAlive);
@@ -562,9 +559,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
// save server handle. // save server handle.
result.ServerHandle = serverHandle; result.ServerHandle = serverHandle;
@@ -619,7 +616,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCServer>(methodName, true); var server = BeginComCall<IOPCServer>(methodName, true);
server.RemoveGroup((int)state.ServerHandle, 0); server.RemoveGroup((int)state.ServerHandle, 0);
@@ -635,7 +632,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
} }
} }
@@ -670,7 +667,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCBrowse>(methodName, true); var server = BeginComCall<IOPCBrowse>(methodName, true);
server.Browse( server.Browse(
(itemId != null && itemId.ItemName != null) ? itemId.ItemName : "", (itemId != null && itemId.ItemName != null) ? itemId.ItemName : "",
@@ -699,7 +696,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
// unmarshal results. // unmarshal results.
@@ -760,7 +757,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCBrowse>(methodName, true); var server = BeginComCall<IOPCBrowse>(methodName, true);
server.Browse( server.Browse(
(itemID != null && itemID.ItemName != null) ? itemID.ItemName : "", (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "",
@@ -789,7 +786,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
// unmarshal results. // unmarshal results.
@@ -842,7 +839,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
// invoke COM method. // invoke COM method.
try try
{ {
var server = BeginComCall<IOPCBrowse>(methodName, true); var server = BeginComCall<IOPCBrowse>(methodName, true);
server.GetProperties( server.GetProperties(
itemIds.Length, itemIds.Length,
@@ -863,8 +860,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e);
} }
finally finally
{ {
EndComCall(methodName); EndComCall(methodName);
} }
// unmarshal results. // unmarshal results.

View File

@@ -247,7 +247,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
var localeID = 0; var localeID = 0;
var clientHandle = 0; var clientHandle = 0;
var serverHandle = 0; var serverHandle = 0;
var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true); var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true);
subscription.GetState( subscription.GetState(
out updateRate, out updateRate,
@@ -289,7 +289,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
{ {
methodName = "IOPCGroupStateMgt2.GetKeepAlive"; methodName = "IOPCGroupStateMgt2.GetKeepAlive";
try try
{ {
var keepAlive = 0; var keepAlive = 0;
var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true); var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true);
subscription.GetKeepAlive(out keepAlive); subscription.GetKeepAlive(out keepAlive);
@@ -328,7 +328,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
lock (lock_) lock (lock_)
{ {
var methodName = "IOPCGroupStateMgt.SetName"; var methodName = "IOPCGroupStateMgt.SetName";
// update the subscription name. // update the subscription name.
if ((masks & (int)TsCDaStateMask.Name) != 0 && state.Name != name_) if ((masks & (int)TsCDaStateMask.Name) != 0 && state.Name != name_)
@@ -378,7 +378,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
methodName = "IOPCGroupStateMgt.SetState"; methodName = "IOPCGroupStateMgt.SetState";
try try
{ {
var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true); var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true);
subscription.SetState( subscription.SetState(
((masks & (int)TsCDaStateMask.UpdateRate) != 0) ? hUpdateRate.AddrOfPinnedObject() : IntPtr.Zero, ((masks & (int)TsCDaStateMask.UpdateRate) != 0) ? hUpdateRate.AddrOfPinnedObject() : IntPtr.Zero,
@@ -415,7 +415,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
methodName = "IOPCGroupStateMgt2.SetKeepAlive"; methodName = "IOPCGroupStateMgt2.SetKeepAlive";
try try
{ {
var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true); var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true);
subscription.SetKeepAlive(state.KeepAlive, out keepAlive); subscription.SetKeepAlive(state.KeepAlive, out keepAlive);
@@ -477,7 +477,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
var methodName = "IOPCItemMgt.AddItems"; var methodName = "IOPCItemMgt.AddItems";
try try
{ {
var subscription = BeginComCall<IOPCItemMgt>(methodName, true); var subscription = BeginComCall<IOPCItemMgt>(methodName, true);
subscription.AddItems( subscription.AddItems(
count, count,
@@ -647,7 +647,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
var methodName = "IOPCItemMgt.RemoveItems"; var methodName = "IOPCItemMgt.RemoveItems";
try try
{ {
var subscription = BeginComCall<IOPCItemMgt>(methodName, true); var subscription = BeginComCall<IOPCItemMgt>(methodName, true);
subscription.RemoveItems(itemIDs.Length, serverHandles, out pErrors); subscription.RemoveItems(itemIDs.Length, serverHandles, out pErrors);

View File

@@ -23,14 +23,12 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Da; using Technosoftware.DaAeHdaClient.Com.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.DaAeHdaClient.Com.Utilities; using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Da;
#endregion #endregion

View File

@@ -23,13 +23,10 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Collections; using System.Collections;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Da; using Technosoftware.DaAeHdaClient.Com.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using Technosoftware.DaAeHdaClient.Com.Utilities; using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.OpcRcw.Da;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Com.Da20 namespace Technosoftware.DaAeHdaClient.Com.Da20

View File

@@ -32,7 +32,7 @@ namespace Technosoftware.DaAeHdaClient.Com
/// A wrapper for the COM IEnumString interface. /// A wrapper for the COM IEnumString interface.
/// </summary> /// </summary>
internal class EnumString : IDisposable internal class EnumString : IDisposable
{ {
/// <summary> /// <summary>
/// A reference to the remote COM object. /// A reference to the remote COM object.
/// </summary> /// </summary>
@@ -45,7 +45,7 @@ namespace Technosoftware.DaAeHdaClient.Com
{ {
m_enumerator = (IEnumString)enumerator; m_enumerator = (IEnumString)enumerator;
} }
/// <summary> /// <summary>
/// Releases the remote COM object. /// Releases the remote COM object.
/// </summary> /// </summary>
@@ -66,7 +66,7 @@ namespace Technosoftware.DaAeHdaClient.Com
try try
{ {
// create buffer. // create buffer.
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))*count); var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr)) * count);
try try
{ {

View File

@@ -22,14 +22,9 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Xml;
using System.Net;
using System.Text;
using System.Collections;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
#endregion #endregion

View File

@@ -23,10 +23,9 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Collections; using System.Collections;
using Technosoftware.DaAeHdaClient.Hda; using Technosoftware.DaAeHdaClient.Hda;
using Technosoftware.OpcRcw.Hda;
using Technosoftware.OpcRcw.Comn; using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Hda;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Com.Hda namespace Technosoftware.DaAeHdaClient.Com.Hda
@@ -34,8 +33,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// <summary> /// <summary>
/// An in-process wrapper an OPC HDA browser object. /// An in-process wrapper an OPC HDA browser object.
/// </summary> /// </summary>
internal class Browser : ITsCHdaBrowser internal class Browser : ITsCHdaBrowser
{ {
//====================================================================== //======================================================================
// Construction // Construction
@@ -73,7 +72,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// <summary> /// <summary>
/// This must be called explicitly by clients to ensure the COM server is released. /// This must be called explicitly by clients to ensure the COM server is released.
/// </summary> /// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
lock (this) lock (this)
{ {
@@ -90,9 +89,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// <summary> /// <summary>
/// Returns the set of attribute filters used by the browser. /// Returns the set of attribute filters used by the browser.
/// </summary> /// </summary>
public TsCHdaBrowseFilterCollection Filters public TsCHdaBrowseFilterCollection Filters
{ {
get get
{ {
lock (this) lock (this)
{ {
@@ -103,7 +102,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
//====================================================================== //======================================================================
// Browse // Browse
/// <summary> /// <summary>
/// Browses the server's address space at the specified branch. /// Browses the server's address space at the specified branch.
/// </summary> /// </summary>
@@ -121,7 +120,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
return elements; return elements;
} }
/// <summary> /// <summary>
/// Begins a browsing the server's address space at the specified branch. /// Begins a browsing the server's address space at the specified branch.
/// </summary> /// </summary>
@@ -141,11 +140,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
lock (this) lock (this)
{ {
var branchPath = (itemID != null && itemID.ItemName != null)?itemID.ItemName:""; var branchPath = (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "";
// move to the correct position in the server's address space. // move to the correct position in the server's address space.
try try
{ {
m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, branchPath); m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, branchPath);
} }
catch (Exception e) catch (Exception e)
@@ -171,7 +170,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// browse for items // browse for items
enumerator = GetEnumerator(false); enumerator = GetEnumerator(false);
var items = FetchElements(enumerator, maxElements-elements.Count, false); var items = FetchElements(enumerator, maxElements - elements.Count, false);
if (items != null) if (items != null)
{ {
@@ -233,13 +232,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// release enumerator. // release enumerator.
pos.Enumerator.Dispose(); pos.Enumerator.Dispose();
pos.Enumerator = null; pos.Enumerator = null;
pos.FetchingItems = true; pos.FetchingItems = true;
// move to the correct position in the server's address space. // move to the correct position in the server's address space.
try try
{ {
m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, pos.BranchPath); m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, pos.BranchPath);
} }
catch (Exception e) catch (Exception e)
@@ -252,7 +251,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
} }
// fetch next set of items. // fetch next set of items.
var items = FetchElements(pos.Enumerator, maxElements-elements.Count, false); var items = FetchElements(pos.Enumerator, maxElements - elements.Count, false);
if (items != null) if (items != null)
{ {
@@ -282,7 +281,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
try try
{ {
var browseType = (isBranch)?OPCHDA_BROWSETYPE.OPCHDA_BRANCH:OPCHDA_BROWSETYPE.OPCHDA_LEAF; var browseType = (isBranch) ? OPCHDA_BROWSETYPE.OPCHDA_BRANCH : OPCHDA_BROWSETYPE.OPCHDA_LEAF;
IEnumString pEnumerator = null; IEnumString pEnumerator = null;
m_browser.GetEnum(browseType, out pEnumerator); m_browser.GetEnum(browseType, out pEnumerator);
@@ -303,13 +302,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
var elements = new ArrayList(); var elements = new ArrayList();
while (elements.Count < maxElements) while (elements.Count < maxElements)
{ {
// fetch next batch of element names. // fetch next batch of element names.
var count = BLOCK_SIZE; var count = BLOCK_SIZE;
if (elements.Count + count > maxElements) if (elements.Count + count > maxElements)
{ {
count = maxElements - elements.Count; count = maxElements - elements.Count;
} }
var names = enumerator.Next(count); var names = enumerator.Next(count);
@@ -321,18 +320,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// create new element objects. // create new element objects.
foreach (var name in names) foreach (var name in names)
{ {
var element = new TsCHdaBrowseElement(); var element = new TsCHdaBrowseElement();
element.Name = name; element.Name = name;
// lookup item id for element. // lookup item id for element.
try try
{ {
string itemID = null; string itemID = null;
m_browser.GetItemID(name, out itemID); m_browser.GetItemID(name, out itemID);
element.ItemName = itemID; element.ItemName = itemID;
element.ItemPath = null; element.ItemPath = null;
element.HasChildren = isBranch; element.HasChildren = isBranch;
} }
catch catch
@@ -384,8 +383,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// <param name="fetchingItems">Whether the enumerator is return branches or items.</param> /// <param name="fetchingItems">Whether the enumerator is return branches or items.</param>
internal BrowsePosition(string branchPath, EnumString enumerator, bool fetchingItems) internal BrowsePosition(string branchPath, EnumString enumerator, bool fetchingItems)
{ {
m_branchPath = branchPath; m_branchPath = branchPath;
m_enumerator = enumerator; m_enumerator = enumerator;
m_fetchingItems = fetchingItems; m_fetchingItems = fetchingItems;
} }

View File

@@ -30,26 +30,26 @@ using Technosoftware.OpcRcw.Hda;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Com.Hda namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
/// <summary> /// <summary>
/// A class that implements the HDA data callback interface. /// A class that implements the HDA data callback interface.
/// </summary> /// </summary>
internal class DataCallback : IOPCHDA_DataCallback internal class DataCallback : IOPCHDA_DataCallback
{ {
/// <summary> /// <summary>
/// Initializes the object with the containing subscription object. /// Initializes the object with the containing subscription object.
/// </summary> /// </summary>
public DataCallback() {} public DataCallback() { }
/// <summary> /// <summary>
/// Fired when an exception occurs during callback processing. /// Fired when an exception occurs during callback processing.
/// </summary> /// </summary>
public event TsCHdaCallbackExceptionEventHandler CallbackExceptionEvent public event TsCHdaCallbackExceptionEventHandler CallbackExceptionEvent
{ {
add {lock (this) { _callbackExceptionEvent += value; }} add { lock (this) { _callbackExceptionEvent += value; } }
remove {lock (this) { _callbackExceptionEvent -= value; }} remove { lock (this) { _callbackExceptionEvent -= value; } }
} }
/// <summary> /// <summary>
/// Creates a new request object. /// Creates a new request object.
/// </summary> /// </summary>
@@ -61,8 +61,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
var request = new Request(requestHandle, callback, ++m_nextID); var request = new Request(requestHandle, callback, ++m_nextID);
// no items yet - callback may return before async call returns. // no items yet - callback may return before async call returns.
m_requests[request.RequestID] = request; m_requests[request.RequestID] = request;
// return requests. // return requests.
return request; return request;
} }
@@ -103,11 +103,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when new data arrives for a subscription. /// Called when new data arrives for a subscription.
/// </summary> /// </summary>
public void OnDataChange( public void OnDataChange(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwNumItems, int dwNumItems,
OPCHDA_ITEM[] pItemValues, OPCHDA_ITEM[] pItemValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -130,7 +130,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
results[ii].ServerHandle = results[ii].ClientHandle; results[ii].ServerHandle = results[ii].ClientHandle;
results[ii].ClientHandle = null; results[ii].ClientHandle = null;
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
} }
// invoke callback - remove request if unexpected error occured. // invoke callback - remove request if unexpected error occured.
@@ -150,11 +150,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous read request completes. /// Called when an asynchronous read request completes.
/// </summary> /// </summary>
public void OnReadComplete( public void OnReadComplete(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwNumItems, int dwNumItems,
OPCHDA_ITEM[] pItemValues, OPCHDA_ITEM[] pItemValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -176,7 +176,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
results[ii] = Interop.GetItemValueCollection(pItemValues[ii], false); results[ii] = Interop.GetItemValueCollection(pItemValues[ii], false);
results[ii].ServerHandle = pItemValues[ii].hClient; results[ii].ServerHandle = pItemValues[ii].hClient;
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
} }
// invoke callback - remove request if all results arrived. // invoke callback - remove request if all results arrived.
@@ -196,11 +196,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous read modified request completes. /// Called when an asynchronous read modified request completes.
/// </summary> /// </summary>
public void OnReadModifiedComplete( public void OnReadModifiedComplete(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwNumItems, int dwNumItems,
OPCHDA_MODIFIEDITEM[] pItemValues, OPCHDA_MODIFIEDITEM[] pItemValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -222,7 +222,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
results[ii] = Interop.GetModifiedValueCollection(pItemValues[ii], false); results[ii] = Interop.GetModifiedValueCollection(pItemValues[ii], false);
results[ii].ServerHandle = pItemValues[ii].hClient; results[ii].ServerHandle = pItemValues[ii].hClient;
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
} }
// invoke callback - remove request if all results arrived. // invoke callback - remove request if all results arrived.
@@ -242,12 +242,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous read attributes request completes. /// Called when an asynchronous read attributes request completes.
/// </summary> /// </summary>
public void OnReadAttributeComplete( public void OnReadAttributeComplete(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int hClient, int hClient,
int dwNumItems, int dwNumItems,
OPCHDA_ATTRIBUTE[] pAttributeValues, OPCHDA_ATTRIBUTE[] pAttributeValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -273,7 +273,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
results[ii] = Interop.GetAttributeValueCollection(pAttributeValues[ii], false); results[ii] = Interop.GetAttributeValueCollection(pAttributeValues[ii], false);
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
item.Add(results[ii]); item.Add(results[ii]);
} }
@@ -294,11 +294,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous read annotations request completes. /// Called when an asynchronous read annotations request completes.
/// </summary> /// </summary>
public void OnReadAnnotations( public void OnReadAnnotations(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwNumItems, int dwNumItems,
OPCHDA_ANNOTATION[] pAnnotationValues, OPCHDA_ANNOTATION[] pAnnotationValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -320,7 +320,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
results[ii] = Interop.GetAnnotationValueCollection(pAnnotationValues[ii], false); results[ii] = Interop.GetAnnotationValueCollection(pAnnotationValues[ii], false);
results[ii].ServerHandle = pAnnotationValues[ii].hClient; results[ii].ServerHandle = pAnnotationValues[ii].hClient;
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
} }
// invoke callback - remove request if all results arrived. // invoke callback - remove request if all results arrived.
@@ -340,10 +340,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous insert annotations request completes. /// Called when an asynchronous insert annotations request completes.
/// </summary> /// </summary>
public void OnInsertAnnotations( public void OnInsertAnnotations(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwCount, int dwCount,
int[] phClients, int[] phClients,
int[] phrErrors) int[] phrErrors)
{ {
@@ -376,7 +376,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
itemResults.ServerHandle = currentHandle; itemResults.ServerHandle = currentHandle;
results.Add(itemResults); results.Add(itemResults);
currentHandle = phClients[ii]; currentHandle = phClients[ii];
itemResults = new TsCHdaResultCollection(); itemResults = new TsCHdaResultCollection();
} }
@@ -407,11 +407,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when a batch of data from playback request arrives. /// Called when a batch of data from playback request arrives.
/// </summary> /// </summary>
public void OnPlayback( public void OnPlayback(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwNumItems, int dwNumItems,
IntPtr ppItemValues, IntPtr ppItemValues,
int[] phrErrors) int[] phrErrors)
{ {
try try
{ {
@@ -436,16 +436,16 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
// get pointer to item. // get pointer to item.
var pItem = (IntPtr)pItems[ii]; var pItem = (IntPtr)pItems[ii];
// unmarshal item as an array of length 1. // unmarshal item as an array of length 1.
var item = Interop.GetItemValueCollections(ref pItem, 1, false); var item = Interop.GetItemValueCollections(ref pItem, 1, false);
if (item != null && item.Length == 1) if (item != null && item.Length == 1)
{ {
results[ii] = item[0]; results[ii] = item[0];
results[ii].ServerHandle = results[ii].ClientHandle; results[ii].ServerHandle = results[ii].ClientHandle;
results[ii].ClientHandle = null; results[ii].ClientHandle = null;
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]); results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
} }
} }
@@ -466,10 +466,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Called when an asynchronous update request completes. /// Called when an asynchronous update request completes.
/// </summary> /// </summary>
public void OnUpdateComplete( public void OnUpdateComplete(
int dwTransactionID, int dwTransactionID,
int hrStatus, int hrStatus,
int dwCount, int dwCount,
int[] phClients, int[] phClients,
int[] phrErrors) int[] phrErrors)
{ {
try try
@@ -501,7 +501,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
itemResults.ServerHandle = currentHandle; itemResults.ServerHandle = currentHandle;
results.Add(itemResults); results.Add(itemResults);
currentHandle = phClients[ii]; currentHandle = phClients[ii];
itemResults = new TsCHdaResultCollection(); itemResults = new TsCHdaResultCollection();
} }
@@ -583,9 +583,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
#endregion #endregion
#region Private Members #region Private Members
private int m_nextID; private int m_nextID;
private Hashtable m_requests = new Hashtable(); private Hashtable m_requests = new Hashtable();
private TsCHdaCallbackExceptionEventHandler _callbackExceptionEvent; private TsCHdaCallbackExceptionEventHandler _callbackExceptionEvent;
#endregion #endregion
} }
} }

View File

@@ -32,410 +32,410 @@ using Technosoftware.DaAeHdaClient.Hda;
namespace Technosoftware.DaAeHdaClient.Com.Hda namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
/// <summary> /// <summary>
/// Contains state information for a single asynchronous Technosoftware.DaAeHdaClient.Com.Hda.Interop. /// Contains state information for a single asynchronous Technosoftware.DaAeHdaClient.Com.Hda.Interop.
/// </summary> /// </summary>
internal class Interop internal class Interop
{ {
/// <summary> /// <summary>
/// Converts a standard FILETIME to an OpcRcw.Da.FILETIME structure. /// Converts a standard FILETIME to an OpcRcw.Da.FILETIME structure.
/// </summary> /// </summary>
internal static OpcRcw.Hda.OPCHDA_FILETIME Convert(FILETIME input) internal static OpcRcw.Hda.OPCHDA_FILETIME Convert(FILETIME input)
{ {
var output = new OpcRcw.Hda.OPCHDA_FILETIME(); var output = new OpcRcw.Hda.OPCHDA_FILETIME();
output.dwLowDateTime = input.dwLowDateTime; output.dwLowDateTime = input.dwLowDateTime;
output.dwHighDateTime = input.dwHighDateTime; output.dwHighDateTime = input.dwHighDateTime;
return output; return output;
} }
/// <summary> /// <summary>
/// Converts an OpcRcw.Da.FILETIME to a standard FILETIME structure. /// Converts an OpcRcw.Da.FILETIME to a standard FILETIME structure.
/// </summary> /// </summary>
internal static FILETIME Convert(OpcRcw.Hda.OPCHDA_FILETIME input) internal static FILETIME Convert(OpcRcw.Hda.OPCHDA_FILETIME input)
{ {
var output = new FILETIME(); var output = new FILETIME();
output.dwLowDateTime = input.dwLowDateTime; output.dwLowDateTime = input.dwLowDateTime;
output.dwHighDateTime = input.dwHighDateTime; output.dwHighDateTime = input.dwHighDateTime;
return output; return output;
} }
/// <summary> /// <summary>
/// Converts a decimal value to a OpcRcw.Hda.OPCHDA_TIME structure. /// Converts a decimal value to a OpcRcw.Hda.OPCHDA_TIME structure.
/// </summary> /// </summary>
internal static OpcRcw.Hda.OPCHDA_FILETIME GetFILETIME(decimal input) internal static OpcRcw.Hda.OPCHDA_FILETIME GetFILETIME(decimal input)
{ {
var output = new OpcRcw.Hda.OPCHDA_FILETIME(); var output = new OpcRcw.Hda.OPCHDA_FILETIME();
output.dwHighDateTime = (int)((((ulong)(input*10000000)) & 0xFFFFFFFF00000000)>>32); output.dwHighDateTime = (int)((((ulong)(input * 10000000)) & 0xFFFFFFFF00000000) >> 32);
output.dwLowDateTime = (int)((((ulong)(input*10000000)) & 0x00000000FFFFFFFF)); output.dwLowDateTime = (int)((((ulong)(input * 10000000)) & 0x00000000FFFFFFFF));
return output; return output;
} }
/// <summary> /// <summary>
/// Returns an array of FILETIMEs. /// Returns an array of FILETIMEs.
/// </summary> /// </summary>
internal static OpcRcw.Hda.OPCHDA_FILETIME[] GetFILETIMEs(DateTime[] input) internal static OpcRcw.Hda.OPCHDA_FILETIME[] GetFILETIMEs(DateTime[] input)
{ {
OpcRcw.Hda.OPCHDA_FILETIME[] output = null; OpcRcw.Hda.OPCHDA_FILETIME[] output = null;
if (input != null) if (input != null)
{ {
output = new OpcRcw.Hda.OPCHDA_FILETIME[input.Length]; output = new OpcRcw.Hda.OPCHDA_FILETIME[input.Length];
for (var ii = 0; ii < input.Length; ii++) for (var ii = 0; ii < input.Length; ii++)
{ {
output[ii] = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input[ii])); output[ii] = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input[ii]));
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Converts a Technosoftware.DaAeHdaClient.Time object to a Technosoftware.DaAeHdaClient.Com.Hda.OPCHDA_TIME structure. /// Converts a Technosoftware.DaAeHdaClient.Time object to a Technosoftware.DaAeHdaClient.Com.Hda.OPCHDA_TIME structure.
/// </summary> /// </summary>
internal static OpcRcw.Hda.OPCHDA_TIME GetTime(TsCHdaTime input) internal static OpcRcw.Hda.OPCHDA_TIME GetTime(TsCHdaTime input)
{ {
var output = new OpcRcw.Hda.OPCHDA_TIME(); var output = new OpcRcw.Hda.OPCHDA_TIME();
if (input != null) if (input != null)
{ {
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input.AbsoluteTime)); output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input.AbsoluteTime));
output.szTime = (input.IsRelative)?input.ToString():""; output.szTime = (input.IsRelative) ? input.ToString() : "";
output.bString = (input.IsRelative)?1:0; output.bString = (input.IsRelative) ? 1 : 0;
} }
// create a null value for a time structure. // create a null value for a time structure.
else else
{ {
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(DateTime.MinValue)); output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(DateTime.MinValue));
output.szTime = ""; output.szTime = "";
output.bString = 1; output.bString = 1;
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an array of OPCHDA_ITEM structures. /// Unmarshals and deallocates an array of OPCHDA_ITEM structures.
/// </summary> /// </summary>
internal static TsCHdaItemValueCollection[] GetItemValueCollections(ref IntPtr pInput, int count, bool deallocate) internal static TsCHdaItemValueCollection[] GetItemValueCollections(ref IntPtr pInput, int count, bool deallocate)
{ {
TsCHdaItemValueCollection[] output = null; TsCHdaItemValueCollection[] output = null;
if (pInput != IntPtr.Zero && count > 0) if (pInput != IntPtr.Zero && count > 0)
{ {
output = new TsCHdaItemValueCollection[count]; output = new TsCHdaItemValueCollection[count];
var pos = pInput; var pos = pInput;
for (var ii = 0; ii < count; ii++) for (var ii = 0; ii < count; ii++)
{ {
output[ii] = GetItemValueCollection(pos, deallocate); output[ii] = GetItemValueCollection(pos, deallocate);
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ITEM))); pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ITEM)));
} }
if (deallocate) if (deallocate)
{ {
Marshal.FreeCoTaskMem(pInput); Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero; pInput = IntPtr.Zero;
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ITEM structure. /// Unmarshals and deallocates an OPCHDA_ITEM structure.
/// </summary> /// </summary>
internal static TsCHdaItemValueCollection GetItemValueCollection(IntPtr pInput, bool deallocate) internal static TsCHdaItemValueCollection GetItemValueCollection(IntPtr pInput, bool deallocate)
{ {
TsCHdaItemValueCollection output = null; TsCHdaItemValueCollection output = null;
if (pInput != IntPtr.Zero) if (pInput != IntPtr.Zero)
{ {
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM)); var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM));
output = GetItemValueCollection((OpcRcw.Hda.OPCHDA_ITEM)item, deallocate); output = GetItemValueCollection((OpcRcw.Hda.OPCHDA_ITEM)item, deallocate);
if (deallocate) if (deallocate)
{ {
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM)); Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM));
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ITEM structure. /// Unmarshals and deallocates an OPCHDA_ITEM structure.
/// </summary> /// </summary>
internal static TsCHdaItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate) internal static TsCHdaItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate)
{ {
var output = new TsCHdaItemValueCollection(); var output = new TsCHdaItemValueCollection();
output.ClientHandle = input.hClient; output.ClientHandle = input.hClient;
output.Aggregate = input.haAggregate; output.Aggregate = input.haAggregate;
var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate); var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate);
var timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate); var timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate);
var qualities = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate); var qualities = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);
for (var ii = 0; ii < input.dwCount; ii++) for (var ii = 0; ii < input.dwCount; ii++)
{ {
var value = new TsCHdaItemValue(); var value = new TsCHdaItemValue();
value.Value = values[ii]; value.Value = values[ii];
value.Timestamp = timestamps[ii]; value.Timestamp = timestamps[ii];
value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF)); value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF));
value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000)); value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000));
output.Add(value); output.Add(value);
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an array of OPCHDA_MODIFIEDITEM structures. /// Unmarshals and deallocates an array of OPCHDA_MODIFIEDITEM structures.
/// </summary> /// </summary>
internal static TsCHdaModifiedValueCollection[] GetModifiedValueCollections(ref IntPtr pInput, int count, bool deallocate) internal static TsCHdaModifiedValueCollection[] GetModifiedValueCollections(ref IntPtr pInput, int count, bool deallocate)
{ {
TsCHdaModifiedValueCollection[] output = null; TsCHdaModifiedValueCollection[] output = null;
if (pInput != IntPtr.Zero && count > 0) if (pInput != IntPtr.Zero && count > 0)
{ {
output = new TsCHdaModifiedValueCollection[count]; output = new TsCHdaModifiedValueCollection[count];
var pos = pInput; var pos = pInput;
for (var ii = 0; ii < count; ii++) for (var ii = 0; ii < count; ii++)
{ {
output[ii] = GetModifiedValueCollection(pos, deallocate); output[ii] = GetModifiedValueCollection(pos, deallocate);
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM))); pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM)));
} }
if (deallocate) if (deallocate)
{ {
Marshal.FreeCoTaskMem(pInput); Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero; pInput = IntPtr.Zero;
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure. /// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
/// </summary> /// </summary>
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(IntPtr pInput, bool deallocate) internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(IntPtr pInput, bool deallocate)
{ {
TsCHdaModifiedValueCollection output = null; TsCHdaModifiedValueCollection output = null;
if (pInput != IntPtr.Zero) if (pInput != IntPtr.Zero)
{ {
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM)); var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM));
output = GetModifiedValueCollection((OpcRcw.Hda.OPCHDA_MODIFIEDITEM)item, deallocate); output = GetModifiedValueCollection((OpcRcw.Hda.OPCHDA_MODIFIEDITEM)item, deallocate);
if (deallocate) if (deallocate)
{ {
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM)); Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM));
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure. /// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
/// </summary> /// </summary>
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(OpcRcw.Hda.OPCHDA_MODIFIEDITEM input, bool deallocate) internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(OpcRcw.Hda.OPCHDA_MODIFIEDITEM input, bool deallocate)
{ {
var output = new TsCHdaModifiedValueCollection(); var output = new TsCHdaModifiedValueCollection();
output.ClientHandle = input.hClient; output.ClientHandle = input.hClient;
var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate); var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate);
var timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate); var timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate);
var qualities = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate); var qualities = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);
var modificationTimes = Utilities.Interop.GetDateTimes(ref input.pftModificationTime, input.dwCount, deallocate); var modificationTimes = Utilities.Interop.GetDateTimes(ref input.pftModificationTime, input.dwCount, deallocate);
var editTypes = Utilities.Interop.GetInt32s(ref input.pEditType, input.dwCount, deallocate); var editTypes = Utilities.Interop.GetInt32s(ref input.pEditType, input.dwCount, deallocate);
var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwCount, deallocate); var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwCount, deallocate);
for (var ii = 0; ii < input.dwCount; ii++) for (var ii = 0; ii < input.dwCount; ii++)
{ {
var value = new TsCHdaModifiedValue(); var value = new TsCHdaModifiedValue();
value.Value = values[ii]; value.Value = values[ii];
value.Timestamp = timestamps[ii]; value.Timestamp = timestamps[ii];
value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF)); value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF));
value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000)); value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000));
value.ModificationTime = modificationTimes[ii]; value.ModificationTime = modificationTimes[ii];
value.EditType = (TsCHdaEditType)editTypes[ii]; value.EditType = (TsCHdaEditType)editTypes[ii];
value.User = users[ii]; value.User = users[ii];
output.Add(value); output.Add(value);
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an array of OPCHDA_ATTRIBUTE structures. /// Unmarshals and deallocates an array of OPCHDA_ATTRIBUTE structures.
/// </summary> /// </summary>
internal static TsCHdaAttributeValueCollection[] GetAttributeValueCollections(ref IntPtr pInput, int count, bool deallocate) internal static TsCHdaAttributeValueCollection[] GetAttributeValueCollections(ref IntPtr pInput, int count, bool deallocate)
{ {
TsCHdaAttributeValueCollection[] output = null; TsCHdaAttributeValueCollection[] output = null;
if (pInput != IntPtr.Zero && count > 0) if (pInput != IntPtr.Zero && count > 0)
{ {
output = new TsCHdaAttributeValueCollection[count]; output = new TsCHdaAttributeValueCollection[count];
var pos = pInput; var pos = pInput;
for (var ii = 0; ii < count; ii++) for (var ii = 0; ii < count; ii++)
{ {
output[ii] = GetAttributeValueCollection(pos, deallocate); output[ii] = GetAttributeValueCollection(pos, deallocate);
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE))); pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE)));
} }
if (deallocate) if (deallocate)
{ {
Marshal.FreeCoTaskMem(pInput); Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero; pInput = IntPtr.Zero;
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure. /// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
/// </summary> /// </summary>
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(IntPtr pInput, bool deallocate) internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(IntPtr pInput, bool deallocate)
{ {
TsCHdaAttributeValueCollection output = null; TsCHdaAttributeValueCollection output = null;
if (pInput != IntPtr.Zero) if (pInput != IntPtr.Zero)
{ {
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE)); var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE));
output = GetAttributeValueCollection((OpcRcw.Hda.OPCHDA_ATTRIBUTE)item, deallocate); output = GetAttributeValueCollection((OpcRcw.Hda.OPCHDA_ATTRIBUTE)item, deallocate);
if (deallocate) if (deallocate)
{ {
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE)); Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE));
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure. /// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
/// </summary> /// </summary>
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(OpcRcw.Hda.OPCHDA_ATTRIBUTE input, bool deallocate) internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(OpcRcw.Hda.OPCHDA_ATTRIBUTE input, bool deallocate)
{ {
var output = new TsCHdaAttributeValueCollection(); var output = new TsCHdaAttributeValueCollection();
output.AttributeID = input.dwAttributeID; output.AttributeID = input.dwAttributeID;
var values = Com.Interop.GetVARIANTs(ref input.vAttributeValues, input.dwNumValues, deallocate); var values = Com.Interop.GetVARIANTs(ref input.vAttributeValues, input.dwNumValues, deallocate);
var timestamps = Utilities.Interop.GetDateTimes(ref input.ftTimeStamps, input.dwNumValues, deallocate); var timestamps = Utilities.Interop.GetDateTimes(ref input.ftTimeStamps, input.dwNumValues, deallocate);
for (var ii = 0; ii < input.dwNumValues; ii++) for (var ii = 0; ii < input.dwNumValues; ii++)
{ {
var value = new TsCHdaAttributeValue(); var value = new TsCHdaAttributeValue();
value.Value = values[ii]; value.Value = values[ii];
value.Timestamp = timestamps[ii]; value.Timestamp = timestamps[ii];
output.Add(value); output.Add(value);
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an array of OPCHDA_ANNOTATION structures. /// Unmarshals and deallocates an array of OPCHDA_ANNOTATION structures.
/// </summary> /// </summary>
internal static TsCHdaAnnotationValueCollection[] GetAnnotationValueCollections(ref IntPtr pInput, int count, bool deallocate) internal static TsCHdaAnnotationValueCollection[] GetAnnotationValueCollections(ref IntPtr pInput, int count, bool deallocate)
{ {
TsCHdaAnnotationValueCollection[] output = null; TsCHdaAnnotationValueCollection[] output = null;
if (pInput != IntPtr.Zero && count > 0) if (pInput != IntPtr.Zero && count > 0)
{ {
output = new TsCHdaAnnotationValueCollection[count]; output = new TsCHdaAnnotationValueCollection[count];
var pos = pInput; var pos = pInput;
for (var ii = 0; ii < count; ii++) for (var ii = 0; ii < count; ii++)
{ {
output[ii] = GetAnnotationValueCollection(pos, deallocate); output[ii] = GetAnnotationValueCollection(pos, deallocate);
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ANNOTATION))); pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ANNOTATION)));
} }
if (deallocate) if (deallocate)
{ {
Marshal.FreeCoTaskMem(pInput); Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero; pInput = IntPtr.Zero;
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure. /// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
/// </summary> /// </summary>
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(IntPtr pInput, bool deallocate) internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(IntPtr pInput, bool deallocate)
{ {
TsCHdaAnnotationValueCollection output = null; TsCHdaAnnotationValueCollection output = null;
if (pInput != IntPtr.Zero) if (pInput != IntPtr.Zero)
{ {
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION)); var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION));
output = GetAnnotationValueCollection((OpcRcw.Hda.OPCHDA_ANNOTATION)item, deallocate); output = GetAnnotationValueCollection((OpcRcw.Hda.OPCHDA_ANNOTATION)item, deallocate);
if (deallocate) if (deallocate)
{ {
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION)); Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION));
} }
} }
return output; return output;
} }
/// <summary> /// <summary>
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure. /// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
/// </summary> /// </summary>
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(OpcRcw.Hda.OPCHDA_ANNOTATION input, bool deallocate) internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(OpcRcw.Hda.OPCHDA_ANNOTATION input, bool deallocate)
{ {
var output = new TsCHdaAnnotationValueCollection(); var output = new TsCHdaAnnotationValueCollection();
output.ClientHandle = input.hClient; output.ClientHandle = input.hClient;
var timestamps = Utilities.Interop.GetDateTimes(ref input.ftTimeStamps, input.dwNumValues, deallocate); var timestamps = Utilities.Interop.GetDateTimes(ref input.ftTimeStamps, input.dwNumValues, deallocate);
var annotations = Utilities.Interop.GetUnicodeStrings(ref input.szAnnotation, input.dwNumValues, deallocate); var annotations = Utilities.Interop.GetUnicodeStrings(ref input.szAnnotation, input.dwNumValues, deallocate);
var creationTimes = Utilities.Interop.GetDateTimes(ref input.ftAnnotationTime, input.dwNumValues, deallocate); var creationTimes = Utilities.Interop.GetDateTimes(ref input.ftAnnotationTime, input.dwNumValues, deallocate);
var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwNumValues, deallocate); var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwNumValues, deallocate);
for (var ii = 0; ii < input.dwNumValues; ii++) for (var ii = 0; ii < input.dwNumValues; ii++)
{ {
var value = new TsCHdaAnnotationValue(); var value = new TsCHdaAnnotationValue();
value.Timestamp = timestamps[ii]; value.Timestamp = timestamps[ii];
value.Annotation = annotations[ii]; value.Annotation = annotations[ii];
value.CreationTime = creationTimes[ii]; value.CreationTime = creationTimes[ii];
value.User = users[ii]; value.User = users[ii];
output.Add(value); output.Add(value);
} }
return output; return output;
} }
} }
} }

View File

@@ -58,10 +58,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// Initializes the object with all required information. /// Initializes the object with all required information.
/// </summary> /// </summary>
public Request(object requestHandle, Delegate callback, int requestID) public Request(object requestHandle, Delegate callback, int requestID)
{ {
m_requestHandle = requestHandle; m_requestHandle = requestHandle;
m_callback = callback; m_callback = callback;
m_requestID = requestID; m_requestID = requestID;
} }
/// <summary> /// <summary>
@@ -72,7 +72,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
lock (this) lock (this)
{ {
// save the server assigned id. // save the server assigned id.
m_cancelID = cancelID; m_cancelID = cancelID;
// create a table of items indexed by the handle returned by the server in a callback. // create a table of items indexed by the handle returned by the server in a callback.
m_items = new Hashtable(); m_items = new Hashtable();
@@ -140,25 +140,25 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
return InvokeCallback((TsCHdaReadValuesCompleteEventHandler)m_callback, results); return InvokeCallback((TsCHdaReadValuesCompleteEventHandler)m_callback, results);
} }
// invoke read attributes completed callback. // invoke read attributes completed callback.
if (typeof(TsCHdaReadAttributesCompleteEventHandler).IsInstanceOfType(m_callback)) if (typeof(TsCHdaReadAttributesCompleteEventHandler).IsInstanceOfType(m_callback))
{ {
return InvokeCallback((TsCHdaReadAttributesCompleteEventHandler)m_callback, results); return InvokeCallback((TsCHdaReadAttributesCompleteEventHandler)m_callback, results);
} }
// invoke read annotations completed callback. // invoke read annotations completed callback.
if (typeof(TsCHdaReadAnnotationsCompleteEventHandler).IsInstanceOfType(m_callback)) if (typeof(TsCHdaReadAnnotationsCompleteEventHandler).IsInstanceOfType(m_callback))
{ {
return InvokeCallback((TsCHdaReadAnnotationsCompleteEventHandler)m_callback, results); return InvokeCallback((TsCHdaReadAnnotationsCompleteEventHandler)m_callback, results);
} }
// invoke update completed callback. // invoke update completed callback.
if (typeof(TsCHdaUpdateCompleteEventHandler).IsInstanceOfType(m_callback)) if (typeof(TsCHdaUpdateCompleteEventHandler).IsInstanceOfType(m_callback))
{ {
return InvokeCallback((TsCHdaUpdateCompleteEventHandler)m_callback, results); return InvokeCallback((TsCHdaUpdateCompleteEventHandler)m_callback, results);
} }
// callback not supported. // callback not supported.
return true; return true;
} }
@@ -227,11 +227,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
callback(this, values); callback(this, values);
} }
catch catch
{ {
// ignore exceptions in the callbacks. // ignore exceptions in the callbacks.
} }
// request never completes. // request never completes.
return false; return false;
} }
@@ -256,7 +256,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
callback(this, values); callback(this, values);
} }
catch catch
{ {
// ignore exceptions in the callbacks. // ignore exceptions in the callbacks.
} }
@@ -272,7 +272,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// request is complete. // request is complete.
return true; return true;
} }
/// <summary> /// <summary>
/// Invokes callback for a read attributes request. /// Invokes callback for a read attributes request.
@@ -294,7 +294,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
callback(this, values); callback(this, values);
} }
catch catch
{ {
// ignore exceptions in the callbacks. // ignore exceptions in the callbacks.
} }
@@ -302,7 +302,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// request always completes // request always completes
return true; return true;
} }
/// <summary> /// <summary>
/// Invokes callback for a read annotations request. /// Invokes callback for a read annotations request.
/// </summary> /// </summary>
@@ -323,7 +323,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
callback(this, values); callback(this, values);
} }
catch catch
{ {
// ignore exceptions in the callbacks. // ignore exceptions in the callbacks.
} }
@@ -352,7 +352,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{ {
callback(this, values); callback(this, values);
} }
catch catch
{ {
// ignore exceptions in the callbacks. // ignore exceptions in the callbacks.
} }
@@ -372,7 +372,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
if (typeof(ITsCHdaActualTime).IsInstanceOfType(result)) if (typeof(ITsCHdaActualTime).IsInstanceOfType(result))
{ {
((ITsCHdaActualTime)result).StartTime = StartTime; ((ITsCHdaActualTime)result).StartTime = StartTime;
((ITsCHdaActualTime)result).EndTime = EndTime; ((ITsCHdaActualTime)result).EndTime = EndTime;
} }
// add item identifier to value collection. // add item identifier to value collection.
@@ -380,8 +380,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
if (itemID != null) if (itemID != null)
{ {
result.ItemName = itemID.ItemName; result.ItemName = itemID.ItemName;
result.ItemPath = itemID.ItemPath; result.ItemPath = itemID.ItemPath;
result.ServerHandle = itemID.ServerHandle; result.ServerHandle = itemID.ServerHandle;
result.ClientHandle = itemID.ClientHandle; result.ClientHandle = itemID.ClientHandle;
} }
@@ -390,9 +390,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
#endregion #endregion
#region Private Members #region Private Members
private object m_requestHandle = null; private object m_requestHandle = null;
private Delegate m_callback = null; private Delegate m_callback = null;
private int m_requestID = 0; private int m_requestID = 0;
private int m_cancelID = 0; private int m_cancelID = 0;
private DateTime m_startTime = DateTime.MinValue; private DateTime m_startTime = DateTime.MinValue;
private DateTime m_endTime = DateTime.MinValue; private DateTime m_endTime = DateTime.MinValue;

View File

@@ -32,37 +32,37 @@ namespace Technosoftware.DaAeHdaClient.Com
/// Defines all well known COM HDA HRESULT codes. /// Defines all well known COM HDA HRESULT codes.
/// </summary> /// </summary>
internal struct Result internal struct Result
{ {
/// <remarks/> /// <remarks/>
public const int E_MAXEXCEEDED = -0X3FFBEFFF; // 0xC0041001 public const int E_MAXEXCEEDED = -0X3FFBEFFF; // 0xC0041001
/// <remarks/> /// <remarks/>
public const int S_NODATA = +0x40041002; // 0x40041002 public const int S_NODATA = +0x40041002; // 0x40041002
/// <remarks/> /// <remarks/>
public const int S_MOREDATA = +0x40041003; // 0x40041003 public const int S_MOREDATA = +0x40041003; // 0x40041003
/// <remarks/> /// <remarks/>
public const int E_INVALIDAGGREGATE = -0X3FFBEFFC; // 0xC0041004 public const int E_INVALIDAGGREGATE = -0X3FFBEFFC; // 0xC0041004
/// <remarks/> /// <remarks/>
public const int S_CURRENTVALUE = +0x40041005; // 0x40041005 public const int S_CURRENTVALUE = +0x40041005; // 0x40041005
/// <remarks/> /// <remarks/>
public const int S_EXTRADATA = +0x40041006; // 0x40041006 public const int S_EXTRADATA = +0x40041006; // 0x40041006
/// <remarks/> /// <remarks/>
public const int W_NOFILTER = -0x7FFBEFF9; // 0x80041007 public const int W_NOFILTER = -0x7FFBEFF9; // 0x80041007
/// <remarks/> /// <remarks/>
public const int E_UNKNOWNATTRID = -0x3FFBEFF8; // 0xC0041008 public const int E_UNKNOWNATTRID = -0x3FFBEFF8; // 0xC0041008
/// <remarks/> /// <remarks/>
public const int E_NOT_AVAIL = -0x3FFBEFF7; // 0xC0041009 public const int E_NOT_AVAIL = -0x3FFBEFF7; // 0xC0041009
/// <remarks/> /// <remarks/>
public const int E_INVALIDDATATYPE = -0x3FFBEFF6; // 0xC004100A public const int E_INVALIDDATATYPE = -0x3FFBEFF6; // 0xC004100A
/// <remarks/> /// <remarks/>
public const int E_DATAEXISTS = -0x3FFBEFF5; // 0xC004100B public const int E_DATAEXISTS = -0x3FFBEFF5; // 0xC004100B
/// <remarks/> /// <remarks/>
public const int E_INVALIDATTRID = -0x3FFBEFF4; // 0xC004100C public const int E_INVALIDATTRID = -0x3FFBEFF4; // 0xC004100C
/// <remarks/> /// <remarks/>
public const int E_NODATAEXISTS = -0x3FFBEFF3; // 0xC004100D public const int E_NODATAEXISTS = -0x3FFBEFF3; // 0xC004100D
/// <remarks/> /// <remarks/>
public const int S_INSERTED = +0x4004100E; // 0x4004100E public const int S_INSERTED = +0x4004100E; // 0x4004100E
/// <remarks/> /// <remarks/>
public const int S_REPLACED = +0x4004100F; // 0x4004100F public const int S_REPLACED = +0x4004100F; // 0x4004100F
} }
} }
} }

View File

@@ -3175,8 +3175,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
OPCHDA_TIME pEndTime) OPCHDA_TIME pEndTime)
{ {
// unmarshal actual times from input arguments. // unmarshal actual times from input arguments.
var startTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pStartTime.ftTime)); var startTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pStartTime.ftTime));
var endTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pEndTime.ftTime)); var endTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pEndTime.ftTime));
foreach (var result in results) foreach (var result in results)
{ {
@@ -3466,7 +3466,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// The synchronization object for subscription access /// The synchronization object for subscription access
/// </summary> /// </summary>
private static volatile object lock_ = new object(); private static volatile object lock_ = new object();
private bool disposed_ = false; private bool disposed_ = false;
#endregion #endregion
} }

View File

@@ -22,12 +22,11 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Net;
using System.Globalization; using System.Globalization;
using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Utilities; using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
#endregion #endregion
#pragma warning disable 0618 #pragma warning disable 0618
@@ -598,10 +597,10 @@ namespace Technosoftware.DaAeHdaClient.Com
clsctx, clsctx,
ref coserverInfo, ref coserverInfo,
1, 1,
results); results);
} }
finally finally
{ {
if (hIID.IsAllocated) hIID.Free(); if (hIID.IsAllocated) hIID.Free();
serverInfo.Deallocate(); serverInfo.Deallocate();
@@ -859,7 +858,8 @@ namespace Technosoftware.DaAeHdaClient.Com
/// <summary> /// <summary>
/// This flag suppresses the conversion to local time done during marshalling. /// This flag suppresses the conversion to local time done during marshalling.
/// </summary> /// </summary>
public static bool PreserveUtc { public static bool PreserveUtc
{
get { lock (typeof(Interop)) { return DaAeHdaClient.ApplicationInstance.TimeAsUtc; } } get { lock (typeof(Interop)) { return DaAeHdaClient.ApplicationInstance.TimeAsUtc; } }
set { lock (typeof(Interop)) { DaAeHdaClient.ApplicationInstance.TimeAsUtc = value; } } set { lock (typeof(Interop)) { DaAeHdaClient.ApplicationInstance.TimeAsUtc = value; } }
} }
@@ -1387,22 +1387,22 @@ namespace Technosoftware.DaAeHdaClient.Com
case Ae.Result.E_NOINFO: return new OpcResult(OpcResult.Ae.E_NOINFO, input); case Ae.Result.E_NOINFO: return new OpcResult(OpcResult.Ae.E_NOINFO, input);
default: default:
{
// check for RPC error.
if ((input & 0x7FFF0000) == 0x00010000)
{ {
return new OpcResult(OpcResult.E_NETWORK_ERROR, input); // check for RPC error.
} if ((input & 0x7FFF0000) == 0x00010000)
{
return new OpcResult(OpcResult.E_NETWORK_ERROR, input);
}
// chekc for success code. // chekc for success code.
if (input >= 0) if (input >= 0)
{ {
return new OpcResult(OpcResult.S_FALSE, input); return new OpcResult(OpcResult.S_FALSE, input);
} }
// return generic error. // return generic error.
return new OpcResult(OpcResult.E_FAIL, input); return new OpcResult(OpcResult.E_FAIL, input);
} }
} }
} }
@@ -1410,79 +1410,79 @@ namespace Technosoftware.DaAeHdaClient.Com
/// Converts a result id to an HRESULT. /// Converts a result id to an HRESULT.
/// </summary> /// </summary>
internal static int GetResultID(OpcResult input) internal static int GetResultID(OpcResult input)
{ {
// data access. // data access.
if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_DATA_ACCESS) if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_DATA_ACCESS)
{ {
if (input == OpcResult.S_OK) return Da.Result.S_OK; if (input == OpcResult.S_OK) return Da.Result.S_OK;
if (input == OpcResult.E_FAIL) return Da.Result.E_FAIL; if (input == OpcResult.E_FAIL) return Da.Result.E_FAIL;
if (input == OpcResult.E_INVALIDARG) return Da.Result.E_INVALIDARG; if (input == OpcResult.E_INVALIDARG) return Da.Result.E_INVALIDARG;
if (input == OpcResult.Da.E_BADTYPE) return Da.Result.E_BADTYPE; if (input == OpcResult.Da.E_BADTYPE) return Da.Result.E_BADTYPE;
if (input == OpcResult.Da.E_READONLY) return Da.Result.E_BADRIGHTS; if (input == OpcResult.Da.E_READONLY) return Da.Result.E_BADRIGHTS;
if (input == OpcResult.Da.E_WRITEONLY) return Da.Result.E_BADRIGHTS; if (input == OpcResult.Da.E_WRITEONLY) return Da.Result.E_BADRIGHTS;
if (input == OpcResult.Da.E_RANGE) return Da.Result.E_RANGE; if (input == OpcResult.Da.E_RANGE) return Da.Result.E_RANGE;
if (input == OpcResult.E_OUTOFMEMORY) return Da.Result.E_OUTOFMEMORY; if (input == OpcResult.E_OUTOFMEMORY) return Da.Result.E_OUTOFMEMORY;
if (input == OpcResult.E_NOTSUPPORTED) return Da.Result.E_NOINTERFACE; if (input == OpcResult.E_NOTSUPPORTED) return Da.Result.E_NOINTERFACE;
if (input == OpcResult.Da.E_INVALIDHANDLE) return Da.Result.E_INVALIDHANDLE; if (input == OpcResult.Da.E_INVALIDHANDLE) return Da.Result.E_INVALIDHANDLE;
if (input == OpcResult.Da.E_UNKNOWN_ITEM_NAME) return Da.Result.E_UNKNOWNITEMID; if (input == OpcResult.Da.E_UNKNOWN_ITEM_NAME) return Da.Result.E_UNKNOWNITEMID;
if (input == OpcResult.Da.E_INVALID_ITEM_NAME) return Da.Result.E_INVALIDITEMID; if (input == OpcResult.Da.E_INVALID_ITEM_NAME) return Da.Result.E_INVALIDITEMID;
if (input == OpcResult.Da.E_INVALID_ITEM_PATH) return Da.Result.E_INVALIDITEMID; if (input == OpcResult.Da.E_INVALID_ITEM_PATH) return Da.Result.E_INVALIDITEMID;
if (input == OpcResult.Da.E_UNKNOWN_ITEM_PATH) return Da.Result.E_UNKNOWNPATH; if (input == OpcResult.Da.E_UNKNOWN_ITEM_PATH) return Da.Result.E_UNKNOWNPATH;
if (input == OpcResult.Da.E_INVALID_FILTER) return Da.Result.E_INVALIDFILTER; if (input == OpcResult.Da.E_INVALID_FILTER) return Da.Result.E_INVALIDFILTER;
if (input == OpcResult.Da.S_UNSUPPORTEDRATE) return Da.Result.S_UNSUPPORTEDRATE; if (input == OpcResult.Da.S_UNSUPPORTEDRATE) return Da.Result.S_UNSUPPORTEDRATE;
if (input == OpcResult.Da.S_CLAMP) return Da.Result.S_CLAMP; if (input == OpcResult.Da.S_CLAMP) return Da.Result.S_CLAMP;
if (input == OpcResult.Da.E_INVALID_PID) return Da.Result.E_INVALID_PID; if (input == OpcResult.Da.E_INVALID_PID) return Da.Result.E_INVALID_PID;
if (input == OpcResult.Da.E_NO_ITEM_DEADBAND) return Da.Result.E_DEADBANDNOTSUPPORTED; if (input == OpcResult.Da.E_NO_ITEM_DEADBAND) return Da.Result.E_DEADBANDNOTSUPPORTED;
if (input == OpcResult.Da.E_NO_ITEM_BUFFERING) return Da.Result.E_NOBUFFERING; if (input == OpcResult.Da.E_NO_ITEM_BUFFERING) return Da.Result.E_NOBUFFERING;
if (input == OpcResult.Da.E_NO_WRITEQT) return Da.Result.E_NOTSUPPORTED; if (input == OpcResult.Da.E_NO_WRITEQT) return Da.Result.E_NOTSUPPORTED;
if (input == OpcResult.Da.E_INVALIDCONTINUATIONPOINT) return Da.Result.E_INVALIDCONTINUATIONPOINT; if (input == OpcResult.Da.E_INVALIDCONTINUATIONPOINT) return Da.Result.E_INVALIDCONTINUATIONPOINT;
if (input == OpcResult.Da.S_DATAQUEUEOVERFLOW) return Da.Result.S_DATAQUEUEOVERFLOW; if (input == OpcResult.Da.S_DATAQUEUEOVERFLOW) return Da.Result.S_DATAQUEUEOVERFLOW;
} }
// complex data. // complex data.
else if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_COMPLEX_DATA) else if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_COMPLEX_DATA)
{ {
if (input == OpcResult.Cpx.E_TYPE_CHANGED) return Cpx.Result.E_TYPE_CHANGED; if (input == OpcResult.Cpx.E_TYPE_CHANGED) return Cpx.Result.E_TYPE_CHANGED;
if (input == OpcResult.Cpx.E_FILTER_DUPLICATE) return Cpx.Result.E_FILTER_DUPLICATE; if (input == OpcResult.Cpx.E_FILTER_DUPLICATE) return Cpx.Result.E_FILTER_DUPLICATE;
if (input == OpcResult.Cpx.E_FILTER_INVALID) return Cpx.Result.E_FILTER_INVALID; if (input == OpcResult.Cpx.E_FILTER_INVALID) return Cpx.Result.E_FILTER_INVALID;
if (input == OpcResult.Cpx.E_FILTER_ERROR) return Cpx.Result.E_FILTER_ERROR; if (input == OpcResult.Cpx.E_FILTER_ERROR) return Cpx.Result.E_FILTER_ERROR;
if (input == OpcResult.Cpx.S_FILTER_NO_DATA) return Cpx.Result.S_FILTER_NO_DATA; if (input == OpcResult.Cpx.S_FILTER_NO_DATA) return Cpx.Result.S_FILTER_NO_DATA;
} }
// historical data access.
else if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_HISTORICAL_DATA_ACCESS)
{
if (input == OpcResult.Hda.E_MAXEXCEEDED) return Hda.Result.E_MAXEXCEEDED;
if (input == OpcResult.Hda.S_NODATA) return Hda.Result.S_NODATA;
if (input == OpcResult.Hda.S_MOREDATA) return Hda.Result.S_MOREDATA;
if (input == OpcResult.Hda.E_INVALIDAGGREGATE) return Hda.Result.E_INVALIDAGGREGATE;
if (input == OpcResult.Hda.S_CURRENTVALUE) return Hda.Result.S_CURRENTVALUE;
if (input == OpcResult.Hda.S_EXTRADATA) return Hda.Result.S_EXTRADATA;
if (input == OpcResult.Hda.E_UNKNOWNATTRID) return Hda.Result.E_UNKNOWNATTRID;
if (input == OpcResult.Hda.E_NOT_AVAIL) return Hda.Result.E_NOT_AVAIL;
if (input == OpcResult.Hda.E_INVALIDDATATYPE) return Hda.Result.E_INVALIDDATATYPE;
if (input == OpcResult.Hda.E_DATAEXISTS) return Hda.Result.E_DATAEXISTS;
if (input == OpcResult.Hda.E_INVALIDATTRID) return Hda.Result.E_INVALIDATTRID;
if (input == OpcResult.Hda.E_NODATAEXISTS) return Hda.Result.E_NODATAEXISTS;
if (input == OpcResult.Hda.S_INSERTED) return Hda.Result.S_INSERTED;
if (input == OpcResult.Hda.S_REPLACED) return Hda.Result.S_REPLACED;
}
// check for custom code. // historical data access.
else if (input.Code == -1) else if (input.Name != null && input.Name.Namespace == OpcNamespace.OPC_HISTORICAL_DATA_ACCESS)
{ {
// default success code. if (input == OpcResult.Hda.E_MAXEXCEEDED) return Hda.Result.E_MAXEXCEEDED;
if (input.Succeeded()) if (input == OpcResult.Hda.S_NODATA) return Hda.Result.S_NODATA;
{ if (input == OpcResult.Hda.S_MOREDATA) return Hda.Result.S_MOREDATA;
return Da.Result.S_FALSE; if (input == OpcResult.Hda.E_INVALIDAGGREGATE) return Hda.Result.E_INVALIDAGGREGATE;
} if (input == OpcResult.Hda.S_CURRENTVALUE) return Hda.Result.S_CURRENTVALUE;
if (input == OpcResult.Hda.S_EXTRADATA) return Hda.Result.S_EXTRADATA;
if (input == OpcResult.Hda.E_UNKNOWNATTRID) return Hda.Result.E_UNKNOWNATTRID;
if (input == OpcResult.Hda.E_NOT_AVAIL) return Hda.Result.E_NOT_AVAIL;
if (input == OpcResult.Hda.E_INVALIDDATATYPE) return Hda.Result.E_INVALIDDATATYPE;
if (input == OpcResult.Hda.E_DATAEXISTS) return Hda.Result.E_DATAEXISTS;
if (input == OpcResult.Hda.E_INVALIDATTRID) return Hda.Result.E_INVALIDATTRID;
if (input == OpcResult.Hda.E_NODATAEXISTS) return Hda.Result.E_NODATAEXISTS;
if (input == OpcResult.Hda.S_INSERTED) return Hda.Result.S_INSERTED;
if (input == OpcResult.Hda.S_REPLACED) return Hda.Result.S_REPLACED;
}
// default error code. // check for custom code.
return Da.Result.E_FAIL; else if (input.Code == -1)
} {
// default success code.
if (input.Succeeded())
{
return Da.Result.S_FALSE;
}
// return custom code. // default error code.
return input.Code; return Da.Result.E_FAIL;
}
// return custom code.
return input.Code;
} }
/// <summary> /// <summary>

View File

@@ -23,12 +23,11 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Net;
using System.Globalization; using System.Globalization;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using Technosoftware.DaAeHdaClient.Utilities; using Technosoftware.DaAeHdaClient.Utilities;
#endregion #endregion
@@ -264,11 +263,11 @@ namespace Technosoftware.DaAeHdaClient.Com
[DllImport("ole32.dll")] [DllImport("ole32.dll")]
private static extern int CoQueryProxyBlanket( private static extern int CoQueryProxyBlanket(
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object pProxy, object pProxy,
ref uint pAuthnSvc, ref uint pAuthnSvc,
ref uint pAuthzSvc, ref uint pAuthzSvc,
[MarshalAs(UnmanagedType.LPWStr)] [MarshalAs(UnmanagedType.LPWStr)]
ref string pServerPrincName, ref string pServerPrincName,
ref uint pAuthnLevel, ref uint pAuthnLevel,
ref uint pImpLevel, ref uint pImpLevel,
ref IntPtr pAuthInfo, ref IntPtr pAuthInfo,
@@ -277,7 +276,7 @@ namespace Technosoftware.DaAeHdaClient.Com
[DllImport("ole32.dll")] [DllImport("ole32.dll")]
private static extern int CoSetProxyBlanket( private static extern int CoSetProxyBlanket(
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object pProxy, object pProxy,
uint pAuthnSvc, uint pAuthnSvc,
uint pAuthzSvc, uint pAuthzSvc,
IntPtr pServerPrincName, IntPtr pServerPrincName,
@@ -347,13 +346,13 @@ namespace Technosoftware.DaAeHdaClient.Com
private static extern int CoCreateInstanceEx( private static extern int CoCreateInstanceEx(
ref Guid clsid, ref Guid clsid,
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object punkOuter, object punkOuter,
uint dwClsCtx, uint dwClsCtx,
[In] [In]
ref COSERVERINFO pServerInfo, ref COSERVERINFO pServerInfo,
uint dwCount, uint dwCount,
[In, Out] [In, Out]
MULTI_QI[] pResults); MULTI_QI[] pResults);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct LICINFO private struct LICINFO
@@ -372,15 +371,15 @@ namespace Technosoftware.DaAeHdaClient.Com
{ {
void CreateInstance( void CreateInstance(
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object punkOuter, object punkOuter,
[MarshalAs(UnmanagedType.LPStruct)] [MarshalAs(UnmanagedType.LPStruct)]
Guid riid, Guid riid,
[MarshalAs(UnmanagedType.Interface)] [MarshalAs(UnmanagedType.Interface)]
[Out] out object ppvObject); [Out] out object ppvObject);
void LockServer( void LockServer(
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
bool fLock); bool fLock);
} }
[ComImport] [ComImport]
@@ -390,15 +389,15 @@ namespace Technosoftware.DaAeHdaClient.Com
{ {
void CreateInstance( void CreateInstance(
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object punkOuter, object punkOuter,
[MarshalAs(UnmanagedType.LPStruct)] [MarshalAs(UnmanagedType.LPStruct)]
Guid riid, Guid riid,
[MarshalAs(UnmanagedType.Interface)] [MarshalAs(UnmanagedType.Interface)]
[Out] out object ppvObject); [Out] out object ppvObject);
void LockServer( void LockServer(
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
bool fLock); bool fLock);
void GetLicInfo( void GetLicInfo(
[In, Out] ref LICINFO pLicInfo); [In, Out] ref LICINFO pLicInfo);
@@ -406,31 +405,31 @@ namespace Technosoftware.DaAeHdaClient.Com
void RequestLicKey( void RequestLicKey(
int dwReserved, int dwReserved,
[MarshalAs(UnmanagedType.BStr)] [MarshalAs(UnmanagedType.BStr)]
string pbstrKey); string pbstrKey);
void CreateInstanceLic( void CreateInstanceLic(
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object punkOuter, object punkOuter,
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
object punkReserved, object punkReserved,
[MarshalAs(UnmanagedType.LPStruct)] [MarshalAs(UnmanagedType.LPStruct)]
Guid riid, Guid riid,
[MarshalAs(UnmanagedType.BStr)] [MarshalAs(UnmanagedType.BStr)]
string bstrKey, string bstrKey,
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
[Out] out object ppvObject); [Out] out object ppvObject);
} }
[DllImport("ole32.dll")] [DllImport("ole32.dll")]
private static extern int CoGetClassObject( private static extern int CoGetClassObject(
[MarshalAs(UnmanagedType.LPStruct)] [MarshalAs(UnmanagedType.LPStruct)]
Guid clsid, Guid clsid,
uint dwClsContext, uint dwClsContext,
[In] ref COSERVERINFO pServerInfo, [In] ref COSERVERINFO pServerInfo,
[MarshalAs(UnmanagedType.LPStruct)] [MarshalAs(UnmanagedType.LPStruct)]
Guid riid, Guid riid,
[MarshalAs(UnmanagedType.IUnknown)] [MarshalAs(UnmanagedType.IUnknown)]
[Out] out object ppv); [Out] out object ppv);
internal const int LOGON32_PROVIDER_DEFAULT = 0; internal const int LOGON32_PROVIDER_DEFAULT = 0;
internal const int LOGON32_LOGON_INTERACTIVE = 2; internal const int LOGON32_LOGON_INTERACTIVE = 2;

View File

@@ -22,14 +22,12 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Net;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.DaAeHdaClient.Ae; using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.DaAeHdaClient.Da; using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Hda; using Technosoftware.DaAeHdaClient.Hda;
using Technosoftware.OpcRcw.Comn;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Com namespace Technosoftware.DaAeHdaClient.Com
@@ -38,192 +36,192 @@ namespace Technosoftware.DaAeHdaClient.Com
/// A unique identifier for the result of an operation of an item. /// A unique identifier for the result of an operation of an item.
/// </summary> /// </summary>
public class ServerEnumerator : IOpcDiscovery public class ServerEnumerator : IOpcDiscovery
{ {
//====================================================================== //======================================================================
// IDisposable // IDisposable
/// <summary> /// <summary>
/// Frees all unmanaged resources /// Frees all unmanaged resources
/// </summary> /// </summary>
public void Dispose() {} public void Dispose() { }
//====================================================================== //======================================================================
// IDiscovery // IDiscovery
/// <summary> /// <summary>
/// Enumerates hosts that may be accessed for server discovery. /// Enumerates hosts that may be accessed for server discovery.
/// </summary> /// </summary>
public string[] EnumerateHosts() public string[] EnumerateHosts()
{ {
return Interop.EnumComputers(); return Interop.EnumComputers();
} }
/// <summary> /// <summary>
/// Returns a list of servers that support the specified interface specification. /// Returns a list of servers that support the specified interface specification.
/// </summary> /// </summary>
public OpcServer[] GetAvailableServers(OpcSpecification specification) public OpcServer[] GetAvailableServers(OpcSpecification specification)
{ {
return GetAvailableServers(specification, null, null); return GetAvailableServers(specification, null, null);
} }
/// <summary> /// <summary>
/// Returns a list of servers that support the specified specification on the specified host. /// Returns a list of servers that support the specified specification on the specified host.
/// </summary> /// </summary>
public OpcServer[] GetAvailableServers(OpcSpecification specification, string host, OpcConnectData connectData) public OpcServer[] GetAvailableServers(OpcSpecification specification, string host, OpcConnectData connectData)
{ {
lock (this) lock (this)
{ {
var credentials = (connectData != null)?connectData.GetCredential(null, null):null; var credentials = (connectData != null) ? connectData.GetCredential(null, null) : null;
// connect to the server. // connect to the server.
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false); m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
m_host = host; m_host = host;
try try
{ {
var servers = new ArrayList(); var servers = new ArrayList();
// convert the interface version to a guid.
var catid = new Guid(specification.Id);
// get list of servers in the specified specification.
IOPCEnumGUID enumerator = null;
m_server.EnumClassesOfCategories( // convert the interface version to a guid.
1, var catid = new Guid(specification.Id);
new Guid[] { catid },
0,
null,
out enumerator);
// read clsids. // get list of servers in the specified specification.
var clsids = ReadClasses(enumerator); IOPCEnumGUID enumerator = null;
m_server.EnumClassesOfCategories(
1,
new Guid[] { catid },
0,
null,
out enumerator);
// read clsids.
var clsids = ReadClasses(enumerator);
// release enumerator object. // release enumerator object.
Interop.ReleaseServer(enumerator); Interop.ReleaseServer(enumerator);
enumerator = null; enumerator = null;
// fetch class descriptions. // fetch class descriptions.
foreach (var clsid in clsids) foreach (var clsid in clsids)
{ {
var factory = new Factory(); var factory = new Factory();
try try
{ {
var url = CreateUrl(specification, clsid); var url = CreateUrl(specification, clsid);
OpcServer server = null; OpcServer server = null;
if (specification == OpcSpecification.OPC_DA_30) if (specification == OpcSpecification.OPC_DA_30)
{ {
server = new TsCDaServer(factory, url); server = new TsCDaServer(factory, url);
} }
else if (specification == OpcSpecification.OPC_DA_20) else if (specification == OpcSpecification.OPC_DA_20)
{ {
server = new TsCDaServer(factory, url); server = new TsCDaServer(factory, url);
} }
else if (specification == OpcSpecification.OPC_AE_10)
{
server = new TsCAeServer(factory, url);
}
else if (specification == OpcSpecification.OPC_HDA_10) else if (specification == OpcSpecification.OPC_AE_10)
{ {
server = new TsCHdaServer(factory, url); server = new TsCAeServer(factory, url);
} }
servers.Add(server);
}
catch (Exception)
{
// ignore bad clsids.
}
}
return (OpcServer[])servers.ToArray(typeof(OpcServer)); else if (specification == OpcSpecification.OPC_HDA_10)
} {
finally server = new TsCHdaServer(factory, url);
{ }
// free the server.
Interop.ReleaseServer(m_server); servers.Add(server);
m_server = null; }
} catch (Exception)
} {
} // ignore bad clsids.
}
/// <summary> }
/// Looks up the CLSID for the specified prog id on a remote host.
/// </summary> return (OpcServer[])servers.ToArray(typeof(OpcServer));
public Guid CLSIDFromProgID(string progID, string host, OpcConnectData connectData) }
{ finally
lock (this) {
{ // free the server.
var credentials = (connectData != null)?connectData.GetCredential(null, null):null; Interop.ReleaseServer(m_server);
m_server = null;
}
}
}
/// <summary>
/// Looks up the CLSID for the specified prog id on a remote host.
/// </summary>
public Guid CLSIDFromProgID(string progID, string host, OpcConnectData connectData)
{
lock (this)
{
var credentials = (connectData != null) ? connectData.GetCredential(null, null) : null;
// connect to the server. // connect to the server.
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false); m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
m_host = host; m_host = host;
// lookup prog id. // lookup prog id.
Guid clsid; Guid clsid;
try try
{ {
m_server.CLSIDFromProgID(progID, out clsid); m_server.CLSIDFromProgID(progID, out clsid);
} }
catch catch
{ {
clsid = Guid.Empty; clsid = Guid.Empty;
} }
finally finally
{ {
Interop.ReleaseServer(m_server); Interop.ReleaseServer(m_server);
m_server = null; m_server = null;
} }
// return empty guid if prog id not found. // return empty guid if prog id not found.
return clsid; return clsid;
} }
} }
//====================================================================== //======================================================================
// Private Members // Private Members
/// <summary> /// <summary>
/// The server enumerator COM server. /// The server enumerator COM server.
/// </summary> /// </summary>
private IOPCServerList2 m_server = null; private IOPCServerList2 m_server = null;
/// <summary> /// <summary>
/// The host where the servers are being enumerated. /// The host where the servers are being enumerated.
/// </summary> /// </summary>
private string m_host = null; private string m_host = null;
/// <summary> /// <summary>
/// The ProgID for the OPC Server Enumerator. /// The ProgID for the OPC Server Enumerator.
/// </summary> /// </summary>
private const string ProgID = "OPC.ServerList.1"; private const string ProgID = "OPC.ServerList.1";
/// <summary>
/// The CLSID for the OPC Server Enumerator.
/// </summary>
private static readonly Guid CLSID = new Guid("13486D51-4821-11D2-A494-3CB306C10000");
//====================================================================== /// <summary>
// Private Methods /// The CLSID for the OPC Server Enumerator.
/// </summary>
private static readonly Guid CLSID = new Guid("13486D51-4821-11D2-A494-3CB306C10000");
/// <summary> //======================================================================
/// Reads the guids from the enumerator. // Private Methods
/// </summary>
private Guid[] ReadClasses(IOPCEnumGUID enumerator) /// <summary>
{ /// Reads the guids from the enumerator.
var guids = new ArrayList(); /// </summary>
private Guid[] ReadClasses(IOPCEnumGUID enumerator)
{
var guids = new ArrayList();
var count = 10; var count = 10;
// create buffer. // create buffer.
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid))*count); var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)) * count);
try try
{ {
@@ -257,64 +255,64 @@ namespace Technosoftware.DaAeHdaClient.Com
{ {
Marshal.FreeCoTaskMem(buffer); Marshal.FreeCoTaskMem(buffer);
} }
} }
/// <summary> /// <summary>
/// Reads the server details from the enumerator. /// Reads the server details from the enumerator.
/// </summary> /// </summary>
OpcUrl CreateUrl(OpcSpecification specification, Guid clsid) OpcUrl CreateUrl(OpcSpecification specification, Guid clsid)
{ {
// initialize the server url. // initialize the server url.
var url = new OpcUrl(); var url = new OpcUrl();
url.HostName = m_host;
url.Port = 0;
url.Path = null;
if (specification == OpcSpecification.OPC_DA_30) { url.Scheme = OpcUrlScheme.DA; } url.HostName = m_host;
else if (specification == OpcSpecification.OPC_DA_20) { url.Scheme = OpcUrlScheme.DA; } url.Port = 0;
else if (specification == OpcSpecification.OPC_DA_10) { url.Scheme = OpcUrlScheme.DA; } url.Path = null;
else if (specification == OpcSpecification.OPC_AE_10) { url.Scheme = OpcUrlScheme.AE; }
else if (specification == OpcSpecification.OPC_HDA_10) { url.Scheme = OpcUrlScheme.HDA; }
try if (specification == OpcSpecification.OPC_DA_30) { url.Scheme = OpcUrlScheme.DA; }
{ else if (specification == OpcSpecification.OPC_DA_20) { url.Scheme = OpcUrlScheme.DA; }
// fetch class details from the enumerator. else if (specification == OpcSpecification.OPC_DA_10) { url.Scheme = OpcUrlScheme.DA; }
string progID = null; else if (specification == OpcSpecification.OPC_AE_10) { url.Scheme = OpcUrlScheme.AE; }
string description = null; else if (specification == OpcSpecification.OPC_HDA_10) { url.Scheme = OpcUrlScheme.HDA; }
string verIndProgID = null;
m_server.GetClassDetails( try
ref clsid, {
out progID, // fetch class details from the enumerator.
out description, string progID = null;
out verIndProgID); string description = null;
string verIndProgID = null;
// create the server URL path.
if (verIndProgID != null)
{
url.Path = string.Format("{0}/{1}", verIndProgID, "{" + clsid.ToString() + "}");
}
else if (progID != null)
{
url.Path = string.Format("{0}/{1}", progID, "{" + clsid.ToString() + "}");
}
}
catch (Exception)
{
// bad value in registry.
}
finally
{
// default to the clsid if the prog is not known.
if (url.Path == null)
{
url.Path = string.Format("{0}", "{" + clsid.ToString() + "}");
}
}
// return the server url. m_server.GetClassDetails(
return url; ref clsid,
} out progID,
} out description,
out verIndProgID);
// create the server URL path.
if (verIndProgID != null)
{
url.Path = string.Format("{0}/{1}", verIndProgID, "{" + clsid.ToString() + "}");
}
else if (progID != null)
{
url.Path = string.Format("{0}/{1}", progID, "{" + clsid.ToString() + "}");
}
}
catch (Exception)
{
// bad value in registry.
}
finally
{
// default to the clsid if the prog is not known.
if (url.Path == null)
{
url.Path = string.Format("{0}", "{" + clsid.ToString() + "}");
}
}
// return the server url.
return url;
}
}
} }

View File

@@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Technosoftware.DaAeHdaClient.Utilities; using Technosoftware.DaAeHdaClient.Utilities;
@@ -47,7 +44,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
private static Task watchdogTask_; private static Task watchdogTask_;
private static DCOMWatchdogResult lastWatchdogResult_ = DCOMWatchdogResult.None; private static DCOMWatchdogResult lastWatchdogResult_ = DCOMWatchdogResult.None;
private static DateTime setStart_; private static DateTime setStart_;
#endregion #endregion
#region Properties #region Properties
@@ -97,7 +94,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
/// </summary> /// </summary>
public static TimeSpan Timeout public static TimeSpan Timeout
{ {
get => timeout_; get => timeout_;
set set
{ {
Enable(value); Enable(value);
@@ -124,7 +121,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
/// <param name="timeout">The maximum time to wait for a DCOM call to succeed before it is cancelled. Note that DCOM will typically timeout /// <param name="timeout">The maximum time to wait for a DCOM call to succeed before it is cancelled. Note that DCOM will typically timeout
/// between 1-2 minutes, depending on the OS</param> /// between 1-2 minutes, depending on the OS</param>
public static void Enable(TimeSpan timeout) public static void Enable(TimeSpan timeout)
{ {
if (timeout == TimeSpan.Zero) if (timeout == TimeSpan.Zero)
{ {
timeout = TimeSpan.FromSeconds(DEFAULT_TIMEOUT_SECONDS); timeout = TimeSpan.FromSeconds(DEFAULT_TIMEOUT_SECONDS);
@@ -159,7 +156,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
} }
} }
} }
/// <summary> /// <summary>
/// Sets the watchdog timer active on the current thread. If Reset is not called within the timeout period, any current thread DCOM call will be cancelled. The /// Sets the watchdog timer active on the current thread. If Reset is not called within the timeout period, any current thread DCOM call will be cancelled. The
/// calling thread must be the originator of the DCOM call and must be an STA thread. /// calling thread must be the originator of the DCOM call and must be an STA thread.
@@ -200,7 +197,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
{ {
setStart_ = DateTime.UtcNow; setStart_ = DateTime.UtcNow;
watchDogThreadID_ = threadId; watchDogThreadID_ = threadId;
Utils.Trace(Utils.TraceMasks.Information, $"COM call cancellation on thread [{watchDogThreadID_}] was set with timeout [{timeout_.TotalSeconds} seconds]"); Utils.Trace(Utils.TraceMasks.Information, $"COM call cancellation on thread [{watchDogThreadID_}] was set with timeout [{timeout_.TotalSeconds} seconds]");
} }
else else
@@ -289,7 +286,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
{ {
return false; return false;
} }
} }
/// <summary> /// <summary>
/// Allows for manual cancellation of the current DCOM call /// Allows for manual cancellation of the current DCOM call
@@ -341,7 +338,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
/// then cancels the current DCOM call automatically if Reset is not called within the timeout period. /// then cancels the current DCOM call automatically if Reset is not called within the timeout period.
/// </summary> /// </summary>
private static void WatchdogTask() private static void WatchdogTask()
{ {
while (IsEnabled) while (IsEnabled)
{ {
try try
@@ -353,7 +350,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
Utils.Trace(Utils.TraceMasks.Information, $"Sync call watchdog for thread [{watchDogThreadID_}] timed out - cancelling current call..."); Utils.Trace(Utils.TraceMasks.Information, $"Sync call watchdog for thread [{watchDogThreadID_}] timed out - cancelling current call...");
Cancel(DCOMWatchdogResult.TimedOut); Cancel(DCOMWatchdogResult.TimedOut);
} }
} }
} }
catch (Exception e) catch (Exception e)
@@ -367,7 +364,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
} }
} }
private static TimeSpan TimeElapsed(DateTime startTime) private static TimeSpan TimeElapsed(DateTime startTime)
{ {
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
@@ -386,5 +383,5 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
#endregion #endregion
} }
} }

View File

@@ -22,10 +22,9 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Net;
using System.Globalization; using System.Globalization;
using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da; using Technosoftware.DaAeHdaClient.Da;
#pragma warning disable 618 #pragma warning disable 618
#endregion #endregion

View File

@@ -26,37 +26,37 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Contains a writable collection attribute ids. /// Contains a writable collection attribute ids.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeAttributeCollection : OpcWriteableCollection public class TsCAeAttributeCollection : OpcWriteableCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal TsCAeAttributeCollection() : base(null, typeof(int)) { } internal TsCAeAttributeCollection() : base(null, typeof(int)) { }
/// <summary> /// <summary>
/// Creates a collection from an array. /// Creates a collection from an array.
/// </summary> /// </summary>
internal TsCAeAttributeCollection(int[] attributeIDs) : base(attributeIDs, typeof(int)) { } internal TsCAeAttributeCollection(int[] attributeIDs) : base(attributeIDs, typeof(int)) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new int this[int index] => (int)Array[index]; public new int this[int index] => (int)Array[index];
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new int[] ToArray() public new int[] ToArray()
{ {
return (int[])Array.ToArray(typeof(int)); return (int[])Array.ToArray(typeof(int));
} }
#endregion #endregion
} }
} }

View File

@@ -26,23 +26,23 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Contains multiple lists of the attributes indexed by category. /// Contains multiple lists of the attributes indexed by category.
/// </summary> /// </summary>
[Serializable] [Serializable]
public sealed class TsCAeAttributeDictionary : OpcWriteableDictionary public sealed class TsCAeAttributeDictionary : OpcWriteableDictionary
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Constructs an empty dictionary. /// Constructs an empty dictionary.
/// </summary> /// </summary>
public TsCAeAttributeDictionary() : base(null, typeof(int), typeof(TsCAeAttributeCollection)) { } public TsCAeAttributeDictionary() : base(null, typeof(int), typeof(TsCAeAttributeCollection)) { }
/// <summary> /// <summary>
/// Constructs an dictionary from a set of category ids. /// Constructs an dictionary from a set of category ids.
/// </summary> /// </summary>
public TsCAeAttributeDictionary(int[] categoryIds) public TsCAeAttributeDictionary(int[] categoryIds)
: base(null, typeof(int), typeof(TsCAeAttributeCollection)) : base(null, typeof(int), typeof(TsCAeAttributeCollection))
{ {
foreach (var categoryId in categoryIds) foreach (var categoryId in categoryIds)
{ {
@@ -51,41 +51,41 @@ namespace Technosoftware.DaAeHdaClient.Ae
} }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Gets or sets the attribute collection for the specified category. /// Gets or sets the attribute collection for the specified category.
/// </summary> /// </summary>
public TsCAeAttributeCollection this[int categoryId] public TsCAeAttributeCollection this[int categoryId]
{ {
get => (TsCAeAttributeCollection)base[categoryId]; get => (TsCAeAttributeCollection)base[categoryId];
set set
{ {
if (value != null) if (value != null)
{ {
base[categoryId] = value; base[categoryId] = value;
} }
else else
{ {
base[categoryId] = new TsCAeAttributeCollection(); base[categoryId] = new TsCAeAttributeCollection();
} }
} }
} }
/// <summary> /// <summary>
/// Adds an element with the provided key and value to the IDictionary. /// Adds an element with the provided key and value to the IDictionary.
/// </summary> /// </summary>
public void Add(int key, int[] value) public void Add(int key, int[] value)
{ {
if (value != null) if (value != null)
{ {
base.Add(key, new TsCAeAttributeCollection(value)); base.Add(key, new TsCAeAttributeCollection(value));
} }
else else
{ {
base.Add(key, new TsCAeAttributeCollection()); base.Add(key, new TsCAeAttributeCollection());
} }
} }
#endregion #endregion
} }
} }

View File

@@ -26,54 +26,54 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The value of an attribute for an event source. /// The value of an attribute for an event source.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeAttributeValue : ICloneable, IOpcResult public class TsCAeAttributeValue : ICloneable, IOpcResult
{ {
#region Fields #region Fields
private OpcResult result_ = OpcResult.S_OK; private OpcResult result_ = OpcResult.S_OK;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// A unique identifier for the attribute. /// A unique identifier for the attribute.
/// </summary> /// </summary>
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
/// The attribute value. /// The attribute value.
/// </summary> /// </summary>
public object Value { get; set; } public object Value { get; set; }
#endregion #endregion
#region IOpcResult Members #region IOpcResult Members
/// <summary> /// <summary>
/// The error id for the result of an operation on an property. /// The error id for the result of an operation on an property.
/// </summary> /// </summary>
public OpcResult Result public OpcResult Result
{ {
get => result_; get => result_;
set => result_ = value; set => result_ = value;
} }
/// <summary> /// <summary>
/// Vendor specific diagnostic information (not the localized error text). /// Vendor specific diagnostic information (not the localized error text).
/// </summary> /// </summary>
public string DiagnosticInfo { get; set; } public string DiagnosticInfo { get; set; }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
var clone = (TsCAeAttributeValue)MemberwiseClone(); var clone = (TsCAeAttributeValue)MemberwiseClone();
clone.Value = OpcConvert.Clone(Value); clone.Value = OpcConvert.Clone(Value);
return clone; return clone;
} }
#endregion #endregion
} }
} }

View File

@@ -25,22 +25,22 @@ using System;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Contains a description of an element in the server address space. /// Contains a description of an element in the server address space.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeBrowseElement public class TsCAeBrowseElement
{ {
#region Fields #region Fields
private TsCAeBrowseType browseType_ = TsCAeBrowseType.Area; private TsCAeBrowseType browseType_ = TsCAeBrowseType.Area;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// A descriptive name for element that is unique within a branch. /// A descriptive name for element that is unique within a branch.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// The fully qualified name for the element. /// The fully qualified name for the element.
@@ -57,12 +57,12 @@ namespace Technosoftware.DaAeHdaClient.Ae
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
return MemberwiseClone(); return MemberwiseClone();
} }
#endregion #endregion

View File

@@ -29,81 +29,81 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// Stores the state of a browse operation. /// Stores the state of a browse operation.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeBrowsePosition : IOpcBrowsePosition public class TsCAeBrowsePosition : IOpcBrowsePosition
{ {
#region Fields #region Fields
private bool disposed_; private bool disposed_;
private string areaId_; private string areaId_;
private TsCAeBrowseType browseType_; private TsCAeBrowseType browseType_;
private string browseFilter_; private string browseFilter_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Saves the parameters for an incomplete browse information. /// Saves the parameters for an incomplete browse information.
/// </summary> /// </summary>
public TsCAeBrowsePosition( public TsCAeBrowsePosition(
string areaId, string areaId,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter) string browseFilter)
{ {
areaId_ = areaId; areaId_ = areaId;
browseType_ = browseType; browseType_ = browseType;
browseFilter_ = browseFilter; browseFilter_ = browseFilter;
} }
/// <summary> /// <summary>
/// The finalizer implementation. /// The finalizer implementation.
/// </summary> /// </summary>
~TsCAeBrowsePosition() ~TsCAeBrowsePosition()
{ {
Dispose(false); Dispose(false);
} }
/// <summary> /// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary> /// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
Dispose(true); Dispose(true);
// Take yourself off the Finalization queue // Take yourself off the Finalization queue
// to prevent finalization code for this object // to prevent finalization code for this object
// from executing a second time. // from executing a second time.
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary> /// <summary>
/// Dispose(bool disposing) executes in two distinct scenarios. /// Dispose(bool disposing) executes in two distinct scenarios.
/// If disposing equals true, the method has been called directly /// If disposing equals true, the method has been called directly
/// or indirectly by a user's code. Managed and unmanaged resources /// or indirectly by a user's code. Managed and unmanaged resources
/// can be disposed. /// can be disposed.
/// If disposing equals false, the method has been called by the /// If disposing equals false, the method has been called by the
/// runtime from inside the finalizer and you should not reference /// runtime from inside the finalizer and you should not reference
/// other objects. Only unmanaged resources can be disposed. /// other objects. Only unmanaged resources can be disposed.
/// </summary> /// </summary>
/// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param> /// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
// Check to see if Dispose has already been called. // Check to see if Dispose has already been called.
if(!disposed_) if (!disposed_)
{ {
// If disposing equals true, dispose all managed // If disposing equals true, dispose all managed
// and unmanaged resources. // and unmanaged resources.
if(disposing) if (disposing)
{ {
} }
// Release unmanaged resources. If disposing is false, // Release unmanaged resources. If disposing is false,
// only the following code is executed. // only the following code is executed.
} }
disposed_ = true; disposed_ = true;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The fully qualified id for the area being browsed. /// The fully qualified id for the area being browsed.
/// </summary> /// </summary>
public string AreaID => areaId_; public string AreaID => areaId_;
/// <summary> /// <summary>
/// The type of child element being returned with the browse. /// The type of child element being returned with the browse.
@@ -116,14 +116,14 @@ namespace Technosoftware.DaAeHdaClient.Ae
public string BrowseFilter => browseFilter_; public string BrowseFilter => browseFilter_;
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a shallow copy of the object. /// Creates a shallow copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
return (TsCAeBrowsePosition)MemberwiseClone(); return (TsCAeBrowsePosition)MemberwiseClone();
} }
#endregion #endregion
} }
} }

View File

@@ -26,19 +26,19 @@
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The type of nodes to return during a browse. /// The type of nodes to return during a browse.
/// </summary> /// </summary>
public enum TsCAeBrowseType public enum TsCAeBrowseType
{ {
/// <summary> /// <summary>
/// Return only nodes that are process areas. /// Return only nodes that are process areas.
/// </summary> /// </summary>
Area, Area,
/// <summary> /// <summary>
/// Return only nodes that are event sources. /// Return only nodes that are event sources.
/// </summary> /// </summary>
Source Source
} }
} }

View File

@@ -32,11 +32,11 @@ namespace Technosoftware.DaAeHdaClient.Ae
[Serializable] [Serializable]
public class TsCAeCategory : ICloneable public class TsCAeCategory : ICloneable
{ {
#region Properties #region Properties
/// <summary> /// <summary>
/// A unique identifier for the category. /// A unique identifier for the category.
/// </summary> /// </summary>
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
/// The unique name for the category. /// The unique name for the category.
@@ -53,7 +53,7 @@ namespace Technosoftware.DaAeHdaClient.Ae
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a shallow copy of the object. /// Creates a shallow copy of the object.
/// </summary> /// </summary>

View File

@@ -26,50 +26,50 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The bits indicating what changes generated an event notification. /// The bits indicating what changes generated an event notification.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCAeChangeMask public enum TsCAeChangeMask
{ {
/// <summary> /// <summary>
/// The conditions active state has changed. /// The conditions active state has changed.
/// </summary> /// </summary>
ActiveState = 0x0001, ActiveState = 0x0001,
/// <summary> /// <summary>
/// The conditions acknowledgment state has changed. /// The conditions acknowledgment state has changed.
/// </summary> /// </summary>
AcknowledgeState = 0x0002, AcknowledgeState = 0x0002,
/// <summary> /// <summary>
/// The conditions enabled state has changed. /// The conditions enabled state has changed.
/// </summary> /// </summary>
EnableState = 0x0004, EnableState = 0x0004,
/// <summary> /// <summary>
/// The condition quality has changed. /// The condition quality has changed.
/// </summary> /// </summary>
Quality = 0x0008, Quality = 0x0008,
/// <summary> /// <summary>
/// The severity level has changed. /// The severity level has changed.
/// </summary> /// </summary>
Severity = 0x0010, Severity = 0x0010,
/// <summary> /// <summary>
/// The condition has transitioned into a new sub-condition. /// The condition has transitioned into a new sub-condition.
/// </summary> /// </summary>
SubCondition = 0x0020, SubCondition = 0x0020,
/// <summary> /// <summary>
/// The event message has changed. /// The event message has changed.
/// </summary> /// </summary>
Message = 0x0040, Message = 0x0040,
/// <summary> /// <summary>
/// One or more event attributes have changed. /// One or more event attributes have changed.
/// </summary> /// </summary>
Attribute = 0x0080 Attribute = 0x0080
} }
} }

View File

@@ -117,8 +117,8 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// The quality associated with the condition state. /// The quality associated with the condition state.
/// </summary> /// </summary>
public TsCDaQuality Quality public TsCDaQuality Quality
{ {
get => _quality; get => _quality;
set => _quality = value; set => _quality = value;
} }

View File

@@ -26,25 +26,25 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The possible states for a condition. /// The possible states for a condition.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCAeConditionState public enum TsCAeConditionState
{ {
/// <summary> /// <summary>
/// The server is currently checking the state of the condition. /// The server is currently checking the state of the condition.
/// </summary> /// </summary>
Enabled = 0x0001, Enabled = 0x0001,
/// <summary> /// <summary>
/// The associated object is in the state represented by the condition. /// The associated object is in the state represented by the condition.
/// </summary> /// </summary>
Active = 0x0002, Active = 0x0002,
/// <summary> /// <summary>
/// The condition has been acknowledged. /// The condition has been acknowledged.
/// </summary> /// </summary>
Acknowledged = 0x0004 Acknowledged = 0x0004
} }
} }

View File

@@ -25,56 +25,56 @@
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The current state of a process area or an event source. /// The current state of a process area or an event source.
/// </summary> /// </summary>
public class TsCAeEnabledStateResult : IOpcResult public class TsCAeEnabledStateResult : IOpcResult
{ {
#region Fields #region Fields
private string qualifiedName_; private string qualifiedName_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with default values. /// Initializes the object with default values.
/// </summary> /// </summary>
public TsCAeEnabledStateResult() { } public TsCAeEnabledStateResult() { }
/// <summary> /// <summary>
/// Initializes the object with an qualified name. /// Initializes the object with an qualified name.
/// </summary> /// </summary>
public TsCAeEnabledStateResult(string qualifiedName) public TsCAeEnabledStateResult(string qualifiedName)
{ {
qualifiedName_ = qualifiedName; qualifiedName_ = qualifiedName;
} }
/// <summary> /// <summary>
/// Initializes the object with an qualified name and Result. /// Initializes the object with an qualified name and Result.
/// </summary> /// </summary>
public TsCAeEnabledStateResult(string qualifiedName, OpcResult result) public TsCAeEnabledStateResult(string qualifiedName, OpcResult result)
{ {
qualifiedName_ = qualifiedName; qualifiedName_ = qualifiedName;
Result = result; Result = result;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// Whether if the area or source is enabled. /// Whether if the area or source is enabled.
/// </summary> /// </summary>
public bool Enabled { get; set; } public bool Enabled { get; set; }
/// <summary> /// <summary>
/// Whether the area or source is enabled and all areas within the hierarchy of its containing areas are enabled. /// Whether the area or source is enabled and all areas within the hierarchy of its containing areas are enabled.
/// </summary> /// </summary>
public bool EffectivelyEnabled { get; set; } public bool EffectivelyEnabled { get; set; }
#endregion #endregion
#region IOpcResult Members #region IOpcResult Members
/// <summary> /// <summary>
/// The error id for the result of an operation on an item. /// The error id for the result of an operation on an item.
/// </summary> /// </summary>
public OpcResult Result { get; set; } = OpcResult.S_OK; public OpcResult Result { get; set; } = OpcResult.S_OK;
/// <summary> /// <summary>
/// Vendor specific diagnostic information (not the localized error text). /// Vendor specific diagnostic information (not the localized error text).
@@ -82,14 +82,14 @@ namespace Technosoftware.DaAeHdaClient.Ae
public string DiagnosticInfo { get; set; } public string DiagnosticInfo { get; set; }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
return MemberwiseClone(); return MemberwiseClone();
} }
#endregion #endregion
} }
} }

View File

@@ -26,68 +26,68 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Specifies the information required to acknowledge an event. /// Specifies the information required to acknowledge an event.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeEventAcknowledgement : ICloneable public class TsCAeEventAcknowledgement : ICloneable
{ {
#region Fields #region Fields
private DateTime activeTime_ = DateTime.MinValue; private DateTime activeTime_ = DateTime.MinValue;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The name of the source that generated the event. /// The name of the source that generated the event.
/// </summary> /// </summary>
public string SourceName { get; set; } public string SourceName { get; set; }
/// <summary> /// <summary>
/// The name of the condition that is being acknowledged. /// The name of the condition that is being acknowledged.
/// </summary> /// </summary>
public string ConditionName { get; set; } public string ConditionName { get; set; }
/// <summary> /// <summary>
/// The time that the condition or sub-condition became active. /// The time that the condition or sub-condition became active.
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines /// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
/// the time format (UTC or local time). /// the time format (UTC or local time).
/// </summary> /// </summary>
public DateTime ActiveTime public DateTime ActiveTime
{ {
get => activeTime_; get => activeTime_;
set => activeTime_ = value; set => activeTime_ = value;
} }
/// <summary>
/// The cookie for the condition passed to client during the event notification.
/// </summary>
public int Cookie { get; set; }
/// <summary>
/// Constructs an acknowledgment with its default values.
/// </summary>
public TsCAeEventAcknowledgement() { }
/// <summary>
/// Constructs an acknowledgment from an event notification.
/// </summary>
public TsCAeEventAcknowledgement(TsCAeEventNotification notification)
{
SourceName = notification.SourceID;
ConditionName = notification.ConditionName;
activeTime_ = notification.ActiveTime;
Cookie = notification.Cookie;
}
#endregion
#region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// The cookie for the condition passed to client during the event notification.
/// </summary> /// </summary>
public virtual object Clone() public int Cookie { get; set; }
{
return MemberwiseClone(); /// <summary>
} /// Constructs an acknowledgment with its default values.
/// </summary>
public TsCAeEventAcknowledgement() { }
/// <summary>
/// Constructs an acknowledgment from an event notification.
/// </summary>
public TsCAeEventAcknowledgement(TsCAeEventNotification notification)
{
SourceName = notification.SourceID;
ConditionName = notification.ConditionName;
activeTime_ = notification.ActiveTime;
Cookie = notification.Cookie;
}
#endregion #endregion
}
#region ICloneable Members
/// <summary>
/// Creates a deep copy of the object.
/// </summary>
public virtual object Clone()
{
return MemberwiseClone();
}
#endregion
}
} }

View File

@@ -206,8 +206,8 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// The quality associated with the condition state. /// The quality associated with the condition state.
/// </summary> /// </summary>
public TsCDaQuality Quality public TsCDaQuality Quality
{ {
get => daQuality_; get => daQuality_;
set => daQuality_ = value; set => daQuality_ = value;
} }

View File

@@ -25,30 +25,30 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The types of events that could be generated by a server. /// The types of events that could be generated by a server.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCAeEventType public enum TsCAeEventType
{ {
/// <summary> /// <summary>
/// Events that are not tracking or condition events. /// Events that are not tracking or condition events.
/// </summary> /// </summary>
Simple = 0x0001, Simple = 0x0001,
/// <summary> /// <summary>
/// Events that represent occurrences which involve the interaction of the client with a target within the server. /// Events that represent occurrences which involve the interaction of the client with a target within the server.
/// </summary> /// </summary>
Tracking = 0x0002, Tracking = 0x0002,
/// <summary> /// <summary>
/// Events that are associated with transitions in and out states defined by the server. /// Events that are associated with transitions in and out states defined by the server.
/// </summary> /// </summary>
Condition = 0x0004, Condition = 0x0004,
/// <summary> /// <summary>
/// All events generated by the server. /// All events generated by the server.
/// </summary> /// </summary>
All = 0xFFFF All = 0xFFFF
} }
} }

View File

@@ -26,40 +26,40 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The types of event filters that the server could support. /// The types of event filters that the server could support.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCAeFilterType public enum TsCAeFilterType
{ {
/// <summary> /// <summary>
/// The server supports filtering by event type. /// The server supports filtering by event type.
/// </summary> /// </summary>
Event = 0x0001, Event = 0x0001,
/// <summary> /// <summary>
/// The server supports filtering by event categories. /// The server supports filtering by event categories.
/// </summary> /// </summary>
Category = 0x0002, Category = 0x0002,
/// <summary> /// <summary>
/// The server supports filtering by severity levels. /// The server supports filtering by severity levels.
/// </summary> /// </summary>
Severity = 0x0004, Severity = 0x0004,
/// <summary> /// <summary>
/// The server supports filtering by process area. /// The server supports filtering by process area.
/// </summary> /// </summary>
Area = 0x0008, Area = 0x0008,
/// <summary> /// <summary>
/// The server supports filtering by event sources. /// The server supports filtering by event sources.
/// </summary> /// </summary>
Source = 0x0010, Source = 0x0010,
/// <summary> /// <summary>
/// All filters supported by the server. /// All filters supported by the server.
/// </summary> /// </summary>
All = 0xFFFF All = 0xFFFF
} }
} }

View File

@@ -24,179 +24,179 @@
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Defines functionality that is common to all OPC Alarms and Events servers. /// Defines functionality that is common to all OPC Alarms and Events servers.
/// </summary> /// </summary>
public interface ITsCAeServer : IOpcServer public interface ITsCAeServer : IOpcServer
{ {
/// <summary> /// <summary>
/// Returns the current server status. /// Returns the current server status.
/// </summary> /// </summary>
/// <returns>The current server status.</returns> /// <returns>The current server status.</returns>
OpcServerStatus GetServerStatus(); OpcServerStatus GetServerStatus();
/// <summary> /// <summary>
/// Creates a new event subscription. /// Creates a new event subscription.
/// </summary> /// </summary>
/// <param name="state">The initial state for the subscription.</param> /// <param name="state">The initial state for the subscription.</param>
/// <returns>The new subscription object.</returns> /// <returns>The new subscription object.</returns>
ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state); ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state);
/// <summary> /// <summary>
/// Returns the event filters supported by the server. /// Returns the event filters supported by the server.
/// </summary> /// </summary>
/// <returns>A bit mask of all event filters supported by the server.</returns> /// <returns>A bit mask of all event filters supported by the server.</returns>
int QueryAvailableFilters(); int QueryAvailableFilters();
/// <summary> /// <summary>
/// Returns the event categories supported by the server for the specified event types. /// Returns the event categories supported by the server for the specified event types.
/// </summary> /// </summary>
/// <param name="eventType">A bit mask for the event types of interest.</param> /// <param name="eventType">A bit mask for the event types of interest.</param>
/// <returns>A collection of event categories.</returns> /// <returns>A collection of event categories.</returns>
TsCAeCategory[] QueryEventCategories(int eventType); TsCAeCategory[] QueryEventCategories(int eventType);
/// <summary> /// <summary>
/// Returns the condition names supported by the server for the specified event categories. /// Returns the condition names supported by the server for the specified event categories.
/// </summary> /// </summary>
/// <param name="eventCategory">A bit mask for the event categories of interest.</param> /// <param name="eventCategory">A bit mask for the event categories of interest.</param>
/// <returns>A list of condition names.</returns> /// <returns>A list of condition names.</returns>
string[] QueryConditionNames(int eventCategory); string[] QueryConditionNames(int eventCategory);
/// <summary> /// <summary>
/// Returns the sub-condition names supported by the server for the specified event condition. /// Returns the sub-condition names supported by the server for the specified event condition.
/// </summary> /// </summary>
/// <param name="conditionName">The name of the condition.</param> /// <param name="conditionName">The name of the condition.</param>
/// <returns>A list of sub-condition names.</returns> /// <returns>A list of sub-condition names.</returns>
string[] QuerySubConditionNames(string conditionName); string[] QuerySubConditionNames(string conditionName);
/// <summary> /// <summary>
/// Returns the condition names supported by the server for the specified event source. /// Returns the condition names supported by the server for the specified event source.
/// </summary> /// </summary>
/// <param name="sourceName">The name of the event source.</param> /// <param name="sourceName">The name of the event source.</param>
/// <returns>A list of condition names.</returns> /// <returns>A list of condition names.</returns>
string[] QueryConditionNames(string sourceName); string[] QueryConditionNames(string sourceName);
/// <summary> /// <summary>
/// Returns the event attributes supported by the server for the specified event categories. /// Returns the event attributes supported by the server for the specified event categories.
/// </summary> /// </summary>
/// <param name="eventCategory">The event category of interest.</param> /// <param name="eventCategory">The event category of interest.</param>
/// <returns>A collection of event attributes.</returns> /// <returns>A collection of event attributes.</returns>
TsCAeAttribute[] QueryEventAttributes(int eventCategory); TsCAeAttribute[] QueryEventAttributes(int eventCategory);
/// <summary> /// <summary>
/// Returns the DA item ids for a set of attribute ids belonging to events which meet the specified filter criteria. /// Returns the DA item ids for a set of attribute ids belonging to events which meet the specified filter criteria.
/// </summary> /// </summary>
/// <param name="sourceName">The event source of interest.</param> /// <param name="sourceName">The event source of interest.</param>
/// <param name="eventCategory">The id of the event category for the events of interest.</param> /// <param name="eventCategory">The id of the event category for the events of interest.</param>
/// <param name="conditionName">The name of a condition within the event category.</param> /// <param name="conditionName">The name of a condition within the event category.</param>
/// <param name="subConditionName">The name of a sub-condition within a multi-state condition.</param> /// <param name="subConditionName">The name of a sub-condition within a multi-state condition.</param>
/// <param name="attributeIDs">The ids of the attributes to return item ids for.</param> /// <param name="attributeIDs">The ids of the attributes to return item ids for.</param>
/// <returns>A list of item urls for each specified attribute.</returns> /// <returns>A list of item urls for each specified attribute.</returns>
TsCAeItemUrl[] TranslateToItemIDs( TsCAeItemUrl[] TranslateToItemIDs(
string sourceName, string sourceName,
int eventCategory, int eventCategory,
string conditionName, string conditionName,
string subConditionName, string subConditionName,
int[] attributeIDs); int[] attributeIDs);
/// <summary> /// <summary>
/// Returns the current state information for the condition instance corresponding to the source and condition name. /// Returns the current state information for the condition instance corresponding to the source and condition name.
/// </summary> /// </summary>
/// <param name="sourceName">The source name</param> /// <param name="sourceName">The source name</param>
/// <param name="conditionName">A condition name for the source.</param> /// <param name="conditionName">A condition name for the source.</param>
/// <param name="attributeIDs">The list of attributes to return with the condition state.</param> /// <param name="attributeIDs">The list of attributes to return with the condition state.</param>
/// <returns>The current state of the connection.</returns> /// <returns>The current state of the connection.</returns>
TsCAeCondition GetConditionState( TsCAeCondition GetConditionState(
string sourceName, string sourceName,
string conditionName, string conditionName,
int[] attributeIDs); int[] attributeIDs);
/// <summary> /// <summary>
/// Places the specified process areas into the enabled state. /// Places the specified process areas into the enabled state.
/// </summary> /// </summary>
/// <param name="areas">A list of fully qualified area names.</param> /// <param name="areas">A list of fully qualified area names.</param>
/// <returns>The results of the operation for each area.</returns> /// <returns>The results of the operation for each area.</returns>
OpcResult[] EnableConditionByArea(string[] areas); OpcResult[] EnableConditionByArea(string[] areas);
/// <summary> /// <summary>
/// Places the specified process areas into the disabled state. /// Places the specified process areas into the disabled state.
/// </summary> /// </summary>
/// <param name="areas">A list of fully qualified area names.</param> /// <param name="areas">A list of fully qualified area names.</param>
/// <returns>The results of the operation for each area.</returns> /// <returns>The results of the operation for each area.</returns>
OpcResult[] DisableConditionByArea(string[] areas); OpcResult[] DisableConditionByArea(string[] areas);
/// <summary> /// <summary>
/// Places the specified process areas into the enabled state. /// Places the specified process areas into the enabled state.
/// </summary> /// </summary>
/// <param name="sources">A list of fully qualified source names.</param> /// <param name="sources">A list of fully qualified source names.</param>
/// <returns>The results of the operation for each area.</returns> /// <returns>The results of the operation for each area.</returns>
OpcResult[] EnableConditionBySource(string[] sources); OpcResult[] EnableConditionBySource(string[] sources);
/// <summary> /// <summary>
/// Places the specified process areas into the disabled state. /// Places the specified process areas into the disabled state.
/// </summary> /// </summary>
/// <param name="sources">A list of fully qualified source names.</param> /// <param name="sources">A list of fully qualified source names.</param>
/// <returns>The results of the operation for each area.</returns> /// <returns>The results of the operation for each area.</returns>
OpcResult[] DisableConditionBySource(string[] sources); OpcResult[] DisableConditionBySource(string[] sources);
/// <summary> /// <summary>
/// Returns the enabled state for the specified process areas. /// Returns the enabled state for the specified process areas.
/// </summary> /// </summary>
/// <param name="areas">A list of fully qualified area names.</param> /// <param name="areas">A list of fully qualified area names.</param>
TsCAeEnabledStateResult[] GetEnableStateByArea(string[] areas); TsCAeEnabledStateResult[] GetEnableStateByArea(string[] areas);
/// <summary> /// <summary>
/// Returns the enabled state for the specified event sources. /// Returns the enabled state for the specified event sources.
/// </summary> /// </summary>
/// <param name="sources">A list of fully qualified source names.</param> /// <param name="sources">A list of fully qualified source names.</param>
TsCAeEnabledStateResult[] GetEnableStateBySource(string[] sources); TsCAeEnabledStateResult[] GetEnableStateBySource(string[] sources);
/// <summary> /// <summary>
/// Used to acknowledge one or more conditions in the event server. /// Used to acknowledge one or more conditions in the event server.
/// </summary> /// </summary>
/// <param name="acknowledgerID">The identifier for who is acknowledging the condition.</param> /// <param name="acknowledgerID">The identifier for who is acknowledging the condition.</param>
/// <param name="comment">A comment associated with the acknowledgment.</param> /// <param name="comment">A comment associated with the acknowledgment.</param>
/// <param name="conditions">The conditions being acknowledged.</param> /// <param name="conditions">The conditions being acknowledged.</param>
/// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns> /// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns>
OpcResult[] AcknowledgeCondition( OpcResult[] AcknowledgeCondition(
string acknowledgerID, string acknowledgerID,
string comment, string comment,
TsCAeEventAcknowledgement[] conditions); TsCAeEventAcknowledgement[] conditions);
/// <summary> /// <summary>
/// Browses for all children of the specified area that meet the filter criteria. /// Browses for all children of the specified area that meet the filter criteria.
/// </summary> /// </summary>
/// <param name="areaID">The full-qualified id for the area.</param> /// <param name="areaID">The full-qualified id for the area.</param>
/// <param name="browseType">The type of children to return.</param> /// <param name="browseType">The type of children to return.</param>
/// <param name="browseFilter">The expression used to filter the names of children returned.</param> /// <param name="browseFilter">The expression used to filter the names of children returned.</param>
/// <returns>The set of elements that meet the filter criteria.</returns> /// <returns>The set of elements that meet the filter criteria.</returns>
TsCAeBrowseElement[] Browse( TsCAeBrowseElement[] Browse(
string areaID, string areaID,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter); string browseFilter);
/// <summary> /// <summary>
/// Browses for all children of the specified area that meet the filter criteria. /// Browses for all children of the specified area that meet the filter criteria.
/// </summary> /// </summary>
/// <param name="areaID">The full-qualified id for the area.</param> /// <param name="areaID">The full-qualified id for the area.</param>
/// <param name="browseType">The type of children to return.</param> /// <param name="browseType">The type of children to return.</param>
/// <param name="browseFilter">The expression used to filter the names of children returned.</param> /// <param name="browseFilter">The expression used to filter the names of children returned.</param>
/// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="maxElements">The maximum number of elements to return.</param>
/// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param> /// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param>
/// <returns>The set of elements that meet the filter criteria.</returns> /// <returns>The set of elements that meet the filter criteria.</returns>
TsCAeBrowseElement[] Browse( TsCAeBrowseElement[] Browse(
string areaID, string areaID,
TsCAeBrowseType browseType, TsCAeBrowseType browseType,
string browseFilter, string browseFilter,
int maxElements, int maxElements,
out IOpcBrowsePosition position); out IOpcBrowsePosition position);
/// <summary> /// <summary>
/// Continues browsing the server's address space at the specified position. /// Continues browsing the server's address space at the specified position.
/// </summary> /// </summary>
/// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="maxElements">The maximum number of elements to return.</param>
/// <param name="position">The position object used to continue a browse operation.</param> /// <param name="position">The position object used to continue a browse operation.</param>
/// <returns>The set of elements that meet the filter criteria.</returns> /// <returns>The set of elements that meet the filter criteria.</returns>
TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position); TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position);
} }
} }

View File

@@ -31,20 +31,20 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// </summary> /// </summary>
public interface ITsCAeSubscription : IDisposable public interface ITsCAeSubscription : IDisposable
{ {
#region Events #region Events
/// <summary> /// <summary>
/// An event to receive event change updates. /// An event to receive event change updates.
/// </summary> /// </summary>
event TsCAeDataChangedEventHandler DataChangedEvent; event TsCAeDataChangedEventHandler DataChangedEvent;
#endregion #endregion
#region State Management #region State Management
/// <summary> /// <summary>
/// Returns the current state of the subscription. /// Returns the current state of the subscription.
/// </summary> /// </summary>
/// <returns>The current state of the subscription.</returns> /// <returns>The current state of the subscription.</returns>
TsCAeSubscriptionState GetState(); TsCAeSubscriptionState GetState();
/// <summary> /// <summary>
/// Changes the state of a subscription. /// Changes the state of a subscription.
/// </summary> /// </summary>
@@ -54,7 +54,7 @@ namespace Technosoftware.DaAeHdaClient.Ae
TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state); TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state);
#endregion #endregion
#region Filter Management #region Filter Management
/// <summary> /// <summary>
/// Returns the current filters for the subscription. /// Returns the current filters for the subscription.
/// </summary> /// </summary>
@@ -68,7 +68,7 @@ namespace Technosoftware.DaAeHdaClient.Ae
void SetFilters(TsCAeSubscriptionFilters filters); void SetFilters(TsCAeSubscriptionFilters filters);
#endregion #endregion
#region Attribute Management #region Attribute Management
/// <summary> /// <summary>
/// Returns the set of attributes to return with event notifications. /// Returns the set of attributes to return with event notifications.
/// </summary> /// </summary>
@@ -84,7 +84,7 @@ namespace Technosoftware.DaAeHdaClient.Ae
void SelectReturnedAttributes(int eventCategory, int[] attributeIDs); void SelectReturnedAttributes(int eventCategory, int[] attributeIDs);
#endregion #endregion
#region Refresh #region Refresh
/// <summary> /// <summary>
/// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription. /// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription.
/// </summary> /// </summary>
@@ -95,9 +95,9 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// </summary> /// </summary>
void CancelRefresh(); void CancelRefresh();
#endregion #endregion
} }
#region Delegate Declarations #region Delegate Declarations
/// <summary> /// <summary>
/// A delegate to receive data change updates from the server. /// A delegate to receive data change updates from the server.
/// </summary> /// </summary>

View File

@@ -32,29 +32,29 @@ namespace Technosoftware.DaAeHdaClient.Ae
[Serializable] [Serializable]
public class TsCAeItemUrl : OpcItem public class TsCAeItemUrl : OpcItem
{ {
#region Fields #region Fields
private OpcUrl url_ = new OpcUrl(); private OpcUrl url_ = new OpcUrl();
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with default values. /// Initializes the object with default values.
/// </summary> /// </summary>
public TsCAeItemUrl() {} public TsCAeItemUrl() { }
/// <summary> /// <summary>
/// Initializes the object with an ItemIdentifier object. /// Initializes the object with an ItemIdentifier object.
/// </summary> /// </summary>
public TsCAeItemUrl(OpcItem item) : base(item) {} public TsCAeItemUrl(OpcItem item) : base(item) { }
/// <summary> /// <summary>
/// Initializes the object with an ItemIdentifier object and url. /// Initializes the object with an ItemIdentifier object and url.
/// </summary> /// </summary>
public TsCAeItemUrl(OpcItem item, OpcUrl url) public TsCAeItemUrl(OpcItem item, OpcUrl url)
: base(item) : base(item)
{ {
Url = url; Url = url;
} }
/// <summary> /// <summary>
/// Initializes object with the specified ItemResult object. /// Initializes object with the specified ItemResult object.
@@ -65,26 +65,26 @@ namespace Technosoftware.DaAeHdaClient.Ae
{ {
Url = item.Url; Url = item.Url;
} }
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The url of the server that contains the item. /// The url of the server that contains the item.
/// </summary> /// </summary>
public OpcUrl Url public OpcUrl Url
{ {
get => url_; get => url_;
set => url_ = value; set => url_ = value;
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public override object Clone() public override object Clone()
{ {
return new TsCAeItemUrl(this); return new TsCAeItemUrl(this);
} }
#endregion #endregion

View File

@@ -25,36 +25,36 @@
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Contains a collection of item urls. /// Contains a collection of item urls.
/// </summary> /// </summary>
internal class TsCAeItemUrlCollection : OpcReadOnlyCollection internal class TsCAeItemUrlCollection : OpcReadOnlyCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Constructs an empty collection. /// Constructs an empty collection.
/// </summary> /// </summary>
public TsCAeItemUrlCollection() : base(new TsCAeItemUrl[0]) { } public TsCAeItemUrlCollection() : base(new TsCAeItemUrl[0]) { }
/// <summary> /// <summary>
/// Constructs a collection from an array of item urls. /// Constructs a collection from an array of item urls.
/// </summary> /// </summary>
public TsCAeItemUrlCollection(TsCAeItemUrl[] itemUrls) : base(itemUrls) { } public TsCAeItemUrlCollection(TsCAeItemUrl[] itemUrls) : base(itemUrls) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new TsCAeItemUrl this[int index] => (TsCAeItemUrl)Array.GetValue(index); public new TsCAeItemUrl this[int index] => (TsCAeItemUrl)Array.GetValue(index);
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new TsCAeItemUrl[] ToArray() public new TsCAeItemUrl[] ToArray()
{ {
return (TsCAeItemUrl[])OpcConvert.Clone(Array); return (TsCAeItemUrl[])OpcConvert.Clone(Array);
} }
#endregion #endregion
} }
} }

View File

@@ -23,7 +23,6 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Collections;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#endregion #endregion

View File

@@ -25,44 +25,44 @@
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Current Status of an OPC AE server /// Current Status of an OPC AE server
/// </summary> /// </summary>
public enum TsCAeServerState public enum TsCAeServerState
{ {
/// <summary> /// <summary>
/// The server state is not known. /// The server state is not known.
/// </summary> /// </summary>
Unknown, Unknown,
/// <summary> /// <summary>
/// The server is running normally. This is the usual state for a server /// The server is running normally. This is the usual state for a server
/// </summary> /// </summary>
Running, Running,
/// <summary> /// <summary>
/// A vendor specific fatal error has occurred within the server. The server is no longer functioning. The recovery procedure from this situation is vendor specific. An error code of E_FAIL should generally be returned from any other server method. /// A vendor specific fatal error has occurred within the server. The server is no longer functioning. The recovery procedure from this situation is vendor specific. An error code of E_FAIL should generally be returned from any other server method.
/// </summary> /// </summary>
Failed, Failed,
/// <summary> /// <summary>
/// The server is running but has no configuration information loaded and thus cannot function normally. Note this state implies that the server needs configuration information in order to function. Servers which do not require configuration information should not return this state. /// The server is running but has no configuration information loaded and thus cannot function normally. Note this state implies that the server needs configuration information in order to function. Servers which do not require configuration information should not return this state.
/// </summary> /// </summary>
NoConfig, NoConfig,
/// <summary> /// <summary>
/// The server has been temporarily suspended via some vendor specific method and is not getting or sending data. Note that Quality will be returned as OPC_QUALITY_OUT_OF_SERVICE. /// The server has been temporarily suspended via some vendor specific method and is not getting or sending data. Note that Quality will be returned as OPC_QUALITY_OUT_OF_SERVICE.
/// </summary> /// </summary>
Suspended, Suspended,
/// <summary> /// <summary>
/// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally. /// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally.
/// </summary> /// </summary>
Test, Test,
/// <summary> /// <summary>
/// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally. /// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally.
/// </summary> /// </summary>
CommFault CommFault
} }
} }

View File

@@ -26,45 +26,45 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Defines masks to be used when modifying the subscription or item state. /// Defines masks to be used when modifying the subscription or item state.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCAeStateMask public enum TsCAeStateMask
{ {
/// <summary> /// <summary>
/// A name assigned to subscription. /// A name assigned to subscription.
/// </summary> /// </summary>
Name = 0x0001, Name = 0x0001,
/// <summary> /// <summary>
/// The client assigned handle for the item or subscription. /// The client assigned handle for the item or subscription.
/// </summary> /// </summary>
ClientHandle = 0x0002, ClientHandle = 0x0002,
/// <summary> /// <summary>
/// Whether the subscription is active. /// Whether the subscription is active.
/// </summary> /// </summary>
Active = 0x0004, Active = 0x0004,
/// <summary> /// <summary>
/// The maximum rate at which the server send event notifications. /// The maximum rate at which the server send event notifications.
/// </summary> /// </summary>
BufferTime = 0x0008, BufferTime = 0x0008,
/// <summary> /// <summary>
/// The requested maximum number of events that will be sent in a single callback. /// The requested maximum number of events that will be sent in a single callback.
/// </summary> /// </summary>
MaxSize = 0x0010, MaxSize = 0x0010,
/// <summary> /// <summary>
/// The maximum period between updates sent to the client. /// The maximum period between updates sent to the client.
/// </summary> /// </summary>
KeepAlive = 0x0020, KeepAlive = 0x0020,
/// <summary> /// <summary>
/// All fields are valid. /// All fields are valid.
/// </summary> /// </summary>
All = 0xFFFF All = 0xFFFF
} }
} }

View File

@@ -26,58 +26,58 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// The description of an item sub-condition supported by the server. /// The description of an item sub-condition supported by the server.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeSubCondition : ICloneable public class TsCAeSubCondition : ICloneable
{ {
#region Fields #region Fields
private int severity_ = 1; private int severity_ = 1;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The name assigned to the sub-condition. /// The name assigned to the sub-condition.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// A server-specific expression which defines the sub-state represented by the sub-condition. /// A server-specific expression which defines the sub-state represented by the sub-condition.
/// </summary> /// </summary>
public string Definition { get; set; } public string Definition { get; set; }
/// <summary> /// <summary>
/// The severity of any event notifications generated on behalf of this sub-condition. /// The severity of any event notifications generated on behalf of this sub-condition.
/// </summary> /// </summary>
public int Severity public int Severity
{ {
get => severity_; get => severity_;
set => severity_ = value; set => severity_ = value;
} }
/// <summary> /// <summary>
/// The text string to be included in any event notification generated on behalf of this sub-condition. /// The text string to be included in any event notification generated on behalf of this sub-condition.
/// </summary> /// </summary>
public string Description { get; set; } public string Description { get; set; }
#endregion #endregion
#region Helper Methods #region Helper Methods
/// <summary> /// <summary>
/// Returns a string that represents the current object. /// Returns a string that represents the current object.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string ToString() public override string ToString()
{ {
return Name; return Name;
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a shallow copy of the object. /// Creates a shallow copy of the object.
/// </summary> /// </summary>
public virtual object Clone() { return MemberwiseClone(); } public virtual object Clone() { return MemberwiseClone(); }
#endregion #endregion
} }
} }

View File

@@ -30,230 +30,230 @@ using System.Runtime.Serialization;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// An in-process object which provides access to AE subscription objects. /// An in-process object which provides access to AE subscription objects.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeSubscription : ITsCAeSubscription, ISerializable, ICloneable public class TsCAeSubscription : ITsCAeSubscription, ISerializable, ICloneable
{ {
#region CategoryCollection Class #region CategoryCollection Class
/// <summary> /// <summary>
/// Contains a read-only collection category ids. /// Contains a read-only collection category ids.
/// </summary> /// </summary>
public class CategoryCollection : OpcReadOnlyCollection public class CategoryCollection : OpcReadOnlyCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal CategoryCollection() : base(new int[0]) { } internal CategoryCollection() : base(new int[0]) { }
/// <summary> /// <summary>
/// Creates a collection containing the list of category ids. /// Creates a collection containing the list of category ids.
/// </summary> /// </summary>
internal CategoryCollection(int[] categoryIDs) : base(categoryIDs) { } internal CategoryCollection(int[] categoryIDs) : base(categoryIDs) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new int this[int index] => (int)Array.GetValue(index); public new int this[int index] => (int)Array.GetValue(index);
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new int[] ToArray() public new int[] ToArray()
{ {
return (int[])OpcConvert.Clone(Array); return (int[])OpcConvert.Clone(Array);
} }
#endregion #endregion
} }
#endregion #endregion
#region StringCollection Class #region StringCollection Class
/// <summary> /// <summary>
/// Contains a read-only collection of strings. /// Contains a read-only collection of strings.
/// </summary> /// </summary>
public class StringCollection : OpcReadOnlyCollection public class StringCollection : OpcReadOnlyCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal StringCollection() : base(new string[0]) { } internal StringCollection() : base(new string[0]) { }
/// <summary>
/// Creates a collection containing the specified strings.
/// </summary>
internal StringCollection(string[] strings) : base(strings) { }
#endregion
#region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// Creates a collection containing the specified strings.
/// </summary> /// </summary>
public new string this[int index] => (string)Array.GetValue(index); internal StringCollection(string[] strings) : base(strings) { }
#endregion
#region Public Methods
/// <summary>
/// An indexer for the collection.
/// </summary>
public new string this[int index] => (string)Array.GetValue(index);
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new string[] ToArray() public new string[] ToArray()
{ {
return (string[])OpcConvert.Clone(Array); return (string[])OpcConvert.Clone(Array);
} }
#endregion #endregion
} }
#endregion #endregion
#region AttributeDictionary Class #region AttributeDictionary Class
/// <summary> /// <summary>
/// Contains a read-only dictionary of attribute lists indexed by category id. /// Contains a read-only dictionary of attribute lists indexed by category id.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class AttributeDictionary : OpcReadOnlyDictionary public class AttributeDictionary : OpcReadOnlyDictionary
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal AttributeDictionary() : base(null) { } internal AttributeDictionary() : base(null) { }
/// <summary> /// <summary>
/// Constructs an dictionary from a set of category ids. /// Constructs an dictionary from a set of category ids.
/// </summary> /// </summary>
internal AttributeDictionary(Hashtable dictionary) : base(dictionary) { } internal AttributeDictionary(Hashtable dictionary) : base(dictionary) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Gets or sets the attribute collection for the specified category. /// Gets or sets the attribute collection for the specified category.
/// </summary> /// </summary>
public AttributeCollection this[int categoryId] => (AttributeCollection)base[categoryId]; public AttributeCollection this[int categoryId] => (AttributeCollection)base[categoryId];
/// <summary> /// <summary>
/// Adds or replaces the set of attributes associated with the category. /// Adds or replaces the set of attributes associated with the category.
/// </summary> /// </summary>
internal void Update(int categoryId, int[] attributeIDs) internal void Update(int categoryId, int[] attributeIDs)
{ {
Dictionary[categoryId] = new AttributeCollection(attributeIDs); Dictionary[categoryId] = new AttributeCollection(attributeIDs);
} }
#endregion #endregion
#region ISerializable Members #region ISerializable Members
/// <summary> /// <summary>
/// Constructs an object by deserializing it from a stream. /// Constructs an object by deserializing it from a stream.
/// </summary> /// </summary>
protected AttributeDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { } protected AttributeDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endregion #endregion
} }
#endregion #endregion
#region AttributeCollection Class #region AttributeCollection Class
/// <summary> /// <summary>
/// Contains a read-only collection attribute ids. /// Contains a read-only collection attribute ids.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class AttributeCollection : OpcReadOnlyCollection public class AttributeCollection : OpcReadOnlyCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal AttributeCollection() : base(new int[0]) { } internal AttributeCollection() : base(new int[0]) { }
/// <summary> /// <summary>
/// Creates a collection containing the specified attribute ids. /// Creates a collection containing the specified attribute ids.
/// </summary> /// </summary>
internal AttributeCollection(int[] attributeIDs) : base(attributeIDs) { } internal AttributeCollection(int[] attributeIDs) : base(attributeIDs) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new int this[int index] => (int)Array.GetValue(index); public new int this[int index] => (int)Array.GetValue(index);
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new int[] ToArray() public new int[] ToArray()
{ {
return (int[])OpcConvert.Clone(Array); return (int[])OpcConvert.Clone(Array);
} }
#endregion #endregion
#region ISerializable Members #region ISerializable Members
/// <summary> /// <summary>
/// Constructs an object by deserializing it from a stream. /// Constructs an object by deserializing it from a stream.
/// </summary> /// </summary>
protected AttributeCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } protected AttributeCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endregion #endregion
} }
#endregion
#region Names Class
/// <summary>
/// A set of names for fields used in serialization.
/// </summary>
private class Names
{
internal const string State = "ST";
internal const string Filters = "FT";
internal const string Attributes = "AT";
}
#endregion #endregion
#region Fields #region Names Class
/// <summary>
/// A set of names for fields used in serialization.
/// </summary>
private class Names
{
internal const string State = "ST";
internal const string Filters = "FT";
internal const string Attributes = "AT";
}
#endregion
#region Fields
private bool disposed_; private bool disposed_;
private TsCAeServer server_; private TsCAeServer server_;
private ITsCAeSubscription subscription_; private ITsCAeSubscription subscription_;
// state // state
private TsCAeSubscriptionState state_; private TsCAeSubscriptionState state_;
private string name_; private string name_;
// filters // filters
private TsCAeSubscriptionFilters subscriptionFilters_ = new TsCAeSubscriptionFilters(); private TsCAeSubscriptionFilters subscriptionFilters_ = new TsCAeSubscriptionFilters();
private CategoryCollection categories_ = new CategoryCollection(); private CategoryCollection categories_ = new CategoryCollection();
private StringCollection areas_ = new StringCollection(); private StringCollection areas_ = new StringCollection();
private StringCollection sources_ = new StringCollection(); private StringCollection sources_ = new StringCollection();
// returned attributes // returned attributes
private AttributeDictionary attributes_ = new AttributeDictionary(); private AttributeDictionary attributes_ = new AttributeDictionary();
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes object with default values. /// Initializes object with default values.
/// </summary> /// </summary>
public TsCAeSubscription(TsCAeServer server, ITsCAeSubscription subscription, TsCAeSubscriptionState state) public TsCAeSubscription(TsCAeServer server, ITsCAeSubscription subscription, TsCAeSubscriptionState state)
{ {
server_ = server ?? throw new ArgumentNullException(nameof(server)); server_ = server ?? throw new ArgumentNullException(nameof(server));
subscription_ = subscription ?? throw new ArgumentNullException(nameof(subscription)); subscription_ = subscription ?? throw new ArgumentNullException(nameof(subscription));
state_ = (TsCAeSubscriptionState)state.Clone(); state_ = (TsCAeSubscriptionState)state.Clone();
name_ = state.Name; name_ = state.Name;
} }
/// <summary> /// <summary>
/// The finalizer implementation. /// The finalizer implementation.
/// </summary> /// </summary>
~TsCAeSubscription() ~TsCAeSubscription()
{ {
Dispose(false); Dispose(false);
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
Dispose(true); Dispose(true);
// Take yourself off the Finalization queue // Take yourself off the Finalization queue
// to prevent finalization code for this object // to prevent finalization code for this object
// from executing a second time. // from executing a second time.
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary> /// <summary>
/// Dispose(bool disposing) executes in two distinct scenarios. /// Dispose(bool disposing) executes in two distinct scenarios.
@@ -266,34 +266,34 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// </summary> /// </summary>
/// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param> /// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
// Check to see if Dispose has already been called. // Check to see if Dispose has already been called.
if(!disposed_) if (!disposed_)
{ {
// If disposing equals true, dispose all managed // If disposing equals true, dispose all managed
// and unmanaged resources. // and unmanaged resources.
if(disposing) if (disposing)
{ {
if (subscription_ != null) if (subscription_ != null)
{ {
server_.SubscriptionDisposed(this); server_.SubscriptionDisposed(this);
subscription_.Dispose(); subscription_.Dispose();
} }
} }
// Release unmanaged resources. If disposing is false, // Release unmanaged resources. If disposing is false,
// only the following code is executed. // only the following code is executed.
} }
disposed_ = true; disposed_ = true;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The server that the subscription object belongs to. /// The server that the subscription object belongs to.
/// </summary> /// </summary>
public TsCAeServer Server => server_; public TsCAeServer Server => server_;
/// <summary> /// <summary>
/// A descriptive name for the subscription. /// A descriptive name for the subscription.
@@ -365,19 +365,19 @@ namespace Technosoftware.DaAeHdaClient.Ae
public AttributeDictionary Attributes => attributes_; public AttributeDictionary Attributes => attributes_;
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Returns a writable copy of the current attributes. /// Returns a writable copy of the current attributes.
/// </summary> /// </summary>
public TsCAeAttributeDictionary GetAttributes() public TsCAeAttributeDictionary GetAttributes()
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
var attributes = new TsCAeAttributeDictionary(); var attributes = new TsCAeAttributeDictionary();
var enumerator = attributes_.GetEnumerator(); var enumerator = attributes_.GetEnumerator();
while (enumerator.MoveNext()) while (enumerator.MoveNext())
{ {
if (enumerator.Key != null) if (enumerator.Key != null)
{ {
var categoryId = (int)enumerator.Key; var categoryId = (int)enumerator.Key;
@@ -387,48 +387,48 @@ namespace Technosoftware.DaAeHdaClient.Ae
} }
} }
return attributes; return attributes;
} }
#endregion #endregion
#region ISerializable Members #region ISerializable Members
/// <summary> /// <summary>
/// Constructs a server by de-serializing its OpcUrl from the stream. /// Constructs a server by de-serializing its OpcUrl from the stream.
/// </summary> /// </summary>
protected TsCAeSubscription(SerializationInfo info, StreamingContext context) protected TsCAeSubscription(SerializationInfo info, StreamingContext context)
{ {
state_ = (TsCAeSubscriptionState)info.GetValue(Names.State, typeof(TsCAeSubscriptionState)); state_ = (TsCAeSubscriptionState)info.GetValue(Names.State, typeof(TsCAeSubscriptionState));
subscriptionFilters_ = (TsCAeSubscriptionFilters)info.GetValue(Names.Filters, typeof(TsCAeSubscriptionFilters)); subscriptionFilters_ = (TsCAeSubscriptionFilters)info.GetValue(Names.Filters, typeof(TsCAeSubscriptionFilters));
attributes_ = (AttributeDictionary)info.GetValue(Names.Attributes, typeof(AttributeDictionary)); attributes_ = (AttributeDictionary)info.GetValue(Names.Attributes, typeof(AttributeDictionary));
name_ = state_.Name; name_ = state_.Name;
categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray()); categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray());
areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray()); areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray());
sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray()); sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray());
} }
/// <summary> /// <summary>
/// Serializes a server into a stream. /// Serializes a server into a stream.
/// </summary> /// </summary>
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.AddValue(Names.State, state_); info.AddValue(Names.State, state_);
info.AddValue(Names.Filters, subscriptionFilters_); info.AddValue(Names.Filters, subscriptionFilters_);
info.AddValue(Names.Attributes, attributes_); info.AddValue(Names.Attributes, attributes_);
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Returns an unconnected copy of the subscription with the same items. /// Returns an unconnected copy of the subscription with the same items.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
// do a memberwise clone. // do a memberwise clone.
var clone = (TsCAeSubscription)MemberwiseClone(); var clone = (TsCAeSubscription)MemberwiseClone();
/* /*
// place clone in disconnected state. // place clone in disconnected state.
clone.server = null; clone.server = null;
clone.subscription = null; clone.subscription = null;
@@ -454,12 +454,12 @@ namespace Technosoftware.DaAeHdaClient.Ae
} }
*/ */
// return clone. // return clone.
return clone; return clone;
} }
#endregion #endregion
#region ISubscription Members #region ISubscription Members
/// <summary> /// <summary>
/// An event to receive data change updates. /// An event to receive data change updates.
/// </summary> /// </summary>
@@ -469,136 +469,136 @@ namespace Technosoftware.DaAeHdaClient.Ae
remove => subscription_.DataChangedEvent -= value; remove => subscription_.DataChangedEvent -= value;
} }
/// <summary> /// <summary>
/// Returns the current state of the subscription. /// Returns the current state of the subscription.
/// </summary> /// </summary>
/// <returns>The current state of the subscription.</returns> /// <returns>The current state of the subscription.</returns>
public TsCAeSubscriptionState GetState() public TsCAeSubscriptionState GetState()
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
state_ = subscription_.GetState(); state_ = subscription_.GetState();
state_.Name = name_; state_.Name = name_;
return (TsCAeSubscriptionState)state_.Clone(); return (TsCAeSubscriptionState)state_.Clone();
} }
/// <summary> /// <summary>
/// Changes the state of a subscription. /// Changes the state of a subscription.
/// </summary> /// </summary>
/// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param> /// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
/// <param name="state">The new subscription state.</param> /// <param name="state">The new subscription state.</param>
/// <returns>The actual subscription state after applying the changes.</returns> /// <returns>The actual subscription state after applying the changes.</returns>
public TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state) public TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state)
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
state_ = subscription_.ModifyState(masks, state); state_ = subscription_.ModifyState(masks, state);
if ((masks & (int)TsCAeStateMask.Name) != 0) if ((masks & (int)TsCAeStateMask.Name) != 0)
{ {
state_.Name = name_ = state.Name; state_.Name = name_ = state.Name;
} }
else else
{ {
state_.Name = name_; state_.Name = name_;
} }
return (TsCAeSubscriptionState)state_.Clone(); return (TsCAeSubscriptionState)state_.Clone();
} }
/// <summary> /// <summary>
/// Returns the current filters for the subscription. /// Returns the current filters for the subscription.
/// </summary> /// </summary>
/// <returns>The current filters for the subscription.</returns> /// <returns>The current filters for the subscription.</returns>
public TsCAeSubscriptionFilters GetFilters() public TsCAeSubscriptionFilters GetFilters()
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
subscriptionFilters_ = subscription_.GetFilters(); subscriptionFilters_ = subscription_.GetFilters();
categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray()); categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray());
areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray()); areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray());
sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray()); sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray());
return (TsCAeSubscriptionFilters)subscriptionFilters_.Clone(); return (TsCAeSubscriptionFilters)subscriptionFilters_.Clone();
} }
/// <summary> /// <summary>
/// Sets the current filters for the subscription. /// Sets the current filters for the subscription.
/// </summary> /// </summary>
/// <param name="filters">The new filters to use for the subscription.</param> /// <param name="filters">The new filters to use for the subscription.</param>
public void SetFilters(TsCAeSubscriptionFilters filters) public void SetFilters(TsCAeSubscriptionFilters filters)
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
subscription_.SetFilters(filters); subscription_.SetFilters(filters);
GetFilters(); GetFilters();
} }
/// <summary> /// <summary>
/// Returns the set of attributes to return with event notifications. /// Returns the set of attributes to return with event notifications.
/// </summary> /// </summary>
/// <returns>The set of attributes to returned with event notifications.</returns> /// <returns>The set of attributes to returned with event notifications.</returns>
public int[] GetReturnedAttributes(int eventCategory) public int[] GetReturnedAttributes(int eventCategory)
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
var attributeIDs = subscription_.GetReturnedAttributes(eventCategory); var attributeIDs = subscription_.GetReturnedAttributes(eventCategory);
attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs)); attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs));
return attributeIDs; return attributeIDs;
} }
/// <summary> /// <summary>
/// Selects the set of attributes to return with event notifications. /// Selects the set of attributes to return with event notifications.
/// </summary> /// </summary>
/// <param name="eventCategory">The specific event category for which the attributes apply.</param> /// <param name="eventCategory">The specific event category for which the attributes apply.</param>
/// <param name="attributeIDs">The list of attribute ids to return.</param> /// <param name="attributeIDs">The list of attribute ids to return.</param>
public void SelectReturnedAttributes(int eventCategory, int[] attributeIDs) public void SelectReturnedAttributes(int eventCategory, int[] attributeIDs)
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
subscription_.SelectReturnedAttributes(eventCategory, attributeIDs); subscription_.SelectReturnedAttributes(eventCategory, attributeIDs);
attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs)); attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs));
} }
/// <summary> /// <summary>
/// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription. /// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription.
/// </summary> /// </summary>
public void Refresh() public void Refresh()
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
subscription_.Refresh(); subscription_.Refresh();
} }
/// <summary> /// <summary>
/// Cancels an outstanding refresh request. /// Cancels an outstanding refresh request.
/// </summary> /// </summary>
public void CancelRefresh() public void CancelRefresh()
{ {
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
if (subscription_ == null) throw new NotConnectedException(); if (subscription_ == null) throw new NotConnectedException();
subscription_.CancelRefresh(); subscription_.CancelRefresh();
} }
#endregion #endregion
#region Internal Properties #region Internal Properties
/// <summary> /// <summary>
/// The current state. /// The current state.
/// </summary> /// </summary>
internal TsCAeSubscriptionState State => state_; internal TsCAeSubscriptionState State => state_;
/// <summary> /// <summary>
/// The current filters. /// The current filters.
@@ -606,5 +606,5 @@ namespace Technosoftware.DaAeHdaClient.Ae
internal TsCAeSubscriptionFilters Filters => subscriptionFilters_; internal TsCAeSubscriptionFilters Filters => subscriptionFilters_;
#endregion #endregion
} }
} }

View File

@@ -27,165 +27,165 @@ using System.Runtime.Serialization;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Describes the event filters for a subscription. /// Describes the event filters for a subscription.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeSubscriptionFilters : ICloneable, ISerializable public class TsCAeSubscriptionFilters : ICloneable, ISerializable
{ {
#region CategoryCollection Class #region CategoryCollection Class
/// <summary> /// <summary>
/// Contains a writable collection category ids. /// Contains a writable collection category ids.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class CategoryCollection : OpcWriteableCollection public class CategoryCollection : OpcWriteableCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary>
/// Creates an empty collection.
/// </summary>
internal CategoryCollection() : base(null, typeof(int)) { }
#region ISerializable Members
/// <summary> /// <summary>
/// Constructs an object by deserializing it from a stream. /// Creates an empty collection.
/// </summary> /// </summary>
protected CategoryCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } internal CategoryCollection() : base(null, typeof(int)) { }
#region ISerializable Members
/// <summary>
/// Constructs an object by deserializing it from a stream.
/// </summary>
protected CategoryCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endregion #endregion
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new int this[int index] => (int)Array[index]; public new int this[int index] => (int)Array[index];
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new int[] ToArray() public new int[] ToArray()
{ {
return (int[])Array.ToArray(typeof(int)); return (int[])Array.ToArray(typeof(int));
} }
#endregion #endregion
} }
#endregion #endregion
#region StringCollection Class #region StringCollection Class
/// <summary> /// <summary>
/// Contains a writable collection of strings. /// Contains a writable collection of strings.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class StringCollection : OpcWriteableCollection public class StringCollection : OpcWriteableCollection
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Creates an empty collection. /// Creates an empty collection.
/// </summary> /// </summary>
internal StringCollection() : base(null, typeof(string)) { } internal StringCollection() : base(null, typeof(string)) { }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// An indexer for the collection. /// An indexer for the collection.
/// </summary> /// </summary>
public new string this[int index] => (string)Array[index]; public new string this[int index] => (string)Array[index];
/// <summary> /// <summary>
/// Returns a copy of the collection as an array. /// Returns a copy of the collection as an array.
/// </summary> /// </summary>
public new string[] ToArray() public new string[] ToArray()
{ {
return (string[])Array.ToArray(typeof(string)); return (string[])Array.ToArray(typeof(string));
} }
#endregion #endregion
#region ISerializable Members #region ISerializable Members
/// <summary> /// <summary>
/// Constructs an object by deserializing it from a stream. /// Constructs an object by deserializing it from a stream.
/// </summary> /// </summary>
protected StringCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } protected StringCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endregion #endregion
} }
#endregion #endregion
#region Names Class #region Names Class
/// <summary>
/// A set of names for fields used in serialization.
/// </summary>
private class Names
{
internal const string EventTypes = "ET";
internal const string Categories = "CT";
internal const string HighSeverity = "HS";
internal const string LowSeverity = "LS";
internal const string Areas = "AR";
internal const string Sources = "SR";
}
#endregion
#region Fields
private int eventTypes_ = (int)TsCAeEventType.All;
private CategoryCollection categories_ = new CategoryCollection();
private int highSeverity_ = 1000;
private int lowSeverity_ = 1;
private StringCollection areas_ = new StringCollection();
private StringCollection sources_ = new StringCollection();
#endregion
#region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes object with default values. /// A set of names for fields used in serialization.
/// </summary> /// </summary>
public TsCAeSubscriptionFilters() { } private class Names
{
/// <summary> internal const string EventTypes = "ET";
/// Constructs a server by de-serializing its OpcUrl from the stream. internal const string Categories = "CT";
/// </summary> internal const string HighSeverity = "HS";
protected TsCAeSubscriptionFilters(SerializationInfo info, StreamingContext context) internal const string LowSeverity = "LS";
{ internal const string Areas = "AR";
eventTypes_ = (int)info.GetValue(Names.EventTypes, typeof(int)); internal const string Sources = "SR";
categories_ = (CategoryCollection)info.GetValue(Names.Categories, typeof(CategoryCollection)); }
highSeverity_ = (int)info.GetValue(Names.HighSeverity, typeof(int));
lowSeverity_ = (int)info.GetValue(Names.LowSeverity, typeof(int));
areas_ = (StringCollection)info.GetValue(Names.Areas, typeof(StringCollection));
sources_ = (StringCollection)info.GetValue(Names.Sources, typeof(StringCollection));
}
#endregion #endregion
#region Properties #region Fields
/// <summary> private int eventTypes_ = (int)TsCAeEventType.All;
/// A mask indicating which event types should be sent to the client. private CategoryCollection categories_ = new CategoryCollection();
/// </summary> private int highSeverity_ = 1000;
public int EventTypes private int lowSeverity_ = 1;
{ private StringCollection areas_ = new StringCollection();
get => eventTypes_; private StringCollection sources_ = new StringCollection();
#endregion
#region Constructors, Destructor, Initialization
/// <summary>
/// Initializes object with default values.
/// </summary>
public TsCAeSubscriptionFilters() { }
/// <summary>
/// Constructs a server by de-serializing its OpcUrl from the stream.
/// </summary>
protected TsCAeSubscriptionFilters(SerializationInfo info, StreamingContext context)
{
eventTypes_ = (int)info.GetValue(Names.EventTypes, typeof(int));
categories_ = (CategoryCollection)info.GetValue(Names.Categories, typeof(CategoryCollection));
highSeverity_ = (int)info.GetValue(Names.HighSeverity, typeof(int));
lowSeverity_ = (int)info.GetValue(Names.LowSeverity, typeof(int));
areas_ = (StringCollection)info.GetValue(Names.Areas, typeof(StringCollection));
sources_ = (StringCollection)info.GetValue(Names.Sources, typeof(StringCollection));
}
#endregion
#region Properties
/// <summary>
/// A mask indicating which event types should be sent to the client.
/// </summary>
public int EventTypes
{
get => eventTypes_;
set => eventTypes_ = value; set => eventTypes_ = value;
} }
/// <summary> /// <summary>
/// The highest severity for the events that should be sent to the client. /// The highest severity for the events that should be sent to the client.
/// </summary> /// </summary>
public int HighSeverity public int HighSeverity
{ {
get => highSeverity_; get => highSeverity_;
set => highSeverity_ = value; set => highSeverity_ = value;
} }
/// <summary> /// <summary>
/// The lowest severity for the events that should be sent to the client. /// The lowest severity for the events that should be sent to the client.
/// </summary> /// </summary>
public int LowSeverity public int LowSeverity
{ {
get => lowSeverity_; get => lowSeverity_;
set => lowSeverity_ = value; set => lowSeverity_ = value;
} }
/// <summary> /// <summary>
/// The category ids for the events that should be sent to the client. /// The category ids for the events that should be sent to the client.
/// </summary> /// </summary>
public CategoryCollection Categories => categories_; public CategoryCollection Categories => categories_;
/// <summary> /// <summary>
/// A list of full-qualified ids for process areas of interest - only events or conditions in these areas will be reported. /// A list of full-qualified ids for process areas of interest - only events or conditions in these areas will be reported.
@@ -198,35 +198,35 @@ namespace Technosoftware.DaAeHdaClient.Ae
public StringCollection Sources => sources_; public StringCollection Sources => sources_;
#endregion #endregion
#region ISerializable Members #region ISerializable Members
/// <summary> /// <summary>
/// Serializes a server into a stream. /// Serializes a server into a stream.
/// </summary> /// </summary>
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.AddValue(Names.EventTypes, eventTypes_); info.AddValue(Names.EventTypes, eventTypes_);
info.AddValue(Names.Categories, categories_); info.AddValue(Names.Categories, categories_);
info.AddValue(Names.HighSeverity, highSeverity_); info.AddValue(Names.HighSeverity, highSeverity_);
info.AddValue(Names.LowSeverity, lowSeverity_); info.AddValue(Names.LowSeverity, lowSeverity_);
info.AddValue(Names.Areas, areas_); info.AddValue(Names.Areas, areas_);
info.AddValue(Names.Sources, sources_); info.AddValue(Names.Sources, sources_);
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
var filters = (TsCAeSubscriptionFilters)MemberwiseClone(); var filters = (TsCAeSubscriptionFilters)MemberwiseClone();
filters.categories_ = (CategoryCollection)categories_.Clone(); filters.categories_ = (CategoryCollection)categories_.Clone();
filters.areas_ = (StringCollection)areas_.Clone(); filters.areas_ = (StringCollection)areas_.Clone();
filters.sources_ = (StringCollection)sources_.Clone(); filters.sources_ = (StringCollection)sources_.Clone();
return filters; return filters;
} }
#endregion #endregion
} }
} }

View File

@@ -26,63 +26,63 @@ using System;
namespace Technosoftware.DaAeHdaClient.Ae namespace Technosoftware.DaAeHdaClient.Ae
{ {
/// <summary> /// <summary>
/// Describes the state of a subscription. /// Describes the state of a subscription.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCAeSubscriptionState : ICloneable public class TsCAeSubscriptionState : ICloneable
{ {
#region Fields #region Fields
private bool active_ = true; private bool active_ = true;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// A descriptive name for the subscription. /// A descriptive name for the subscription.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// A unique identifier for the subscription assigned by the client. /// A unique identifier for the subscription assigned by the client.
/// </summary> /// </summary>
public object ClientHandle { get; set; } public object ClientHandle { get; set; }
/// <summary> /// <summary>
/// Whether the subscription is monitoring for events to send to the client. /// Whether the subscription is monitoring for events to send to the client.
/// </summary> /// </summary>
public bool Active public bool Active
{ {
get => active_; get => active_;
set => active_ = value; set => active_ = value;
} }
/// <summary>
/// The maximum rate at which the server send event notifications.
/// </summary>
public int BufferTime { get; set; }
/// <summary>
/// The requested maximum number of events that will be sent in a single callback.
/// </summary>
public int MaxSize { get; set; }
/// <summary>
/// The maximum period between updates sent to the client.
/// </summary>
public int KeepAlive { get; set; }
#endregion
#region ICloneable Members
/// <summary> /// <summary>
/// Creates a shallow copy of the object. /// The maximum rate at which the server send event notifications.
/// </summary> /// </summary>
public virtual object Clone() public int BufferTime { get; set; }
{
return MemberwiseClone(); /// <summary>
} /// The requested maximum number of events that will be sent in a single callback.
/// </summary>
public int MaxSize { get; set; }
/// <summary>
/// The maximum period between updates sent to the client.
/// </summary>
public int KeepAlive { get; set; }
#endregion #endregion
}
#region ICloneable Members
/// <summary>
/// Creates a shallow copy of the object.
/// </summary>
public virtual object Clone()
{
return MemberwiseClone();
}
#endregion
}
} }

View File

@@ -21,7 +21,6 @@
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved #endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
#region Using Directives #region Using Directives
using System;
using Technosoftware.DaAeHdaClient.Utilities; using Technosoftware.DaAeHdaClient.Utilities;
#endregion #endregion

File diff suppressed because it is too large Load Diff

View File

@@ -29,179 +29,179 @@ using Technosoftware.DaAeHdaClient.Da;
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// A class that caches properties of complex data items. /// A class that caches properties of complex data items.
/// </summary> /// </summary>
public class TsCCpxComplexTypeCache public class TsCCpxComplexTypeCache
{ {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#region Fields #region Fields
/// <summary> /// <summary>
/// The active server for the application. /// The active server for the application.
/// </summary> /// </summary>
private static TsCDaServer _server; private static TsCDaServer _server;
/// <summary> /// <summary>
/// A cache of item properties fetched from the active server. /// A cache of item properties fetched from the active server.
/// </summary> /// </summary>
private static Hashtable _items = new Hashtable(); private static Hashtable _items = new Hashtable();
/// <summary> /// <summary>
/// A cache of type dictionaries fetched from the active server. /// A cache of type dictionaries fetched from the active server.
/// </summary> /// </summary>
private static Hashtable _dictionaries = new Hashtable(); private static Hashtable _dictionaries = new Hashtable();
/// <summary> /// <summary>
/// A cache of type descriptions fetched from the active server. /// A cache of type descriptions fetched from the active server.
/// </summary> /// </summary>
private static Hashtable _descriptions = new Hashtable(); private static Hashtable _descriptions = new Hashtable();
#endregion #endregion
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary>
/// Initializes the complex type cache with defaults.
/// </summary>
public TsCCpxComplexTypeCache() { }
#endregion /// <summary>
/// Initializes the complex type cache with defaults.
/// </summary>
public TsCCpxComplexTypeCache() { }
/////////////////////////////////////////////////////////////////////// #endregion
#region Properties
/// <summary> ///////////////////////////////////////////////////////////////////////
/// Get or sets the server to use for the cache. #region Properties
/// </summary>
public static TsCDaServer Server
{
get
{
lock (typeof(TsCCpxComplexTypeCache))
{
return _server;
}
}
set /// <summary>
{ /// Get or sets the server to use for the cache.
lock (typeof(TsCCpxComplexTypeCache)) /// </summary>
{ public static TsCDaServer Server
_server = value; {
_items.Clear(); get
_dictionaries.Clear(); {
_descriptions.Clear(); lock (typeof(TsCCpxComplexTypeCache))
} {
} return _server;
} }
}
#endregion set
{
lock (typeof(TsCCpxComplexTypeCache))
{
_server = value;
_items.Clear();
_dictionaries.Clear();
_descriptions.Clear();
}
}
}
/////////////////////////////////////////////////////////////////////// #endregion
#region Public Methods
/// <summary> ///////////////////////////////////////////////////////////////////////
/// Returns the complex item for the specified item id. #region Public Methods
/// </summary>
/// <param name="itemID">The item id.</param>
public static TsCCpxComplexItem GetComplexItem(OpcItem itemID)
{
if (itemID == null) return null;
lock (typeof(TsCCpxComplexTypeCache)) /// <summary>
{ /// Returns the complex item for the specified item id.
var item = new TsCCpxComplexItem(itemID); /// </summary>
/// <param name="itemID">The item id.</param>
public static TsCCpxComplexItem GetComplexItem(OpcItem itemID)
{
if (itemID == null) return null;
try lock (typeof(TsCCpxComplexTypeCache))
{ {
item.Update(_server); var item = new TsCCpxComplexItem(itemID);
}
catch
{
// item is not a valid complex data item.
item = null;
}
_items[itemID.Key] = item; try
return item; {
} item.Update(_server);
} }
catch
{
// item is not a valid complex data item.
item = null;
}
/// <summary> _items[itemID.Key] = item;
/// Returns the complex item for the specified item browse element. return item;
/// </summary> }
/// <param name="element">The item browse element.</param> }
public static TsCCpxComplexItem GetComplexItem(TsCDaBrowseElement element)
{
if (element == null) return null;
lock (typeof(TsCCpxComplexTypeCache)) /// <summary>
{ /// Returns the complex item for the specified item browse element.
return GetComplexItem(new OpcItem(element.ItemPath, element.ItemName)); /// </summary>
} /// <param name="element">The item browse element.</param>
} public static TsCCpxComplexItem GetComplexItem(TsCDaBrowseElement element)
{
if (element == null) return null;
/// <summary> lock (typeof(TsCCpxComplexTypeCache))
/// Fetches the type dictionary for the item. {
/// </summary> return GetComplexItem(new OpcItem(element.ItemPath, element.ItemName));
/// <param name="itemID">The item id.</param> }
public static string GetTypeDictionary(OpcItem itemID) }
{
if (itemID == null) return null;
lock (typeof(TsCCpxComplexTypeCache)) /// <summary>
{ /// Fetches the type dictionary for the item.
var dictionary = (string)_dictionaries[itemID.Key]; /// </summary>
/// <param name="itemID">The item id.</param>
public static string GetTypeDictionary(OpcItem itemID)
{
if (itemID == null) return null;
if (dictionary != null) lock (typeof(TsCCpxComplexTypeCache))
{ {
return dictionary; var dictionary = (string)_dictionaries[itemID.Key];
}
var item = GetComplexItem(itemID); if (dictionary != null)
{
return dictionary;
}
if (item != null) var item = GetComplexItem(itemID);
{
dictionary = item.GetTypeDictionary(_server);
}
return dictionary; if (item != null)
} {
} dictionary = item.GetTypeDictionary(_server);
}
/// <summary> return dictionary;
/// Fetches the type description for the item. }
/// </summary> }
/// <param name="itemID">The item id.</param>
public static string GetTypeDescription(OpcItem itemID)
{
if (itemID == null) return null;
lock (typeof(TsCCpxComplexTypeCache)) /// <summary>
{ /// Fetches the type description for the item.
string description = null; /// </summary>
/// <param name="itemID">The item id.</param>
public static string GetTypeDescription(OpcItem itemID)
{
if (itemID == null) return null;
var item = GetComplexItem(itemID); lock (typeof(TsCCpxComplexTypeCache))
{
string description = null;
if (item != null) var item = GetComplexItem(itemID);
{
description = (string)_descriptions[item.TypeItemID.Key];
if (description != null) if (item != null)
{ {
return description; description = (string)_descriptions[item.TypeItemID.Key];
}
_descriptions[item.TypeItemID.Key] = description = item.GetTypeDescription(_server); if (description != null)
} {
return description;
}
return description; _descriptions[item.TypeItemID.Key] = description = item.GetTypeDescription(_server);
} }
}
#endregion return description;
} }
}
#endregion
}
} }

View File

@@ -26,24 +26,24 @@
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// Stores a value with an associated name and/or type. /// Stores a value with an associated name and/or type.
/// </summary> /// </summary>
public class TsCCpxComplexValue public class TsCCpxComplexValue
{ {
/// <summary> /// <summary>
/// The name of the value. /// The name of the value.
/// </summary> /// </summary>
public string Name; public string Name;
/// <summary> /// <summary>
/// The complex or simple data type of the value. /// The complex or simple data type of the value.
/// </summary> /// </summary>
public string Type; public string Type;
/// <summary> /// <summary>
/// The actual value. /// The actual value.
/// </summary> /// </summary>
public object Value; public object Value;
} }
} }

View File

@@ -26,46 +26,46 @@
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// Stores the current serialization context. /// Stores the current serialization context.
/// </summary> /// </summary>
internal struct TsCCpxContext internal struct TsCCpxContext
{ {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
public TsCCpxContext(byte[] buffer) public TsCCpxContext(byte[] buffer)
{ {
Buffer = buffer; Buffer = buffer;
Index = 0; Index = 0;
Dictionary = null; Dictionary = null;
Type = null; Type = null;
BigEndian = false; BigEndian = false;
CharWidth = 2; CharWidth = 2;
StringEncoding = STRING_ENCODING_UCS2; StringEncoding = STRING_ENCODING_UCS2;
FloatFormat = FLOAT_FORMAT_IEEE754; FloatFormat = FLOAT_FORMAT_IEEE754;
} }
#endregion #endregion
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#region Public Fields #region Public Fields
public byte[] Buffer; public byte[] Buffer;
public int Index; public int Index;
public TypeDictionary Dictionary; public TypeDictionary Dictionary;
public TypeDescription Type; public TypeDescription Type;
public bool BigEndian; public bool BigEndian;
public int CharWidth; public int CharWidth;
public string StringEncoding; public string StringEncoding;
public string FloatFormat; public string FloatFormat;
public const string STRING_ENCODING_ACSII = "ASCII"; public const string STRING_ENCODING_ACSII = "ASCII";
public const string STRING_ENCODING_UCS2 = "UCS-2"; public const string STRING_ENCODING_UCS2 = "UCS-2";
public const string FLOAT_FORMAT_IEEE754 = "IEEE-754"; public const string FLOAT_FORMAT_IEEE754 = "IEEE-754";
#endregion #endregion
} }
} }

View File

@@ -27,22 +27,22 @@ using System.Runtime.Serialization;
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// Raised if the data in buffer is not consistent with the schema. /// Raised if the data in buffer is not consistent with the schema.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCCpxInvalidDataInBufferException : ApplicationException public class TsCCpxInvalidDataInBufferException : ApplicationException
{ {
private const string Default = "The data in the buffer cannot be read because it is not consistent with the schema."; private const string Default = "The data in the buffer cannot be read because it is not consistent with the schema.";
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataInBufferException() : base(Default) { } public TsCCpxInvalidDataInBufferException() : base(Default) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataInBufferException(string message) : base(Default + Environment.NewLine + message) { } public TsCCpxInvalidDataInBufferException(string message) : base(Default + Environment.NewLine + message) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataInBufferException(Exception e) : base(Default, e) { } public TsCCpxInvalidDataInBufferException(Exception e) : base(Default, e) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataInBufferException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { } public TsCCpxInvalidDataInBufferException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
/// <remarks/> /// <remarks/>
protected TsCCpxInvalidDataInBufferException(SerializationInfo info, StreamingContext context) : base(info, context) { } protected TsCCpxInvalidDataInBufferException(SerializationInfo info, StreamingContext context) : base(info, context) { }
} }
} }

View File

@@ -27,22 +27,22 @@ using System.Runtime.Serialization;
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// Raised if the data in buffer is not consistent with the schema. /// Raised if the data in buffer is not consistent with the schema.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCCpxInvalidDataToWriteException : ApplicationException public class TsCCpxInvalidDataToWriteException : ApplicationException
{ {
private const string Default = "The object cannot be written because it is not consistent with the schema."; private const string Default = "The object cannot be written because it is not consistent with the schema.";
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataToWriteException() : base(Default) { } public TsCCpxInvalidDataToWriteException() : base(Default) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataToWriteException(string message) : base(Default + Environment.NewLine + message) { } public TsCCpxInvalidDataToWriteException(string message) : base(Default + Environment.NewLine + message) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataToWriteException(Exception e) : base(Default, e) { } public TsCCpxInvalidDataToWriteException(Exception e) : base(Default, e) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidDataToWriteException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { } public TsCCpxInvalidDataToWriteException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
/// <remarks/> /// <remarks/>
protected TsCCpxInvalidDataToWriteException(SerializationInfo info, StreamingContext context) : base(info, context) { } protected TsCCpxInvalidDataToWriteException(SerializationInfo info, StreamingContext context) : base(info, context) { }
} }
} }

View File

@@ -27,22 +27,22 @@ using System.Runtime.Serialization;
namespace Technosoftware.DaAeHdaClient.Cpx namespace Technosoftware.DaAeHdaClient.Cpx
{ {
/// <summary> /// <summary>
/// Raised if the schema contains errors or inconsistencies. /// Raised if the schema contains errors or inconsistencies.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCCpxInvalidSchemaException : ApplicationException public class TsCCpxInvalidSchemaException : ApplicationException
{ {
private const string Default = "The schema cannot be used because it contains errors or inconsitencies."; private const string Default = "The schema cannot be used because it contains errors or inconsitencies.";
/// <remarks/> /// <remarks/>
public TsCCpxInvalidSchemaException() : base(Default) { } public TsCCpxInvalidSchemaException() : base(Default) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidSchemaException(string message) : base(Default + Environment.NewLine + message) { } public TsCCpxInvalidSchemaException(string message) : base(Default + Environment.NewLine + message) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidSchemaException(Exception e) : base(Default, e) { } public TsCCpxInvalidSchemaException(Exception e) : base(Default, e) { }
/// <remarks/> /// <remarks/>
public TsCCpxInvalidSchemaException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { } public TsCCpxInvalidSchemaException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
/// <remarks/> /// <remarks/>
protected TsCCpxInvalidSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { } protected TsCCpxInvalidSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { }
} }
} }

View File

@@ -25,21 +25,21 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// <para>Defines possible item access rights.</para> /// <para>Defines possible item access rights.</para>
/// <para align="left">Indicates if this item is read only, write only or read/write. /// <para align="left">Indicates if this item is read only, write only or read/write.
/// This is NOT related to security but rather to the nature of the underlying /// This is NOT related to security but rather to the nature of the underlying
/// hardware.</para> /// hardware.</para>
/// </summary> /// </summary>
public enum TsDaAccessRights public enum TsDaAccessRights
{ {
/// <summary>The access rights for this item are server.</summary> /// <summary>The access rights for this item are server.</summary>
Unknown = 0x00, Unknown = 0x00,
/// <summary>The client can read the data item's value.</summary> /// <summary>The client can read the data item's value.</summary>
Readable = 0x01, Readable = 0x01,
/// <summary>The client can change the data item's value.</summary> /// <summary>The client can change the data item's value.</summary>
Writable = 0x02, Writable = 0x02,
/// <summary>The client can read and change the data item's value.</summary> /// <summary>The client can read and change the data item's value.</summary>
ReadWritable = 0x03 ReadWritable = 0x03
} }
} }

View File

@@ -32,33 +32,33 @@ namespace Technosoftware.DaAeHdaClient.Da
[Serializable] [Serializable]
public class TsCDaBrowsePosition : IOpcBrowsePosition public class TsCDaBrowsePosition : IOpcBrowsePosition
{ {
#region Fields #region Fields
private TsCDaBrowseFilters browseFilters_; private TsCDaBrowseFilters browseFilters_;
private OpcItem itemId_; private OpcItem itemId_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Saves the parameters for an incomplete browse information. /// Saves the parameters for an incomplete browse information.
/// </summary> /// </summary>
public TsCDaBrowsePosition(OpcItem itemId, TsCDaBrowseFilters filters) public TsCDaBrowsePosition(OpcItem itemId, TsCDaBrowseFilters filters)
{ {
if (filters == null) throw new ArgumentNullException(nameof(filters)); if (filters == null) throw new ArgumentNullException(nameof(filters));
itemId_ = (OpcItem)itemId?.Clone(); itemId_ = (OpcItem)itemId?.Clone();
browseFilters_ = (TsCDaBrowseFilters)filters.Clone(); browseFilters_ = (TsCDaBrowseFilters)filters.Clone();
} }
/// <summary> /// <summary>
/// Releases unmanaged resources held by the object. /// Releases unmanaged resources held by the object.
/// </summary> /// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
// does nothing. // does nothing.
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The item identifier of the branch being browsed. /// The item identifier of the branch being browsed.
/// </summary> /// </summary>
@@ -73,21 +73,21 @@ namespace Technosoftware.DaAeHdaClient.Da
/// The maximum number of elements that may be returned in a single browse. /// The maximum number of elements that may be returned in a single browse.
/// </summary> /// </summary>
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Global
public int MaxElementsReturned public int MaxElementsReturned
{ {
get => browseFilters_.MaxElementsReturned; get => browseFilters_.MaxElementsReturned;
set => browseFilters_.MaxElementsReturned = value; set => browseFilters_.MaxElementsReturned = value;
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
return (TsCDaBrowsePosition)MemberwiseClone(); return (TsCDaBrowsePosition)MemberwiseClone();
} }
#endregion #endregion
} }
} }

View File

@@ -26,62 +26,62 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Contains a description of an element in the server address space. /// Contains a description of an element in the server address space.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaBrowseElement : ICloneable public class TsCDaBrowseElement : ICloneable
{ {
#region Fields #region Fields
private TsCDaItemProperty[] itemProperties_ = new TsCDaItemProperty[0]; private TsCDaItemProperty[] itemProperties_ = new TsCDaItemProperty[0];
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// A descriptive name for element that is unique within a branch. /// A descriptive name for element that is unique within a branch.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// The primary identifier for the element within the server namespace. /// The primary identifier for the element within the server namespace.
/// </summary> /// </summary>
public string ItemName { get; set; } public string ItemName { get; set; }
/// <summary> /// <summary>
/// An secondary identifier for the element within the server namespace. /// An secondary identifier for the element within the server namespace.
/// </summary> /// </summary>
public string ItemPath { get; set; } public string ItemPath { get; set; }
/// <summary> /// <summary>
/// Whether the element refers to an item with data that can be accessed. /// Whether the element refers to an item with data that can be accessed.
/// </summary> /// </summary>
public bool IsItem { get; set; } public bool IsItem { get; set; }
/// <summary> /// <summary>
/// Whether the element has children. /// Whether the element has children.
/// </summary> /// </summary>
public bool HasChildren { get; set; } public bool HasChildren { get; set; }
/// <summary> /// <summary>
/// The set of properties for the element. /// The set of properties for the element.
/// </summary> /// </summary>
public TsCDaItemProperty[] Properties public TsCDaItemProperty[] Properties
{ {
get => itemProperties_; get => itemProperties_;
set => itemProperties_ = value; set => itemProperties_ = value;
} }
#endregion
#region ICloneable Members
/// <summary>
/// Creates a deep copy of the object.
/// </summary>
public virtual object Clone()
{
var clone = (TsCDaBrowseElement)MemberwiseClone();
clone.itemProperties_ = (TsCDaItemProperty[])OpcConvert.Clone(itemProperties_);
return clone;
}
#endregion #endregion
};
#region ICloneable Members
/// <summary>
/// Creates a deep copy of the object.
/// </summary>
public virtual object Clone()
{
var clone = (TsCDaBrowseElement)MemberwiseClone();
clone.itemProperties_ = (TsCDaItemProperty[])OpcConvert.Clone(itemProperties_);
return clone;
}
#endregion
};
} }

View File

@@ -25,24 +25,24 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// The type of browse elements to return during a browse. /// The type of browse elements to return during a browse.
/// </summary> /// </summary>
public enum TsCDaBrowseFilter public enum TsCDaBrowseFilter
{ {
/// <summary> /// <summary>
/// Return all types of browse elements. /// Return all types of browse elements.
/// </summary> /// </summary>
All, All,
/// <summary> /// <summary>
/// Return only elements that contain other elements. /// Return only elements that contain other elements.
/// </summary> /// </summary>
Branch, Branch,
/// <summary> /// <summary>
/// Return only elements that represent items. /// Return only elements that represent items.
/// </summary> /// </summary>
Item Item
} }
} }

View File

@@ -26,72 +26,72 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Defines a set of filters to apply when browsing. /// Defines a set of filters to apply when browsing.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaBrowseFilters : ICloneable public class TsCDaBrowseFilters : ICloneable
{ {
#region Fields #region Fields
private TsCDaBrowseFilter browseFilter_ = TsCDaBrowseFilter.All; private TsCDaBrowseFilter browseFilter_ = TsCDaBrowseFilter.All;
private TsDaPropertyID[] propertyIds_; private TsDaPropertyID[] propertyIds_;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The maximum number of elements to return. Zero means no limit. /// The maximum number of elements to return. Zero means no limit.
/// </summary> /// </summary>
public int MaxElementsReturned { get; set; } public int MaxElementsReturned { get; set; }
/// <summary> /// <summary>
/// The type of element to return. /// The type of element to return.
/// </summary> /// </summary>
public TsCDaBrowseFilter BrowseFilter public TsCDaBrowseFilter BrowseFilter
{ {
get => browseFilter_; get => browseFilter_;
set => browseFilter_ = value; set => browseFilter_ = value;
} }
/// <summary> /// <summary>
/// An expression used to match the name of the element. /// An expression used to match the name of the element.
/// </summary> /// </summary>
public string ElementNameFilter { get; set; } public string ElementNameFilter { get; set; }
/// <summary> /// <summary>
/// A filter which has semantics that defined by the server. /// A filter which has semantics that defined by the server.
/// </summary> /// </summary>
public string VendorFilter { get; set; } public string VendorFilter { get; set; }
/// <summary> /// <summary>
/// Whether all supported properties to return with each element. /// Whether all supported properties to return with each element.
/// </summary> /// </summary>
public bool ReturnAllProperties { get; set; } public bool ReturnAllProperties { get; set; }
/// <summary> /// <summary>
/// A list of names of the properties to return with each element. /// A list of names of the properties to return with each element.
/// </summary> /// </summary>
public TsDaPropertyID[] PropertyIDs public TsDaPropertyID[] PropertyIDs
{ {
get => propertyIds_; get => propertyIds_;
set => propertyIds_ = value; set => propertyIds_ = value;
} }
/// <summary> /// <summary>
/// Whether property values should be returned with the properties. /// Whether property values should be returned with the properties.
/// </summary> /// </summary>
public bool ReturnPropertyValues { get; set; } public bool ReturnPropertyValues { get; set; }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
var clone = (TsCDaBrowseFilters)MemberwiseClone(); var clone = (TsCDaBrowseFilters)MemberwiseClone();
clone.PropertyIDs = (TsDaPropertyID[])PropertyIDs?.Clone(); clone.PropertyIDs = (TsDaPropertyID[])PropertyIDs?.Clone();
return clone; return clone;
} }
#endregion #endregion
} }
} }

View File

@@ -25,21 +25,21 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary><para>Defines possible item engineering unit types</para></summary> /// <summary><para>Defines possible item engineering unit types</para></summary>
public enum TsDaEuType public enum TsDaEuType
{ {
/// <summary>No engineering unit information available</summary> /// <summary>No engineering unit information available</summary>
NoEnum = 0x01, NoEnum = 0x01,
/// <summary> /// <summary>
/// Analog engineering unit - will contain a SAFE ARRAY of exactly two doubles /// Analog engineering unit - will contain a SAFE ARRAY of exactly two doubles
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range. /// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
/// </summary> /// </summary>
Analog = 0x02, Analog = 0x02,
/// <summary> /// <summary>
/// Enumerated engineering unit - will contain a SAFE ARRAY of strings (VT_ARRAY | /// Enumerated engineering unit - will contain a SAFE ARRAY of strings (VT_ARRAY |
/// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN TRANSIT”, /// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN TRANSIT”,
/// etc.) corresponding to sequential numeric values (0, 1, 2, etc.) /// etc.) corresponding to sequential numeric values (0, 1, 2, etc.)
/// </summary> /// </summary>
Enumerated = 0x03 Enumerated = 0x03
} }
} }

View File

@@ -25,22 +25,22 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Defines functionality that is common to all OPC Data Access servers. /// Defines functionality that is common to all OPC Data Access servers.
/// </summary> /// </summary>
public interface ITsDaServer : IOpcServer public interface ITsDaServer : IOpcServer
{ {
/// <summary> /// <summary>
/// Returns the filters applied by the server to any item results returned to the client. /// Returns the filters applied by the server to any item results returned to the client.
/// </summary> /// </summary>
/// <returns>A bit mask indicating which fields should be returned in any item results.</returns> /// <returns>A bit mask indicating which fields should be returned in any item results.</returns>
int GetResultFilters(); int GetResultFilters();
/// <summary> /// <summary>
/// Sets the filters applied by the server to any item results returned to the client. /// Sets the filters applied by the server to any item results returned to the client.
/// </summary> /// </summary>
/// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param> /// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param>
void SetResultFilters(int filters); void SetResultFilters(int filters);
/// <summary> /// <summary>
/// Returns the current server status. /// Returns the current server status.
@@ -48,62 +48,62 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <returns>The current server status.</returns> /// <returns>The current server status.</returns>
OpcServerStatus GetServerStatus(); OpcServerStatus GetServerStatus();
/// <summary> /// <summary>
/// Reads the current values for a set of items. /// Reads the current values for a set of items.
/// </summary> /// </summary>
/// <param name="items">The set of items to read.</param> /// <param name="items">The set of items to read.</param>
/// <returns>The results of the read operation for each item.</returns> /// <returns>The results of the read operation for each item.</returns>
TsCDaItemValueResult[] Read(TsCDaItem[] items); TsCDaItemValueResult[] Read(TsCDaItem[] items);
/// <summary> /// <summary>
/// Writes the value, quality and timestamp for a set of items. /// Writes the value, quality and timestamp for a set of items.
/// </summary> /// </summary>
/// <param name="values">The set of item values to write.</param> /// <param name="values">The set of item values to write.</param>
/// <returns>The results of the write operation for each item.</returns> /// <returns>The results of the write operation for each item.</returns>
OpcItemResult[] Write(TsCDaItemValue[] values); OpcItemResult[] Write(TsCDaItemValue[] values);
/// <summary> /// <summary>
/// Creates a new subscription. /// Creates a new subscription.
/// </summary> /// </summary>
/// <param name="state">The initial state of the subscription.</param> /// <param name="state">The initial state of the subscription.</param>
/// <returns>The new subscription object.</returns> /// <returns>The new subscription object.</returns>
ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state); ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state);
/// <summary> /// <summary>
/// Cancels a subscription and releases all resources allocated for it. /// Cancels a subscription and releases all resources allocated for it.
/// </summary> /// </summary>
/// <param name="subscription">The subscription to cancel.</param> /// <param name="subscription">The subscription to cancel.</param>
void CancelSubscription(ITsCDaSubscription subscription); void CancelSubscription(ITsCDaSubscription subscription);
/// <summary> /// <summary>
/// Fetches the children of a branch that meet the filter criteria. /// Fetches the children of a branch that meet the filter criteria.
/// </summary> /// </summary>
/// <param name="itemId">The identifier of branch which is the target of the search.</param> /// <param name="itemId">The identifier of branch which is the target of the search.</param>
/// <param name="filters">The filters to use to limit the set of child elements returned.</param> /// <param name="filters">The filters to use to limit the set of child elements returned.</param>
/// <param name="position">An object used to continue a browse that could not be completed.</param> /// <param name="position">An object used to continue a browse that could not be completed.</param>
/// <returns>The set of elements found.</returns> /// <returns>The set of elements found.</returns>
TsCDaBrowseElement[] Browse( TsCDaBrowseElement[] Browse(
OpcItem itemId, OpcItem itemId,
TsCDaBrowseFilters filters, TsCDaBrowseFilters filters,
out TsCDaBrowsePosition position); out TsCDaBrowsePosition position);
/// <summary> /// <summary>
/// Continues a browse operation with previously specified search criteria. /// Continues a browse operation with previously specified search criteria.
/// </summary> /// </summary>
/// <param name="position">An object containing the browse operation state information.</param> /// <param name="position">An object containing the browse operation state information.</param>
/// <returns>The set of elements found.</returns> /// <returns>The set of elements found.</returns>
TsCDaBrowseElement[] BrowseNext(ref TsCDaBrowsePosition position); TsCDaBrowseElement[] BrowseNext(ref TsCDaBrowsePosition position);
/// <summary> /// <summary>
/// Returns the item properties for a set of items. /// Returns the item properties for a set of items.
/// </summary> /// </summary>
/// <param name="itemIds">A list of item identifiers.</param> /// <param name="itemIds">A list of item identifiers.</param>
/// <param name="propertyIDs">A list of properties to fetch for each item.</param> /// <param name="propertyIDs">A list of properties to fetch for each item.</param>
/// <param name="returnValues">Whether the property values should be returned with the properties.</param> /// <param name="returnValues">Whether the property values should be returned with the properties.</param>
/// <returns>A list of properties for each item.</returns> /// <returns>A list of properties for each item.</returns>
TsCDaItemPropertyCollection[] GetProperties( TsCDaItemPropertyCollection[] GetProperties(
OpcItem[] itemIds, OpcItem[] itemIds,
TsDaPropertyID[] propertyIDs, TsDaPropertyID[] propertyIDs,
bool returnValues); bool returnValues);
} }
} }

View File

@@ -27,89 +27,89 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// A subscription for a set of items on a single OPC server. /// A subscription for a set of items on a single OPC server.
/// </summary> /// </summary>
public interface ITsCDaSubscription : IDisposable public interface ITsCDaSubscription : IDisposable
{ {
#region Events #region Events
/// <summary> /// <summary>
/// An event to receive data change updates. /// An event to receive data change updates.
/// </summary> /// </summary>
event TsCDaDataChangedEventHandler DataChangedEvent; event TsCDaDataChangedEventHandler DataChangedEvent;
#endregion #endregion
#region Result Filters #region Result Filters
/// <summary> /// <summary>
/// Returns the filters applied by the server to any item results returned to the client. /// Returns the filters applied by the server to any item results returned to the client.
/// </summary> /// </summary>
/// <returns>A bit mask indicating which fields should be returned in any item results.</returns> /// <returns>A bit mask indicating which fields should be returned in any item results.</returns>
int GetResultFilters(); int GetResultFilters();
/// <summary> /// <summary>
/// Sets the filters applied by the server to any item results returned to the client. /// Sets the filters applied by the server to any item results returned to the client.
/// </summary> /// </summary>
/// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param> /// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param>
void SetResultFilters(int filters); void SetResultFilters(int filters);
#endregion #endregion
#region State Management #region State Management
/// <summary> /// <summary>
/// Returns the current state of the subscription. /// Returns the current state of the subscription.
/// </summary> /// </summary>
/// <returns>The current state of the subscription.</returns> /// <returns>The current state of the subscription.</returns>
TsCDaSubscriptionState GetState(); TsCDaSubscriptionState GetState();
/// <summary> /// <summary>
/// Changes the state of a subscription. /// Changes the state of a subscription.
/// </summary> /// </summary>
/// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param> /// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
/// <param name="state">The new subscription state.</param> /// <param name="state">The new subscription state.</param>
/// <returns>The actual subscription state after applying the changes.</returns> /// <returns>The actual subscription state after applying the changes.</returns>
TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state); TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state);
#endregion #endregion
#region Item Management #region Item Management
/// <summary> /// <summary>
/// Adds items to the subscription. /// Adds items to the subscription.
/// </summary> /// </summary>
/// <param name="items">The set of items to add to the subscription.</param> /// <param name="items">The set of items to add to the subscription.</param>
/// <returns>The results of the add item operation for each item.</returns> /// <returns>The results of the add item operation for each item.</returns>
TsCDaItemResult[] AddItems(TsCDaItem[] items); TsCDaItemResult[] AddItems(TsCDaItem[] items);
/// <summary> /// <summary>
/// Modifies the state of items in the subscription /// Modifies the state of items in the subscription
/// </summary> /// </summary>
/// <param name="masks">Specifies which item state parameters are being modified.</param> /// <param name="masks">Specifies which item state parameters are being modified.</param>
/// <param name="items">The new state for each item.</param> /// <param name="items">The new state for each item.</param>
/// <returns>The results of the modify item operation for each item.</returns> /// <returns>The results of the modify item operation for each item.</returns>
TsCDaItemResult[] ModifyItems(int masks, TsCDaItem[] items); TsCDaItemResult[] ModifyItems(int masks, TsCDaItem[] items);
/// <summary> /// <summary>
/// Removes items from the subscription. /// Removes items from the subscription.
/// </summary> /// </summary>
/// <param name="items">The identifiers (i.e. server handles) for the items being removed.</param> /// <param name="items">The identifiers (i.e. server handles) for the items being removed.</param>
/// <returns>The results of the remove item operation for each item.</returns> /// <returns>The results of the remove item operation for each item.</returns>
OpcItemResult[] RemoveItems(OpcItem[] items); OpcItemResult[] RemoveItems(OpcItem[] items);
#endregion #endregion
#region Synchronous I/O #region Synchronous I/O
/// <summary> /// <summary>
/// Reads the values for a set of items in the subscription. /// Reads the values for a set of items in the subscription.
/// </summary> /// </summary>
/// <param name="items">The identifiers (i.e. server handles) for the items being read.</param> /// <param name="items">The identifiers (i.e. server handles) for the items being read.</param>
/// <returns>The value for each of items.</returns> /// <returns>The value for each of items.</returns>
TsCDaItemValueResult[] Read(TsCDaItem[] items); TsCDaItemValueResult[] Read(TsCDaItem[] items);
/// <summary> /// <summary>
/// Writes the value, quality and timestamp for a set of items in the subscription. /// Writes the value, quality and timestamp for a set of items in the subscription.
/// </summary> /// </summary>
/// <param name="items">The item values to write.</param> /// <param name="items">The item values to write.</param>
/// <returns>The results of the write operation for each item.</returns> /// <returns>The results of the write operation for each item.</returns>
OpcItemResult[] Write(TsCDaItemValue[] items); OpcItemResult[] Write(TsCDaItemValue[] items);
#endregion #endregion
#region Asynchronous I/O #region Asynchronous I/O
/// <summary> /// <summary>
/// Begins an asynchronous read operation for a set of items. /// Begins an asynchronous read operation for a set of items.
/// </summary> /// </summary>
@@ -145,36 +145,36 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <param name="callback">The function to invoke when the cancel completes.</param> /// <param name="callback">The function to invoke when the cancel completes.</param>
void Cancel(IOpcRequest request, TsCDaCancelCompleteEventHandler callback); void Cancel(IOpcRequest request, TsCDaCancelCompleteEventHandler callback);
/// <summary> /// <summary>
/// Causes the server to send a data changed notification for all active items. /// Causes the server to send a data changed notification for all active items.
/// </summary> /// </summary>
void Refresh(); void Refresh();
/// <summary> /// <summary>
/// Causes the server to send a data changed notification for all active items. /// Causes the server to send a data changed notification for all active items.
/// </summary> /// </summary>
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param> /// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param> /// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns> /// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
void Refresh( void Refresh(
object requestHandle, object requestHandle,
out IOpcRequest request); out IOpcRequest request);
/// <summary> /// <summary>
/// Enables or disables data change notifications from the server. /// Enables or disables data change notifications from the server.
/// </summary> /// </summary>
/// <param name="enabled">Whether data change notifications are enabled.</param> /// <param name="enabled">Whether data change notifications are enabled.</param>
void SetEnabled(bool enabled); void SetEnabled(bool enabled);
/// <summary> /// <summary>
/// Checks whether data change notifications from the server are enabled. /// Checks whether data change notifications from the server are enabled.
/// </summary> /// </summary>
/// <returns>Whether data change notifications are enabled.</returns> /// <returns>Whether data change notifications are enabled.</returns>
bool GetEnabled(); bool GetEnabled();
#endregion #endregion
} }
#region Delegate Declarations #region Delegate Declarations
/// <summary> /// <summary>
/// A delegate to receive data change updates from the server. /// A delegate to receive data change updates from the server.
/// </summary> /// </summary>

View File

@@ -32,21 +32,21 @@ namespace Technosoftware.DaAeHdaClient.Da
[Serializable] [Serializable]
public class TsCDaItem : OpcItem public class TsCDaItem : OpcItem
{ {
#region Fields #region Fields
private bool active_ = true; private bool active_ = true;
private float deadband_; private float deadband_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with default values. /// Initializes the object with default values.
/// </summary> /// </summary>
public TsCDaItem() { } public TsCDaItem() { }
/// <summary> /// <summary>
/// Initializes object with the specified ItemIdentifier object. /// Initializes object with the specified ItemIdentifier object.
/// </summary> /// </summary>
public TsCDaItem(OpcItem item) public TsCDaItem(OpcItem item)
{ {
if (item == null) if (item == null)
{ {
@@ -58,11 +58,11 @@ namespace Technosoftware.DaAeHdaClient.Da
ServerHandle = item.ServerHandle; ServerHandle = item.ServerHandle;
} }
/// <summary> /// <summary>
/// Initializes object with the specified Item object. /// Initializes object with the specified Item object.
/// </summary> /// </summary>
public TsCDaItem(TsCDaItem item) public TsCDaItem(TsCDaItem item)
: base(item) : base(item)
{ {
if (item == null) if (item == null)
{ {
@@ -80,13 +80,13 @@ namespace Technosoftware.DaAeHdaClient.Da
EnableBuffering = item.EnableBuffering; EnableBuffering = item.EnableBuffering;
EnableBufferingSpecified = item.EnableBufferingSpecified; EnableBufferingSpecified = item.EnableBufferingSpecified;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The data type to use when returning the item value. /// The data type to use when returning the item value.
/// </summary> /// </summary>
public Type ReqType { get; set; } public Type ReqType { get; set; }
/// <summary> /// <summary>
/// The oldest (in milliseconds) acceptable cached value when reading an item. /// The oldest (in milliseconds) acceptable cached value when reading an item.

View File

@@ -27,26 +27,26 @@ using System.Collections;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// A collection of items. /// A collection of items.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemCollection : ICloneable, IList public class TsCDaItemCollection : ICloneable, IList
{ {
#region Fields #region Fields
private ArrayList items_ = new ArrayList(); private ArrayList items_ = new ArrayList();
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes object with the default values. /// Initializes object with the default values.
/// </summary> /// </summary>
public TsCDaItemCollection() { } public TsCDaItemCollection() { }
/// <summary> /// <summary>
/// Initializes object with the specified ResultCollection object. /// Initializes object with the specified ResultCollection object.
/// </summary> /// </summary>
public TsCDaItemCollection(TsCDaItemCollection items) public TsCDaItemCollection(TsCDaItemCollection items)
{ {
if (items == null) if (items == null)
{ {
@@ -59,59 +59,59 @@ namespace Technosoftware.DaAeHdaClient.Da
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// Gets the item at the specified index. /// Gets the item at the specified index.
/// </summary> /// </summary>
public TsCDaItem this[int index] public TsCDaItem this[int index]
{ {
get => (TsCDaItem)items_[index]; get => (TsCDaItem)items_[index];
set => items_[index] = value; set => items_[index] = value;
} }
/// <summary> /// <summary>
/// Gets the first item with the specified item id. /// Gets the first item with the specified item id.
/// </summary> /// </summary>
public TsCDaItem this[OpcItem itemId] public TsCDaItem this[OpcItem itemId]
{ {
get get
{ {
foreach (TsCDaItem item in items_) foreach (TsCDaItem item in items_)
{ {
if (itemId.Key == item.Key) if (itemId.Key == item.Key)
{ {
return item; return item;
} }
} }
return null; return null;
} }
} }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
var clone = (TsCDaItemCollection)MemberwiseClone(); var clone = (TsCDaItemCollection)MemberwiseClone();
clone.items_ = new ArrayList(); clone.items_ = new ArrayList();
foreach (TsCDaItem item in items_) foreach (TsCDaItem item in items_)
{ {
clone.items_.Add(item.Clone()); clone.items_.Add(item.Clone());
} }
return clone; return clone;
} }
#endregion #endregion
#region ICollection Members #region ICollection Members
/// <summary> /// <summary>
/// Indicates whether access to the ICollection is synchronized (thread-safe). /// Indicates whether access to the ICollection is synchronized (thread-safe).
/// </summary> /// </summary>
public bool IsSynchronized => false; public bool IsSynchronized => false;
/// <summary> /// <summary>
/// Gets the number of objects in the collection. /// Gets the number of objects in the collection.
@@ -128,137 +128,137 @@ namespace Technosoftware.DaAeHdaClient.Da
items_?.CopyTo(array, index); items_?.CopyTo(array, index);
} }
/// <summary> /// <summary>
/// Copies the objects to an Array, starting at a the specified index. /// Copies the objects to an Array, starting at a the specified index.
/// </summary> /// </summary>
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param> /// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
/// <param name="index">The zero-based index in the Array at which copying begins.</param> /// <param name="index">The zero-based index in the Array at which copying begins.</param>
public void CopyTo(TsCDaItem[] array, int index) public void CopyTo(TsCDaItem[] array, int index)
{ {
CopyTo((Array)array, index); CopyTo((Array)array, index);
} }
/// <summary> /// <summary>
/// Indicates whether access to the ICollection is synchronized (thread-safe). /// Indicates whether access to the ICollection is synchronized (thread-safe).
/// </summary> /// </summary>
public object SyncRoot => this; public object SyncRoot => this;
#endregion #endregion
#region IEnumerable Members #region IEnumerable Members
/// <summary> /// <summary>
/// Returns an enumerator that can iterate through a collection. /// Returns an enumerator that can iterate through a collection.
/// </summary> /// </summary>
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns> /// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
public IEnumerator GetEnumerator() public IEnumerator GetEnumerator()
{ {
return items_.GetEnumerator(); return items_.GetEnumerator();
} }
#endregion #endregion
#region IList Members #region IList Members
/// <summary> /// <summary>
/// Gets a value indicating whether the IList is read-only. /// Gets a value indicating whether the IList is read-only.
/// </summary> /// </summary>
public bool IsReadOnly => false; public bool IsReadOnly => false;
/// <summary> /// <summary>
/// Gets or sets the element at the specified index. /// Gets or sets the element at the specified index.
/// </summary> /// </summary>
object IList.this[int index] object IList.this[int index]
{ {
get => items_[index]; get => items_[index];
set set
{ {
if (!typeof(TsCDaItem).IsInstanceOfType(value)) if (!typeof(TsCDaItem).IsInstanceOfType(value))
{ {
throw new ArgumentException("May only add Item objects into the collection."); throw new ArgumentException("May only add Item objects into the collection.");
} }
items_[index] = value; items_[index] = value;
} }
} }
/// <summary> /// <summary>
/// Removes the IList item at the specified index. /// Removes the IList item at the specified index.
/// </summary> /// </summary>
/// <param name="index">The zero-based index of the item to remove.</param> /// <param name="index">The zero-based index of the item to remove.</param>
public void RemoveAt(int index) public void RemoveAt(int index)
{ {
items_.RemoveAt(index); items_.RemoveAt(index);
} }
/// <summary> /// <summary>
/// Inserts an item to the IList at the specified position. /// Inserts an item to the IList at the specified position.
/// </summary> /// </summary>
/// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="index">The zero-based index at which value should be inserted.</param>
/// <param name="value">The Object to insert into the IList. </param> /// <param name="value">The Object to insert into the IList. </param>
public void Insert(int index, object value) public void Insert(int index, object value)
{ {
if (!typeof(TsCDaItem).IsInstanceOfType(value)) if (!typeof(TsCDaItem).IsInstanceOfType(value))
{ {
throw new ArgumentException("May only add Item objects into the collection."); throw new ArgumentException("May only add Item objects into the collection.");
} }
items_.Insert(index, value); items_.Insert(index, value);
} }
/// <summary> /// <summary>
/// Removes the first occurrence of a specific object from the IList. /// Removes the first occurrence of a specific object from the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to remove from the IList.</param> /// <param name="value">The Object to remove from the IList.</param>
public void Remove(object value) public void Remove(object value)
{ {
items_.Remove(value); items_.Remove(value);
} }
/// <summary> /// <summary>
/// Determines whether the IList contains a specific value. /// Determines whether the IList contains a specific value.
/// </summary> /// </summary>
/// <param name="value">The Object to locate in the IList.</param> /// <param name="value">The Object to locate in the IList.</param>
/// <returns>true if the Object is found in the IList; otherwise, false.</returns> /// <returns>true if the Object is found in the IList; otherwise, false.</returns>
public bool Contains(object value) public bool Contains(object value)
{ {
return items_.Contains(value); return items_.Contains(value);
} }
/// <summary> /// <summary>
/// Removes all items from the IList. /// Removes all items from the IList.
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
items_.Clear(); items_.Clear();
} }
/// <summary> /// <summary>
/// Determines the index of a specific item in the IList. /// Determines the index of a specific item in the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to locate in the IList.</param> /// <param name="value">The Object to locate in the IList.</param>
/// <returns>The index of value if found in the list; otherwise, -1.</returns> /// <returns>The index of value if found in the list; otherwise, -1.</returns>
public int IndexOf(object value) public int IndexOf(object value)
{ {
return items_.IndexOf(value); return items_.IndexOf(value);
} }
/// <summary> /// <summary>
/// Adds an item to the IList. /// Adds an item to the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to add to the IList. </param> /// <param name="value">The Object to add to the IList. </param>
/// <returns>The position into which the new element was inserted.</returns> /// <returns>The position into which the new element was inserted.</returns>
public int Add(object value) public int Add(object value)
{ {
if (!typeof(TsCDaItem).IsInstanceOfType(value)) if (!typeof(TsCDaItem).IsInstanceOfType(value))
{ {
throw new ArgumentException("May only add Item objects into the collection."); throw new ArgumentException("May only add Item objects into the collection.");
} }
return items_.Add(value); return items_.Add(value);
} }
/// <summary> /// <summary>
/// Indicates whether the IList has a fixed size. /// Indicates whether the IList has a fixed size.
/// </summary> /// </summary>
public bool IsFixedSize => false; public bool IsFixedSize => false;
/// <summary> /// <summary>
/// Inserts an item to the IList at the specified position. /// Inserts an item to the IList at the specified position.
@@ -266,48 +266,48 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="index">The zero-based index at which value should be inserted.</param>
/// <param name="value">The Object to insert into the IList. </param> /// <param name="value">The Object to insert into the IList. </param>
public void Insert(int index, TsCDaItem value) public void Insert(int index, TsCDaItem value)
{ {
Insert(index, (object)value); Insert(index, (object)value);
} }
/// <summary> /// <summary>
/// Removes the first occurrence of a specific object from the IList. /// Removes the first occurrence of a specific object from the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to remove from the IList.</param> /// <param name="value">The Object to remove from the IList.</param>
public void Remove(TsCDaItem value) public void Remove(TsCDaItem value)
{ {
Remove((object)value); Remove((object)value);
} }
/// <summary> /// <summary>
/// Determines whether the IList contains a specific value. /// Determines whether the IList contains a specific value.
/// </summary> /// </summary>
/// <param name="value">The Object to locate in the IList.</param> /// <param name="value">The Object to locate in the IList.</param>
/// <returns>true if the Object is found in the IList; otherwise, false.</returns> /// <returns>true if the Object is found in the IList; otherwise, false.</returns>
public bool Contains(TsCDaItem value) public bool Contains(TsCDaItem value)
{ {
return Contains((object)value); return Contains((object)value);
} }
/// <summary> /// <summary>
/// Determines the index of a specific item in the IList. /// Determines the index of a specific item in the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to locate in the IList.</param> /// <param name="value">The Object to locate in the IList.</param>
/// <returns>The index of value if found in the list; otherwise, -1.</returns> /// <returns>The index of value if found in the list; otherwise, -1.</returns>
public int IndexOf(TsCDaItem value) public int IndexOf(TsCDaItem value)
{ {
return IndexOf((object)value); return IndexOf((object)value);
} }
/// <summary> /// <summary>
/// Adds an item to the IList. /// Adds an item to the IList.
/// </summary> /// </summary>
/// <param name="value">The Object to add to the IList. </param> /// <param name="value">The Object to add to the IList. </param>
/// <returns>The position into which the new element was inserted.</returns> /// <returns>The position into which the new element was inserted.</returns>
public int Add(TsCDaItem value) public int Add(TsCDaItem value)
{ {
return Add((object)value); return Add((object)value);
} }
#endregion #endregion
} }
} }

View File

@@ -26,75 +26,75 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Contains a description of a single item property. /// Contains a description of a single item property.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemProperty : ICloneable, IOpcResult public class TsCDaItemProperty : ICloneable, IOpcResult
{ {
#region Fields #region Fields
private OpcResult result_ = OpcResult.S_OK; private OpcResult result_ = OpcResult.S_OK;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The property identifier. /// The property identifier.
/// </summary> /// </summary>
public TsDaPropertyID ID { get; set; } public TsDaPropertyID ID { get; set; }
/// <summary> /// <summary>
/// A short description of the property. /// A short description of the property.
/// </summary> /// </summary>
public string Description { get; set; } public string Description { get; set; }
/// <summary> /// <summary>
/// The data type of the property. /// The data type of the property.
/// </summary> /// </summary>
public Type DataType { get; set; } public Type DataType { get; set; }
/// <summary> /// <summary>
/// The value of the property. /// The value of the property.
/// </summary> /// </summary>
public object Value { get; set; } public object Value { get; set; }
/// <summary> /// <summary>
/// The primary identifier for the property if it is directly accessible as an item. /// The primary identifier for the property if it is directly accessible as an item.
/// </summary> /// </summary>
public string ItemName { get; set; } public string ItemName { get; set; }
/// <summary> /// <summary>
/// The secondary identifier for the property if it is directly accessible as an item. /// The secondary identifier for the property if it is directly accessible as an item.
/// </summary> /// </summary>
public string ItemPath { get; set; } public string ItemPath { get; set; }
#endregion #endregion
#region IOpcResult Members #region IOpcResult Members
/// <summary> /// <summary>
/// The <see cref="OpcResult" /> object with the result of an operation on an property. /// The <see cref="OpcResult" /> object with the result of an operation on an property.
/// </summary> /// </summary>
public OpcResult Result public OpcResult Result
{ {
get => result_; get => result_;
set => result_ = value; set => result_ = value;
} }
/// <summary> /// <summary>
/// Vendor specific diagnostic information (not the localized error text). /// Vendor specific diagnostic information (not the localized error text).
/// </summary> /// </summary>
public string DiagnosticInfo { get; set; } public string DiagnosticInfo { get; set; }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public virtual object Clone() public virtual object Clone()
{ {
var clone = (TsCDaItemProperty)MemberwiseClone(); var clone = (TsCDaItemProperty)MemberwiseClone();
clone.Value = OpcConvert.Clone(Value); clone.Value = OpcConvert.Clone(Value);
return clone; return clone;
} }
#endregion #endregion
} }
} }

View File

@@ -27,149 +27,149 @@ using System.Collections;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// A list of properties for a single item. /// A list of properties for a single item.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemPropertyCollection : ArrayList, IOpcResult public class TsCDaItemPropertyCollection : ArrayList, IOpcResult
{ {
#region Fields #region Fields
private OpcResult result_ = OpcResult.S_OK; private OpcResult result_ = OpcResult.S_OK;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with its default values. /// Initializes the object with its default values.
/// </summary> /// </summary>
public TsCDaItemPropertyCollection() public TsCDaItemPropertyCollection()
{ {
} }
/// <summary> /// <summary>
/// Initializes the object with the specified item identifier. /// Initializes the object with the specified item identifier.
/// </summary> /// </summary>
public TsCDaItemPropertyCollection(OpcItem itemId) public TsCDaItemPropertyCollection(OpcItem itemId)
{ {
if (itemId != null) if (itemId != null)
{ {
ItemName = itemId.ItemName; ItemName = itemId.ItemName;
ItemPath = itemId.ItemPath; ItemPath = itemId.ItemPath;
} }
} }
/// <summary> /// <summary>
/// Initializes the object with the specified item identifier and result. /// Initializes the object with the specified item identifier and result.
/// </summary> /// </summary>
public TsCDaItemPropertyCollection(OpcItem itemId, OpcResult result) public TsCDaItemPropertyCollection(OpcItem itemId, OpcResult result)
{ {
if (itemId != null) if (itemId != null)
{ {
ItemName = itemId.ItemName; ItemName = itemId.ItemName;
ItemPath = itemId.ItemPath; ItemPath = itemId.ItemPath;
} }
result_ = result; result_ = result;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The primary identifier for the item within the server namespace. /// The primary identifier for the item within the server namespace.
/// </summary> /// </summary>
public string ItemName { get; set; } public string ItemName { get; set; }
/// <summary> /// <summary>
/// An secondary identifier for the item within the server namespace. /// An secondary identifier for the item within the server namespace.
/// </summary> /// </summary>
public string ItemPath { get; set; } public string ItemPath { get; set; }
/// <summary> /// <summary>
/// Accesses the items at the specified index. /// Accesses the items at the specified index.
/// </summary> /// </summary>
public new TsCDaItemProperty this[int index] public new TsCDaItemProperty this[int index]
{ {
get => (TsCDaItemProperty)base[index]; get => (TsCDaItemProperty)base[index];
set => base[index] = value; set => base[index] = value;
} }
#endregion #endregion
#region IOpcResult Members #region IOpcResult Members
/// <summary> /// <summary>
/// The error id for the result of an operation on an item. /// The error id for the result of an operation on an item.
/// </summary> /// </summary>
public OpcResult Result public OpcResult Result
{ {
get => result_; get => result_;
set => result_ = value; set => result_ = value;
} }
/// <summary>
/// Vendor specific diagnostic information (not the localized error text).
/// </summary>
public string DiagnosticInfo { get; set; }
#endregion
#region ICollection Members
/// <summary> /// <summary>
/// Copies the objects to an Array, starting at a the specified index. /// Vendor specific diagnostic information (not the localized error text).
/// </summary> /// </summary>
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param> public string DiagnosticInfo { get; set; }
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
public void CopyTo(TsCDaItemProperty[] array, int index)
{
CopyTo((Array)array, index);
}
#endregion #endregion
#region IList Members #region ICollection Members
/// <summary> /// <summary>
/// Inserts an item to the IList at the specified position. /// Copies the objects to an Array, starting at a the specified index.
/// </summary> /// </summary>
/// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
/// <param name="value">The Object to insert into the IList. </param> /// <param name="index">The zero-based index in the Array at which copying begins.</param>
public void Insert(int index, TsCDaItemProperty value) public void CopyTo(TsCDaItemProperty[] array, int index)
{ {
Insert(index, (object)value); CopyTo((Array)array, index);
} }
/// <summary>
/// Removes the first occurrence of a specific object from the IList.
/// </summary>
/// <param name="value">The Object to remove from the IList.</param>
public void Remove(TsCDaItemProperty value)
{
Remove((object)value);
}
/// <summary>
/// Determines whether the IList contains a specific value.
/// </summary>
/// <param name="value">The Object to locate in the IList.</param>
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
public bool Contains(TsCDaItemProperty value)
{
return Contains((object)value);
}
/// <summary>
/// Determines the index of a specific item in the IList.
/// </summary>
/// <param name="value">The Object to locate in the IList.</param>
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
public int IndexOf(TsCDaItemProperty value)
{
return IndexOf((object)value);
}
/// <summary>
/// Adds an item to the IList.
/// </summary>
/// <param name="value">The Object to add to the IList. </param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(TsCDaItemProperty value)
{
return Add((object)value);
}
#endregion #endregion
}
#region IList Members
/// <summary>
/// Inserts an item to the IList at the specified position.
/// </summary>
/// <param name="index">The zero-based index at which value should be inserted.</param>
/// <param name="value">The Object to insert into the IList. </param>
public void Insert(int index, TsCDaItemProperty value)
{
Insert(index, (object)value);
}
/// <summary>
/// Removes the first occurrence of a specific object from the IList.
/// </summary>
/// <param name="value">The Object to remove from the IList.</param>
public void Remove(TsCDaItemProperty value)
{
Remove((object)value);
}
/// <summary>
/// Determines whether the IList contains a specific value.
/// </summary>
/// <param name="value">The Object to locate in the IList.</param>
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
public bool Contains(TsCDaItemProperty value)
{
return Contains((object)value);
}
/// <summary>
/// Determines the index of a specific item in the IList.
/// </summary>
/// <param name="value">The Object to locate in the IList.</param>
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
public int IndexOf(TsCDaItemProperty value)
{
return IndexOf((object)value);
}
/// <summary>
/// Adds an item to the IList.
/// </summary>
/// <param name="value">The Object to add to the IList. </param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(TsCDaItemProperty value)
{
return Add((object)value);
}
#endregion
}
} }

View File

@@ -26,79 +26,79 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// The results of an operation on a uniquely identifiable item. /// The results of an operation on a uniquely identifiable item.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemResult : TsCDaItem, IOpcResult public class TsCDaItemResult : TsCDaItem, IOpcResult
{ {
#region Fields #region Fields
private OpcResult result_ = OpcResult.S_OK; private OpcResult result_ = OpcResult.S_OK;
#endregion
#region Constructors, Destructor, Initialization
/// <summary>
/// Initializes the object with default values.
/// </summary>
public TsCDaItemResult() { }
/// <summary>
/// Initializes the object with an ItemIdentifier object.
/// </summary>
public TsCDaItemResult(OpcItem item) : base(item) { }
/// <summary>
/// Initializes the object with an ItemIdentifier object and Result.
/// </summary>
public TsCDaItemResult(OpcItem item, OpcResult resultId)
: base(item)
{
Result = resultId;
}
/// <summary>
/// Initializes the object with an Item object.
/// </summary>
public TsCDaItemResult(TsCDaItem item) : base(item) { }
/// <summary>
/// Initializes the object with an Item object and Result.
/// </summary>
public TsCDaItemResult(TsCDaItem item, OpcResult resultId)
: base(item)
{
Result = resultId;
}
/// <summary>
/// Initializes object with the specified ItemResult object.
/// </summary>
public TsCDaItemResult(TsCDaItemResult item)
: base(item)
{
if (item != null)
{
Result = item.Result;
DiagnosticInfo = item.DiagnosticInfo;
}
}
#endregion #endregion
#region IOpcResult Members #region Constructors, Destructor, Initialization
/// <summary>
/// Initializes the object with default values.
/// </summary>
public TsCDaItemResult() { }
/// <summary> /// <summary>
/// The error id for the result of an operation on an property. /// Initializes the object with an ItemIdentifier object.
/// </summary> /// </summary>
public OpcResult Result public TsCDaItemResult(OpcItem item) : base(item) { }
{
get => result_; /// <summary>
/// Initializes the object with an ItemIdentifier object and Result.
/// </summary>
public TsCDaItemResult(OpcItem item, OpcResult resultId)
: base(item)
{
Result = resultId;
}
/// <summary>
/// Initializes the object with an Item object.
/// </summary>
public TsCDaItemResult(TsCDaItem item) : base(item) { }
/// <summary>
/// Initializes the object with an Item object and Result.
/// </summary>
public TsCDaItemResult(TsCDaItem item, OpcResult resultId)
: base(item)
{
Result = resultId;
}
/// <summary>
/// Initializes object with the specified ItemResult object.
/// </summary>
public TsCDaItemResult(TsCDaItemResult item)
: base(item)
{
if (item != null)
{
Result = item.Result;
DiagnosticInfo = item.DiagnosticInfo;
}
}
#endregion
#region IOpcResult Members
/// <summary>
/// The error id for the result of an operation on an property.
/// </summary>
public OpcResult Result
{
get => result_;
set => result_ = value; set => result_ = value;
} }
/// <summary> /// <summary>
/// Vendor specific diagnostic information (not the localized error text). /// Vendor specific diagnostic information (not the localized error text).
/// </summary> /// </summary>
public string DiagnosticInfo { get; set; } public string DiagnosticInfo { get; set; }
#endregion #endregion
} }
} }

View File

@@ -27,27 +27,27 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Contains the value for a single item. /// Contains the value for a single item.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemValue : OpcItem public class TsCDaItemValue : OpcItem
{ {
#region Fields #region Fields
private TsCDaQuality daQuality_ = TsCDaQuality.Bad; private TsCDaQuality daQuality_ = TsCDaQuality.Bad;
private DateTime timestamp_ = DateTime.MinValue; private DateTime timestamp_ = DateTime.MinValue;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with default values. /// Initializes the object with default values.
/// </summary> /// </summary>
public TsCDaItemValue() { } public TsCDaItemValue() { }
/// <summary> /// <summary>
/// Initializes the object with and ItemIdentifier object. /// Initializes the object with and ItemIdentifier object.
/// </summary> /// </summary>
public TsCDaItemValue(OpcItem item) public TsCDaItemValue(OpcItem item)
{ {
if (item == null) if (item == null)
{ {
@@ -59,19 +59,19 @@ namespace Technosoftware.DaAeHdaClient.Da
ServerHandle = item.ServerHandle; ServerHandle = item.ServerHandle;
} }
/// <summary> /// <summary>
/// Initializes the object with the specified item name. /// Initializes the object with the specified item name.
/// </summary> /// </summary>
public TsCDaItemValue(string itemName) public TsCDaItemValue(string itemName)
: base(itemName) : base(itemName)
{ {
} }
/// <summary> /// <summary>
/// Initializes object with the specified ItemValue object. /// Initializes object with the specified ItemValue object.
/// </summary> /// </summary>
public TsCDaItemValue(TsCDaItemValue item) public TsCDaItemValue(TsCDaItemValue item)
: base(item) : base(item)
{ {
if (item == null) if (item == null)
{ {
@@ -85,53 +85,53 @@ namespace Technosoftware.DaAeHdaClient.Da
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The item value. /// The item value.
/// </summary> /// </summary>
public object Value { get; set; } public object Value { get; set; }
/// <summary> /// <summary>
/// The quality of the item value. /// The quality of the item value.
/// </summary> /// </summary>
public TsCDaQuality Quality public TsCDaQuality Quality
{ {
get => daQuality_; get => daQuality_;
set => daQuality_ = value; set => daQuality_ = value;
} }
/// <summary> /// <summary>
/// Whether the quality is specified. /// Whether the quality is specified.
/// </summary> /// </summary>
public bool QualitySpecified { get; set; } public bool QualitySpecified { get; set; }
/// <summary> /// <summary>
/// The timestamp for the item value. /// The timestamp for the item value.
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines /// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
/// the time format (UTC or local time). /// the time format (UTC or local time).
/// </summary> /// </summary>
public DateTime Timestamp public DateTime Timestamp
{ {
get => timestamp_; get => timestamp_;
set => timestamp_ = value; set => timestamp_ = value;
} }
/// <summary> /// <summary>
/// Whether the timestamp is specified. /// Whether the timestamp is specified.
/// </summary> /// </summary>
public bool TimestampSpecified { get; set; } public bool TimestampSpecified { get; set; }
#endregion #endregion
#region ICloneable Members #region ICloneable Members
/// <summary> /// <summary>
/// Creates a deep copy of the object. /// Creates a deep copy of the object.
/// </summary> /// </summary>
public override object Clone() public override object Clone()
{ {
var clone = (TsCDaItemValue)MemberwiseClone(); var clone = (TsCDaItemValue)MemberwiseClone();
clone.Value = OpcConvert.Clone(Value); clone.Value = OpcConvert.Clone(Value);
return clone; return clone;
} }
#endregion #endregion
} }
} }

View File

@@ -26,98 +26,98 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// The results of an operation on a uniquely identifiable item value. /// The results of an operation on a uniquely identifiable item value.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaItemValueResult : TsCDaItemValue, IOpcResult public class TsCDaItemValueResult : TsCDaItemValue, IOpcResult
{ {
#region Fields #region Fields
private OpcResult result_ = OpcResult.S_OK; private OpcResult result_ = OpcResult.S_OK;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with default values. /// Initializes the object with default values.
/// </summary> /// </summary>
public TsCDaItemValueResult() { } public TsCDaItemValueResult() { }
/// <summary> /// <summary>
/// Initializes the object with an ItemIdentifier object. /// Initializes the object with an ItemIdentifier object.
/// </summary> /// </summary>
public TsCDaItemValueResult(OpcItem item) : base(item) { } public TsCDaItemValueResult(OpcItem item) : base(item) { }
/// <summary> /// <summary>
/// Initializes the object with an ItemValue object. /// Initializes the object with an ItemValue object.
/// </summary> /// </summary>
public TsCDaItemValueResult(TsCDaItemValue item) : base(item) { } public TsCDaItemValueResult(TsCDaItemValue item) : base(item) { }
/// <summary> /// <summary>
/// Initializes object with the specified ItemValueResult object. /// Initializes object with the specified ItemValueResult object.
/// </summary> /// </summary>
public TsCDaItemValueResult(TsCDaItemValueResult item) public TsCDaItemValueResult(TsCDaItemValueResult item)
: base(item) : base(item)
{ {
if (item != null) if (item != null)
{ {
Result = item.Result; Result = item.Result;
DiagnosticInfo = item.DiagnosticInfo; DiagnosticInfo = item.DiagnosticInfo;
} }
} }
/// <summary> /// <summary>
/// Initializes the object with the specified item name and result code. /// Initializes the object with the specified item name and result code.
/// </summary> /// </summary>
public TsCDaItemValueResult(string itemName, OpcResult resultId) public TsCDaItemValueResult(string itemName, OpcResult resultId)
: base(itemName) : base(itemName)
{ {
Result = resultId; Result = resultId;
} }
/// <summary> /// <summary>
/// Initializes the object with the specified item name, result code and diagnostic info. /// Initializes the object with the specified item name, result code and diagnostic info.
/// </summary> /// </summary>
public TsCDaItemValueResult(string itemName, OpcResult resultId, string diagnosticInfo) public TsCDaItemValueResult(string itemName, OpcResult resultId, string diagnosticInfo)
: base(itemName) : base(itemName)
{ {
Result = resultId; Result = resultId;
DiagnosticInfo = diagnosticInfo; DiagnosticInfo = diagnosticInfo;
} }
/// <summary> /// <summary>
/// Initialize object with the specified ItemIdentifier and result code. /// Initialize object with the specified ItemIdentifier and result code.
/// </summary> /// </summary>
public TsCDaItemValueResult(OpcItem item, OpcResult resultId) public TsCDaItemValueResult(OpcItem item, OpcResult resultId)
: base(item) : base(item)
{ {
Result = resultId; Result = resultId;
} }
/// <summary> /// <summary>
/// Initializes the object with the specified ItemIdentifier, result code and diagnostic info. /// Initializes the object with the specified ItemIdentifier, result code and diagnostic info.
/// </summary> /// </summary>
public TsCDaItemValueResult(OpcItem item, OpcResult resultId, string diagnosticInfo) public TsCDaItemValueResult(OpcItem item, OpcResult resultId, string diagnosticInfo)
: base(item) : base(item)
{ {
Result = resultId; Result = resultId;
DiagnosticInfo = diagnosticInfo; DiagnosticInfo = diagnosticInfo;
} }
#endregion #endregion
#region IOpcResult Members #region IOpcResult Members
/// <summary> /// <summary>
/// The error id for the result of an operation on an property. /// The error id for the result of an operation on an property.
/// </summary> /// </summary>
public OpcResult Result public OpcResult Result
{ {
get => result_; get => result_;
set => result_ = value; set => result_ = value;
} }
/// <summary> /// <summary>
/// Vendor specific diagnostic information (not the localized error text). /// Vendor specific diagnostic information (not the localized error text).
/// </summary> /// </summary>
public string DiagnosticInfo { get; set; } public string DiagnosticInfo { get; set; }
#endregion #endregion
} }
} }

View File

@@ -25,20 +25,20 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// <para>Defines the possible limit status bits.</para> /// <para>Defines the possible limit status bits.</para>
/// <para>The Limit Field is valid regardless of the Quality and Substatus. In some /// <para>The Limit Field is valid regardless of the Quality and Substatus. In some
/// cases such as Sensor Failure it can provide useful diagnostic information.</para> /// cases such as Sensor Failure it can provide useful diagnostic information.</para>
/// </summary> /// </summary>
public enum TsDaLimitBits public enum TsDaLimitBits
{ {
/// <summary>The value is free to move up or down</summary> /// <summary>The value is free to move up or down</summary>
None = 0x0, None = 0x0,
/// <summary>The value has pegged at some lower limit</summary> /// <summary>The value has pegged at some lower limit</summary>
Low = 0x1, Low = 0x1,
/// <summary>The value has pegged at some high limit</summary> /// <summary>The value has pegged at some high limit</summary>
High = 0x2, High = 0x2,
/// <summary>The value is a constant and cannot move</summary> /// <summary>The value is a constant and cannot move</summary>
Constant = 0x3 Constant = 0x3
} }
} }

View File

@@ -25,294 +25,294 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Defines identifiers for well-known properties. /// Defines identifiers for well-known properties.
/// </summary> /// </summary>
public class TsDaProperty public class TsDaProperty
{ {
#region Data Access Properties #region Data Access Properties
/// <summary><para>Item Canonical DataType</para></summary> /// <summary><para>Item Canonical DataType</para></summary>
public static readonly TsDaPropertyID DATATYPE = new TsDaPropertyID("dataType", 1, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DATATYPE = new TsDaPropertyID("dataType", 1, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Item Value</para></summary> /// <summary><para>Item Value</para></summary>
/// <remarks> /// <remarks>
/// Note the type of value returned is as indicated by the "Item Canonical DataType" /// Note the type of value returned is as indicated by the "Item Canonical DataType"
/// and depends on the item. This will behave like a read from DEVICE. /// and depends on the item. This will behave like a read from DEVICE.
/// </remarks> /// </remarks>
public static readonly TsDaPropertyID VALUE = new TsDaPropertyID("value", 2, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID VALUE = new TsDaPropertyID("value", 2, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Item Quality</para></summary> /// <summary><para>Item Quality</para></summary>
/// <remarks>(OPCQUALITY stored in an I2). This will behave like a read from DEVICE.</remarks> /// <remarks>(OPCQUALITY stored in an I2). This will behave like a read from DEVICE.</remarks>
public static readonly TsDaPropertyID QUALITY = new TsDaPropertyID("quality", 3, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID QUALITY = new TsDaPropertyID("quality", 3, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Item Timestamp</para></summary> /// <summary><para>Item Timestamp</para></summary>
/// <remarks> /// <remarks>
/// (will be converted from FILETIME). This will behave like a read from /// (will be converted from FILETIME). This will behave like a read from
/// DEVICE. /// DEVICE.
/// </remarks> /// </remarks>
public static readonly TsDaPropertyID TIMESTAMP = new TsDaPropertyID("timestamp", 4, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID TIMESTAMP = new TsDaPropertyID("timestamp", 4, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Item Access Rights</para></summary> /// <summary><para>Item Access Rights</para></summary>
/// <remarks>(OPCACCESSRIGHTS stored in an I4)</remarks> /// <remarks>(OPCACCESSRIGHTS stored in an I4)</remarks>
public static readonly TsDaPropertyID ACCESSRIGHTS = new TsDaPropertyID("accessRights", 5, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID ACCESSRIGHTS = new TsDaPropertyID("accessRights", 5, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Server Scan Rate</para></summary> /// <summary><para>Server Scan Rate</para></summary>
/// <remarks> /// <remarks>
/// In Milliseconds. This represents the fastest rate at which the server could /// In Milliseconds. This represents the fastest rate at which the server could
/// obtain data from the underlying data source. The nature of this source is not defined /// obtain data from the underlying data source. The nature of this source is not defined
/// but is typically a DCS system, a SCADA system, a PLC via a COMM port or network, a /// but is typically a DCS system, a SCADA system, a PLC via a COMM port or network, a
/// Device Network, etc. This value generally represents the best case fastest /// Device Network, etc. This value generally represents the best case fastest
/// RequestedUpdateRate which could be used if this item were added to an OPCGroup.<br/> /// RequestedUpdateRate which could be used if this item were added to an OPCGroup.<br/>
/// The accuracy of this value (the ability of the server to attain best case /// The accuracy of this value (the ability of the server to attain best case
/// performance) can be greatly affected by system load and other factors. /// performance) can be greatly affected by system load and other factors.
/// </remarks> /// </remarks>
public static readonly TsDaPropertyID SCANRATE = new TsDaPropertyID("scanRate", 6, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID SCANRATE = new TsDaPropertyID("scanRate", 6, OpcNamespace.OPC_DATA_ACCESS);
/// <remarks> /// <remarks>
/// <para>Indicate the type of Engineering Units (EU) information (if any) contained in /// <para>Indicate the type of Engineering Units (EU) information (if any) contained in
/// EUINFO.</para> /// EUINFO.</para>
/// <list type="bullet"> /// <list type="bullet">
/// <item> /// <item>
/// 0 - No EU information available (EUINFO will be VT_EMPTY). /// 0 - No EU information available (EUINFO will be VT_EMPTY).
/// </item> /// </item>
/// <item> /// <item>
/// 1 - Analog - EUINFO will contain a SAFEARRAY of exactly two doubles /// 1 - Analog - EUINFO will contain a SAFEARRAY of exactly two doubles
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range. /// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
/// </item> /// </item>
/// <item>2 - Enumerated - EUINFO will contain a SAFEARRAY of strings (VT_ARRAY | /// <item>2 - Enumerated - EUINFO will contain a SAFEARRAY of strings (VT_ARRAY |
/// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN /// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN
/// TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2, /// TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2,
/// etc.)</item> /// etc.)</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
/// <summary><para>Item EU Type</para></summary> /// <summary><para>Item EU Type</para></summary>
public static readonly TsDaPropertyID EUTYPE = new TsDaPropertyID("euType", 7, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID EUTYPE = new TsDaPropertyID("euType", 7, OpcNamespace.OPC_DATA_ACCESS);
/// <summary><para>Item EUInfo</para></summary> /// <summary><para>Item EUInfo</para></summary>
/// <value> /// <value>
/// <para> /// <para>
/// If EUTYPE is “Analog” EUINFO will contain a SAFEARRAY of exactly two doubles /// If EUTYPE is “Analog” EUINFO will contain a SAFEARRAY of exactly two doubles
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range. /// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
/// </para> /// </para>
/// <para>If EUTYPE is “Enumerated” - EUINFO will contain a SAFEARRAY of strings /// <para>If EUTYPE is “Enumerated” - EUINFO will contain a SAFEARRAY of strings
/// (VT_ARRAY | VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, /// (VT_ARRAY | VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”,
/// “IN TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2, /// “IN TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2,
/// etc.)</para> /// etc.)</para>
/// </value> /// </value>
public static readonly TsDaPropertyID EUINFO = new TsDaPropertyID("euInfo", 8, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID EUINFO = new TsDaPropertyID("euInfo", 8, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>EU Units</para> /// <para>EU Units</para>
/// <para>e.g. "DEGC" or "GALLONS"</para> /// <para>e.g. "DEGC" or "GALLONS"</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID ENGINEERINGUINTS = new TsDaPropertyID("engineeringUnits", 100, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID ENGINEERINGUINTS = new TsDaPropertyID("engineeringUnits", 100, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Item Description</para> /// <para>Item Description</para>
/// <para>e.g. "Evaporator 6 Coolant Temp"</para> /// <para>e.g. "Evaporator 6 Coolant Temp"</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID DESCRIPTION = new TsDaPropertyID("description", 101, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DESCRIPTION = new TsDaPropertyID("description", 101, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>High EU</para> /// <para>High EU</para>
/// <para>Present only for 'analog' data. This represents the highest value likely to /// <para>Present only for 'analog' data. This represents the highest value likely to
/// be obtained in normal operation and is intended for such use as automatically /// be obtained in normal operation and is intended for such use as automatically
/// scaling a bargraph display.</para> /// scaling a bargraph display.</para>
/// <para>e.g. 1400.0</para> /// <para>e.g. 1400.0</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID HIGHEU = new TsDaPropertyID("highEU", 102, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID HIGHEU = new TsDaPropertyID("highEU", 102, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Low EU</para> /// <para>Low EU</para>
/// <para>Present only for 'analog' data. This represents the lowest value likely to be /// <para>Present only for 'analog' data. This represents the lowest value likely to be
/// obtained in normal operation and is intended for such use as automatically scaling /// obtained in normal operation and is intended for such use as automatically scaling
/// a bargraph display.</para> /// a bargraph display.</para>
/// <para>e.g. -200.0</para> /// <para>e.g. -200.0</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID LOWEU = new TsDaPropertyID("lowEU", 103, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID LOWEU = new TsDaPropertyID("lowEU", 103, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>High Instrument Range</para> /// <para>High Instrument Range</para>
/// <para>Present only for analog data. This represents the highest value that can be /// <para>Present only for analog data. This represents the highest value that can be
/// returned by the instrument.</para> /// returned by the instrument.</para>
/// <para>e.g. 9999.9</para> /// <para>e.g. 9999.9</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID HIGHIR = new TsDaPropertyID("highIR", 104, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID HIGHIR = new TsDaPropertyID("highIR", 104, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Low Instrument Range</para> /// <para>Low Instrument Range</para>
/// <para>Present only for analog data. This represents the lowest value that can be /// <para>Present only for analog data. This represents the lowest value that can be
/// returned by the instrument.</para> /// returned by the instrument.</para>
/// <para>e.g. -9999.9</para> /// <para>e.g. -9999.9</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID LOWIR = new TsDaPropertyID("lowIR", 105, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID LOWIR = new TsDaPropertyID("lowIR", 105, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Contact Close Label</para> /// <para>Contact Close Label</para>
/// <para>Present only for discrete' data. This represents a string to be associated /// <para>Present only for discrete' data. This represents a string to be associated
/// with this contact when it is in the closed (non-zero) state</para> /// with this contact when it is in the closed (non-zero) state</para>
/// <para>e.g. "RUN", "CLOSE", "ENABLE", "SAFE" ,etc.</para> /// <para>e.g. "RUN", "CLOSE", "ENABLE", "SAFE" ,etc.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID CLOSELABEL = new TsDaPropertyID("closeLabel", 106, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID CLOSELABEL = new TsDaPropertyID("closeLabel", 106, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Contact Open Label</para> /// <para>Contact Open Label</para>
/// <para>Present only for discrete' data. This represents a string to be associated /// <para>Present only for discrete' data. This represents a string to be associated
/// with this contact when it is in the open (zero) state</para> /// with this contact when it is in the open (zero) state</para>
/// <para>e.g. "STOP", "OPEN", "DISABLE", "UNSAFE" ,etc.</para> /// <para>e.g. "STOP", "OPEN", "DISABLE", "UNSAFE" ,etc.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID OPENLABEL = new TsDaPropertyID("openLabel", 107, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID OPENLABEL = new TsDaPropertyID("openLabel", 107, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Item Timezone</para> /// <para>Item Timezone</para>
/// <para>The difference in minutes between the items UTC Timestamp and the local time /// <para>The difference in minutes between the items UTC Timestamp and the local time
/// in which the item value was obtained.</para> /// in which the item value was obtained.</para>
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// See the OPCGroup TimeBias property. Also see the WIN32 TIME_ZONE_INFORMATION /// See the OPCGroup TimeBias property. Also see the WIN32 TIME_ZONE_INFORMATION
/// structure. /// structure.
/// </remarks> /// </remarks>
public static readonly TsDaPropertyID TIMEZONE = new TsDaPropertyID("timeZone", 108, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID TIMEZONE = new TsDaPropertyID("timeZone", 108, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Condition Status</para> /// <para>Condition Status</para>
/// <para>The current alarm or condition status associated with the Item<br/> /// <para>The current alarm or condition status associated with the Item<br/>
/// e.g. "NORMAL", "ACTIVE", "HI ALARM", etc</para> /// e.g. "NORMAL", "ACTIVE", "HI ALARM", etc</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID CONDITION_STATUS = new TsDaPropertyID("conditionStatus", 300, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID CONDITION_STATUS = new TsDaPropertyID("conditionStatus", 300, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Alarm Quick Help</para> /// <para>Alarm Quick Help</para>
/// <para>A short text string providing a brief set of instructions for the operator to /// <para>A short text string providing a brief set of instructions for the operator to
/// follow when this alarm occurs.</para> /// follow when this alarm occurs.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID ALARM_QUICK_HELP = new TsDaPropertyID("alarmQuickHelp", 301, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID ALARM_QUICK_HELP = new TsDaPropertyID("alarmQuickHelp", 301, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Alarm Area List</para> /// <para>Alarm Area List</para>
/// <para>An array of stings indicating the plant or alarm areas which include this /// <para>An array of stings indicating the plant or alarm areas which include this
/// ItemID.</para> /// ItemID.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID ALARM_AREA_LIST = new TsDaPropertyID("alarmAreaList", 302, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID ALARM_AREA_LIST = new TsDaPropertyID("alarmAreaList", 302, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Primary Alarm Area</para> /// <para>Primary Alarm Area</para>
/// <para>A string indicating the primary plant or alarm area including this /// <para>A string indicating the primary plant or alarm area including this
/// ItemID</para> /// ItemID</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID PRIMARY_ALARM_AREA = new TsDaPropertyID("primaryAlarmArea", 303, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID PRIMARY_ALARM_AREA = new TsDaPropertyID("primaryAlarmArea", 303, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Condition Logic</para> /// <para>Condition Logic</para>
/// <para>An arbitrary string describing the test being performed.</para> /// <para>An arbitrary string describing the test being performed.</para>
/// <para>e.g. "High Limit Exceeded" or "TAG.PV &gt;= TAG.HILIM"</para> /// <para>e.g. "High Limit Exceeded" or "TAG.PV &gt;= TAG.HILIM"</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID CONDITION_LOGIC = new TsDaPropertyID("conditionLogic", 304, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID CONDITION_LOGIC = new TsDaPropertyID("conditionLogic", 304, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Limit Exceeded</para> /// <para>Limit Exceeded</para>
/// <para>For multistate alarms, the condition exceeded</para> /// <para>For multistate alarms, the condition exceeded</para>
/// <para>e.g. HIHI, HI, LO, LOLO</para> /// <para>e.g. HIHI, HI, LO, LOLO</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID LIMIT_EXCEEDED = new TsDaPropertyID("limitExceeded", 305, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID LIMIT_EXCEEDED = new TsDaPropertyID("limitExceeded", 305, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>Deadband</summary> /// <summary>Deadband</summary>
public static readonly TsDaPropertyID DEADBAND = new TsDaPropertyID("deadband", 306, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DEADBAND = new TsDaPropertyID("deadband", 306, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>HiHi limit</summary> /// <summary>HiHi limit</summary>
public static readonly TsDaPropertyID HIHI_LIMIT = new TsDaPropertyID("hihiLimit", 307, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID HIHI_LIMIT = new TsDaPropertyID("hihiLimit", 307, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>Hi Limit</summary> /// <summary>Hi Limit</summary>
public static readonly TsDaPropertyID HI_LIMIT = new TsDaPropertyID("hiLimit", 308, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID HI_LIMIT = new TsDaPropertyID("hiLimit", 308, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>Lo Limit</summary> /// <summary>Lo Limit</summary>
public static readonly TsDaPropertyID LO_LIMIT = new TsDaPropertyID("loLimit", 309, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID LO_LIMIT = new TsDaPropertyID("loLimit", 309, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>LoLo Limit</summary> /// <summary>LoLo Limit</summary>
public static readonly TsDaPropertyID LOLO_LIMIT = new TsDaPropertyID("loloLimit", 310, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID LOLO_LIMIT = new TsDaPropertyID("loloLimit", 310, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>Rate of Change Limit</summary> /// <summary>Rate of Change Limit</summary>
public static readonly TsDaPropertyID RATE_CHANGE_LIMIT = new TsDaPropertyID("rangeOfChangeLimit", 311, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID RATE_CHANGE_LIMIT = new TsDaPropertyID("rangeOfChangeLimit", 311, OpcNamespace.OPC_DATA_ACCESS);
/// <summary>Deviation Limit</summary> /// <summary>Deviation Limit</summary>
public static readonly TsDaPropertyID DEVIATION_LIMIT = new TsDaPropertyID("deviationLimit", 312, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DEVIATION_LIMIT = new TsDaPropertyID("deviationLimit", 312, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Sound File</para> /// <para>Sound File</para>
/// <para>e.g. C:\MEDIA\FIC101.WAV, or .MID</para> /// <para>e.g. C:\MEDIA\FIC101.WAV, or .MID</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID SOUNDFILE = new TsDaPropertyID("soundFile", 313, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID SOUNDFILE = new TsDaPropertyID("soundFile", 313, OpcNamespace.OPC_DATA_ACCESS);
#endregion #endregion
#region Complex Data Properties #region Complex Data Properties
/// <summary> /// <summary>
/// <para>Type System ID</para> /// <para>Type System ID</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID TYPE_SYSTEM_ID = new TsDaPropertyID("typeSystemID", 600, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID TYPE_SYSTEM_ID = new TsDaPropertyID("typeSystemID", 600, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Dictionary ID</para> /// <para>Dictionary ID</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID DICTIONARY_ID = new TsDaPropertyID("dictionaryID", 601, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DICTIONARY_ID = new TsDaPropertyID("dictionaryID", 601, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Type ID</para> /// <para>Type ID</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID TYPE_ID = new TsDaPropertyID("typeID", 602, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID TYPE_ID = new TsDaPropertyID("typeID", 602, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Dictionary</para> /// <para>Dictionary</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID DICTIONARY = new TsDaPropertyID("dictionary", 603, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DICTIONARY = new TsDaPropertyID("dictionary", 603, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Type description</para> /// <para>Type description</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID TYPE_DESCRIPTION = new TsDaPropertyID("typeDescription", 604, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID TYPE_DESCRIPTION = new TsDaPropertyID("typeDescription", 604, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Consistency Window</para> /// <para>Consistency Window</para>
/// <para>Complex Data Property</para> /// <para>Complex Data Property</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID CONSISTENCY_WINDOW = new TsDaPropertyID("consistencyWindow", 605, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID CONSISTENCY_WINDOW = new TsDaPropertyID("consistencyWindow", 605, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Write Behaviour</para> /// <para>Write Behaviour</para>
/// <para>Complex Data Property, defaults to “All or Nothing” if the complex data item /// <para>Complex Data Property, defaults to “All or Nothing” if the complex data item
/// is writable. Not used for Read-Only items.</para> /// is writable. Not used for Read-Only items.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID WRITE_BEHAVIOR = new TsDaPropertyID("writeBehavior", 606, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID WRITE_BEHAVIOR = new TsDaPropertyID("writeBehavior", 606, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Unconverted Item ID</para> /// <para>Unconverted Item ID</para>
/// <para>Complex Data Property, the ID of the item that exposes the same complex data /// <para>Complex Data Property, the ID of the item that exposes the same complex data
/// value in its native format. This property is mandatory for items that implement /// value in its native format. This property is mandatory for items that implement
/// complex data type conversions.</para> /// complex data type conversions.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID UNCONVERTED_ITEM_ID = new TsDaPropertyID("unconvertedItemID", 607, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID UNCONVERTED_ITEM_ID = new TsDaPropertyID("unconvertedItemID", 607, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Unfiltered Item ID</para> /// <para>Unfiltered Item ID</para>
/// <para>Complex Data Property, the ID the item that exposes the same complex data /// <para>Complex Data Property, the ID the item that exposes the same complex data
/// value without any data filter or with the default query applied to it. It is /// value without any data filter or with the default query applied to it. It is
/// mandatory for items that implement complex data filters or queries.</para> /// mandatory for items that implement complex data filters or queries.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID UNFILTERED_ITEM_ID = new TsDaPropertyID("unfilteredItemID", 608, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID UNFILTERED_ITEM_ID = new TsDaPropertyID("unfilteredItemID", 608, OpcNamespace.OPC_DATA_ACCESS);
/// <summary> /// <summary>
/// <para>Data Filter Value</para> /// <para>Data Filter Value</para>
/// <para>Complex Data Property, the value of the filter that is currently applied to /// <para>Complex Data Property, the value of the filter that is currently applied to
/// the item. It is mandatory for items that implement complex data filters or /// the item. It is mandatory for items that implement complex data filters or
/// queries.</para> /// queries.</para>
/// </summary> /// </summary>
public static readonly TsDaPropertyID DATA_FILTER_VALUE = new TsDaPropertyID("dataFilterValue", 609, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID DATA_FILTER_VALUE = new TsDaPropertyID("dataFilterValue", 609, OpcNamespace.OPC_DATA_ACCESS);
#endregion #endregion
#region XML Data Access Properties #region XML Data Access Properties
@@ -324,5 +324,5 @@ namespace Technosoftware.DaAeHdaClient.Da
public static readonly TsDaPropertyID VALUE_PRECISION = new TsDaPropertyID("valuePrecision", 111, OpcNamespace.OPC_DATA_ACCESS); public static readonly TsDaPropertyID VALUE_PRECISION = new TsDaPropertyID("valuePrecision", 111, OpcNamespace.OPC_DATA_ACCESS);
#endregion #endregion
} }
} }

View File

@@ -28,173 +28,173 @@ using System.Reflection;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Describes an item property. /// Describes an item property.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsDaPropertyDescription public class TsDaPropertyDescription
{ {
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with the specified values. /// Initializes the object with the specified values.
/// </summary> /// </summary>
public TsDaPropertyDescription(TsDaPropertyID id, Type type, string name) public TsDaPropertyDescription(TsDaPropertyID id, Type type, string name)
{ {
ID = id; ID = id;
Type = type; Type = type;
Name = name; Name = name;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The unique identifier for the property. /// The unique identifier for the property.
/// </summary> /// </summary>
public TsDaPropertyID ID { get; set; } public TsDaPropertyID ID { get; set; }
/// <summary> /// <summary>
/// The .NET data type for the property. /// The .NET data type for the property.
/// </summary> /// </summary>
public Type Type { get; set; } public Type Type { get; set; }
/// <summary> /// <summary>
/// The short description defined in the OPC specifications. /// The short description defined in the OPC specifications.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
#endregion #endregion
#region Data Access Properties #region Data Access Properties
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription DATATYPE = new TsDaPropertyDescription(TsDaProperty.DATATYPE, typeof(Type), "Item Canonical DataType"); public static readonly TsDaPropertyDescription DATATYPE = new TsDaPropertyDescription(TsDaProperty.DATATYPE, typeof(Type), "Item Canonical DataType");
/// <remarks/>
public static readonly TsDaPropertyDescription VALUE = new TsDaPropertyDescription(TsDaProperty.VALUE, typeof(object), "Item Value");
/// <remarks/>
public static readonly TsDaPropertyDescription QUALITY = new TsDaPropertyDescription(TsDaProperty.QUALITY, typeof(TsCDaQuality), "Item Quality");
/// <remarks/>
public static readonly TsDaPropertyDescription TIMESTAMP = new TsDaPropertyDescription(TsDaProperty.TIMESTAMP, typeof(DateTime), "Item Timestamp");
/// <remarks/>
public static readonly TsDaPropertyDescription ACCESSRIGHTS = new TsDaPropertyDescription(TsDaProperty.ACCESSRIGHTS, typeof(TsDaAccessRights), "Item Access Rights");
/// <remarks/>
public static readonly TsDaPropertyDescription SCANRATE = new TsDaPropertyDescription(TsDaProperty.SCANRATE, typeof(float), "Server Scan Rate");
/// <remarks/>
public static readonly TsDaPropertyDescription EUTYPE = new TsDaPropertyDescription(TsDaProperty.EUTYPE, typeof(TsDaEuType), "Item EU Type");
/// <remarks/>
public static readonly TsDaPropertyDescription EUINFO = new TsDaPropertyDescription(TsDaProperty.EUINFO, typeof(string[]), "Item EU Info");
/// <remarks/>
public static readonly TsDaPropertyDescription ENGINEERINGUINTS = new TsDaPropertyDescription(TsDaProperty.ENGINEERINGUINTS, typeof(string), "EU Units");
/// <remarks/>
public static readonly TsDaPropertyDescription DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.DESCRIPTION, typeof(string), "Item Description");
/// <remarks/>
public static readonly TsDaPropertyDescription HIGHEU = new TsDaPropertyDescription(TsDaProperty.HIGHEU, typeof(double), "High EU");
/// <remarks/>
public static readonly TsDaPropertyDescription LOWEU = new TsDaPropertyDescription(TsDaProperty.LOWEU, typeof(double), "Low EU");
/// <remarks/>
public static readonly TsDaPropertyDescription HIGHIR = new TsDaPropertyDescription(TsDaProperty.HIGHIR, typeof(double), "High Instrument Range");
/// <remarks/>
public static readonly TsDaPropertyDescription LOWIR = new TsDaPropertyDescription(TsDaProperty.LOWIR, typeof(double), "Low Instrument Range");
/// <remarks/>
public static readonly TsDaPropertyDescription CLOSELABEL = new TsDaPropertyDescription(TsDaProperty.CLOSELABEL, typeof(string), "Contact Close Label");
/// <remarks/>
public static readonly TsDaPropertyDescription OPENLABEL = new TsDaPropertyDescription(TsDaProperty.OPENLABEL, typeof(string), "Contact Open Label");
/// <remarks/>
public static readonly TsDaPropertyDescription TIMEZONE = new TsDaPropertyDescription(TsDaProperty.TIMEZONE, typeof(int), "Timezone");
/// <remarks/>
public static readonly TsDaPropertyDescription CONDITION_STATUS = new TsDaPropertyDescription(TsDaProperty.CONDITION_STATUS, typeof(string), "Condition Status");
/// <remarks/>
public static readonly TsDaPropertyDescription ALARM_QUICK_HELP = new TsDaPropertyDescription(TsDaProperty.ALARM_QUICK_HELP, typeof(string), "Alarm Quick Help");
/// <remarks/>
public static readonly TsDaPropertyDescription ALARM_AREA_LIST = new TsDaPropertyDescription(TsDaProperty.ALARM_AREA_LIST, typeof(string), "Alarm Area List");
/// <remarks/>
public static readonly TsDaPropertyDescription PRIMARY_ALARM_AREA = new TsDaPropertyDescription(TsDaProperty.PRIMARY_ALARM_AREA, typeof(string), "Primary Alarm Area");
/// <remarks/>
public static readonly TsDaPropertyDescription CONDITION_LOGIC = new TsDaPropertyDescription(TsDaProperty.CONDITION_LOGIC, typeof(string), "Condition Logic");
/// <remarks/>
public static readonly TsDaPropertyDescription LIMIT_EXCEEDED = new TsDaPropertyDescription(TsDaProperty.LIMIT_EXCEEDED, typeof(string), "Limit Exceeded");
/// <remarks/>
public static readonly TsDaPropertyDescription DEADBAND = new TsDaPropertyDescription(TsDaProperty.DEADBAND, typeof(double), "Deadband");
/// <remarks/>
public static readonly TsDaPropertyDescription HIHI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HIHI_LIMIT, typeof(double), "HiHi Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription HI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HI_LIMIT, typeof(double), "Hi Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription LO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LO_LIMIT, typeof(double), "Lo Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription LOLO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LOLO_LIMIT, typeof(double), "LoLo Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription RATE_CHANGE_LIMIT = new TsDaPropertyDescription(TsDaProperty.RATE_CHANGE_LIMIT, typeof(double), "Rate of Change Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription DEVIATION_LIMIT = new TsDaPropertyDescription(TsDaProperty.DEVIATION_LIMIT, typeof(double), "Deviation Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription SOUNDFILE = new TsDaPropertyDescription(TsDaProperty.SOUNDFILE, typeof(string), "Sound File");
#endregion
#region Complex Data Properties
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription TYPE_SYSTEM_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_SYSTEM_ID, typeof(string), "Type System ID"); public static readonly TsDaPropertyDescription VALUE = new TsDaPropertyDescription(TsDaProperty.VALUE, typeof(object), "Item Value");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription DICTIONARY_ID = new TsDaPropertyDescription(TsDaProperty.DICTIONARY_ID, typeof(string), "Dictionary ID"); public static readonly TsDaPropertyDescription QUALITY = new TsDaPropertyDescription(TsDaProperty.QUALITY, typeof(TsCDaQuality), "Item Quality");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription TYPE_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_ID, typeof(string), "Type ID"); public static readonly TsDaPropertyDescription TIMESTAMP = new TsDaPropertyDescription(TsDaProperty.TIMESTAMP, typeof(DateTime), "Item Timestamp");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription DICTIONARY = new TsDaPropertyDescription(TsDaProperty.DICTIONARY, typeof(object), "Dictionary"); public static readonly TsDaPropertyDescription ACCESSRIGHTS = new TsDaPropertyDescription(TsDaProperty.ACCESSRIGHTS, typeof(TsDaAccessRights), "Item Access Rights");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription TYPE_DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.TYPE_DESCRIPTION, typeof(string), "Type Description"); public static readonly TsDaPropertyDescription SCANRATE = new TsDaPropertyDescription(TsDaProperty.SCANRATE, typeof(float), "Server Scan Rate");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription CONSISTENCY_WINDOW = new TsDaPropertyDescription(TsDaProperty.CONSISTENCY_WINDOW, typeof(string), "Consistency Window"); public static readonly TsDaPropertyDescription EUTYPE = new TsDaPropertyDescription(TsDaProperty.EUTYPE, typeof(TsDaEuType), "Item EU Type");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription WRITE_BEHAVIOR = new TsDaPropertyDescription(TsDaProperty.WRITE_BEHAVIOR, typeof(string), "Write Behavior"); public static readonly TsDaPropertyDescription EUINFO = new TsDaPropertyDescription(TsDaProperty.EUINFO, typeof(string[]), "Item EU Info");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription UNCONVERTED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNCONVERTED_ITEM_ID, typeof(string), "Unconverted Item ID"); public static readonly TsDaPropertyDescription ENGINEERINGUINTS = new TsDaPropertyDescription(TsDaProperty.ENGINEERINGUINTS, typeof(string), "EU Units");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription UNFILTERED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNFILTERED_ITEM_ID, typeof(string), "Unfiltered Item ID"); public static readonly TsDaPropertyDescription DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.DESCRIPTION, typeof(string), "Item Description");
/// <remarks/> /// <remarks/>
public static readonly TsDaPropertyDescription DATA_FILTER_VALUE = new TsDaPropertyDescription(TsDaProperty.DATA_FILTER_VALUE, typeof(string), "Data Filter Value"); public static readonly TsDaPropertyDescription HIGHEU = new TsDaPropertyDescription(TsDaProperty.HIGHEU, typeof(double), "High EU");
/// <remarks/>
public static readonly TsDaPropertyDescription LOWEU = new TsDaPropertyDescription(TsDaProperty.LOWEU, typeof(double), "Low EU");
/// <remarks/>
public static readonly TsDaPropertyDescription HIGHIR = new TsDaPropertyDescription(TsDaProperty.HIGHIR, typeof(double), "High Instrument Range");
/// <remarks/>
public static readonly TsDaPropertyDescription LOWIR = new TsDaPropertyDescription(TsDaProperty.LOWIR, typeof(double), "Low Instrument Range");
/// <remarks/>
public static readonly TsDaPropertyDescription CLOSELABEL = new TsDaPropertyDescription(TsDaProperty.CLOSELABEL, typeof(string), "Contact Close Label");
/// <remarks/>
public static readonly TsDaPropertyDescription OPENLABEL = new TsDaPropertyDescription(TsDaProperty.OPENLABEL, typeof(string), "Contact Open Label");
/// <remarks/>
public static readonly TsDaPropertyDescription TIMEZONE = new TsDaPropertyDescription(TsDaProperty.TIMEZONE, typeof(int), "Timezone");
/// <remarks/>
public static readonly TsDaPropertyDescription CONDITION_STATUS = new TsDaPropertyDescription(TsDaProperty.CONDITION_STATUS, typeof(string), "Condition Status");
/// <remarks/>
public static readonly TsDaPropertyDescription ALARM_QUICK_HELP = new TsDaPropertyDescription(TsDaProperty.ALARM_QUICK_HELP, typeof(string), "Alarm Quick Help");
/// <remarks/>
public static readonly TsDaPropertyDescription ALARM_AREA_LIST = new TsDaPropertyDescription(TsDaProperty.ALARM_AREA_LIST, typeof(string), "Alarm Area List");
/// <remarks/>
public static readonly TsDaPropertyDescription PRIMARY_ALARM_AREA = new TsDaPropertyDescription(TsDaProperty.PRIMARY_ALARM_AREA, typeof(string), "Primary Alarm Area");
/// <remarks/>
public static readonly TsDaPropertyDescription CONDITION_LOGIC = new TsDaPropertyDescription(TsDaProperty.CONDITION_LOGIC, typeof(string), "Condition Logic");
/// <remarks/>
public static readonly TsDaPropertyDescription LIMIT_EXCEEDED = new TsDaPropertyDescription(TsDaProperty.LIMIT_EXCEEDED, typeof(string), "Limit Exceeded");
/// <remarks/>
public static readonly TsDaPropertyDescription DEADBAND = new TsDaPropertyDescription(TsDaProperty.DEADBAND, typeof(double), "Deadband");
/// <remarks/>
public static readonly TsDaPropertyDescription HIHI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HIHI_LIMIT, typeof(double), "HiHi Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription HI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HI_LIMIT, typeof(double), "Hi Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription LO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LO_LIMIT, typeof(double), "Lo Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription LOLO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LOLO_LIMIT, typeof(double), "LoLo Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription RATE_CHANGE_LIMIT = new TsDaPropertyDescription(TsDaProperty.RATE_CHANGE_LIMIT, typeof(double), "Rate of Change Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription DEVIATION_LIMIT = new TsDaPropertyDescription(TsDaProperty.DEVIATION_LIMIT, typeof(double), "Deviation Limit");
/// <remarks/>
public static readonly TsDaPropertyDescription SOUNDFILE = new TsDaPropertyDescription(TsDaProperty.SOUNDFILE, typeof(string), "Sound File");
#endregion #endregion
#region Object Member Overrides #region Complex Data Properties
/// <remarks/>
public static readonly TsDaPropertyDescription TYPE_SYSTEM_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_SYSTEM_ID, typeof(string), "Type System ID");
/// <remarks/>
public static readonly TsDaPropertyDescription DICTIONARY_ID = new TsDaPropertyDescription(TsDaProperty.DICTIONARY_ID, typeof(string), "Dictionary ID");
/// <remarks/>
public static readonly TsDaPropertyDescription TYPE_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_ID, typeof(string), "Type ID");
/// <remarks/>
public static readonly TsDaPropertyDescription DICTIONARY = new TsDaPropertyDescription(TsDaProperty.DICTIONARY, typeof(object), "Dictionary");
/// <remarks/>
public static readonly TsDaPropertyDescription TYPE_DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.TYPE_DESCRIPTION, typeof(string), "Type Description");
/// <remarks/>
public static readonly TsDaPropertyDescription CONSISTENCY_WINDOW = new TsDaPropertyDescription(TsDaProperty.CONSISTENCY_WINDOW, typeof(string), "Consistency Window");
/// <remarks/>
public static readonly TsDaPropertyDescription WRITE_BEHAVIOR = new TsDaPropertyDescription(TsDaProperty.WRITE_BEHAVIOR, typeof(string), "Write Behavior");
/// <remarks/>
public static readonly TsDaPropertyDescription UNCONVERTED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNCONVERTED_ITEM_ID, typeof(string), "Unconverted Item ID");
/// <remarks/>
public static readonly TsDaPropertyDescription UNFILTERED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNFILTERED_ITEM_ID, typeof(string), "Unfiltered Item ID");
/// <remarks/>
public static readonly TsDaPropertyDescription DATA_FILTER_VALUE = new TsDaPropertyDescription(TsDaProperty.DATA_FILTER_VALUE, typeof(string), "Data Filter Value");
#endregion
#region Object Member Overrides
/// <summary> /// <summary>
/// Converts the description to a string. /// Converts the description to a string.
/// </summary> /// </summary>
public override string ToString() public override string ToString()
{ {
return Name; return Name;
} }
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Returns the description for the specified property. /// Returns the description for the specified property.
/// </summary> /// </summary>
public static TsDaPropertyDescription Find(TsDaPropertyID id) public static TsDaPropertyDescription Find(TsDaPropertyID id)
{ {
var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public); var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public);
foreach (var field in fields) foreach (var field in fields)
{ {
var property = (TsDaPropertyDescription)field.GetValue(typeof(TsDaPropertyDescription)); var property = (TsDaPropertyDescription)field.GetValue(typeof(TsDaPropertyDescription));
if (property.ID == id) if (property.ID == id)
{ {
return property; return property;
} }
} }
return null; return null;
} }
/// <summary> /// <summary>
/// Returns an array of all well-known property descriptions. /// Returns an array of all well-known property descriptions.
/// </summary> /// </summary>
public static TsDaPropertyDescription[] Enumerate() public static TsDaPropertyDescription[] Enumerate()
{ {
var values = new ArrayList(); var values = new ArrayList();
var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public); var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public);
Array.ForEach(fields, field => values.Add(field.GetValue(typeof(TsDaPropertyDescription)))); Array.ForEach(fields, field => values.Add(field.GetValue(typeof(TsDaPropertyDescription))));
return (TsDaPropertyDescription[])values.ToArray(typeof(TsDaPropertyDescription)); return (TsDaPropertyDescription[])values.ToArray(typeof(TsDaPropertyDescription));
} }
#endregion #endregion
} }
} }

View File

@@ -22,91 +22,91 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Xml;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Xml;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Contains a unique identifier for a property. /// Contains a unique identifier for a property.
/// </summary> /// </summary>
[Serializable] [Serializable]
public struct TsDaPropertyID : ISerializable public struct TsDaPropertyID : ISerializable
{ {
#region Names Class #region Names Class
/// <summary> /// <summary>
/// A set of names for fields used in serialization. /// A set of names for fields used in serialization.
/// </summary> /// </summary>
private class Names private class Names
{ {
internal const string Name = "NA"; internal const string Name = "NA";
internal const string Namespace = "NS"; internal const string Namespace = "NS";
internal const string Code = "CO"; internal const string Code = "CO";
} }
#endregion #endregion
#region Fields #region Fields
private int code_; private int code_;
private XmlQualifiedName qualifiedName_; private XmlQualifiedName qualifiedName_;
#endregion
#region Constructors, Destructor, Initialization
/// <summary>
/// Initializes a property identified by a qualified name.
/// </summary>
public TsDaPropertyID(XmlQualifiedName name) { qualifiedName_ = name; code_ = 0; }
/// <summary>
/// Initializes a property identified by an integer.
/// </summary>
public TsDaPropertyID(int code) { qualifiedName_ = null; code_ = code; }
/// <summary>
/// Initializes a property identified by a property description.
/// </summary>
public TsDaPropertyID(string name, int code, string ns) { qualifiedName_ = new XmlQualifiedName(name, ns); code_ = code; }
///<remarks>
/// During deserialization, SerializationInfo is passed to the class using the constructor provided for this purpose. Any visibility
/// constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public,
/// protected, internal, or private. However, it is best practice to make the constructor protected unless the class is sealed, in which case
/// the constructor should be marked private. The constructor should also perform thorough input validation. To avoid misuse by malicious code,
/// the constructor should enforce the same security checks and permissions required to obtain an instance of the class using any other
/// constructor.
/// </remarks>
/// <summary>
/// Constructs a server by de-serializing its OpcUrl from the stream.
/// </summary>
private TsDaPropertyID(SerializationInfo info, StreamingContext context)
{
var enumerator = info.GetEnumerator();
var name = "";
var ns = "";
enumerator.Reset();
while (enumerator.MoveNext())
{
if (enumerator.Current.Name.Equals(Names.Name))
{
name = (string)enumerator.Current.Value;
continue;
}
if (enumerator.Current.Name.Equals(Names.Namespace))
{
ns = (string)enumerator.Current.Value;
}
}
qualifiedName_ = new XmlQualifiedName(name, ns);
code_ = (int)info.GetValue(Names.Code, typeof(int));
}
#endregion #endregion
#region Properties #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Used for properties identified by a qualified name. /// Initializes a property identified by a qualified name.
/// </summary> /// </summary>
public XmlQualifiedName Name => qualifiedName_; public TsDaPropertyID(XmlQualifiedName name) { qualifiedName_ = name; code_ = 0; }
/// <summary>
/// Initializes a property identified by an integer.
/// </summary>
public TsDaPropertyID(int code) { qualifiedName_ = null; code_ = code; }
/// <summary>
/// Initializes a property identified by a property description.
/// </summary>
public TsDaPropertyID(string name, int code, string ns) { qualifiedName_ = new XmlQualifiedName(name, ns); code_ = code; }
///<remarks>
/// During deserialization, SerializationInfo is passed to the class using the constructor provided for this purpose. Any visibility
/// constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public,
/// protected, internal, or private. However, it is best practice to make the constructor protected unless the class is sealed, in which case
/// the constructor should be marked private. The constructor should also perform thorough input validation. To avoid misuse by malicious code,
/// the constructor should enforce the same security checks and permissions required to obtain an instance of the class using any other
/// constructor.
/// </remarks>
/// <summary>
/// Constructs a server by de-serializing its OpcUrl from the stream.
/// </summary>
private TsDaPropertyID(SerializationInfo info, StreamingContext context)
{
var enumerator = info.GetEnumerator();
var name = "";
var ns = "";
enumerator.Reset();
while (enumerator.MoveNext())
{
if (enumerator.Current.Name.Equals(Names.Name))
{
name = (string)enumerator.Current.Value;
continue;
}
if (enumerator.Current.Name.Equals(Names.Namespace))
{
ns = (string)enumerator.Current.Value;
}
}
qualifiedName_ = new XmlQualifiedName(name, ns);
code_ = (int)info.GetValue(Names.Code, typeof(int));
}
#endregion
#region Properties
/// <summary>
/// Used for properties identified by a qualified name.
/// </summary>
public XmlQualifiedName Name => qualifiedName_;
/// <summary> /// <summary>
/// Used for properties identified by a integer. /// Used for properties identified by a integer.
@@ -114,85 +114,85 @@ namespace Technosoftware.DaAeHdaClient.Da
public int Code => code_; public int Code => code_;
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Returns true if the objects are equal. /// Returns true if the objects are equal.
/// </summary> /// </summary>
public static bool operator ==(TsDaPropertyID a, TsDaPropertyID b) public static bool operator ==(TsDaPropertyID a, TsDaPropertyID b)
{ {
return a.Equals(b); return a.Equals(b);
} }
/// <summary> /// <summary>
/// Returns true if the objects are not equal. /// Returns true if the objects are not equal.
/// </summary> /// </summary>
public static bool operator !=(TsDaPropertyID a, TsDaPropertyID b) public static bool operator !=(TsDaPropertyID a, TsDaPropertyID b)
{ {
return !a.Equals(b); return !a.Equals(b);
} }
#endregion #endregion
#region Serialization Functions #region Serialization Functions
/// <summary> /// <summary>
/// Serializes a server into a stream. /// Serializes a server into a stream.
/// </summary> /// </summary>
public void GetObjectData(SerializationInfo info, StreamingContext context) public void GetObjectData(SerializationInfo info, StreamingContext context)
{ {
if (qualifiedName_ != null) if (qualifiedName_ != null)
{ {
info.AddValue(Names.Name, qualifiedName_.Name); info.AddValue(Names.Name, qualifiedName_.Name);
info.AddValue(Names.Namespace, qualifiedName_.Namespace); info.AddValue(Names.Namespace, qualifiedName_.Namespace);
} }
info.AddValue(Names.Code, code_); info.AddValue(Names.Code, code_);
} }
#endregion #endregion
#region Object Member Overrides #region Object Member Overrides
/// <summary> /// <summary>
/// Returns true if the target object is equal to the object. /// Returns true if the target object is equal to the object.
/// </summary> /// </summary>
public override bool Equals(object target) public override bool Equals(object target)
{ {
if (target != null && target.GetType() == typeof(TsDaPropertyID)) if (target != null && target.GetType() == typeof(TsDaPropertyID))
{ {
var propertyId = (TsDaPropertyID)target; var propertyId = (TsDaPropertyID)target;
// compare by integer if both specify valid integers. // compare by integer if both specify valid integers.
if (propertyId.Code != 0 && Code != 0) if (propertyId.Code != 0 && Code != 0)
{ {
return (propertyId.Code == Code); return (propertyId.Code == Code);
} }
// compare by name if both specify valid names. // compare by name if both specify valid names.
if (propertyId.Name != null && Name != null) if (propertyId.Name != null && Name != null)
{ {
return (propertyId.Name == Name); return (propertyId.Name == Name);
} }
} }
return false; return false;
} }
/// <summary> /// <summary>
/// Returns a useful hash code for the object. /// Returns a useful hash code for the object.
/// </summary> /// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
if (Code != 0) return Code.GetHashCode(); if (Code != 0) return Code.GetHashCode();
if (Name != null) return Name.GetHashCode(); if (Name != null) return Name.GetHashCode();
return base.GetHashCode(); return base.GetHashCode();
} }
/// <summary> /// <summary>
/// Converts the property id to a string. /// Converts the property id to a string.
/// </summary> /// </summary>
public override string ToString() public override string ToString()
{ {
if (Name != null && Code != 0) return $"{Name.Name} ({Code})"; if (Name != null && Code != 0) return $"{Name.Name} ({Code})";
if (Name != null) return Name.Name; if (Name != null) return Name.Name;
if (Code != 0) return $"{Code}"; if (Code != 0) return $"{Code}";
return ""; return "";
} }
#endregion #endregion
} }
} }

View File

@@ -27,225 +27,225 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Contains the quality field for an item value. /// Contains the quality field for an item value.
/// </summary> /// </summary>
[Serializable] [Serializable]
public struct TsCDaQuality public struct TsCDaQuality
{ {
#region Fields #region Fields
private TsDaQualityBits qualityBits_; private TsDaQualityBits qualityBits_;
private TsDaLimitBits limitBits_; private TsDaLimitBits limitBits_;
private byte vendorBits_; private byte vendorBits_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with the specified quality. /// Initializes the object with the specified quality.
/// </summary> /// </summary>
public TsCDaQuality(TsDaQualityBits quality) public TsCDaQuality(TsDaQualityBits quality)
{ {
qualityBits_ = quality; qualityBits_ = quality;
limitBits_ = TsDaLimitBits.None; limitBits_ = TsDaLimitBits.None;
vendorBits_ = 0; vendorBits_ = 0;
} }
/// <summary> /// <summary>
/// Initializes the object from the contents of a 16 bit integer. /// Initializes the object from the contents of a 16 bit integer.
/// </summary> /// </summary>
public TsCDaQuality(short code) public TsCDaQuality(short code)
{ {
qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask); qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask);
limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask); limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask);
vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8); vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8);
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The value in the quality bits field. /// The value in the quality bits field.
/// </summary> /// </summary>
public TsDaQualityBits QualityBits public TsDaQualityBits QualityBits
{ {
get => qualityBits_; get => qualityBits_;
set => qualityBits_ = value; set => qualityBits_ = value;
} }
/// <summary> /// <summary>
/// The value in the limit bits field. /// The value in the limit bits field.
/// </summary> /// </summary>
public TsDaLimitBits LimitBits public TsDaLimitBits LimitBits
{ {
get => limitBits_; get => limitBits_;
set => limitBits_ = value; set => limitBits_ = value;
} }
/// <summary> /// <summary>
/// The value in the quality bits field. /// The value in the quality bits field.
/// </summary> /// </summary>
public byte VendorBits public byte VendorBits
{ {
get => vendorBits_; get => vendorBits_;
set => vendorBits_ = value; set => vendorBits_ = value;
} }
/// <summary> /// <summary>
/// A 'good' quality value. /// A 'good' quality value.
/// </summary> /// </summary>
public static readonly TsCDaQuality Good = new TsCDaQuality(TsDaQualityBits.Good); public static readonly TsCDaQuality Good = new TsCDaQuality(TsDaQualityBits.Good);
/// <summary> /// <summary>
/// An 'bad' quality value. /// An 'bad' quality value.
/// </summary> /// </summary>
public static readonly TsCDaQuality Bad = new TsCDaQuality(TsDaQualityBits.Bad); public static readonly TsCDaQuality Bad = new TsCDaQuality(TsDaQualityBits.Bad);
#endregion #endregion
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Returns the quality as a 16 bit integer. /// Returns the quality as a 16 bit integer.
/// </summary> /// </summary>
public short GetCode() public short GetCode()
{ {
ushort code = 0; ushort code = 0;
code |= (ushort)QualityBits; code |= (ushort)QualityBits;
code |= (ushort)LimitBits; code |= (ushort)LimitBits;
code |= (ushort)(VendorBits << 8); code |= (ushort)(VendorBits << 8);
return (code <= short.MaxValue) ? (short)code : (short)-((ushort.MaxValue + 1 - code)); return (code <= short.MaxValue) ? (short)code : (short)-((ushort.MaxValue + 1 - code));
} }
/// <summary> /// <summary>
/// Initializes the quality from a 16 bit integer. /// Initializes the quality from a 16 bit integer.
/// </summary> /// </summary>
public void SetCode(short code) public void SetCode(short code)
{ {
qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask); qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask);
limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask); limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask);
vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8); vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8);
} }
/// <summary> /// <summary>
/// Returns true if the objects are equal. /// Returns true if the objects are equal.
/// </summary> /// </summary>
public static bool operator ==(TsCDaQuality a, TsCDaQuality b) public static bool operator ==(TsCDaQuality a, TsCDaQuality b)
{ {
return a.Equals(b); return a.Equals(b);
} }
/// <summary> /// <summary>
/// Returns true if the objects are not equal. /// Returns true if the objects are not equal.
/// </summary> /// </summary>
public static bool operator !=(TsCDaQuality a, TsCDaQuality b) public static bool operator !=(TsCDaQuality a, TsCDaQuality b)
{ {
return !a.Equals(b); return !a.Equals(b);
} }
#endregion #endregion
#region Object Member Overrides #region Object Member Overrides
/// <summary> /// <summary>
/// Converts a quality to a string with the format: 'quality[limit]:vendor'. /// Converts a quality to a string with the format: 'quality[limit]:vendor'.
/// </summary> /// </summary>
public override string ToString() public override string ToString()
{ {
string text = null; string text = null;
switch (QualityBits) switch (QualityBits)
{ {
case TsDaQualityBits.Good: case TsDaQualityBits.Good:
text += "(Good"; text += "(Good";
break; break;
case TsDaQualityBits.GoodLocalOverride: case TsDaQualityBits.GoodLocalOverride:
text += "(Good:Local Override"; text += "(Good:Local Override";
break; break;
case TsDaQualityBits.Bad: case TsDaQualityBits.Bad:
text += "(Bad"; text += "(Bad";
break; break;
case TsDaQualityBits.BadConfigurationError: case TsDaQualityBits.BadConfigurationError:
text += "(Bad:Configuration Error"; text += "(Bad:Configuration Error";
break; break;
case TsDaQualityBits.BadNotConnected: case TsDaQualityBits.BadNotConnected:
text += "(Bad:Not Connected"; text += "(Bad:Not Connected";
break; break;
case TsDaQualityBits.BadDeviceFailure: case TsDaQualityBits.BadDeviceFailure:
text += "(Bad:Device Failure"; text += "(Bad:Device Failure";
break; break;
case TsDaQualityBits.BadSensorFailure: case TsDaQualityBits.BadSensorFailure:
text += "(Bad:Sensor Failure"; text += "(Bad:Sensor Failure";
break; break;
case TsDaQualityBits.BadLastKnownValue: case TsDaQualityBits.BadLastKnownValue:
text += "(Bad:Last Known Value"; text += "(Bad:Last Known Value";
break; break;
case TsDaQualityBits.BadCommFailure: case TsDaQualityBits.BadCommFailure:
text += "(Bad:Communication Failure"; text += "(Bad:Communication Failure";
break; break;
case TsDaQualityBits.BadOutOfService: case TsDaQualityBits.BadOutOfService:
text += "(Bad:Out of Service"; text += "(Bad:Out of Service";
break; break;
case TsDaQualityBits.BadWaitingForInitialData: case TsDaQualityBits.BadWaitingForInitialData:
text += "(Bad:Waiting for Initial Data"; text += "(Bad:Waiting for Initial Data";
break; break;
case TsDaQualityBits.Uncertain: case TsDaQualityBits.Uncertain:
text += "(Uncertain"; text += "(Uncertain";
break; break;
case TsDaQualityBits.UncertainLastUsableValue: case TsDaQualityBits.UncertainLastUsableValue:
text += "(Uncertain:Last Usable Value"; text += "(Uncertain:Last Usable Value";
break; break;
case TsDaQualityBits.UncertainSensorNotAccurate: case TsDaQualityBits.UncertainSensorNotAccurate:
text += "(Uncertain:Sensor not Accurate"; text += "(Uncertain:Sensor not Accurate";
break; break;
case TsDaQualityBits.UncertainEUExceeded: case TsDaQualityBits.UncertainEUExceeded:
text += "(Uncertain:Engineering Unit exceeded"; text += "(Uncertain:Engineering Unit exceeded";
break; break;
case TsDaQualityBits.UncertainSubNormal: case TsDaQualityBits.UncertainSubNormal:
text += "(Uncertain:Sub Normal"; text += "(Uncertain:Sub Normal";
break; break;
} }
if (LimitBits != TsDaLimitBits.None) if (LimitBits != TsDaLimitBits.None)
{ {
text += $":[{LimitBits.ToString()}]"; text += $":[{LimitBits.ToString()}]";
} }
else else
{ {
text += ":Not Limited"; text += ":Not Limited";
} }
if (VendorBits != 0) if (VendorBits != 0)
{ {
text += $":{VendorBits,0:X})"; text += $":{VendorBits,0:X})";
} }
else else
{ {
text += ")"; text += ")";
} }
return text; return text;
} }
/// <summary> /// <summary>
/// Determines whether the specified Object is equal to the current Quality /// Determines whether the specified Object is equal to the current Quality
/// </summary> /// </summary>
public override bool Equals(object target) public override bool Equals(object target)
{ {
if (target == null || target.GetType() != typeof(TsCDaQuality)) return false; if (target == null || target.GetType() != typeof(TsCDaQuality)) return false;
var quality = (TsCDaQuality)target; var quality = (TsCDaQuality)target;
if (QualityBits != quality.QualityBits) return false; if (QualityBits != quality.QualityBits) return false;
if (LimitBits != quality.LimitBits) return false; if (LimitBits != quality.LimitBits) return false;
if (VendorBits != quality.VendorBits) return false; if (VendorBits != quality.VendorBits) return false;
return true; return true;
} }
/// <summary> /// <summary>
/// Returns hash code for the current Quality. /// Returns hash code for the current Quality.
/// </summary> /// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return GetCode(); return GetCode();
} }
#endregion #endregion
} }
} }

View File

@@ -25,90 +25,90 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// <para>Defines the possible quality status bits.</para> /// <para>Defines the possible quality status bits.</para>
/// <para>These flags represent the quality state for an item's data value. This is /// <para>These flags represent the quality state for an item's data value. This is
/// intended to be similar to but slightly simpler than the Field-bus Data Quality /// intended to be similar to but slightly simpler than the Field-bus Data Quality
/// Specification (section 4.4.1 in the H1 Final Specifications). This design makes it /// Specification (section 4.4.1 in the H1 Final Specifications). This design makes it
/// fairly easy for both servers and client applications to determine how much /// fairly easy for both servers and client applications to determine how much
/// functionality they want to implement.</para> /// functionality they want to implement.</para>
/// </summary> /// </summary>
public enum TsDaQualityBits public enum TsDaQualityBits
{ {
/// <summary>The Quality of the value is Good.</summary> /// <summary>The Quality of the value is Good.</summary>
Good = 0x000000C0, Good = 0x000000C0,
/// <summary>The value has been Overridden. Typically this means the input has been disconnected and a manually entered value has been 'forced'.</summary> /// <summary>The value has been Overridden. Typically this means the input has been disconnected and a manually entered value has been 'forced'.</summary>
GoodLocalOverride = 0x000000D8, GoodLocalOverride = 0x000000D8,
/// <summary>The value is bad but no specific reason is known.</summary> /// <summary>The value is bad but no specific reason is known.</summary>
Bad = 0x00000000, Bad = 0x00000000,
/// <summary> /// <summary>
/// There is some server specific problem with the configuration. For example the /// There is some server specific problem with the configuration. For example the
/// item in question has been deleted from the configuration. /// item in question has been deleted from the configuration.
/// </summary> /// </summary>
BadConfigurationError = 0x00000004, BadConfigurationError = 0x00000004,
/// <summary> /// <summary>
/// The input is required to be logically connected to something but is not. This /// The input is required to be logically connected to something but is not. This
/// quality may reflect that no value is available at this time, for reasons like the value /// quality may reflect that no value is available at this time, for reasons like the value
/// may have not been provided by the data source. /// may have not been provided by the data source.
/// </summary> /// </summary>
BadNotConnected = 0x00000008, BadNotConnected = 0x00000008,
/// <summary>A device failure has been detected.</summary> /// <summary>A device failure has been detected.</summary>
BadDeviceFailure = 0x0000000c, BadDeviceFailure = 0x0000000c,
/// <summary> /// <summary>
/// A sensor failure had been detected (the Limits field can provide additional /// A sensor failure had been detected (the Limits?field can provide additional
/// diagnostic information in some situations). /// diagnostic information in some situations).
/// </summary> /// </summary>
BadSensorFailure = 0x00000010, BadSensorFailure = 0x00000010,
/// <summary> /// <summary>
/// Communications have failed. However, the last known value is available. Note that /// Communications have failed. However, the last known value is available. Note that
/// the age of the value may be determined from the time stamp in the item state. /// the age?of the value may be determined from the time stamp in the item state.
/// </summary> /// </summary>
BadLastKnownValue = 0x00000014, BadLastKnownValue = 0x00000014,
/// <summary>Communications have failed. There is no last known value is available.</summary> /// <summary>Communications have failed. There is no last known value is available.</summary>
BadCommFailure = 0x00000018, BadCommFailure = 0x00000018,
/// <summary> /// <summary>
/// The block is off scan or otherwise locked. This quality is also used when the /// The block is off scan or otherwise locked. This quality is also used when the
/// active state of the item or the subscription containing the item is InActive. /// active state of the item or the subscription containing the item is InActive.
/// </summary> /// </summary>
BadOutOfService = 0x0000001C, BadOutOfService = 0x0000001C,
/// <summary> /// <summary>
/// After Items are added to a subscription, it may take some time for the server to /// After Items are added to a subscription, it may take some time for the server to
/// actually obtain values for these items. In such cases the client might perform a read /// actually obtain values for these items. In such cases the client might perform a read
/// (from cache), or establish a ConnectionPoint based subscription and/or execute a /// (from cache), or establish a ConnectionPoint based subscription and/or execute a
/// Refresh on such a subscription before the values are available. This sub-status is only /// Refresh on such a subscription before the values are available. This sub-status is only
/// available from OPC DA 3.0 or newer servers. /// available from OPC DA 3.0 or newer servers.
/// </summary> /// </summary>
BadWaitingForInitialData = 0x00000020, BadWaitingForInitialData = 0x00000020,
/// <summary>There is no specific reason why the value is uncertain.</summary> /// <summary>There is no specific reason why the value is uncertain.</summary>
Uncertain = 0x00000040, Uncertain = 0x00000040,
/// <summary> /// <summary>
/// Whatever was writing this value has stopped doing so. The returned value should /// Whatever was writing this value has stopped doing so. The returned value should
/// be regarded as stale. Note that this differs from a BAD value with sub-status /// be regarded as stale? Note that this differs from a BAD value with sub-status
/// badLastKnownValue (Last Known Value). That status is associated specifically with a /// badLastKnownValue (Last Known Value). That status is associated specifically with a
/// detectable communications error on a fetched value. This error is associated with the /// detectable communications error on a fetched?value. This error is associated with the
/// failure of some external source to put something into the value within an acceptable /// failure of some external source to put?something into the value within an acceptable
/// period of time. Note that the age of the value can be determined from the time stamp /// period of time. Note that the age?of the value can be determined from the time stamp
/// in the item state. /// in the item state.
/// </summary> /// </summary>
UncertainLastUsableValue = 0x00000044, UncertainLastUsableValue = 0x00000044,
/// <summary> /// <summary>
/// Either the value has pegged at one of the sensor limits (in which case the /// Either the value has pegged?at one of the sensor limits (in which case the
/// limit field should be set to low or high) or the sensor is otherwise known to be out of /// limit field should be set to low or high) or the sensor is otherwise known to be out of
/// calibration via some form of internal diagnostics (in which case the limit field should /// calibration via some form of internal diagnostics (in which case the limit field should
/// be none). /// be none).
/// </summary> /// </summary>
UncertainSensorNotAccurate = 0x00000050, UncertainSensorNotAccurate = 0x00000050,
/// <summary> /// <summary>
/// The returned value is outside the limits defined for this parameter. Note that in /// The returned value is outside the limits defined for this parameter. Note that in
/// this case (per the Field-bus Specification) the Limits field indicates which limit has /// this case (per the Field-bus Specification) the Limits?field indicates which limit has
/// been exceeded but does NOT necessarily imply that the value cannot move farther out of /// been exceeded but does NOT necessarily imply that the value cannot move farther out of
/// range. /// range.
/// </summary> /// </summary>
UncertainEUExceeded = 0x00000054, UncertainEUExceeded = 0x00000054,
/// <summary> /// <summary>
/// The value is derived from multiple sources and has less than the required number /// The value is derived from multiple sources and has less than the required number
/// of Good sources. /// of Good sources.
/// </summary> /// </summary>
UncertainSubNormal = 0x00000058 UncertainSubNormal = 0x00000058
} }
} }

View File

@@ -25,16 +25,16 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Defines bit masks for the quality. /// Defines bit masks for the quality.
/// </summary> /// </summary>
public enum TsDaQualityMasks : int public enum TsDaQualityMasks : int
{ {
/// <summary>Quality related bits</summary> /// <summary>Quality related bits</summary>
QualityMask = +0x00FC, QualityMask = +0x00FC,
/// <summary>Limit related bits</summary> /// <summary>Limit related bits</summary>
LimitMask = +0x0003, LimitMask = +0x0003,
/// <summary>Vendor specific bits</summary> /// <summary>Vendor specific bits</summary>
VendorMask = -0x00FD VendorMask = -0x00FD
} }
} }

View File

@@ -26,33 +26,33 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Describes the state of a subscription. /// Describes the state of a subscription.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TsCDaRequest : IOpcRequest public class TsCDaRequest : IOpcRequest
{ {
#region Fields #region Fields
private ITsCDaSubscription subscription_; private ITsCDaSubscription subscription_;
private object handle_; private object handle_;
#endregion #endregion
#region Constructors, Destructor, Initialization #region Constructors, Destructor, Initialization
/// <summary> /// <summary>
/// Initializes the object with a subscription and a unique id. /// Initializes the object with a subscription and a unique id.
/// </summary> /// </summary>
public TsCDaRequest(ITsCDaSubscription subscription, object handle) public TsCDaRequest(ITsCDaSubscription subscription, object handle)
{ {
subscription_ = subscription; subscription_ = subscription;
handle_ = handle; handle_ = handle;
} }
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// The subscription processing the request. /// The subscription processing the request.
/// </summary> /// </summary>
public ITsCDaSubscription Subscription => subscription_; public ITsCDaSubscription Subscription => subscription_;
/// <summary> /// <summary>
/// An unique identifier, assigned by the client, for the request. /// An unique identifier, assigned by the client, for the request.
@@ -66,5 +66,5 @@ namespace Technosoftware.DaAeHdaClient.Da
/// </summary> /// </summary>
public void Cancel(TsCDaCancelCompleteEventHandler callback) { subscription_.Cancel(this, callback); } public void Cancel(TsCDaCancelCompleteEventHandler callback) { subscription_.Cancel(this, callback); }
#endregion #endregion
} }
} }

View File

@@ -26,50 +26,50 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Filters applied by the server before returning item results. /// Filters applied by the server before returning item results.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCDaResultFilter public enum TsCDaResultFilter
{ {
/// <summary> /// <summary>
/// Include the ItemName in the ItemIdentifier if bit is set. /// Include the ItemName in the ItemIdentifier if bit is set.
/// </summary> /// </summary>
ItemName = 0x01, ItemName = 0x01,
/// <summary> /// <summary>
/// Include the ItemPath in the ItemIdentifier if bit is set. /// Include the ItemPath in the ItemIdentifier if bit is set.
/// </summary> /// </summary>
ItemPath = 0x02, ItemPath = 0x02,
/// <summary> /// <summary>
/// Include the ClientHandle in the ItemIdentifier if bit is set. /// Include the ClientHandle in the ItemIdentifier if bit is set.
/// </summary> /// </summary>
ClientHandle = 0x04, ClientHandle = 0x04,
/// <summary> /// <summary>
/// Include the Timestamp in the ItemValue if bit is set. /// Include the Timestamp in the ItemValue if bit is set.
/// </summary> /// </summary>
ItemTime = 0x08, ItemTime = 0x08,
/// <summary> /// <summary>
/// Include verbose, localized error text with result if bit is set. /// Include verbose, localized error text with result if bit is set.
/// </summary> /// </summary>
ErrorText = 0x10, ErrorText = 0x10,
/// <summary> /// <summary>
/// Include additional diagnostic information with result if bit is set. /// Include additional diagnostic information with result if bit is set.
/// </summary> /// </summary>
DiagnosticInfo = 0x20, DiagnosticInfo = 0x20,
/// <summary> /// <summary>
/// Include the ItemName and Timestamp if bit is set. /// Include the ItemName and Timestamp if bit is set.
/// </summary> /// </summary>
Minimal = ItemName | ItemTime, Minimal = ItemName | ItemTime,
/// <summary> /// <summary>
/// Include all information in the results if bit is set. /// Include all information in the results if bit is set.
/// </summary> /// </summary>
All = 0x3F All = 0x3F
} }
} }

View File

@@ -22,8 +22,8 @@
#region Using Directives #region Using Directives
using System; using System;
using System.Runtime.Serialization;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization;
#endregion #endregion
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da

View File

@@ -25,44 +25,44 @@
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// The set of possible server states. /// The set of possible server states.
/// </summary> /// </summary>
public enum TsCDaServerState public enum TsCDaServerState
{ {
/// <summary> /// <summary>
/// The server state is not known. /// The server state is not known.
/// </summary> /// </summary>
Unknown, Unknown,
/// <summary> /// <summary>
/// The server is running normally. /// The server is running normally.
/// </summary> /// </summary>
Running, Running,
/// <summary> /// <summary>
/// The server is not functioning due to a fatal error. /// The server is not functioning due to a fatal error.
/// </summary> /// </summary>
Failed, Failed,
/// <summary> /// <summary>
/// The server cannot load its configuration information. /// The server cannot load its configuration information.
/// </summary> /// </summary>
NoConfig, NoConfig,
/// <summary> /// <summary>
/// The server has halted all communication with the underlying hardware. /// The server has halted all communication with the underlying hardware.
/// </summary> /// </summary>
Suspended, Suspended,
/// <summary> /// <summary>
/// The server is disconnected from the underlying hardware. /// The server is disconnected from the underlying hardware.
/// </summary> /// </summary>
Test, Test,
/// <summary> /// <summary>
/// The server cannot communicate with the underlying hardware. /// The server cannot communicate with the underlying hardware.
/// </summary> /// </summary>
CommFault CommFault
} }
} }

View File

@@ -26,67 +26,67 @@ using System;
namespace Technosoftware.DaAeHdaClient.Da namespace Technosoftware.DaAeHdaClient.Da
{ {
/// <summary> /// <summary>
/// Defines masks to be used when modifying the subscription or item state. /// Defines masks to be used when modifying the subscription or item state.
/// </summary> /// </summary>
[Flags] [Flags]
public enum TsCDaStateMask public enum TsCDaStateMask
{ {
/// <summary> /// <summary>
/// The name of the subscription. /// The name of the subscription.
/// </summary> /// </summary>
Name = 0x0001, Name = 0x0001,
/// <summary> /// <summary>
/// The client assigned handle for the item or subscription. /// The client assigned handle for the item or subscription.
/// </summary> /// </summary>
ClientHandle = 0x0002, ClientHandle = 0x0002,
/// <summary> /// <summary>
/// The locale to use for results returned to the client from the subscription. /// The locale to use for results returned to the client from the subscription.
/// </summary> /// </summary>
Locale = 0x0004, Locale = 0x0004,
/// <summary> /// <summary>
/// Whether the item or subscription is active. /// Whether the item or subscription is active.
/// </summary> /// </summary>
Active = 0x0008, Active = 0x0008,
/// <summary> /// <summary>
/// The maximum rate at which data update notifications are sent. /// The maximum rate at which data update notifications are sent.
/// </summary> /// </summary>
UpdateRate = 0x0010, UpdateRate = 0x0010,
/// <summary> /// <summary>
/// The longest period between data update notifications.<br/> /// The longest period between data update notifications.<br/>
/// <strong>Note:</strong> This feature is only supported with OPC Data Access 3.0 /// <strong>Note:</strong> This feature is only supported with OPC Data Access 3.0
/// Servers. /// Servers.
/// </summary> /// </summary>
KeepAlive = 0x0020, KeepAlive = 0x0020,
/// <summary> /// <summary>
/// The requested data type for the item. /// The requested data type for the item.
/// </summary> /// </summary>
ReqType = 0x0040, ReqType = 0x0040,
/// <summary> /// <summary>
/// The deadband for the item or subscription. /// The deadband for the item or subscription.
/// </summary> /// </summary>
Deadband = 0x0080, Deadband = 0x0080,
/// <summary> /// <summary>
/// The rate at which the server should check for changes to an item value. /// The rate at which the server should check for changes to an item value.
/// </summary> /// </summary>
SamplingRate = 0x0100, SamplingRate = 0x0100,
/// <summary> /// <summary>
/// Whether the server should buffer multiple changes to a single item. /// Whether the server should buffer multiple changes to a single item.
/// </summary> /// </summary>
EnableBuffering = 0x0200, EnableBuffering = 0x0200,
/// <summary> /// <summary>
/// All fields are valid. /// All fields are valid.
/// </summary> /// </summary>
All = 0xFFFF All = 0xFFFF
} }
} }

View File

@@ -210,8 +210,10 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <summary> /// <summary>
/// The items belonging to the subscription. /// The items belonging to the subscription.
/// </summary> /// </summary>
public TsCDaItem[] Items { public TsCDaItem[] Items
get { {
get
{
if (daItems_ == null) return new TsCDaItem[0]; if (daItems_ == null) return new TsCDaItem[0];
var items = new TsCDaItem[daItems_.Length]; var items = new TsCDaItem[daItems_.Length];
for (var ii = 0; ii < daItems_.Length; ii++) items[ii] = (TsCDaItem)daItems_[ii].Clone(); for (var ii = 0; ii < daItems_.Length; ii++) items[ii] = (TsCDaItem)daItems_[ii].Clone();
@@ -562,7 +564,8 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <summary> /// <summary>
/// An event to receive data change updates. /// An event to receive data change updates.
/// </summary> /// </summary>
public event TsCDaDataChangedEventHandler DataChangedEvent { public event TsCDaDataChangedEventHandler DataChangedEvent
{
add => Subscription.DataChangedEvent += value; add => Subscription.DataChangedEvent += value;
remove => Subscription.DataChangedEvent -= value; remove => Subscription.DataChangedEvent -= value;
} }

Some files were not shown because too many files have changed in this diff Show More