Clean
This commit is contained in:
@@ -30,22 +30,22 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
/// Defines all well known COM AE HRESULT codes.
|
||||
/// </summary>
|
||||
internal struct Result
|
||||
{
|
||||
{
|
||||
/// <remarks/>
|
||||
public const int S_ALREADYACKED = +0x00040200; // 0x00040200
|
||||
public const int S_ALREADYACKED = +0x00040200; // 0x00040200
|
||||
/// <remarks/>
|
||||
public const int S_INVALIDBUFFERTIME = +0x00040201; // 0x00040201
|
||||
public const int S_INVALIDBUFFERTIME = +0x00040201; // 0x00040201
|
||||
/// <remarks/>
|
||||
public const int S_INVALIDMAXSIZE = +0x00040202; // 0x00040202
|
||||
public const int S_INVALIDMAXSIZE = +0x00040202; // 0x00040202
|
||||
/// <remarks/>
|
||||
public const int S_INVALIDKEEPALIVETIME = +0x00040203; // 0x00040203
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDBRANCHNAME = -0x3FFBFDFD; // 0xC0040203
|
||||
public const int E_INVALIDBRANCHNAME = -0x3FFBFDFD; // 0xC0040203
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDTIME = -0x3FFBFDFC; // 0xC0040204
|
||||
public const int E_INVALIDTIME = -0x3FFBFDFC; // 0xC0040204
|
||||
/// <remarks/>
|
||||
public const int E_BUSY = -0x3FFBFDFB; // 0xC0040205
|
||||
public const int E_BUSY = -0x3FFBFDFB; // 0xC0040205
|
||||
/// <remarks/>
|
||||
public const int E_NOINFO = -0x3FFBFDFA; // 0xC0040206
|
||||
public const int E_NOINFO = -0x3FFBFDFA; // 0xC0040206
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Ae;
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
using Technosoftware.OpcRcw.Ae;
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 0618
|
||||
@@ -44,7 +43,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified OpcUrl and COM server.
|
||||
/// </summary>
|
||||
internal Server(OpcUrl url, object server) : base(url, server)
|
||||
internal Server(OpcUrl url, object server) : base(url, server)
|
||||
{
|
||||
m_supportsAE11 = true;
|
||||
|
||||
@@ -177,41 +176,41 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
// verify state and arguments.
|
||||
if (server_ == null) throw new NotConnectedException();
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
|
||||
// initialize arguments.
|
||||
object unknown = null;
|
||||
var riid = typeof(IOPCEventSubscriptionMgt).GUID;
|
||||
var bufferTime = 0;
|
||||
var maxSize = 0;
|
||||
object unknown = null;
|
||||
var riid = typeof(IOPCEventSubscriptionMgt).GUID;
|
||||
var bufferTime = 0;
|
||||
var maxSize = 0;
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).CreateEventSubscription(
|
||||
(state.Active)?1:0,
|
||||
(state.Active) ? 1 : 0,
|
||||
state.BufferTime,
|
||||
state.MaxSize,
|
||||
++m_handles,
|
||||
ref riid,
|
||||
out unknown,
|
||||
out bufferTime,
|
||||
out maxSize);
|
||||
out maxSize);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.CreateEventSubscription", e);
|
||||
}
|
||||
}
|
||||
|
||||
// save actual values.
|
||||
state.BufferTime = bufferTime;
|
||||
state.MaxSize = maxSize;
|
||||
state.MaxSize = maxSize;
|
||||
|
||||
var subscription = new Subscription(state, unknown);
|
||||
|
||||
// set keep alive.
|
||||
subscription.ModifyState((int)TsCAeStateMask.KeepAlive, state);
|
||||
|
||||
|
||||
// save subscription.
|
||||
m_subscriptions.Add(m_handles, subscription);
|
||||
|
||||
@@ -245,8 +244,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryAvailableFilters", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return results.
|
||||
return filters;
|
||||
}
|
||||
@@ -270,23 +269,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// initialize arguments.
|
||||
var count = 0;
|
||||
|
||||
var ppdwEventCategories = IntPtr.Zero;
|
||||
var ppdwEventCategories = IntPtr.Zero;
|
||||
var ppszEventCategoryDescs = IntPtr.Zero;
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).QueryEventCategories(
|
||||
eventType,
|
||||
eventType,
|
||||
out count,
|
||||
out ppdwEventCategories,
|
||||
out ppdwEventCategories,
|
||||
out ppszEventCategoryDescs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventCategories", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check for empty list.
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -294,7 +293,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// build results.
|
||||
@@ -304,7 +303,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
categories[ii] = new TsCAeCategory();
|
||||
|
||||
categories[ii].ID = ids[ii];
|
||||
categories[ii].ID = ids[ii];
|
||||
categories[ii].Name = names[ii];
|
||||
}
|
||||
|
||||
@@ -336,15 +335,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).QueryConditionNames(
|
||||
eventCategory,
|
||||
eventCategory,
|
||||
out count,
|
||||
out ppszConditionNames);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryConditionNames", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check for empty list.
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -382,21 +381,21 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).QuerySubConditionNames(
|
||||
conditionName,
|
||||
conditionName,
|
||||
out count,
|
||||
out ppszSubConditionNames);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySubConditionNames", e);
|
||||
}
|
||||
}
|
||||
|
||||
// check for empty list.
|
||||
if (count == 0)
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
|
||||
// unmarshal arguments.
|
||||
var names = Technosoftware.DaAeHdaClient.Com.Interop.GetUnicodeStrings(ref ppszSubConditionNames, count, true);
|
||||
|
||||
@@ -428,15 +427,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).QuerySourceConditions(
|
||||
sourceName,
|
||||
sourceName,
|
||||
out count,
|
||||
out ppszConditionNames);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QuerySourceConditions", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check for empty list.
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -476,7 +475,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).QueryEventAttributes(
|
||||
eventCategory,
|
||||
eventCategory,
|
||||
out count,
|
||||
out ppdwAttrIDs,
|
||||
out ppszAttrDescs,
|
||||
@@ -485,8 +484,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.QueryEventAttributes", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check for empty list.
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -494,9 +493,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
}
|
||||
|
||||
// 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 types = Technosoftware.DaAeHdaClient.Com.Interop.GetInt16s(ref ppvtAttrTypes, count, true);
|
||||
var types = Technosoftware.DaAeHdaClient.Com.Interop.GetInt16s(ref ppvtAttrTypes, count, true);
|
||||
|
||||
// build results.
|
||||
var attributes = new TsCAeAttribute[count];
|
||||
@@ -505,8 +504,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
attributes[ii] = new TsCAeAttribute();
|
||||
|
||||
attributes[ii].ID = ids[ii];
|
||||
attributes[ii].Name = names[ii];
|
||||
attributes[ii].ID = ids[ii];
|
||||
attributes[ii].Name = names[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>
|
||||
public TsCAeItemUrl[] TranslateToItemIDs(
|
||||
string sourceName,
|
||||
int eventCategory,
|
||||
int eventCategory,
|
||||
string conditionName,
|
||||
string subConditionName,
|
||||
int[] attributeIDs)
|
||||
int[] attributeIDs)
|
||||
{
|
||||
lock (this)
|
||||
lock (this)
|
||||
{
|
||||
// verify state and arguments.
|
||||
if (server_ == null) throw new NotConnectedException();
|
||||
@@ -543,19 +542,19 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
var ppszAttrItemIDs = IntPtr.Zero;
|
||||
var ppszNodeNames = IntPtr.Zero;
|
||||
var ppCLSIDs = IntPtr.Zero;
|
||||
|
||||
var count = (attributeIDs != null)?attributeIDs.Length:0;
|
||||
|
||||
var count = (attributeIDs != null) ? attributeIDs.Length : 0;
|
||||
|
||||
// call server.
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).TranslateToItemIDs(
|
||||
(sourceName != null)?sourceName:"",
|
||||
(sourceName != null) ? sourceName : "",
|
||||
eventCategory,
|
||||
(conditionName != null)?conditionName:"",
|
||||
(subConditionName != null)?subConditionName:"",
|
||||
(conditionName != null) ? conditionName : "",
|
||||
(subConditionName != null) ? subConditionName : "",
|
||||
count,
|
||||
(count > 0)?attributeIDs:new int[0],
|
||||
(count > 0) ? attributeIDs : new int[0],
|
||||
out ppszAttrItemIDs,
|
||||
out ppszNodeNames,
|
||||
out ppCLSIDs);
|
||||
@@ -563,15 +562,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.TranslateToItemIDs", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 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 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];
|
||||
|
||||
|
||||
// fill in item urls.
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
@@ -579,9 +578,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
|
||||
itemUrls[ii].ItemName = itemIDs[ii];
|
||||
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.Path = string.Format("{{{0}}}", clsids[ii]);
|
||||
itemUrls[ii].Url.Path = string.Format("{{{0}}}", clsids[ii]);
|
||||
}
|
||||
|
||||
// return results.
|
||||
@@ -602,7 +601,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
public TsCAeCondition GetConditionState(
|
||||
string sourceName,
|
||||
string conditionName,
|
||||
int[] attributeIDs)
|
||||
int[] attributeIDs)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
@@ -616,20 +615,20 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).GetConditionState(
|
||||
(sourceName != null)?sourceName:"",
|
||||
(conditionName != null)?conditionName:"",
|
||||
(attributeIDs != null)?attributeIDs.Length:0,
|
||||
(attributeIDs != null)?attributeIDs:new int[0],
|
||||
(sourceName != null) ? sourceName : "",
|
||||
(conditionName != null) ? conditionName : "",
|
||||
(attributeIDs != null) ? attributeIDs.Length : 0,
|
||||
(attributeIDs != null) ? attributeIDs : new int[0],
|
||||
out ppConditionState);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.GetConditionState", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal results.
|
||||
var conditions = Interop.GetConditions(ref ppConditionState, 1, true);
|
||||
|
||||
var conditions = Interop.GetConditions(ref ppConditionState, 1, true);
|
||||
|
||||
// fill in attribute ids.
|
||||
for (var ii = 0; ii < conditions[0].Attributes.Count; ii++)
|
||||
{
|
||||
@@ -672,15 +671,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).EnableConditionByArea2(
|
||||
areas.Length,
|
||||
areas.Length,
|
||||
areas,
|
||||
out ppErrors);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionByArea2", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
|
||||
}
|
||||
@@ -689,18 +688,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).EnableConditionByArea(
|
||||
areas.Length,
|
||||
areas.Length,
|
||||
areas);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionByArea", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create dummy error array (0 == S_OK).
|
||||
errors = new int[areas.Length];
|
||||
}
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new OpcResult[errors.Length];
|
||||
|
||||
@@ -713,7 +712,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================================================================
|
||||
// DisableConditionByArea
|
||||
|
||||
@@ -745,15 +744,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).DisableConditionByArea2(
|
||||
areas.Length,
|
||||
areas.Length,
|
||||
areas,
|
||||
out ppErrors);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionByArea2", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
|
||||
}
|
||||
@@ -762,18 +761,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).DisableConditionByArea(
|
||||
areas.Length,
|
||||
areas.Length,
|
||||
areas);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionByArea", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create dummy error array (0 == S_OK).
|
||||
errors = new int[areas.Length];
|
||||
}
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new OpcResult[errors.Length];
|
||||
|
||||
@@ -818,15 +817,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).EnableConditionBySource2(
|
||||
sources.Length,
|
||||
sources.Length,
|
||||
sources,
|
||||
out ppErrors);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.EnableConditionBySource2", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
|
||||
}
|
||||
@@ -835,18 +834,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).EnableConditionBySource(
|
||||
sources.Length,
|
||||
sources.Length,
|
||||
sources);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.EnableConditionBySource", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create dummy error array (0 == S_OK).
|
||||
errors = new int[sources.Length];
|
||||
}
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new OpcResult[errors.Length];
|
||||
|
||||
@@ -891,15 +890,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).DisableConditionBySource2(
|
||||
sources.Length,
|
||||
sources.Length,
|
||||
sources,
|
||||
out ppErrors);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.DisableConditionBySource2", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
|
||||
}
|
||||
@@ -908,18 +907,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
try
|
||||
{
|
||||
((IOPCEventServer)server_).DisableConditionBySource(
|
||||
sources.Length,
|
||||
sources.Length,
|
||||
sources);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.DisableConditionBySource", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create dummy error array (0 == S_OK).
|
||||
errors = new int[sources.Length];
|
||||
}
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new OpcResult[errors.Length];
|
||||
|
||||
@@ -962,23 +961,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
failures[ii] = new TsCAeEnabledStateResult();
|
||||
|
||||
failures[ii].Enabled = false;
|
||||
failures[ii].Enabled = false;
|
||||
failures[ii].EffectivelyEnabled = false;
|
||||
failures[ii].Result = OpcResult.E_FAIL;
|
||||
failures[ii].Result = OpcResult.E_FAIL;
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
|
||||
// initialize arguments.
|
||||
var pbEnabled = IntPtr.Zero;
|
||||
var pbEnabled = IntPtr.Zero;
|
||||
var pbEffectivelyEnabled = IntPtr.Zero;
|
||||
var ppErrors = IntPtr.Zero;
|
||||
var ppErrors = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).GetEnableStateByArea(
|
||||
areas.Length,
|
||||
areas.Length,
|
||||
areas,
|
||||
out pbEnabled,
|
||||
out pbEffectivelyEnabled,
|
||||
@@ -987,14 +986,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateByArea", e);
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
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 errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
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 errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, areas.Length, true);
|
||||
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new TsCAeEnabledStateResult[errors.Length];
|
||||
|
||||
@@ -1002,9 +1001,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
results[ii] = new TsCAeEnabledStateResult();
|
||||
|
||||
results[ii].Enabled = enabled[ii] != 0;
|
||||
results[ii].Enabled = enabled[ii] != 0;
|
||||
results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0;
|
||||
results[ii].Result = Interop.GetResultID(errors[ii]);
|
||||
results[ii].Result = Interop.GetResultID(errors[ii]);
|
||||
}
|
||||
|
||||
// return results
|
||||
@@ -1041,23 +1040,23 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
failures[ii] = new TsCAeEnabledStateResult();
|
||||
|
||||
failures[ii].Enabled = false;
|
||||
failures[ii].Enabled = false;
|
||||
failures[ii].EffectivelyEnabled = false;
|
||||
failures[ii].Result = OpcResult.E_FAIL;
|
||||
failures[ii].Result = OpcResult.E_FAIL;
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
|
||||
// initialize arguments.
|
||||
var pbEnabled = IntPtr.Zero;
|
||||
var pbEnabled = IntPtr.Zero;
|
||||
var pbEffectivelyEnabled = IntPtr.Zero;
|
||||
var ppErrors = IntPtr.Zero;
|
||||
var ppErrors = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
((IOPCEventServer2)server_).GetEnableStateBySource(
|
||||
sources.Length,
|
||||
sources.Length,
|
||||
sources,
|
||||
out pbEnabled,
|
||||
out pbEffectivelyEnabled,
|
||||
@@ -1066,14 +1065,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer2.GetEnableStateBySource", e);
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
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 errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
|
||||
}
|
||||
|
||||
// unmarshal arguments.
|
||||
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 errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, sources.Length, true);
|
||||
|
||||
|
||||
|
||||
// build results.
|
||||
var results = new TsCAeEnabledStateResult[errors.Length];
|
||||
|
||||
@@ -1081,9 +1080,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
results[ii] = new TsCAeEnabledStateResult();
|
||||
|
||||
results[ii].Enabled = enabled[ii] != 0;
|
||||
results[ii].Enabled = enabled[ii] != 0;
|
||||
results[ii].EffectivelyEnabled = effectivelyEnabled[ii] != 0;
|
||||
results[ii].Result = Interop.GetResultID(errors[ii]);
|
||||
results[ii].Result = Interop.GetResultID(errors[ii]);
|
||||
}
|
||||
|
||||
// return results
|
||||
@@ -1102,10 +1101,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
/// <param name="conditions">The conditions being acknowledged.</param>
|
||||
/// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns>
|
||||
public OpcResult[] AcknowledgeCondition(
|
||||
string acknowledgerID,
|
||||
string comment,
|
||||
string acknowledgerID,
|
||||
string comment,
|
||||
TsCAeEventAcknowledgement[] conditions)
|
||||
{
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
// verify state and arguments.
|
||||
@@ -1120,17 +1119,17 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// initialize arguments.
|
||||
var count = conditions.Length;
|
||||
|
||||
var pszSource = new string[count];
|
||||
var pszConditionName = new string[count];
|
||||
var pszSource = new string[count];
|
||||
var pszConditionName = new string[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;
|
||||
pftActiveTime[ii] = Interop.Convert(Com.Interop.GetFILETIME(conditions[ii].ActiveTime));
|
||||
pdwCookie[ii] = conditions[ii].Cookie;
|
||||
pftActiveTime[ii] = Interop.Convert(Com.Interop.GetFILETIME(conditions[ii].ActiveTime));
|
||||
pdwCookie[ii] = conditions[ii].Cookie;
|
||||
}
|
||||
|
||||
var ppErrors = IntPtr.Zero;
|
||||
@@ -1151,11 +1150,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventServer.AckCondition", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// unmarshal results.
|
||||
var errors = Technosoftware.DaAeHdaClient.Com.Interop.GetInt32s(ref ppErrors, count, true);
|
||||
|
||||
|
||||
// build results.
|
||||
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>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
public TsCAeBrowseElement[] Browse(
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter)
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter)
|
||||
{
|
||||
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>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
public TsCAeBrowseElement[] Browse(
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
int maxElements,
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
int maxElements,
|
||||
out IOpcBrowsePosition position)
|
||||
{
|
||||
position = null;
|
||||
@@ -1239,7 +1238,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
var elements = new ArrayList();
|
||||
|
||||
var result = FetchElements(browseType, maxElements, enumerator, elements);
|
||||
|
||||
|
||||
// dispose of enumerator if all done.
|
||||
if (result != 0)
|
||||
{
|
||||
@@ -1256,7 +1255,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================================================================
|
||||
// BrowseNext
|
||||
|
||||
@@ -1282,12 +1281,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
|
||||
// fetch enumerator from position object.
|
||||
var enumerator = ((BrowsePosition)position).Enumerator;
|
||||
|
||||
|
||||
// fetch elements.
|
||||
var elements = new ArrayList();
|
||||
|
||||
var result = FetchElements(((BrowsePosition)position).BrowseType, maxElements, enumerator, elements);
|
||||
|
||||
|
||||
// dispose of position object if all done.
|
||||
if (result != 0)
|
||||
{
|
||||
@@ -1298,7 +1297,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// return results.
|
||||
return (TsCAeBrowseElement[])elements.ToArray(typeof(TsCAeBrowseElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -1333,19 +1332,19 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// verify object.
|
||||
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.
|
||||
m_browser = unknown;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Moves the browse position prior to executing a browse operation.
|
||||
/// </summary>
|
||||
private void ChangeBrowsePosition(string areaID)
|
||||
{
|
||||
var targetID = (areaID != null)?areaID:"";
|
||||
var targetID = (areaID != null) ? areaID : "";
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
@@ -1357,9 +1356,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.ChangeBrowsePosition", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates an enumerator for the names at the current position.
|
||||
/// </summary>
|
||||
@@ -1374,22 +1373,22 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
{
|
||||
((IOPCEventAreaBrowser)m_browser).BrowseOPCAreas(
|
||||
dwBrowseFilterType,
|
||||
(browseFilter != null)?browseFilter:"",
|
||||
(browseFilter != null) ? browseFilter : "",
|
||||
out enumerator);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.BrowseOPCAreas", e);
|
||||
}
|
||||
}
|
||||
|
||||
// verify object.
|
||||
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 (System.Runtime.InteropServices.ComTypes.IEnumString)enumerator;
|
||||
return (System.Runtime.InteropServices.ComTypes.IEnumString)enumerator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1412,7 +1411,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException("IOPCEventAreaBrowser.GetQualifiedAreaName", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fetch source qualified name.
|
||||
else
|
||||
{
|
||||
@@ -1438,47 +1437,47 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
var buffer = new string[1];
|
||||
|
||||
// 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.
|
||||
var pFetched = Marshal.AllocCoTaskMem(sizeof(int));
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var result = enumerator.Next(bufferLength, buffer, pFetched);
|
||||
|
||||
while (result == 0)
|
||||
{
|
||||
while (result == 0)
|
||||
{
|
||||
var fetched = Marshal.ReadInt32(pFetched);
|
||||
|
||||
// create elements.
|
||||
for (var ii = 0; ii < fetched; ii++)
|
||||
{
|
||||
var element = new TsCAeBrowseElement();
|
||||
// create elements.
|
||||
for (var ii = 0; ii < fetched; ii++)
|
||||
{
|
||||
var element = new TsCAeBrowseElement();
|
||||
|
||||
element.Name = buffer[ii];
|
||||
element.QualifiedName = GetQualifiedName(buffer[ii], browseType);
|
||||
element.NodeType = browseType;
|
||||
|
||||
elements.Add(element);
|
||||
}
|
||||
element.Name = buffer[ii];
|
||||
element.QualifiedName = GetQualifiedName(buffer[ii], browseType);
|
||||
element.NodeType = browseType;
|
||||
|
||||
// check for halt.
|
||||
if (maxElements > 0 && elements.Count >= maxElements)
|
||||
{
|
||||
break;
|
||||
}
|
||||
elements.Add(element);
|
||||
}
|
||||
|
||||
// re-calculate buffer length.
|
||||
bufferLength = (maxElements > 0 && maxElements-elements.Count < buffer.Length)?maxElements-elements.Count:buffer.Length;
|
||||
|
||||
// fetch next block.
|
||||
// check for halt.
|
||||
if (maxElements > 0 && elements.Count >= maxElements)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// return final result.
|
||||
return result;
|
||||
}
|
||||
// return final result.
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (pFetched != IntPtr.Zero)
|
||||
@@ -1486,7 +1485,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
Marshal.FreeCoTaskMem(pFetched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
@@ -1496,7 +1495,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
private Hashtable m_subscriptions = new Hashtable();
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
#region BrowsePosition Class
|
||||
/// <summary>
|
||||
/// Stores the state of a browse operation.
|
||||
@@ -1509,14 +1508,14 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
/// Saves the parameters for an incomplete browse information.
|
||||
/// </summary>
|
||||
public BrowsePosition(
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
System.Runtime.InteropServices.ComTypes.IEnumString enumerator)
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
System.Runtime.InteropServices.ComTypes.IEnumString enumerator)
|
||||
:
|
||||
base (areaID, browseType, browseFilter)
|
||||
base(areaID, browseType, browseFilter)
|
||||
{
|
||||
m_enumerator = enumerator;
|
||||
m_enumerator = enumerator;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1543,11 +1542,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// Release unmanaged resources.
|
||||
// Set large fields to null.
|
||||
|
||||
if (m_enumerator != null)
|
||||
{
|
||||
Technosoftware.DaAeHdaClient.Com.Interop.ReleaseServer(m_enumerator);
|
||||
m_enumerator = null;
|
||||
}
|
||||
if (m_enumerator != null)
|
||||
{
|
||||
Technosoftware.DaAeHdaClient.Com.Interop.ReleaseServer(m_enumerator);
|
||||
m_enumerator = null;
|
||||
}
|
||||
|
||||
// Call Dispose on your base class.
|
||||
m_disposed = true;
|
||||
@@ -1568,7 +1567,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
System.Runtime.InteropServices.ComTypes.IEnumString m_enumerator = null;
|
||||
System.Runtime.InteropServices.ComTypes.IEnumString m_enumerator = null;
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -23,11 +23,9 @@
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Ae;
|
||||
using Technosoftware.OpcRcw.Ae;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
using Technosoftware.OpcRcw.Ae;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -333,7 +331,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
|
||||
// build results.
|
||||
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
@@ -41,12 +41,12 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// The id assigned to the connection by the COM server.
|
||||
/// </summary>
|
||||
private int cookie_;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The number of times Advise() has been called without a matching Unadvise().
|
||||
/// </summary>
|
||||
private int refs_;
|
||||
|
||||
private int refs_;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object by finding the specified connection point.
|
||||
/// </summary>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
/// Implements an object that handles multi-step browse operations.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
internal class BrowsePosition : TsCDaBrowsePosition
|
||||
internal class BrowsePosition : TsCDaBrowsePosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The continuation point for a browse operation.
|
||||
@@ -48,13 +48,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
/// Initializes a browse position
|
||||
/// </summary>
|
||||
internal BrowsePosition(
|
||||
OpcItem itemID,
|
||||
TsCDaBrowseFilters filters,
|
||||
string continuationPoint)
|
||||
OpcItem itemID,
|
||||
TsCDaBrowseFilters filters,
|
||||
string continuationPoint)
|
||||
:
|
||||
base(itemID, filters)
|
||||
{
|
||||
ContinuationPoint = continuationPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#endregion
|
||||
|
||||
@@ -134,9 +133,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
output.ProductVersion = string.Format("{0}.{1}.{2}", status.wMajorVersion, status.wMinorVersion, status.wBuildNumber);
|
||||
output.ServerState = (OpcServerState)status.dwServerState;
|
||||
output.StatusInfo = null;
|
||||
output.StartTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftStartTime));
|
||||
output.CurrentTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftCurrentTime));
|
||||
output.LastUpdateTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftLastUpdateTime));
|
||||
output.StartTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftStartTime));
|
||||
output.CurrentTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftCurrentTime));
|
||||
output.LastUpdateTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Convert(status.ftLastUpdateTime));
|
||||
|
||||
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_READABLE | OpcRcw.Da.Constants.OPC_WRITEABLE:
|
||||
{
|
||||
return TsDaAccessRights.ReadWritable;
|
||||
}
|
||||
{
|
||||
return TsDaAccessRights.ReadWritable;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -32,77 +32,77 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// Defines all well known COM DA HRESULT codes.
|
||||
/// </summary>
|
||||
internal struct Result
|
||||
{
|
||||
{
|
||||
/// <remarks/>
|
||||
public const int S_OK = +0x00000000; // 0x00000000
|
||||
public const int S_OK = +0x00000000; // 0x00000000
|
||||
/// <remarks/>
|
||||
public const int S_FALSE = +0x00000001; // 0x00000001
|
||||
public const int S_FALSE = +0x00000001; // 0x00000001
|
||||
/// <remarks/>
|
||||
public const int E_NOTIMPL = -0x7FFFBFFF; // 0x80004001
|
||||
public const int E_NOTIMPL = -0x7FFFBFFF; // 0x80004001
|
||||
/// <remarks/>
|
||||
public const int E_OUTOFMEMORY = -0x7FF8FFF2; // 0x8007000E
|
||||
public const int E_OUTOFMEMORY = -0x7FF8FFF2; // 0x8007000E
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDARG = -0x7FF8FFA9; // 0x80070057
|
||||
public const int E_INVALIDARG = -0x7FF8FFA9; // 0x80070057
|
||||
/// <remarks/>
|
||||
public const int E_NOINTERFACE = -0x7FFFBFFE; // 0x80004002
|
||||
public const int E_NOINTERFACE = -0x7FFFBFFE; // 0x80004002
|
||||
/// <remarks/>
|
||||
public const int E_POINTER = -0x7FFFBFFD; // 0x80004003
|
||||
public const int E_POINTER = -0x7FFFBFFD; // 0x80004003
|
||||
/// <remarks/>
|
||||
public const int E_FAIL = -0x7FFFBFFB; // 0x80004005
|
||||
public const int E_FAIL = -0x7FFFBFFB; // 0x80004005
|
||||
/// <remarks/>
|
||||
public const int CONNECT_E_NOCONNECTION = -0x7FFBFE00; // 0x80040200
|
||||
public const int CONNECT_E_NOCONNECTION = -0x7FFBFE00; // 0x80040200
|
||||
/// <remarks/>
|
||||
public const int CONNECT_E_ADVISELIMIT = -0x7FFBFDFF; // 0x80040201
|
||||
public const int CONNECT_E_ADVISELIMIT = -0x7FFBFDFF; // 0x80040201
|
||||
/// <remarks/>
|
||||
public const int DISP_E_TYPEMISMATCH = -0x7FFDFFFB; // 0x80020005
|
||||
public const int DISP_E_TYPEMISMATCH = -0x7FFDFFFB; // 0x80020005
|
||||
/// <remarks/>
|
||||
public const int DISP_E_OVERFLOW = -0x7FFDFFF6; // 0x8002000A
|
||||
public const int DISP_E_OVERFLOW = -0x7FFDFFF6; // 0x8002000A
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDHANDLE = -0x3FFBFFFF; // 0xC0040001
|
||||
public const int E_INVALIDHANDLE = -0x3FFBFFFF; // 0xC0040001
|
||||
/// <remarks/>
|
||||
public const int E_BADTYPE = -0x3FFBFFFC; // 0xC0040004
|
||||
public const int E_BADTYPE = -0x3FFBFFFC; // 0xC0040004
|
||||
/// <remarks/>
|
||||
public const int E_PUBLIC = -0x3FFBFFFB; // 0xC0040005
|
||||
public const int E_PUBLIC = -0x3FFBFFFB; // 0xC0040005
|
||||
/// <remarks/>
|
||||
public const int E_BADRIGHTS = -0x3FFBFFFA; // 0xC0040006
|
||||
public const int E_BADRIGHTS = -0x3FFBFFFA; // 0xC0040006
|
||||
/// <remarks/>
|
||||
public const int E_UNKNOWNITEMID = -0x3FFBFFF9; // 0xC0040007
|
||||
public const int E_UNKNOWNITEMID = -0x3FFBFFF9; // 0xC0040007
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDITEMID = -0x3FFBFFF8; // 0xC0040008
|
||||
public const int E_INVALIDITEMID = -0x3FFBFFF8; // 0xC0040008
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDFILTER = -0x3FFBFFF7; // 0xC0040009
|
||||
public const int E_INVALIDFILTER = -0x3FFBFFF7; // 0xC0040009
|
||||
/// <remarks/>
|
||||
public const int E_UNKNOWNPATH = -0x3FFBFFF6; // 0xC004000A
|
||||
public const int E_UNKNOWNPATH = -0x3FFBFFF6; // 0xC004000A
|
||||
/// <remarks/>
|
||||
public const int E_RANGE = -0x3FFBFFF5; // 0xC004000B
|
||||
public const int E_RANGE = -0x3FFBFFF5; // 0xC004000B
|
||||
/// <remarks/>
|
||||
public const int E_DUPLICATENAME = -0x3FFBFFF4; // 0xC004000C
|
||||
public const int E_DUPLICATENAME = -0x3FFBFFF4; // 0xC004000C
|
||||
/// <remarks/>
|
||||
public const int S_UNSUPPORTEDRATE = +0x0004000D; // 0x0004000D
|
||||
public const int S_UNSUPPORTEDRATE = +0x0004000D; // 0x0004000D
|
||||
/// <remarks/>
|
||||
public const int S_CLAMP = +0x0004000E; // 0x0004000E
|
||||
public const int S_CLAMP = +0x0004000E; // 0x0004000E
|
||||
/// <remarks/>
|
||||
public const int S_INUSE = +0x0004000F; // 0x0004000F
|
||||
public const int S_INUSE = +0x0004000F; // 0x0004000F
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDCONFIGFILE = -0x3FFBFFF0; // 0xC0040010
|
||||
public const int E_INVALIDCONFIGFILE = -0x3FFBFFF0; // 0xC0040010
|
||||
/// <remarks/>
|
||||
public const int E_NOTFOUND = -0x3FFBFFEF; // 0xC0040011
|
||||
public const int E_NOTFOUND = -0x3FFBFFEF; // 0xC0040011
|
||||
/// <remarks/>
|
||||
public const int E_INVALID_PID = -0x3FFBFDFD; // 0xC0040203
|
||||
public const int E_INVALID_PID = -0x3FFBFDFD; // 0xC0040203
|
||||
/// <remarks/>
|
||||
public const int E_DEADBANDNOTSET = -0x3FFBFC00; // 0xC0040400
|
||||
public const int E_DEADBANDNOTSET = -0x3FFBFC00; // 0xC0040400
|
||||
/// <remarks/>
|
||||
public const int E_DEADBANDNOTSUPPORTED = -0x3FFBFBFF; // 0xC0040401
|
||||
public const int E_DEADBANDNOTSUPPORTED = -0x3FFBFBFF; // 0xC0040401
|
||||
/// <remarks/>
|
||||
public const int E_NOBUFFERING = -0x3FFBFBFE; // 0xC0040402
|
||||
public const int E_NOBUFFERING = -0x3FFBFBFE; // 0xC0040402
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDCONTINUATIONPOINT = -0x3FFBFBFD; // 0xC0040403
|
||||
public const int E_INVALIDCONTINUATIONPOINT = -0x3FFBFBFD; // 0xC0040403
|
||||
/// <remarks/>
|
||||
public const int S_DATAQUEUEOVERFLOW = +0x00040404; // 0x00040404
|
||||
public const int S_DATAQUEUEOVERFLOW = +0x00040404; // 0x00040404
|
||||
/// <remarks/>
|
||||
public const int E_RATENOTSET = -0x3FFBFBFB; // 0xC0040405
|
||||
public const int E_RATENOTSET = -0x3FFBFBFB; // 0xC0040405
|
||||
/// <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
|
||||
{
|
||||
/// <remarks/>
|
||||
public const int E_TYPE_CHANGED = -0x3FFBFBF9; // 0xC0040407
|
||||
public const int E_TYPE_CHANGED = -0x3FFBFBF9; // 0xC0040407
|
||||
/// <remarks/>
|
||||
public const int E_FILTER_DUPLICATE = -0x3FFBFBF8; // 0xC0040408
|
||||
public const int E_FILTER_DUPLICATE = -0x3FFBFBF8; // 0xC0040408
|
||||
/// <remarks/>
|
||||
public const int E_FILTER_INVALID = -0x3FFBFBF7; // 0xC0040409
|
||||
public const int E_FILTER_INVALID = -0x3FFBFBF7; // 0xC0040409
|
||||
/// <remarks/>
|
||||
public const int E_FILTER_ERROR = -0x3FFBFBF6; // 0xC004040A
|
||||
public const int E_FILTER_ERROR = -0x3FFBFBF6; // 0xC004040A
|
||||
/// <remarks/>
|
||||
public const int S_FILTER_NO_DATA = +0x0004040B; // 0xC004040B
|
||||
public const int S_FILTER_NO_DATA = +0x0004040B; // 0xC004040B
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,13 @@
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
|
||||
using Technosoftware.OpcRcw.Da;
|
||||
using System.Threading;
|
||||
using Technosoftware.DaAeHdaClient.Com.Utilities;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.OpcRcw.Da;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -100,7 +97,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
// release all groups.
|
||||
foreach (Subscription subscription in subscriptions_.Values)
|
||||
{
|
||||
var methodName = "IOPCServer.RemoveGroup";
|
||||
var methodName = "IOPCServer.RemoveGroup";
|
||||
|
||||
// remove subscription from server.
|
||||
try
|
||||
@@ -166,7 +163,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCServer>(methodName, true);
|
||||
|
||||
(server).GetErrorString(
|
||||
@@ -188,7 +185,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
EndComCall(methodName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +234,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCServer>(methodName, true);
|
||||
(server).GetStatus(out pStatus);
|
||||
|
||||
@@ -292,10 +289,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
var pQualities = IntPtr.Zero;
|
||||
var pTimestamps = IntPtr.Zero;
|
||||
var pErrors = IntPtr.Zero;
|
||||
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCItemIO>(methodName, true);
|
||||
server.Read(
|
||||
count,
|
||||
@@ -424,7 +421,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCItemIO>(methodName, true);
|
||||
server.WriteVQT(
|
||||
count,
|
||||
@@ -500,7 +497,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
var revisedUpdateRate = 0;
|
||||
|
||||
var hDeadband = GCHandle.Alloc(result.Deadband, GCHandleType.Pinned);
|
||||
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
@@ -538,12 +535,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
|
||||
if (group == null) throw new OpcResultException(OpcResult.E_FAIL, "The subscription was not created.");
|
||||
|
||||
|
||||
methodName = "IOPCGroupStateMgt2.SetKeepAlive";
|
||||
|
||||
// set the keep alive rate if requested.
|
||||
try
|
||||
{
|
||||
{
|
||||
var keepAlive = 0;
|
||||
var comObject = BeginComCall<IOPCGroupStateMgt2>(group, methodName, true);
|
||||
comObject.SetKeepAlive(result.KeepAlive, out keepAlive);
|
||||
@@ -562,9 +559,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
EndComCall(methodName);
|
||||
}
|
||||
|
||||
|
||||
// save server handle.
|
||||
result.ServerHandle = serverHandle;
|
||||
|
||||
@@ -619,7 +616,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCServer>(methodName, true);
|
||||
server.RemoveGroup((int)state.ServerHandle, 0);
|
||||
|
||||
@@ -635,7 +632,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
EndComCall(methodName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,7 +667,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCBrowse>(methodName, true);
|
||||
server.Browse(
|
||||
(itemId != null && itemId.ItemName != null) ? itemId.ItemName : "",
|
||||
@@ -699,7 +696,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
EndComCall(methodName);
|
||||
}
|
||||
|
||||
// unmarshal results.
|
||||
@@ -760,7 +757,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCBrowse>(methodName, true);
|
||||
server.Browse(
|
||||
(itemID != null && itemID.ItemName != null) ? itemID.ItemName : "",
|
||||
@@ -789,7 +786,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
EndComCall(methodName);
|
||||
}
|
||||
|
||||
// unmarshal results.
|
||||
@@ -842,7 +839,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
// invoke COM method.
|
||||
try
|
||||
{
|
||||
{
|
||||
var server = BeginComCall<IOPCBrowse>(methodName, true);
|
||||
server.GetProperties(
|
||||
itemIds.Length,
|
||||
@@ -863,8 +860,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndComCall(methodName);
|
||||
{
|
||||
EndComCall(methodName);
|
||||
}
|
||||
|
||||
// unmarshal results.
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
var localeID = 0;
|
||||
var clientHandle = 0;
|
||||
var serverHandle = 0;
|
||||
|
||||
|
||||
var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true);
|
||||
subscription.GetState(
|
||||
out updateRate,
|
||||
@@ -289,7 +289,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
{
|
||||
methodName = "IOPCGroupStateMgt2.GetKeepAlive";
|
||||
try
|
||||
{
|
||||
{
|
||||
var keepAlive = 0;
|
||||
var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true);
|
||||
subscription.GetKeepAlive(out keepAlive);
|
||||
@@ -328,7 +328,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
lock (lock_)
|
||||
{
|
||||
{
|
||||
var methodName = "IOPCGroupStateMgt.SetName";
|
||||
// update the subscription name.
|
||||
if ((masks & (int)TsCDaStateMask.Name) != 0 && state.Name != name_)
|
||||
@@ -378,7 +378,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
methodName = "IOPCGroupStateMgt.SetState";
|
||||
try
|
||||
{
|
||||
{
|
||||
var subscription = BeginComCall<IOPCGroupStateMgt>(methodName, true);
|
||||
subscription.SetState(
|
||||
((masks & (int)TsCDaStateMask.UpdateRate) != 0) ? hUpdateRate.AddrOfPinnedObject() : IntPtr.Zero,
|
||||
@@ -415,7 +415,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
methodName = "IOPCGroupStateMgt2.SetKeepAlive";
|
||||
try
|
||||
{
|
||||
{
|
||||
var subscription = BeginComCall<IOPCGroupStateMgt2>(methodName, true);
|
||||
subscription.SetKeepAlive(state.KeepAlive, out keepAlive);
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
var methodName = "IOPCItemMgt.AddItems";
|
||||
try
|
||||
{
|
||||
{
|
||||
var subscription = BeginComCall<IOPCItemMgt>(methodName, true);
|
||||
subscription.AddItems(
|
||||
count,
|
||||
@@ -647,7 +647,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Da
|
||||
|
||||
var methodName = "IOPCItemMgt.RemoveItems";
|
||||
try
|
||||
{
|
||||
{
|
||||
var subscription = BeginComCall<IOPCItemMgt>(methodName, true);
|
||||
subscription.RemoveItems(itemIDs.Length, serverHandles, out pErrors);
|
||||
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.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.Da;
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
using Technosoftware.OpcRcw.Da;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -23,13 +23,10 @@
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.DaAeHdaClient.Com.Da;
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
|
||||
using Technosoftware.OpcRcw.Da;
|
||||
using Technosoftware.DaAeHdaClient.Com.Utilities;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.OpcRcw.Da;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Com.Da20
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// A wrapper for the COM IEnumString interface.
|
||||
/// </summary>
|
||||
internal class EnumString : IDisposable
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// A reference to the remote COM object.
|
||||
/// </summary>
|
||||
@@ -45,7 +45,7 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
{
|
||||
m_enumerator = (IEnumString)enumerator;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Releases the remote COM object.
|
||||
/// </summary>
|
||||
@@ -66,7 +66,7 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
try
|
||||
{
|
||||
// create buffer.
|
||||
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))*count);
|
||||
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr)) * count);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -22,14 +22,9 @@
|
||||
|
||||
#region Using Directives
|
||||
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.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Hda;
|
||||
using Technosoftware.OpcRcw.Hda;
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
using Technosoftware.OpcRcw.Hda;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
@@ -34,8 +33,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// <summary>
|
||||
/// An in-process wrapper an OPC HDA browser object.
|
||||
/// </summary>
|
||||
internal class Browser : ITsCHdaBrowser
|
||||
{
|
||||
internal class Browser : ITsCHdaBrowser
|
||||
{
|
||||
//======================================================================
|
||||
// Construction
|
||||
|
||||
@@ -73,7 +72,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// <summary>
|
||||
/// This must be called explicitly by clients to ensure the COM server is released.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
public virtual void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
@@ -90,9 +89,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// <summary>
|
||||
/// Returns the set of attribute filters used by the browser.
|
||||
/// </summary>
|
||||
public TsCHdaBrowseFilterCollection Filters
|
||||
{
|
||||
get
|
||||
public TsCHdaBrowseFilterCollection Filters
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
@@ -103,7 +102,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
//======================================================================
|
||||
// Browse
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Browses the server's address space at the specified branch.
|
||||
/// </summary>
|
||||
@@ -121,7 +120,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Begins a browsing the server's address space at the specified branch.
|
||||
/// </summary>
|
||||
@@ -141,11 +140,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
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.
|
||||
try
|
||||
{
|
||||
{
|
||||
m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, branchPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -171,7 +170,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
// browse for items
|
||||
enumerator = GetEnumerator(false);
|
||||
|
||||
var items = FetchElements(enumerator, maxElements-elements.Count, false);
|
||||
var items = FetchElements(enumerator, maxElements - elements.Count, false);
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
@@ -233,13 +232,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
// release enumerator.
|
||||
pos.Enumerator.Dispose();
|
||||
|
||||
|
||||
pos.Enumerator = null;
|
||||
pos.FetchingItems = true;
|
||||
|
||||
// move to the correct position in the server's address space.
|
||||
try
|
||||
{
|
||||
{
|
||||
m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, pos.BranchPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -252,7 +251,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
@@ -282,7 +281,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
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;
|
||||
m_browser.GetEnum(browseType, out pEnumerator);
|
||||
@@ -303,13 +302,13 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
var elements = new ArrayList();
|
||||
|
||||
while (elements.Count < maxElements)
|
||||
{
|
||||
{
|
||||
// fetch next batch of element names.
|
||||
var count = BLOCK_SIZE;
|
||||
|
||||
if (elements.Count + count > maxElements)
|
||||
{
|
||||
count = maxElements - elements.Count;
|
||||
count = maxElements - elements.Count;
|
||||
}
|
||||
var names = enumerator.Next(count);
|
||||
|
||||
@@ -321,18 +320,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
// create new element objects.
|
||||
foreach (var name in names)
|
||||
{
|
||||
{
|
||||
var element = new TsCHdaBrowseElement();
|
||||
|
||||
element.Name = name;
|
||||
element.Name = name;
|
||||
// lookup item id for element.
|
||||
try
|
||||
{
|
||||
string itemID = null;
|
||||
m_browser.GetItemID(name, out itemID);
|
||||
|
||||
element.ItemName = itemID;
|
||||
element.ItemPath = null;
|
||||
|
||||
element.ItemName = itemID;
|
||||
element.ItemPath = null;
|
||||
element.HasChildren = isBranch;
|
||||
}
|
||||
catch
|
||||
@@ -384,8 +383,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// <param name="fetchingItems">Whether the enumerator is return branches or items.</param>
|
||||
internal BrowsePosition(string branchPath, EnumString enumerator, bool fetchingItems)
|
||||
{
|
||||
m_branchPath = branchPath;
|
||||
m_enumerator = enumerator;
|
||||
m_branchPath = branchPath;
|
||||
m_enumerator = enumerator;
|
||||
m_fetchingItems = fetchingItems;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,26 +30,26 @@ using Technosoftware.OpcRcw.Hda;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that implements the HDA data callback interface.
|
||||
/// </summary>
|
||||
internal class DataCallback : IOPCHDA_DataCallback
|
||||
{
|
||||
internal class DataCallback : IOPCHDA_DataCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the object with the containing subscription object.
|
||||
/// </summary>
|
||||
public DataCallback() {}
|
||||
public DataCallback() { }
|
||||
|
||||
/// <summary>
|
||||
/// Fired when an exception occurs during callback processing.
|
||||
/// </summary>
|
||||
public event TsCHdaCallbackExceptionEventHandler CallbackExceptionEvent
|
||||
{
|
||||
add {lock (this) { _callbackExceptionEvent += value; }}
|
||||
remove {lock (this) { _callbackExceptionEvent -= value; }}
|
||||
add { lock (this) { _callbackExceptionEvent += value; } }
|
||||
remove { lock (this) { _callbackExceptionEvent -= value; } }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new request object.
|
||||
/// </summary>
|
||||
@@ -61,8 +61,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
var request = new Request(requestHandle, callback, ++m_nextID);
|
||||
|
||||
// no items yet - callback may return before async call returns.
|
||||
m_requests[request.RequestID] = request;
|
||||
|
||||
m_requests[request.RequestID] = request;
|
||||
|
||||
// return requests.
|
||||
return request;
|
||||
}
|
||||
@@ -103,11 +103,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when new data arrives for a subscription.
|
||||
/// </summary>
|
||||
public void OnDataChange(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
OPCHDA_ITEM[] pItemValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
results[ii].ServerHandle = results[ii].ClientHandle;
|
||||
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.
|
||||
@@ -150,11 +150,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when an asynchronous read request completes.
|
||||
/// </summary>
|
||||
public void OnReadComplete(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
OPCHDA_ITEM[] pItemValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
results[ii] = Interop.GetItemValueCollection(pItemValues[ii], false);
|
||||
|
||||
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.
|
||||
@@ -196,11 +196,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when an asynchronous read modified request completes.
|
||||
/// </summary>
|
||||
public void OnReadModifiedComplete(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
OPCHDA_MODIFIEDITEM[] pItemValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -222,7 +222,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
results[ii] = Interop.GetModifiedValueCollection(pItemValues[ii], false);
|
||||
|
||||
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.
|
||||
@@ -242,12 +242,12 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when an asynchronous read attributes request completes.
|
||||
/// </summary>
|
||||
public void OnReadAttributeComplete(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int hClient,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int hClient,
|
||||
int dwNumItems,
|
||||
OPCHDA_ATTRIBUTE[] pAttributeValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -273,7 +273,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
results[ii] = Interop.GetAttributeValueCollection(pAttributeValues[ii], false);
|
||||
|
||||
results[ii].Result = Utilities.Interop.GetResultId(phrErrors[ii]);
|
||||
|
||||
|
||||
item.Add(results[ii]);
|
||||
}
|
||||
|
||||
@@ -294,11 +294,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when an asynchronous read annotations request completes.
|
||||
/// </summary>
|
||||
public void OnReadAnnotations(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
OPCHDA_ANNOTATION[] pAnnotationValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -320,7 +320,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
results[ii] = Interop.GetAnnotationValueCollection(pAnnotationValues[ii], false);
|
||||
|
||||
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.
|
||||
@@ -340,10 +340,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when an asynchronous insert annotations request completes.
|
||||
/// </summary>
|
||||
public void OnInsertAnnotations(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwCount,
|
||||
int[] phClients,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwCount,
|
||||
int[] phClients,
|
||||
int[] phrErrors)
|
||||
{
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
itemResults.ServerHandle = currentHandle;
|
||||
results.Add(itemResults);
|
||||
|
||||
|
||||
currentHandle = phClients[ii];
|
||||
itemResults = new TsCHdaResultCollection();
|
||||
}
|
||||
@@ -407,11 +407,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Called when a batch of data from playback request arrives.
|
||||
/// </summary>
|
||||
public void OnPlayback(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwNumItems,
|
||||
IntPtr ppItemValues,
|
||||
int[] phrErrors)
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -436,16 +436,16 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
// get pointer to item.
|
||||
var pItem = (IntPtr)pItems[ii];
|
||||
|
||||
|
||||
// unmarshal item as an array of length 1.
|
||||
var item = Interop.GetItemValueCollections(ref pItem, 1, false);
|
||||
|
||||
if (item != null && item.Length == 1)
|
||||
{
|
||||
results[ii] = item[0];
|
||||
results[ii] = item[0];
|
||||
results[ii].ServerHandle = results[ii].ClientHandle;
|
||||
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.
|
||||
/// </summary>
|
||||
public void OnUpdateComplete(
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwCount,
|
||||
int[] phClients,
|
||||
int dwTransactionID,
|
||||
int hrStatus,
|
||||
int dwCount,
|
||||
int[] phClients,
|
||||
int[] phrErrors)
|
||||
{
|
||||
try
|
||||
@@ -501,7 +501,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
itemResults.ServerHandle = currentHandle;
|
||||
results.Add(itemResults);
|
||||
|
||||
|
||||
currentHandle = phClients[ii];
|
||||
itemResults = new TsCHdaResultCollection();
|
||||
}
|
||||
@@ -583,9 +583,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
private int m_nextID;
|
||||
private int m_nextID;
|
||||
private Hashtable m_requests = new Hashtable();
|
||||
private TsCHdaCallbackExceptionEventHandler _callbackExceptionEvent;
|
||||
private TsCHdaCallbackExceptionEventHandler _callbackExceptionEvent;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,410 +32,410 @@ using Technosoftware.DaAeHdaClient.Hda;
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Contains state information for a single asynchronous Technosoftware.DaAeHdaClient.Com.Hda.Interop.
|
||||
/// </summary>
|
||||
internal class Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a standard FILETIME to an OpcRcw.Da.FILETIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME Convert(FILETIME input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_FILETIME();
|
||||
output.dwLowDateTime = input.dwLowDateTime;
|
||||
output.dwHighDateTime = input.dwHighDateTime;
|
||||
return output;
|
||||
}
|
||||
/// </summary>
|
||||
internal class Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a standard FILETIME to an OpcRcw.Da.FILETIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME Convert(FILETIME input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_FILETIME();
|
||||
output.dwLowDateTime = input.dwLowDateTime;
|
||||
output.dwHighDateTime = input.dwHighDateTime;
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an OpcRcw.Da.FILETIME to a standard FILETIME structure.
|
||||
/// </summary>
|
||||
internal static FILETIME Convert(OpcRcw.Hda.OPCHDA_FILETIME input)
|
||||
{
|
||||
var output = new FILETIME();
|
||||
output.dwLowDateTime = input.dwLowDateTime;
|
||||
output.dwHighDateTime = input.dwHighDateTime;
|
||||
return output;
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts an OpcRcw.Da.FILETIME to a standard FILETIME structure.
|
||||
/// </summary>
|
||||
internal static FILETIME Convert(OpcRcw.Hda.OPCHDA_FILETIME input)
|
||||
{
|
||||
var output = new FILETIME();
|
||||
output.dwLowDateTime = input.dwLowDateTime;
|
||||
output.dwHighDateTime = input.dwHighDateTime;
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a decimal value to a OpcRcw.Hda.OPCHDA_TIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME GetFILETIME(decimal input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_FILETIME();
|
||||
/// <summary>
|
||||
/// Converts a decimal value to a OpcRcw.Hda.OPCHDA_TIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME GetFILETIME(decimal input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_FILETIME();
|
||||
|
||||
output.dwHighDateTime = (int)((((ulong)(input*10000000)) & 0xFFFFFFFF00000000)>>32);
|
||||
output.dwLowDateTime = (int)((((ulong)(input*10000000)) & 0x00000000FFFFFFFF));
|
||||
output.dwHighDateTime = (int)((((ulong)(input * 10000000)) & 0xFFFFFFFF00000000) >> 32);
|
||||
output.dwLowDateTime = (int)((((ulong)(input * 10000000)) & 0x00000000FFFFFFFF));
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of FILETIMEs.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME[] GetFILETIMEs(DateTime[] input)
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns an array of FILETIMEs.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_FILETIME[] GetFILETIMEs(DateTime[] input)
|
||||
{
|
||||
OpcRcw.Hda.OPCHDA_FILETIME[] output = null;
|
||||
|
||||
if (input != null)
|
||||
{
|
||||
output = new OpcRcw.Hda.OPCHDA_FILETIME[input.Length];
|
||||
if (input != null)
|
||||
{
|
||||
output = new OpcRcw.Hda.OPCHDA_FILETIME[input.Length];
|
||||
|
||||
for (var ii = 0; ii < input.Length; ii++)
|
||||
{
|
||||
output[ii] = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input[ii]));
|
||||
}
|
||||
}
|
||||
for (var ii = 0; ii < input.Length; ii++)
|
||||
{
|
||||
output[ii] = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input[ii]));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Technosoftware.DaAeHdaClient.Time object to a Technosoftware.DaAeHdaClient.Com.Hda.OPCHDA_TIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_TIME GetTime(TsCHdaTime input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_TIME();
|
||||
/// <summary>
|
||||
/// Converts a Technosoftware.DaAeHdaClient.Time object to a Technosoftware.DaAeHdaClient.Com.Hda.OPCHDA_TIME structure.
|
||||
/// </summary>
|
||||
internal static OpcRcw.Hda.OPCHDA_TIME GetTime(TsCHdaTime input)
|
||||
{
|
||||
var output = new OpcRcw.Hda.OPCHDA_TIME();
|
||||
|
||||
if (input != null)
|
||||
{
|
||||
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input.AbsoluteTime));
|
||||
output.szTime = (input.IsRelative)?input.ToString():"";
|
||||
output.bString = (input.IsRelative)?1:0;
|
||||
}
|
||||
if (input != null)
|
||||
{
|
||||
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input.AbsoluteTime));
|
||||
output.szTime = (input.IsRelative) ? input.ToString() : "";
|
||||
output.bString = (input.IsRelative) ? 1 : 0;
|
||||
}
|
||||
|
||||
// create a null value for a time structure.
|
||||
else
|
||||
{
|
||||
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(DateTime.MinValue));
|
||||
output.szTime = "";
|
||||
output.bString = 1;
|
||||
}
|
||||
// create a null value for a time structure.
|
||||
else
|
||||
{
|
||||
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(DateTime.MinValue));
|
||||
output.szTime = "";
|
||||
output.bString = 1;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ITEM structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection[] GetItemValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaItemValueCollection[] output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ITEM structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection[] GetItemValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaItemValueCollection[] output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaItemValueCollection[count];
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaItemValueCollection[count];
|
||||
|
||||
var pos = pInput;
|
||||
var pos = pInput;
|
||||
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetItemValueCollection(pos, deallocate);
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetItemValueCollection(pos, deallocate);
|
||||
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ITEM)));
|
||||
}
|
||||
}
|
||||
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection GetItemValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaItemValueCollection output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection GetItemValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaItemValueCollection output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM));
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM));
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ITEM));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaItemValueCollection();
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaItemValueCollection();
|
||||
|
||||
output.ClientHandle = input.hClient;
|
||||
output.Aggregate = input.haAggregate;
|
||||
output.ClientHandle = input.hClient;
|
||||
output.Aggregate = input.haAggregate;
|
||||
|
||||
var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, 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 timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate);
|
||||
var qualities = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);
|
||||
|
||||
for (var ii = 0; ii < input.dwCount; ii++)
|
||||
{
|
||||
var value = new TsCHdaItemValue();
|
||||
for (var ii = 0; ii < input.dwCount; ii++)
|
||||
{
|
||||
var value = new TsCHdaItemValue();
|
||||
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF));
|
||||
value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000));
|
||||
|
||||
output.Add(value);
|
||||
}
|
||||
output.Add(value);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_MODIFIEDITEM structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection[] GetModifiedValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaModifiedValueCollection[] output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_MODIFIEDITEM structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection[] GetModifiedValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaModifiedValueCollection[] output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaModifiedValueCollection[count];
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaModifiedValueCollection[count];
|
||||
|
||||
var pos = pInput;
|
||||
var pos = pInput;
|
||||
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetModifiedValueCollection(pos, deallocate);
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetModifiedValueCollection(pos, deallocate);
|
||||
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM)));
|
||||
}
|
||||
}
|
||||
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaModifiedValueCollection output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaModifiedValueCollection output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM));
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM));
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_MODIFIEDITEM));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(OpcRcw.Hda.OPCHDA_MODIFIEDITEM input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaModifiedValueCollection();
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_MODIFIEDITEM structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaModifiedValueCollection GetModifiedValueCollection(OpcRcw.Hda.OPCHDA_MODIFIEDITEM input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaModifiedValueCollection();
|
||||
|
||||
output.ClientHandle = input.hClient;
|
||||
output.ClientHandle = input.hClient;
|
||||
|
||||
var values = Com.Interop.GetVARIANTs(ref input.pvDataValues, 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 modificationTimes = Utilities.Interop.GetDateTimes(ref input.pftModificationTime, 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 timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, 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 editTypes = Utilities.Interop.GetInt32s(ref input.pEditType, input.dwCount, deallocate);
|
||||
var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwCount, deallocate);
|
||||
|
||||
for (var ii = 0; ii < input.dwCount; ii++)
|
||||
{
|
||||
var value = new TsCHdaModifiedValue();
|
||||
for (var ii = 0; ii < input.dwCount; ii++)
|
||||
{
|
||||
var value = new TsCHdaModifiedValue();
|
||||
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Quality = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF));
|
||||
value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000));
|
||||
value.ModificationTime = modificationTimes[ii];
|
||||
value.EditType = (TsCHdaEditType)editTypes[ii];
|
||||
value.User = users[ii];
|
||||
value.ModificationTime = modificationTimes[ii];
|
||||
value.EditType = (TsCHdaEditType)editTypes[ii];
|
||||
value.User = users[ii];
|
||||
|
||||
output.Add(value);
|
||||
}
|
||||
output.Add(value);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ATTRIBUTE structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection[] GetAttributeValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaAttributeValueCollection[] output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ATTRIBUTE structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection[] GetAttributeValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaAttributeValueCollection[] output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaAttributeValueCollection[count];
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaAttributeValueCollection[count];
|
||||
|
||||
var pos = pInput;
|
||||
var pos = pInput;
|
||||
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetAttributeValueCollection(pos, deallocate);
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetAttributeValueCollection(pos, deallocate);
|
||||
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE)));
|
||||
}
|
||||
}
|
||||
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaAttributeValueCollection output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaAttributeValueCollection output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE));
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE));
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ATTRIBUTE));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(OpcRcw.Hda.OPCHDA_ATTRIBUTE input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaAttributeValueCollection();
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAttributeValueCollection GetAttributeValueCollection(OpcRcw.Hda.OPCHDA_ATTRIBUTE input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaAttributeValueCollection();
|
||||
|
||||
output.AttributeID = input.dwAttributeID;
|
||||
output.AttributeID = input.dwAttributeID;
|
||||
|
||||
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++)
|
||||
{
|
||||
var value = new TsCHdaAttributeValue();
|
||||
for (var ii = 0; ii < input.dwNumValues; ii++)
|
||||
{
|
||||
var value = new TsCHdaAttributeValue();
|
||||
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Value = values[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
|
||||
output.Add(value);
|
||||
}
|
||||
output.Add(value);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ANNOTATION structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection[] GetAnnotationValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaAnnotationValueCollection[] output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an array of OPCHDA_ANNOTATION structures.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection[] GetAnnotationValueCollections(ref IntPtr pInput, int count, bool deallocate)
|
||||
{
|
||||
TsCHdaAnnotationValueCollection[] output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaAnnotationValueCollection[count];
|
||||
if (pInput != IntPtr.Zero && count > 0)
|
||||
{
|
||||
output = new TsCHdaAnnotationValueCollection[count];
|
||||
|
||||
var pos = pInput;
|
||||
var pos = pInput;
|
||||
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetAnnotationValueCollection(pos, deallocate);
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
output[ii] = GetAnnotationValueCollection(pos, deallocate);
|
||||
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Hda.OPCHDA_ANNOTATION)));
|
||||
}
|
||||
}
|
||||
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(pInput);
|
||||
pInput = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaAnnotationValueCollection output = null;
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(IntPtr pInput, bool deallocate)
|
||||
{
|
||||
TsCHdaAnnotationValueCollection output = null;
|
||||
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
var item = Marshal.PtrToStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION));
|
||||
if (pInput != IntPtr.Zero)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION));
|
||||
}
|
||||
}
|
||||
if (deallocate)
|
||||
{
|
||||
Marshal.DestroyStructure(pInput, typeof(OpcRcw.Hda.OPCHDA_ANNOTATION));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(OpcRcw.Hda.OPCHDA_ANNOTATION input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaAnnotationValueCollection();
|
||||
/// <summary>
|
||||
/// Unmarshals and deallocates an OPCHDA_ANNOTATION structure.
|
||||
/// </summary>
|
||||
internal static TsCHdaAnnotationValueCollection GetAnnotationValueCollection(OpcRcw.Hda.OPCHDA_ANNOTATION input, bool deallocate)
|
||||
{
|
||||
var output = new TsCHdaAnnotationValueCollection();
|
||||
|
||||
output.ClientHandle = input.hClient;
|
||||
output.ClientHandle = input.hClient;
|
||||
|
||||
var timestamps = Utilities.Interop.GetDateTimes(ref input.ftTimeStamps, 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 users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, 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 creationTimes = Utilities.Interop.GetDateTimes(ref input.ftAnnotationTime, input.dwNumValues, deallocate);
|
||||
var users = Utilities.Interop.GetUnicodeStrings(ref input.szUser, input.dwNumValues, deallocate);
|
||||
|
||||
for (var ii = 0; ii < input.dwNumValues; ii++)
|
||||
{
|
||||
var value = new TsCHdaAnnotationValue();
|
||||
for (var ii = 0; ii < input.dwNumValues; ii++)
|
||||
{
|
||||
var value = new TsCHdaAnnotationValue();
|
||||
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Annotation = annotations[ii];
|
||||
value.CreationTime = creationTimes[ii];
|
||||
value.User = users[ii];
|
||||
value.Timestamp = timestamps[ii];
|
||||
value.Annotation = annotations[ii];
|
||||
value.CreationTime = creationTimes[ii];
|
||||
value.User = users[ii];
|
||||
|
||||
output.Add(value);
|
||||
}
|
||||
output.Add(value);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// Initializes the object with all required information.
|
||||
/// </summary>
|
||||
public Request(object requestHandle, Delegate callback, int requestID)
|
||||
{
|
||||
m_requestHandle = requestHandle;
|
||||
m_callback = callback;
|
||||
m_requestID = requestID;
|
||||
{
|
||||
m_requestHandle = requestHandle;
|
||||
m_callback = callback;
|
||||
m_requestID = requestID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -72,7 +72,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
lock (this)
|
||||
{
|
||||
// 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.
|
||||
m_items = new Hashtable();
|
||||
@@ -140,25 +140,25 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
return InvokeCallback((TsCHdaReadValuesCompleteEventHandler)m_callback, results);
|
||||
}
|
||||
|
||||
|
||||
// invoke read attributes completed callback.
|
||||
if (typeof(TsCHdaReadAttributesCompleteEventHandler).IsInstanceOfType(m_callback))
|
||||
{
|
||||
return InvokeCallback((TsCHdaReadAttributesCompleteEventHandler)m_callback, results);
|
||||
}
|
||||
|
||||
|
||||
// invoke read annotations completed callback.
|
||||
if (typeof(TsCHdaReadAnnotationsCompleteEventHandler).IsInstanceOfType(m_callback))
|
||||
{
|
||||
return InvokeCallback((TsCHdaReadAnnotationsCompleteEventHandler)m_callback, results);
|
||||
}
|
||||
|
||||
|
||||
// invoke update completed callback.
|
||||
if (typeof(TsCHdaUpdateCompleteEventHandler).IsInstanceOfType(m_callback))
|
||||
{
|
||||
return InvokeCallback((TsCHdaUpdateCompleteEventHandler)m_callback, results);
|
||||
}
|
||||
|
||||
|
||||
// callback not supported.
|
||||
return true;
|
||||
}
|
||||
@@ -227,11 +227,11 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
callback(this, values);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore exceptions in the callbacks.
|
||||
}
|
||||
|
||||
|
||||
// request never completes.
|
||||
return false;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
callback(this, values);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore exceptions in the callbacks.
|
||||
}
|
||||
@@ -272,7 +272,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
// request is complete.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes callback for a read attributes request.
|
||||
@@ -294,7 +294,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
callback(this, values);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore exceptions in the callbacks.
|
||||
}
|
||||
@@ -302,7 +302,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
// request always completes
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Invokes callback for a read annotations request.
|
||||
/// </summary>
|
||||
@@ -323,7 +323,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
callback(this, values);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore exceptions in the callbacks.
|
||||
}
|
||||
@@ -352,7 +352,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
{
|
||||
callback(this, values);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore exceptions in the callbacks.
|
||||
}
|
||||
@@ -372,7 +372,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
if (typeof(ITsCHdaActualTime).IsInstanceOfType(result))
|
||||
{
|
||||
((ITsCHdaActualTime)result).StartTime = StartTime;
|
||||
((ITsCHdaActualTime)result).EndTime = EndTime;
|
||||
((ITsCHdaActualTime)result).EndTime = EndTime;
|
||||
}
|
||||
|
||||
// add item identifier to value collection.
|
||||
@@ -380,8 +380,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
|
||||
if (itemID != null)
|
||||
{
|
||||
result.ItemName = itemID.ItemName;
|
||||
result.ItemPath = itemID.ItemPath;
|
||||
result.ItemName = itemID.ItemName;
|
||||
result.ItemPath = itemID.ItemPath;
|
||||
result.ServerHandle = itemID.ServerHandle;
|
||||
result.ClientHandle = itemID.ClientHandle;
|
||||
}
|
||||
@@ -390,9 +390,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
private object m_requestHandle = null;
|
||||
private Delegate m_callback = null;
|
||||
private int m_requestID = 0;
|
||||
private object m_requestHandle = null;
|
||||
private Delegate m_callback = null;
|
||||
private int m_requestID = 0;
|
||||
private int m_cancelID = 0;
|
||||
private DateTime m_startTime = DateTime.MinValue;
|
||||
private DateTime m_endTime = DateTime.MinValue;
|
||||
|
||||
@@ -32,37 +32,37 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// Defines all well known COM HDA HRESULT codes.
|
||||
/// </summary>
|
||||
internal struct Result
|
||||
{
|
||||
{
|
||||
/// <remarks/>
|
||||
public const int E_MAXEXCEEDED = -0X3FFBEFFF; // 0xC0041001
|
||||
public const int E_MAXEXCEEDED = -0X3FFBEFFF; // 0xC0041001
|
||||
/// <remarks/>
|
||||
public const int S_NODATA = +0x40041002; // 0x40041002
|
||||
public const int S_NODATA = +0x40041002; // 0x40041002
|
||||
/// <remarks/>
|
||||
public const int S_MOREDATA = +0x40041003; // 0x40041003
|
||||
public const int S_MOREDATA = +0x40041003; // 0x40041003
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDAGGREGATE = -0X3FFBEFFC; // 0xC0041004
|
||||
/// <remarks/>
|
||||
public const int S_CURRENTVALUE = +0x40041005; // 0x40041005
|
||||
public const int S_CURRENTVALUE = +0x40041005; // 0x40041005
|
||||
/// <remarks/>
|
||||
public const int S_EXTRADATA = +0x40041006; // 0x40041006
|
||||
public const int S_EXTRADATA = +0x40041006; // 0x40041006
|
||||
/// <remarks/>
|
||||
public const int W_NOFILTER = -0x7FFBEFF9; // 0x80041007
|
||||
public const int W_NOFILTER = -0x7FFBEFF9; // 0x80041007
|
||||
/// <remarks/>
|
||||
public const int E_UNKNOWNATTRID = -0x3FFBEFF8; // 0xC0041008
|
||||
public const int E_UNKNOWNATTRID = -0x3FFBEFF8; // 0xC0041008
|
||||
/// <remarks/>
|
||||
public const int E_NOT_AVAIL = -0x3FFBEFF7; // 0xC0041009
|
||||
public const int E_NOT_AVAIL = -0x3FFBEFF7; // 0xC0041009
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDDATATYPE = -0x3FFBEFF6; // 0xC004100A
|
||||
public const int E_INVALIDDATATYPE = -0x3FFBEFF6; // 0xC004100A
|
||||
/// <remarks/>
|
||||
public const int E_DATAEXISTS = -0x3FFBEFF5; // 0xC004100B
|
||||
public const int E_DATAEXISTS = -0x3FFBEFF5; // 0xC004100B
|
||||
/// <remarks/>
|
||||
public const int E_INVALIDATTRID = -0x3FFBEFF4; // 0xC004100C
|
||||
public const int E_INVALIDATTRID = -0x3FFBEFF4; // 0xC004100C
|
||||
/// <remarks/>
|
||||
public const int E_NODATAEXISTS = -0x3FFBEFF3; // 0xC004100D
|
||||
public const int E_NODATAEXISTS = -0x3FFBEFF3; // 0xC004100D
|
||||
/// <remarks/>
|
||||
public const int S_INSERTED = +0x4004100E; // 0x4004100E
|
||||
public const int S_INSERTED = +0x4004100E; // 0x4004100E
|
||||
/// <remarks/>
|
||||
public const int S_REPLACED = +0x4004100F; // 0x4004100F
|
||||
public const int S_REPLACED = +0x4004100F; // 0x4004100F
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3175,8 +3175,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
OPCHDA_TIME pEndTime)
|
||||
{
|
||||
// unmarshal actual times from input arguments.
|
||||
var startTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pStartTime.ftTime));
|
||||
var endTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pEndTime.ftTime));
|
||||
var startTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pStartTime.ftTime));
|
||||
var endTime = Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(Interop.Convert(pEndTime.ftTime));
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
@@ -3466,7 +3466,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
|
||||
/// The synchronization object for subscription access
|
||||
/// </summary>
|
||||
private static volatile object lock_ = new object();
|
||||
|
||||
|
||||
private bool disposed_ = false;
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -22,12 +22,11 @@
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.DaAeHdaClient.Com.Utilities;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 0618
|
||||
@@ -598,10 +597,10 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
clsctx,
|
||||
ref coserverInfo,
|
||||
1,
|
||||
results);
|
||||
results);
|
||||
}
|
||||
finally
|
||||
{
|
||||
{
|
||||
if (hIID.IsAllocated) hIID.Free();
|
||||
|
||||
serverInfo.Deallocate();
|
||||
@@ -859,7 +858,8 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// <summary>
|
||||
/// This flag suppresses the conversion to local time done during marshalling.
|
||||
/// </summary>
|
||||
public static bool PreserveUtc {
|
||||
public static bool PreserveUtc
|
||||
{
|
||||
get { lock (typeof(Interop)) { return DaAeHdaClient.ApplicationInstance.TimeAsUtc; } }
|
||||
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);
|
||||
|
||||
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.
|
||||
if (input >= 0)
|
||||
{
|
||||
return new OpcResult(OpcResult.S_FALSE, input);
|
||||
}
|
||||
// chekc for success code.
|
||||
if (input >= 0)
|
||||
{
|
||||
return new OpcResult(OpcResult.S_FALSE, input);
|
||||
}
|
||||
|
||||
// return generic error.
|
||||
return new OpcResult(OpcResult.E_FAIL, input);
|
||||
}
|
||||
// return generic error.
|
||||
return new OpcResult(OpcResult.E_FAIL, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,79 +1410,79 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// Converts a result id to an HRESULT.
|
||||
/// </summary>
|
||||
internal static int GetResultID(OpcResult input)
|
||||
{
|
||||
// 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.E_FAIL) return Da.Result.E_FAIL;
|
||||
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_READONLY) 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.E_OUTOFMEMORY) return Da.Result.E_OUTOFMEMORY;
|
||||
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_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_PATH) return Da.Result.E_INVALIDITEMID;
|
||||
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.S_UNSUPPORTEDRATE) return Da.Result.S_UNSUPPORTEDRATE;
|
||||
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_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_WRITEQT) return Da.Result.E_NOTSUPPORTED;
|
||||
if (input == OpcResult.Da.E_INVALIDCONTINUATIONPOINT) return Da.Result.E_INVALIDCONTINUATIONPOINT;
|
||||
if (input == OpcResult.Da.S_DATAQUEUEOVERFLOW) return Da.Result.S_DATAQUEUEOVERFLOW;
|
||||
}
|
||||
{
|
||||
// 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.E_FAIL) return Da.Result.E_FAIL;
|
||||
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_READONLY) 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.E_OUTOFMEMORY) return Da.Result.E_OUTOFMEMORY;
|
||||
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_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_PATH) return Da.Result.E_INVALIDITEMID;
|
||||
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.S_UNSUPPORTEDRATE) return Da.Result.S_UNSUPPORTEDRATE;
|
||||
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_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_WRITEQT) return Da.Result.E_NOTSUPPORTED;
|
||||
if (input == OpcResult.Da.E_INVALIDCONTINUATIONPOINT) return Da.Result.E_INVALIDCONTINUATIONPOINT;
|
||||
if (input == OpcResult.Da.S_DATAQUEUEOVERFLOW) return Da.Result.S_DATAQUEUEOVERFLOW;
|
||||
}
|
||||
|
||||
// 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_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_ERROR) return Cpx.Result.E_FILTER_ERROR;
|
||||
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;
|
||||
}
|
||||
// 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_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_ERROR) return Cpx.Result.E_FILTER_ERROR;
|
||||
if (input == OpcResult.Cpx.S_FILTER_NO_DATA) return Cpx.Result.S_FILTER_NO_DATA;
|
||||
}
|
||||
|
||||
// check for custom code.
|
||||
else if (input.Code == -1)
|
||||
{
|
||||
// default success code.
|
||||
if (input.Succeeded())
|
||||
{
|
||||
return Da.Result.S_FALSE;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
// default error code.
|
||||
return Da.Result.E_FAIL;
|
||||
}
|
||||
// check for custom code.
|
||||
else if (input.Code == -1)
|
||||
{
|
||||
// default success code.
|
||||
if (input.Succeeded())
|
||||
{
|
||||
return Da.Result.S_FALSE;
|
||||
}
|
||||
|
||||
// return custom code.
|
||||
return input.Code;
|
||||
// default error code.
|
||||
return Da.Result.E_FAIL;
|
||||
}
|
||||
|
||||
// return custom code.
|
||||
return input.Code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,12 +23,11 @@
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
#endregion
|
||||
|
||||
@@ -264,11 +263,11 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
[DllImport("ole32.dll")]
|
||||
private static extern int CoQueryProxyBlanket(
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object pProxy,
|
||||
object pProxy,
|
||||
ref uint pAuthnSvc,
|
||||
ref uint pAuthzSvc,
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
ref string pServerPrincName,
|
||||
ref string pServerPrincName,
|
||||
ref uint pAuthnLevel,
|
||||
ref uint pImpLevel,
|
||||
ref IntPtr pAuthInfo,
|
||||
@@ -277,7 +276,7 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
[DllImport("ole32.dll")]
|
||||
private static extern int CoSetProxyBlanket(
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object pProxy,
|
||||
object pProxy,
|
||||
uint pAuthnSvc,
|
||||
uint pAuthzSvc,
|
||||
IntPtr pServerPrincName,
|
||||
@@ -347,13 +346,13 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
private static extern int CoCreateInstanceEx(
|
||||
ref Guid clsid,
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object punkOuter,
|
||||
object punkOuter,
|
||||
uint dwClsCtx,
|
||||
[In]
|
||||
ref COSERVERINFO pServerInfo,
|
||||
ref COSERVERINFO pServerInfo,
|
||||
uint dwCount,
|
||||
[In, Out]
|
||||
MULTI_QI[] pResults);
|
||||
MULTI_QI[] pResults);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
private struct LICINFO
|
||||
@@ -372,15 +371,15 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
{
|
||||
void CreateInstance(
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object punkOuter,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
object punkOuter,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
[MarshalAs(UnmanagedType.Interface)]
|
||||
[Out] out object ppvObject);
|
||||
[Out] out object ppvObject);
|
||||
|
||||
void LockServer(
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
bool fLock);
|
||||
bool fLock);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
@@ -390,15 +389,15 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
{
|
||||
void CreateInstance(
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object punkOuter,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
object punkOuter,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
[MarshalAs(UnmanagedType.Interface)]
|
||||
[Out] out object ppvObject);
|
||||
[Out] out object ppvObject);
|
||||
|
||||
void LockServer(
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
bool fLock);
|
||||
bool fLock);
|
||||
|
||||
void GetLicInfo(
|
||||
[In, Out] ref LICINFO pLicInfo);
|
||||
@@ -406,31 +405,31 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
void RequestLicKey(
|
||||
int dwReserved,
|
||||
[MarshalAs(UnmanagedType.BStr)]
|
||||
string pbstrKey);
|
||||
string pbstrKey);
|
||||
|
||||
void CreateInstanceLic(
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object punkOuter,
|
||||
object punkOuter,
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
object punkReserved,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
object punkReserved,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
[MarshalAs(UnmanagedType.BStr)]
|
||||
string bstrKey,
|
||||
string bstrKey,
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
[Out] out object ppvObject);
|
||||
[Out] out object ppvObject);
|
||||
}
|
||||
|
||||
[DllImport("ole32.dll")]
|
||||
private static extern int CoGetClassObject(
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid clsid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid clsid,
|
||||
uint dwClsContext,
|
||||
[In] ref COSERVERINFO pServerInfo,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
Guid riid,
|
||||
[MarshalAs(UnmanagedType.IUnknown)]
|
||||
[Out] out object ppv);
|
||||
[Out] out object ppv);
|
||||
|
||||
internal const int LOGON32_PROVIDER_DEFAULT = 0;
|
||||
internal const int LOGON32_LOGON_INTERACTIVE = 2;
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
using Technosoftware.DaAeHdaClient.Ae;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
using Technosoftware.DaAeHdaClient.Hda;
|
||||
using Technosoftware.OpcRcw.Comn;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Com
|
||||
@@ -38,192 +36,192 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
/// A unique identifier for the result of an operation of an item.
|
||||
/// </summary>
|
||||
public class ServerEnumerator : IOpcDiscovery
|
||||
{
|
||||
//======================================================================
|
||||
// IDisposable
|
||||
{
|
||||
//======================================================================
|
||||
// IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Frees all unmanaged resources
|
||||
/// </summary>
|
||||
public void Dispose() {}
|
||||
/// <summary>
|
||||
/// Frees all unmanaged resources
|
||||
/// </summary>
|
||||
public void Dispose() { }
|
||||
|
||||
//======================================================================
|
||||
// IDiscovery
|
||||
//======================================================================
|
||||
// IDiscovery
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates hosts that may be accessed for server discovery.
|
||||
/// </summary>
|
||||
public string[] EnumerateHosts()
|
||||
{
|
||||
return Interop.EnumComputers();
|
||||
}
|
||||
/// <summary>
|
||||
/// Enumerates hosts that may be accessed for server discovery.
|
||||
/// </summary>
|
||||
public string[] EnumerateHosts()
|
||||
{
|
||||
return Interop.EnumComputers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of servers that support the specified interface specification.
|
||||
/// </summary>
|
||||
public OpcServer[] GetAvailableServers(OpcSpecification specification)
|
||||
{
|
||||
return GetAvailableServers(specification, null, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a list of servers that support the specified interface specification.
|
||||
/// </summary>
|
||||
public OpcServer[] GetAvailableServers(OpcSpecification specification)
|
||||
{
|
||||
return GetAvailableServers(specification, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of servers that support the specified specification on the specified host.
|
||||
/// </summary>
|
||||
public OpcServer[] GetAvailableServers(OpcSpecification specification, string host, OpcConnectData connectData)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
var credentials = (connectData != null)?connectData.GetCredential(null, null):null;
|
||||
/// <summary>
|
||||
/// Returns a list of servers that support the specified specification on the specified host.
|
||||
/// </summary>
|
||||
public OpcServer[] GetAvailableServers(OpcSpecification specification, string host, OpcConnectData connectData)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
var credentials = (connectData != null) ? connectData.GetCredential(null, null) : null;
|
||||
|
||||
// connect to the server.
|
||||
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
|
||||
m_host = host;
|
||||
// connect to the server.
|
||||
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
|
||||
m_host = host;
|
||||
|
||||
try
|
||||
{
|
||||
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;
|
||||
try
|
||||
{
|
||||
var servers = new ArrayList();
|
||||
|
||||
m_server.EnumClassesOfCategories(
|
||||
1,
|
||||
new Guid[] { catid },
|
||||
0,
|
||||
null,
|
||||
out enumerator);
|
||||
// convert the interface version to a guid.
|
||||
var catid = new Guid(specification.Id);
|
||||
|
||||
// read clsids.
|
||||
var clsids = ReadClasses(enumerator);
|
||||
// get list of servers in the specified specification.
|
||||
IOPCEnumGUID enumerator = null;
|
||||
|
||||
m_server.EnumClassesOfCategories(
|
||||
1,
|
||||
new Guid[] { catid },
|
||||
0,
|
||||
null,
|
||||
out enumerator);
|
||||
|
||||
// read clsids.
|
||||
var clsids = ReadClasses(enumerator);
|
||||
|
||||
// release enumerator object.
|
||||
Interop.ReleaseServer(enumerator);
|
||||
enumerator = null;
|
||||
enumerator = null;
|
||||
|
||||
// fetch class descriptions.
|
||||
foreach (var clsid in clsids)
|
||||
{
|
||||
var factory = new Factory();
|
||||
// fetch class descriptions.
|
||||
foreach (var clsid in clsids)
|
||||
{
|
||||
var factory = new Factory();
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = CreateUrl(specification, clsid);
|
||||
|
||||
OpcServer server = null;
|
||||
OpcServer server = null;
|
||||
|
||||
if (specification == OpcSpecification.OPC_DA_30)
|
||||
{
|
||||
server = new TsCDaServer(factory, url);
|
||||
}
|
||||
if (specification == OpcSpecification.OPC_DA_30)
|
||||
{
|
||||
server = new TsCDaServer(factory, url);
|
||||
}
|
||||
|
||||
else if (specification == OpcSpecification.OPC_DA_20)
|
||||
{
|
||||
server = new TsCDaServer(factory, url);
|
||||
}
|
||||
|
||||
else if (specification == OpcSpecification.OPC_AE_10)
|
||||
{
|
||||
server = new TsCAeServer(factory, url);
|
||||
}
|
||||
else if (specification == OpcSpecification.OPC_DA_20)
|
||||
{
|
||||
server = new TsCDaServer(factory, url);
|
||||
}
|
||||
|
||||
else if (specification == OpcSpecification.OPC_HDA_10)
|
||||
{
|
||||
server = new TsCHdaServer(factory, url);
|
||||
}
|
||||
|
||||
servers.Add(server);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignore bad clsids.
|
||||
}
|
||||
}
|
||||
else if (specification == OpcSpecification.OPC_AE_10)
|
||||
{
|
||||
server = new TsCAeServer(factory, url);
|
||||
}
|
||||
|
||||
return (OpcServer[])servers.ToArray(typeof(OpcServer));
|
||||
}
|
||||
finally
|
||||
{
|
||||
// free the server.
|
||||
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;
|
||||
else if (specification == OpcSpecification.OPC_HDA_10)
|
||||
{
|
||||
server = new TsCHdaServer(factory, url);
|
||||
}
|
||||
|
||||
servers.Add(server);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignore bad clsids.
|
||||
}
|
||||
}
|
||||
|
||||
return (OpcServer[])servers.ToArray(typeof(OpcServer));
|
||||
}
|
||||
finally
|
||||
{
|
||||
// free the server.
|
||||
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.
|
||||
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
|
||||
m_host = host;
|
||||
m_host = host;
|
||||
|
||||
// lookup prog id.
|
||||
Guid clsid;
|
||||
// lookup prog id.
|
||||
Guid clsid;
|
||||
|
||||
try
|
||||
{
|
||||
m_server.CLSIDFromProgID(progID, out clsid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
clsid = Guid.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.ReleaseServer(m_server);
|
||||
m_server = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
m_server.CLSIDFromProgID(progID, out clsid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
clsid = Guid.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.ReleaseServer(m_server);
|
||||
m_server = null;
|
||||
}
|
||||
|
||||
// return empty guid if prog id not found.
|
||||
return clsid;
|
||||
}
|
||||
}
|
||||
// return empty guid if prog id not found.
|
||||
return clsid;
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Private Members
|
||||
//======================================================================
|
||||
// Private Members
|
||||
|
||||
/// <summary>
|
||||
/// The server enumerator COM server.
|
||||
/// </summary>
|
||||
private IOPCServerList2 m_server = null;
|
||||
/// <summary>
|
||||
/// The server enumerator COM server.
|
||||
/// </summary>
|
||||
private IOPCServerList2 m_server = null;
|
||||
|
||||
/// <summary>
|
||||
/// The host where the servers are being enumerated.
|
||||
/// </summary>
|
||||
private string m_host = null;
|
||||
/// <summary>
|
||||
/// The host where the servers are being enumerated.
|
||||
/// </summary>
|
||||
private string m_host = null;
|
||||
|
||||
/// <summary>
|
||||
/// The ProgID for the OPC Server Enumerator.
|
||||
/// </summary>
|
||||
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>
|
||||
/// The ProgID for the OPC Server Enumerator.
|
||||
/// </summary>
|
||||
private const string ProgID = "OPC.ServerList.1";
|
||||
|
||||
//======================================================================
|
||||
// Private Methods
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
private Guid[] ReadClasses(IOPCEnumGUID enumerator)
|
||||
{
|
||||
var guids = new ArrayList();
|
||||
//======================================================================
|
||||
// Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Reads the guids from the enumerator.
|
||||
/// </summary>
|
||||
private Guid[] ReadClasses(IOPCEnumGUID enumerator)
|
||||
{
|
||||
var guids = new ArrayList();
|
||||
var count = 10;
|
||||
|
||||
// create buffer.
|
||||
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid))*count);
|
||||
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)) * count);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -257,64 +255,64 @@ namespace Technosoftware.DaAeHdaClient.Com
|
||||
{
|
||||
Marshal.FreeCoTaskMem(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the server details from the enumerator.
|
||||
/// </summary>
|
||||
OpcUrl CreateUrl(OpcSpecification specification, Guid clsid)
|
||||
{
|
||||
{
|
||||
// initialize the server url.
|
||||
var url = new OpcUrl();
|
||||
|
||||
url.HostName = m_host;
|
||||
url.Port = 0;
|
||||
url.Path = null;
|
||||
|
||||
if (specification == OpcSpecification.OPC_DA_30) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_DA_20) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_DA_10) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_AE_10) { url.Scheme = OpcUrlScheme.AE; }
|
||||
else if (specification == OpcSpecification.OPC_HDA_10) { url.Scheme = OpcUrlScheme.HDA; }
|
||||
url.HostName = m_host;
|
||||
url.Port = 0;
|
||||
url.Path = null;
|
||||
|
||||
try
|
||||
{
|
||||
// fetch class details from the enumerator.
|
||||
string progID = null;
|
||||
string description = null;
|
||||
string verIndProgID = null;
|
||||
if (specification == OpcSpecification.OPC_DA_30) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_DA_20) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_DA_10) { url.Scheme = OpcUrlScheme.DA; }
|
||||
else if (specification == OpcSpecification.OPC_AE_10) { url.Scheme = OpcUrlScheme.AE; }
|
||||
else if (specification == OpcSpecification.OPC_HDA_10) { url.Scheme = OpcUrlScheme.HDA; }
|
||||
|
||||
m_server.GetClassDetails(
|
||||
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() + "}");
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
// fetch class details from the enumerator.
|
||||
string progID = null;
|
||||
string description = null;
|
||||
string verIndProgID = null;
|
||||
|
||||
// return the server url.
|
||||
return url;
|
||||
}
|
||||
}
|
||||
m_server.GetClassDetails(
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
@@ -47,7 +44,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
private static Task watchdogTask_;
|
||||
private static DCOMWatchdogResult lastWatchdogResult_ = DCOMWatchdogResult.None;
|
||||
private static DateTime setStart_;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -97,7 +94,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
/// </summary>
|
||||
public static TimeSpan Timeout
|
||||
{
|
||||
get => timeout_;
|
||||
get => timeout_;
|
||||
set
|
||||
{
|
||||
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
|
||||
/// between 1-2 minutes, depending on the OS</param>
|
||||
public static void Enable(TimeSpan timeout)
|
||||
{
|
||||
{
|
||||
if (timeout == TimeSpan.Zero)
|
||||
{
|
||||
timeout = TimeSpan.FromSeconds(DEFAULT_TIMEOUT_SECONDS);
|
||||
@@ -159,7 +156,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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
|
||||
/// 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;
|
||||
watchDogThreadID_ = threadId;
|
||||
|
||||
|
||||
Utils.Trace(Utils.TraceMasks.Information, $"COM call cancellation on thread [{watchDogThreadID_}] was set with timeout [{timeout_.TotalSeconds} seconds]");
|
||||
}
|
||||
else
|
||||
@@ -289,7 +286,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
private static void WatchdogTask()
|
||||
{
|
||||
{
|
||||
while (IsEnabled)
|
||||
{
|
||||
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...");
|
||||
|
||||
Cancel(DCOMWatchdogResult.TimedOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -367,7 +364,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static TimeSpan TimeElapsed(DateTime startTime)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
@@ -386,5 +383,5 @@ namespace Technosoftware.DaAeHdaClient.Com.Utilities
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#pragma warning disable 618
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user