Clean
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user