Fix
This commit is contained in:
72
Technosoftware/DaAeHdaClient/Ae/Attribute.cs
Normal file
72
Technosoftware/DaAeHdaClient/Ae/Attribute.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an attribute supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeAttribute : ICloneable
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the attribute.
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique name for the attribute.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The data type of the attribute.
|
||||
/// </summary>
|
||||
public Type DataType { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone() { return MemberwiseClone(); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
62
Technosoftware/DaAeHdaClient/Ae/AttributeCollection.cs
Normal file
62
Technosoftware/DaAeHdaClient/Ae/AttributeCollection.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a writable collection attribute ids.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeAttributeCollection : OpcWriteableCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal TsCAeAttributeCollection() : base(null, typeof(int)) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a collection from an array.
|
||||
/// </summary>
|
||||
internal TsCAeAttributeCollection(int[] attributeIDs) : base(attributeIDs, typeof(int)) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new int this[int index] => (int)Array[index];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new int[] ToArray()
|
||||
{
|
||||
return (int[])Array.ToArray(typeof(int));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
91
Technosoftware/DaAeHdaClient/Ae/AttributeDictionary.cs
Normal file
91
Technosoftware/DaAeHdaClient/Ae/AttributeDictionary.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains multiple lists of the attributes indexed by category.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class TsCAeAttributeDictionary : OpcWriteableDictionary
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Constructs an empty dictionary.
|
||||
/// </summary>
|
||||
public TsCAeAttributeDictionary() : base(null, typeof(int), typeof(TsCAeAttributeCollection)) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an dictionary from a set of category ids.
|
||||
/// </summary>
|
||||
public TsCAeAttributeDictionary(int[] categoryIds)
|
||||
: base(null, typeof(int), typeof(TsCAeAttributeCollection))
|
||||
{
|
||||
foreach (var categoryId in categoryIds)
|
||||
{
|
||||
Add(categoryId, null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets or sets the attribute collection for the specified category.
|
||||
/// </summary>
|
||||
public TsCAeAttributeCollection this[int categoryId]
|
||||
{
|
||||
get => (TsCAeAttributeCollection)base[categoryId];
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
base[categoryId] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
base[categoryId] = new TsCAeAttributeCollection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element with the provided key and value to the IDictionary.
|
||||
/// </summary>
|
||||
public void Add(int key, int[] value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
base.Add(key, new TsCAeAttributeCollection(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Add(key, new TsCAeAttributeCollection());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
79
Technosoftware/DaAeHdaClient/Ae/AttributeValue.cs
Normal file
79
Technosoftware/DaAeHdaClient/Ae/AttributeValue.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The value of an attribute for an event source.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeAttributeValue : ICloneable, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the attribute.
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an property.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCAeAttributeValue)MemberwiseClone();
|
||||
clone.Value = OpcConvert.Clone(Value);
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
70
Technosoftware/DaAeHdaClient/Ae/BrowseElement.cs
Normal file
70
Technosoftware/DaAeHdaClient/Ae/BrowseElement.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a description of an element in the server address space.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeBrowseElement
|
||||
{
|
||||
#region Fields
|
||||
private TsCAeBrowseType browseType_ = TsCAeBrowseType.Area;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A descriptive name for element that is unique within a branch.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The fully qualified name for the element.
|
||||
/// </summary>
|
||||
public string QualifiedName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the element is a source or an area.
|
||||
/// </summary>
|
||||
public TsCAeBrowseType NodeType
|
||||
{
|
||||
get => browseType_;
|
||||
set => browseType_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
129
Technosoftware/DaAeHdaClient/Ae/BrowsePosition.cs
Normal file
129
Technosoftware/DaAeHdaClient/Ae/BrowsePosition.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores the state of a browse operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeBrowsePosition : IOpcBrowsePosition
|
||||
{
|
||||
#region Fields
|
||||
private bool disposed_;
|
||||
private string areaId_;
|
||||
private TsCAeBrowseType browseType_;
|
||||
private string browseFilter_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Saves the parameters for an incomplete browse information.
|
||||
/// </summary>
|
||||
public TsCAeBrowsePosition(
|
||||
string areaId,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter)
|
||||
{
|
||||
areaId_ = areaId;
|
||||
browseType_ = browseType;
|
||||
browseFilter_ = browseFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The finalizer implementation.
|
||||
/// </summary>
|
||||
~TsCAeBrowsePosition()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
// Take yourself off the Finalization queue
|
||||
// to prevent finalization code for this object
|
||||
// from executing a second time.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose(bool disposing) executes in two distinct scenarios.
|
||||
/// If disposing equals true, the method has been called directly
|
||||
/// or indirectly by a user's code. Managed and unmanaged resources
|
||||
/// can be disposed.
|
||||
/// If disposing equals false, the method has been called by the
|
||||
/// runtime from inside the finalizer and you should not reference
|
||||
/// other objects. Only unmanaged resources can be disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if(!disposed_)
|
||||
{
|
||||
// If disposing equals true, dispose all managed
|
||||
// and unmanaged resources.
|
||||
if(disposing)
|
||||
{
|
||||
}
|
||||
// Release unmanaged resources. If disposing is false,
|
||||
// only the following code is executed.
|
||||
}
|
||||
disposed_ = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The fully qualified id for the area being browsed.
|
||||
/// </summary>
|
||||
public string AreaID => areaId_;
|
||||
|
||||
/// <summary>
|
||||
/// The type of child element being returned with the browse.
|
||||
/// </summary>
|
||||
public TsCAeBrowseType BrowseType => browseType_;
|
||||
|
||||
/// <summary>
|
||||
/// The filter applied to the name of the elements being returned.
|
||||
/// </summary>
|
||||
public string BrowseFilter => browseFilter_;
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return (TsCAeBrowsePosition)MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
44
Technosoftware/DaAeHdaClient/Ae/BrowseType.cs
Normal file
44
Technosoftware/DaAeHdaClient/Ae/BrowseType.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of nodes to return during a browse.
|
||||
/// </summary>
|
||||
public enum TsCAeBrowseType
|
||||
{
|
||||
/// <summary>
|
||||
/// Return only nodes that are process areas.
|
||||
/// </summary>
|
||||
Area,
|
||||
|
||||
/// <summary>
|
||||
/// Return only nodes that are event sources.
|
||||
/// </summary>
|
||||
Source
|
||||
}
|
||||
}
|
||||
63
Technosoftware/DaAeHdaClient/Ae/Category.cs
Normal file
63
Technosoftware/DaAeHdaClient/Ae/Category.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an event category supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeCategory : ICloneable
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the category.
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique name for the category.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone() { return MemberwiseClone(); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
75
Technosoftware/DaAeHdaClient/Ae/ChangeMask.cs
Normal file
75
Technosoftware/DaAeHdaClient/Ae/ChangeMask.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The bits indicating what changes generated an event notification.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCAeChangeMask
|
||||
{
|
||||
/// <summary>
|
||||
/// The condition’s active state has changed.
|
||||
/// </summary>
|
||||
ActiveState = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// The condition’s acknowledgment state has changed.
|
||||
/// </summary>
|
||||
AcknowledgeState = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// The condition’s enabled state has changed.
|
||||
/// </summary>
|
||||
EnableState = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// The condition quality has changed.
|
||||
/// </summary>
|
||||
Quality = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// The severity level has changed.
|
||||
/// </summary>
|
||||
Severity = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// The condition has transitioned into a new sub-condition.
|
||||
/// </summary>
|
||||
SubCondition = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// The event message has changed.
|
||||
/// </summary>
|
||||
Message = 0x0040,
|
||||
|
||||
/// <summary>
|
||||
/// One or more event attributes have changed.
|
||||
/// </summary>
|
||||
Attribute = 0x0080
|
||||
}
|
||||
}
|
||||
217
Technosoftware/DaAeHdaClient/Ae/Condition.cs
Normal file
217
Technosoftware/DaAeHdaClient/Ae/Condition.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item condition state supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeCondition : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private TsCAeSubCondition _activeSubcondition = new TsCAeSubCondition();
|
||||
private TsCDaQuality _quality = TsCDaQuality.Bad;
|
||||
private DateTime _lastAckTime = DateTime.MinValue;
|
||||
private DateTime _subCondLastActive = DateTime.MinValue;
|
||||
private DateTime _condLastActive = DateTime.MinValue;
|
||||
private DateTime _condLastInactive = DateTime.MinValue;
|
||||
private SubConditionCollection _subconditions = new SubConditionCollection();
|
||||
private AttributeValueCollection _attributes = new AttributeValueCollection();
|
||||
#endregion
|
||||
|
||||
#region AttributeCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection of AttributeValues.
|
||||
/// </summary>
|
||||
public class AttributeValueCollection : OpcWriteableCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new TsCAeAttributeValue this[int index] => (TsCAeAttributeValue)Array[index];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new TsCAeAttributeValue[] ToArray()
|
||||
{
|
||||
return (TsCAeAttributeValue[])Array.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal AttributeValueCollection() : base(null, typeof(TsCAeAttributeValue)) { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SubConditionCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection of SubConditions.
|
||||
/// </summary>
|
||||
public class SubConditionCollection : OpcWriteableCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new TsCAeSubCondition this[int index] => (TsCAeSubCondition)Array[index];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new TsCAeSubCondition[] ToArray()
|
||||
{
|
||||
return (TsCAeSubCondition[])Array.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal SubConditionCollection() : base(null, typeof(TsCAeSubCondition)) { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A bit mask indicating the current state of the condition
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The currently active sub-condition, for multi-state conditions which are active.
|
||||
/// For a single-state condition, this contains the information about the condition itself.
|
||||
/// For inactive conditions, this value is null.
|
||||
/// </summary>
|
||||
public TsCAeSubCondition ActiveSubCondition
|
||||
{
|
||||
get => _activeSubcondition;
|
||||
set => _activeSubcondition = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The quality associated with the condition state.
|
||||
/// </summary>
|
||||
public TsCDaQuality Quality
|
||||
{
|
||||
get => _quality;
|
||||
set => _quality = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The time of the most recent acknowledgment of this condition (of any sub-condition).
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime LastAckTime
|
||||
{
|
||||
get => _lastAckTime;
|
||||
set => _lastAckTime = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time of the most recent transition into active sub-condition.
|
||||
/// This is the time value which must be specified when acknowledging the condition.
|
||||
/// If the condition has never been active, this value is DateTime.MinValue.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime SubCondLastActive
|
||||
{
|
||||
get => _subCondLastActive;
|
||||
set => _subCondLastActive = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time of the most recent transition into the condition.
|
||||
/// There may be transitions among the sub-conditions which are more recent.
|
||||
/// If the condition has never been active, this value is DateTime.MinValue.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime CondLastActive
|
||||
{
|
||||
get => _condLastActive;
|
||||
set => _condLastActive = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time of the most recent transition out of this condition.
|
||||
/// This value is DateTime.MinValue if the condition has never been active,
|
||||
/// or if it is currently active for the first time and has never been exited.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime CondLastInactive
|
||||
{
|
||||
get => _condLastInactive;
|
||||
set => _condLastInactive = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the ID of the client who last acknowledged this condition.
|
||||
/// This value is null if the condition has never been acknowledged.
|
||||
/// </summary>
|
||||
public string AcknowledgerID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The comment string passed in by the client who last acknowledged this condition.
|
||||
/// This value is null if the condition has never been acknowledged.
|
||||
/// </summary>
|
||||
public string Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sub-conditions defined for this condition.
|
||||
/// For single-state conditions, the collection will contain one element, the value of which describes the condition.
|
||||
/// </summary>
|
||||
public SubConditionCollection SubConditions => _subconditions;
|
||||
|
||||
/// <summary>
|
||||
/// The values of the attributes requested for this condition.
|
||||
/// </summary>
|
||||
public AttributeValueCollection Attributes => _attributes;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCAeCondition)MemberwiseClone();
|
||||
|
||||
clone._activeSubcondition = (TsCAeSubCondition)_activeSubcondition.Clone();
|
||||
clone._subconditions = (SubConditionCollection)_subconditions.Clone();
|
||||
clone._attributes = (AttributeValueCollection)_attributes.Clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
50
Technosoftware/DaAeHdaClient/Ae/ConditionState.cs
Normal file
50
Technosoftware/DaAeHdaClient/Ae/ConditionState.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The possible states for a condition.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCAeConditionState
|
||||
{
|
||||
/// <summary>
|
||||
/// The server is currently checking the state of the condition.
|
||||
/// </summary>
|
||||
Enabled = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// The associated object is in the state represented by the condition.
|
||||
/// </summary>
|
||||
Active = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// The condition has been acknowledged.
|
||||
/// </summary>
|
||||
Acknowledged = 0x0004
|
||||
}
|
||||
}
|
||||
95
Technosoftware/DaAeHdaClient/Ae/EnabledStateResult.cs
Normal file
95
Technosoftware/DaAeHdaClient/Ae/EnabledStateResult.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The current state of a process area or an event source.
|
||||
/// </summary>
|
||||
public class TsCAeEnabledStateResult : IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private string qualifiedName_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCAeEnabledStateResult() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an qualified name.
|
||||
/// </summary>
|
||||
public TsCAeEnabledStateResult(string qualifiedName)
|
||||
{
|
||||
qualifiedName_ = qualifiedName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an qualified name and Result.
|
||||
/// </summary>
|
||||
public TsCAeEnabledStateResult(string qualifiedName, OpcResult result)
|
||||
{
|
||||
qualifiedName_ = qualifiedName;
|
||||
Result = result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Whether if the area or source is enabled.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the area or source is enabled and all areas within the hierarchy of its containing areas are enabled.
|
||||
/// </summary>
|
||||
public bool EffectivelyEnabled { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result { get; set; } = OpcResult.S_OK;
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
93
Technosoftware/DaAeHdaClient/Ae/EventAcknowledgement.cs
Normal file
93
Technosoftware/DaAeHdaClient/Ae/EventAcknowledgement.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the information required to acknowledge an event.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeEventAcknowledgement : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private DateTime activeTime_ = DateTime.MinValue;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The name of the source that generated the event.
|
||||
/// </summary>
|
||||
public string SourceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the condition that is being acknowledged.
|
||||
/// </summary>
|
||||
public string ConditionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the condition or sub-condition became active.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime ActiveTime
|
||||
{
|
||||
get => activeTime_;
|
||||
set => activeTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cookie for the condition passed to client during the event notification.
|
||||
/// </summary>
|
||||
public int Cookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an acknowledgment with its default values.
|
||||
/// </summary>
|
||||
public TsCAeEventAcknowledgement() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an acknowledgment from an event notification.
|
||||
/// </summary>
|
||||
public TsCAeEventAcknowledgement(TsCAeEventNotification notification)
|
||||
{
|
||||
SourceName = notification.SourceID;
|
||||
ConditionName = notification.ConditionName;
|
||||
activeTime_ = notification.ActiveTime;
|
||||
Cookie = notification.Cookie;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
275
Technosoftware/DaAeHdaClient/Ae/EventNotification.cs
Normal file
275
Technosoftware/DaAeHdaClient/Ae/EventNotification.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
using System;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// A notification sent by the server when an event change occurs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeEventNotification : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private DateTime time_ = DateTime.MinValue;
|
||||
private TsCAeEventType eventType_ = TsCAeEventType.Condition;
|
||||
private int severity_ = 1;
|
||||
private AttributeCollection attributes_ = new AttributeCollection();
|
||||
private TsCDaQuality daQuality_ = TsCDaQuality.Bad;
|
||||
private DateTime activeTime_ = DateTime.MinValue;
|
||||
#endregion
|
||||
|
||||
#region AttributeCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection of AttributeValues.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AttributeCollection : OpcReadOnlyCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal AttributeCollection() : base(new object[0]) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a collection from an array of objects.
|
||||
/// </summary>
|
||||
internal AttributeCollection(object[] attributes) : base(attributes) { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The handle of the subscription that requested the notification
|
||||
/// </summary>
|
||||
public object ClientHandle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The identifier for the source that generated the event.
|
||||
/// </summary>
|
||||
public string SourceID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time of the event occurrence.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime Time
|
||||
{
|
||||
get => time_;
|
||||
set => time_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event notification message describing the event.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of event that generated the notification.
|
||||
/// </summary>
|
||||
public TsCAeEventType EventType
|
||||
{
|
||||
get => eventType_;
|
||||
set => eventType_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vendor defined category id for the event.
|
||||
/// </summary>
|
||||
public int EventCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The severity of the event (1..1000).
|
||||
/// </summary>
|
||||
public int Severity
|
||||
{
|
||||
get => severity_;
|
||||
set => severity_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the condition related to this event notification.
|
||||
/// </summary>
|
||||
public string ConditionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the current sub-condition, for multi-state conditions.
|
||||
/// For a single-state condition, this contains the condition name.
|
||||
/// </summary>
|
||||
public string SubConditionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The values of the attributes selected for the event subscription.
|
||||
/// </summary>
|
||||
public AttributeCollection Attributes => attributes_;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates which properties of the condition have changed, to have caused the server to send the event notification.
|
||||
/// </summary>
|
||||
public int ChangeMask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates which properties of the condition have changed, to have caused the server to send the event notification.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public string ChangeMaskAsText
|
||||
{
|
||||
get
|
||||
{
|
||||
string str = null;
|
||||
|
||||
if ((ChangeMask & 0x0001) == 0x0001) str = "Active State, ";
|
||||
if ((ChangeMask & 0x0002) == 0x0002) str += "Ack State, ";
|
||||
if ((ChangeMask & 0x0004) == 0x0004) str += "Enable State, ";
|
||||
if ((ChangeMask & 0x0008) == 0x0005) str += "Quality, ";
|
||||
if ((ChangeMask & 0x0010) == 0x0010) str += "Severity, ";
|
||||
if ((ChangeMask & 0x0020) == 0x0020) str += "SubCondition, ";
|
||||
if ((ChangeMask & 0x0040) == 0x0040) str += "Message, ";
|
||||
if ((ChangeMask & 0x0080) == 0x0080) str += "Attribute";
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A bit mask specifying the new state of the condition.
|
||||
/// </summary>
|
||||
public int NewState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A bit mask specifying the new state of the condition.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public string NewStateAsText
|
||||
{
|
||||
get
|
||||
{
|
||||
string str;
|
||||
|
||||
if ((NewState & 0x0001) == 0x0001)
|
||||
{
|
||||
str = "Active, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
str = "Inactive, ";
|
||||
}
|
||||
if ((NewState & 0x0002) == 0x0002)
|
||||
{
|
||||
str += "Acknowledged, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += "UnAcknowledged, ";
|
||||
}
|
||||
if ((NewState & 0x0004) == 0x0004)
|
||||
{
|
||||
str += "Enabled";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += "Disabled";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The quality associated with the condition state.
|
||||
/// </summary>
|
||||
public TsCDaQuality Quality
|
||||
{
|
||||
get => daQuality_;
|
||||
set => daQuality_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the related condition requires acknowledgment of this event.
|
||||
/// </summary>
|
||||
public bool AckRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the condition became active (for single-state conditions), or the
|
||||
/// time of the transition into the current sub-condition (for multi-state conditions).
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime ActiveTime
|
||||
{
|
||||
get => activeTime_;
|
||||
set => activeTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A server defined cookie associated with the event notification.
|
||||
/// </summary>
|
||||
public int Cookie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For tracking events, this is the actor id for the event notification.
|
||||
/// For condition-related events, this is the acknowledgment id passed by the client.
|
||||
/// </summary>
|
||||
public string ActorID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Sets the list of attribute values.
|
||||
/// </summary>
|
||||
public void SetAttributes(object[] attributes)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
attributes_ = new AttributeCollection();
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes_ = new AttributeCollection(attributes);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCAeEventNotification)MemberwiseClone();
|
||||
|
||||
clone.attributes_ = (AttributeCollection)attributes_.Clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
54
Technosoftware/DaAeHdaClient/Ae/EventType.cs
Normal file
54
Technosoftware/DaAeHdaClient/Ae/EventType.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of events that could be generated by a server.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCAeEventType
|
||||
{
|
||||
/// <summary>
|
||||
/// Events that are not tracking or condition events.
|
||||
/// </summary>
|
||||
Simple = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// Events that represent occurrences which involve the interaction of the client with a target within the server.
|
||||
/// </summary>
|
||||
Tracking = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// Events that are associated with transitions in and out states defined by the server.
|
||||
/// </summary>
|
||||
Condition = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// All events generated by the server.
|
||||
/// </summary>
|
||||
All = 0xFFFF
|
||||
}
|
||||
}
|
||||
65
Technosoftware/DaAeHdaClient/Ae/FilterType.cs
Normal file
65
Technosoftware/DaAeHdaClient/Ae/FilterType.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of event filters that the server could support.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCAeFilterType
|
||||
{
|
||||
/// <summary>
|
||||
/// The server supports filtering by event type.
|
||||
/// </summary>
|
||||
Event = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// The server supports filtering by event categories.
|
||||
/// </summary>
|
||||
Category = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// The server supports filtering by severity levels.
|
||||
/// </summary>
|
||||
Severity = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// The server supports filtering by process area.
|
||||
/// </summary>
|
||||
Area = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// The server supports filtering by event sources.
|
||||
/// </summary>
|
||||
Source = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// All filters supported by the server.
|
||||
/// </summary>
|
||||
All = 0xFFFF
|
||||
}
|
||||
}
|
||||
202
Technosoftware/DaAeHdaClient/Ae/IServer.cs
Normal file
202
Technosoftware/DaAeHdaClient/Ae/IServer.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines functionality that is common to all OPC Alarms and Events servers.
|
||||
/// </summary>
|
||||
public interface ITsCAeServer : IOpcServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current server status.
|
||||
/// </summary>
|
||||
/// <returns>The current server status.</returns>
|
||||
OpcServerStatus GetServerStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new event subscription.
|
||||
/// </summary>
|
||||
/// <param name="state">The initial state for the subscription.</param>
|
||||
/// <returns>The new subscription object.</returns>
|
||||
ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event filters supported by the server.
|
||||
/// </summary>
|
||||
/// <returns>A bit mask of all event filters supported by the server.</returns>
|
||||
int QueryAvailableFilters();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event categories supported by the server for the specified event types.
|
||||
/// </summary>
|
||||
/// <param name="eventType">A bit mask for the event types of interest.</param>
|
||||
/// <returns>A collection of event categories.</returns>
|
||||
TsCAeCategory[] QueryEventCategories(int eventType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition names supported by the server for the specified event categories.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">A bit mask for the event categories of interest.</param>
|
||||
/// <returns>A list of condition names.</returns>
|
||||
string[] QueryConditionNames(int eventCategory);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sub-condition names supported by the server for the specified event condition.
|
||||
/// </summary>
|
||||
/// <param name="conditionName">The name of the condition.</param>
|
||||
/// <returns>A list of sub-condition names.</returns>
|
||||
string[] QuerySubConditionNames(string conditionName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition names supported by the server for the specified event source.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The name of the event source.</param>
|
||||
/// <returns>A list of condition names.</returns>
|
||||
string[] QueryConditionNames(string sourceName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event attributes supported by the server for the specified event categories.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">The event category of interest.</param>
|
||||
/// <returns>A collection of event attributes.</returns>
|
||||
TsCAeAttribute[] QueryEventAttributes(int eventCategory);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DA item ids for a set of attribute ids belonging to events which meet the specified filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The event source of interest.</param>
|
||||
/// <param name="eventCategory">The id of the event category for the events of interest.</param>
|
||||
/// <param name="conditionName">The name of a condition within the event category.</param>
|
||||
/// <param name="subConditionName">The name of a sub-condition within a multi-state condition.</param>
|
||||
/// <param name="attributeIDs">The ids of the attributes to return item ids for.</param>
|
||||
/// <returns>A list of item urls for each specified attribute.</returns>
|
||||
TsCAeItemUrl[] TranslateToItemIDs(
|
||||
string sourceName,
|
||||
int eventCategory,
|
||||
string conditionName,
|
||||
string subConditionName,
|
||||
int[] attributeIDs);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current state information for the condition instance corresponding to the source and condition name.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The source name</param>
|
||||
/// <param name="conditionName">A condition name for the source.</param>
|
||||
/// <param name="attributeIDs">The list of attributes to return with the condition state.</param>
|
||||
/// <returns>The current state of the connection.</returns>
|
||||
TsCAeCondition GetConditionState(
|
||||
string sourceName,
|
||||
string conditionName,
|
||||
int[] attributeIDs);
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the enabled state.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
OpcResult[] EnableConditionByArea(string[] areas);
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the disabled state.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
OpcResult[] DisableConditionByArea(string[] areas);
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the enabled state.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
OpcResult[] EnableConditionBySource(string[] sources);
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the disabled state.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
OpcResult[] DisableConditionBySource(string[] sources);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the enabled state for the specified process areas.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
TsCAeEnabledStateResult[] GetEnableStateByArea(string[] areas);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the enabled state for the specified event sources.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
TsCAeEnabledStateResult[] GetEnableStateBySource(string[] sources);
|
||||
|
||||
/// <summary>
|
||||
/// Used to acknowledge one or more conditions in the event server.
|
||||
/// </summary>
|
||||
/// <param name="acknowledgerID">The identifier for who is acknowledging the condition.</param>
|
||||
/// <param name="comment">A comment associated with the acknowledgment.</param>
|
||||
/// <param name="conditions">The conditions being acknowledged.</param>
|
||||
/// <returns>A list of result id indictaing whether each condition was successfully acknowledged.</returns>
|
||||
OpcResult[] AcknowledgeCondition(
|
||||
string acknowledgerID,
|
||||
string comment,
|
||||
TsCAeEventAcknowledgement[] conditions);
|
||||
|
||||
/// <summary>
|
||||
/// Browses for all children of the specified area that meet the filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="areaID">The full-qualified id for the area.</param>
|
||||
/// <param name="browseType">The type of children to return.</param>
|
||||
/// <param name="browseFilter">The expression used to filter the names of children returned.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCAeBrowseElement[] Browse(
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter);
|
||||
|
||||
/// <summary>
|
||||
/// Browses for all children of the specified area that meet the filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="areaID">The full-qualified id for the area.</param>
|
||||
/// <param name="browseType">The type of children to return.</param>
|
||||
/// <param name="browseFilter">The expression used to filter the names of children returned.</param>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCAeBrowseElement[] Browse(
|
||||
string areaID,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
int maxElements,
|
||||
out IOpcBrowsePosition position);
|
||||
|
||||
/// <summary>
|
||||
/// Continues browsing the server's address space at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The position object used to continue a browse operation.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position);
|
||||
}
|
||||
}
|
||||
109
Technosoftware/DaAeHdaClient/Ae/ISubscription.cs
Normal file
109
Technosoftware/DaAeHdaClient/Ae/ISubscription.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface to an object which implements a AE event subscription.
|
||||
/// </summary>
|
||||
public interface ITsCAeSubscription : IDisposable
|
||||
{
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// An event to receive event change updates.
|
||||
/// </summary>
|
||||
event TsCAeDataChangedEventHandler DataChangedEvent;
|
||||
#endregion
|
||||
|
||||
#region State Management
|
||||
/// <summary>
|
||||
/// Returns the current state of the subscription.
|
||||
/// </summary>
|
||||
/// <returns>The current state of the subscription.</returns>
|
||||
TsCAeSubscriptionState GetState();
|
||||
|
||||
/// <summary>
|
||||
/// Changes the state of a subscription.
|
||||
/// </summary>
|
||||
/// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
|
||||
/// <param name="state">The new subscription state.</param>
|
||||
/// <returns>The actual subscription state after applying the changes.</returns>
|
||||
TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state);
|
||||
#endregion
|
||||
|
||||
#region Filter Management
|
||||
/// <summary>
|
||||
/// Returns the current filters for the subscription.
|
||||
/// </summary>
|
||||
/// <returns>The current filters for the subscription.</returns>
|
||||
TsCAeSubscriptionFilters GetFilters();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current filters for the subscription.
|
||||
/// </summary>
|
||||
/// <param name="filters">The new filters to use for the subscription.</param>
|
||||
void SetFilters(TsCAeSubscriptionFilters filters);
|
||||
#endregion
|
||||
|
||||
#region Attribute Management
|
||||
/// <summary>
|
||||
/// Returns the set of attributes to return with event notifications.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">The specific event category for which the attributes apply.</param>
|
||||
/// <returns>The set of attribute ids which returned with event notifications.</returns>
|
||||
int[] GetReturnedAttributes(int eventCategory);
|
||||
|
||||
/// <summary>
|
||||
/// Selects the set of attributes to return with event notifications.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">The specific event category for which the attributes apply.</param>
|
||||
/// <param name="attributeIDs">The list of attribute ids to return.</param>
|
||||
void SelectReturnedAttributes(int eventCategory, int[] attributeIDs);
|
||||
#endregion
|
||||
|
||||
#region Refresh
|
||||
/// <summary>
|
||||
/// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription.
|
||||
/// </summary>
|
||||
void Refresh();
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an outstanding refresh request.
|
||||
/// </summary>
|
||||
void CancelRefresh();
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Delegate Declarations
|
||||
/// <summary>
|
||||
/// A delegate to receive data change updates from the server.
|
||||
/// </summary>
|
||||
/// <param name="notifications">The notifications sent by the server when a event change occurs.</param>
|
||||
/// <param name="refresh">TRUE if this is a subscription refresh</param>
|
||||
/// <param name="lastRefresh">TRUE if this is the last subscription refresh in response to a specific invocation of the Refresh method.</param>
|
||||
public delegate void TsCAeDataChangedEventHandler(TsCAeEventNotification[] notifications, bool refresh, bool lastRefresh);
|
||||
#endregion
|
||||
}
|
||||
93
Technosoftware/DaAeHdaClient/Ae/ItemUrl.cs
Normal file
93
Technosoftware/DaAeHdaClient/Ae/ItemUrl.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The item id and network location of a DA item associated with an event source.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeItemUrl : OpcItem
|
||||
{
|
||||
#region Fields
|
||||
private OpcUrl url_ = new OpcUrl();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCAeItemUrl() {}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCAeItemUrl(OpcItem item) : base(item) {}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemIdentifier object and url.
|
||||
/// </summary>
|
||||
public TsCAeItemUrl(OpcItem item, OpcUrl url)
|
||||
: base(item)
|
||||
{
|
||||
Url = url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemResult object.
|
||||
/// </summary>
|
||||
public TsCAeItemUrl(TsCAeItemUrl item) : base(item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
Url = item.Url;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The url of the server that contains the item.
|
||||
/// </summary>
|
||||
public OpcUrl Url
|
||||
{
|
||||
get => url_;
|
||||
set => url_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
return new TsCAeItemUrl(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
60
Technosoftware/DaAeHdaClient/Ae/ItemUrlCollection.cs
Normal file
60
Technosoftware/DaAeHdaClient/Ae/ItemUrlCollection.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a collection of item urls.
|
||||
/// </summary>
|
||||
internal class TsCAeItemUrlCollection : OpcReadOnlyCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Constructs an empty collection.
|
||||
/// </summary>
|
||||
public TsCAeItemUrlCollection() : base(new TsCAeItemUrl[0]) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a collection from an array of item urls.
|
||||
/// </summary>
|
||||
public TsCAeItemUrlCollection(TsCAeItemUrl[] itemUrls) : base(itemUrls) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new TsCAeItemUrl this[int index] => (TsCAeItemUrl)Array.GetValue(index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new TsCAeItemUrl[] ToArray()
|
||||
{
|
||||
return (TsCAeItemUrl[])OpcConvert.Clone(Array);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
661
Technosoftware/DaAeHdaClient/Ae/Server.cs
Normal file
661
Technosoftware/DaAeHdaClient/Ae/Server.cs
Normal file
@@ -0,0 +1,661 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// An in-process object which provides access to AE server objects.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeServer : OpcServer, ITsCAeServer
|
||||
{
|
||||
#region SubscriptionCollection Class
|
||||
/// <summary>
|
||||
/// A read-only collection of subscriptions.
|
||||
/// </summary>
|
||||
public class SubscriptionCollection : OpcReadOnlyCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal SubscriptionCollection() : base(new TsCAeSubscription[0]) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new TsCAeSubscription this[int index] => (TsCAeSubscription)Array.GetValue(index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new TsCAeSubscription[] ToArray()
|
||||
{
|
||||
return (TsCAeSubscription[])Array;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a subscription to the end of the collection.
|
||||
/// </summary>
|
||||
internal void Add(TsCAeSubscription subscription)
|
||||
{
|
||||
var array = new TsCAeSubscription[Count + 1];
|
||||
|
||||
Array.CopyTo(array, 0);
|
||||
array[Count] = subscription;
|
||||
|
||||
Array = array;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a subscription to the from the collection.
|
||||
/// </summary>
|
||||
internal void Remove(TsCAeSubscription subscription)
|
||||
{
|
||||
var array = new TsCAeSubscription[Count - 1];
|
||||
|
||||
var index = 0;
|
||||
|
||||
for (var ii = 0; ii < Array.Length; ii++)
|
||||
{
|
||||
var element = (TsCAeSubscription)Array.GetValue(ii);
|
||||
|
||||
if (subscription != element)
|
||||
{
|
||||
array[index++] = element;
|
||||
}
|
||||
}
|
||||
|
||||
Array = array;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Names Class
|
||||
/// <summary>
|
||||
/// A set of names for fields used in serialization.
|
||||
/// </summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string Count = "CT";
|
||||
internal const string Subscription = "SU";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private int filters_;
|
||||
private bool disposing_;
|
||||
private SubscriptionCollection subscriptions_ = new SubscriptionCollection();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with a factory and a default OpcUrl.
|
||||
/// </summary>
|
||||
/// <param name="factory">The OpcFactory used to connect to remote servers.</param>
|
||||
/// <param name="url">The network address of a remote server.</param>
|
||||
public TsCAeServer(OpcFactory factory, OpcUrl url)
|
||||
: base(factory, url)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
protected TsCAeServer(SerializationInfo info, StreamingContext context)
|
||||
:
|
||||
base(info, context)
|
||||
{
|
||||
var count = (int)info.GetValue(Names.Count, typeof(int));
|
||||
|
||||
subscriptions_ = new SubscriptionCollection();
|
||||
|
||||
for (var ii = 0; ii < count; ii++)
|
||||
{
|
||||
var subscription = (TsCAeSubscription)info.GetValue(Names.Subscription + ii, typeof(TsCAeSubscription));
|
||||
subscriptions_.Add(subscription);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The filters supported by the server.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public int AvailableFilters => filters_;
|
||||
|
||||
/// <summary>
|
||||
/// The outstanding subscriptions for the server.
|
||||
/// </summary>
|
||||
public SubscriptionCollection Subscriptions => subscriptions_;
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Connects to the server with the specified OpcUrl and credentials.
|
||||
/// </summary>
|
||||
public override void Connect(OpcUrl url, OpcConnectData connectData)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
// connect to server.
|
||||
base.Connect(url, connectData);
|
||||
|
||||
// all done if no subscriptions.
|
||||
if (subscriptions_.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create subscriptions (should only happen if server has been deserialized).
|
||||
var subscriptions = new SubscriptionCollection();
|
||||
|
||||
foreach (TsCAeSubscription template in subscriptions_)
|
||||
{
|
||||
// create subscription for template.
|
||||
try { subscriptions.Add(EstablishSubscription(template)); }
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
// save new set of subscriptions.
|
||||
subscriptions_ = subscriptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the server and releases all network resources.
|
||||
/// </summary>
|
||||
public override void Disconnect()
|
||||
{
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// dispose of all subscriptions first.
|
||||
disposing_ = true;
|
||||
|
||||
foreach (TsCAeSubscription subscription in subscriptions_)
|
||||
{
|
||||
subscription.Dispose();
|
||||
}
|
||||
|
||||
disposing_ = false;
|
||||
|
||||
// disconnect from server.
|
||||
base.Disconnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current server status.
|
||||
/// </summary>
|
||||
/// <returns>The current server status.</returns>
|
||||
public OpcServerStatus GetServerStatus()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var status = ((ITsCAeServer)Server).GetServerStatus();
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
if (status.StatusInfo == null)
|
||||
{
|
||||
status.StatusInfo = GetString($"serverState.{status.ServerState}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new event subscription.
|
||||
/// </summary>
|
||||
/// <param name="state">The initial state for the subscription.</param>
|
||||
/// <returns>The new subscription object.</returns>
|
||||
public ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// create remote object.
|
||||
var subscription = ((ITsCAeServer)Server).CreateSubscription(state);
|
||||
|
||||
if (subscription != null)
|
||||
{
|
||||
// create wrapper.
|
||||
var wrapper = new TsCAeSubscription(this, subscription, state);
|
||||
subscriptions_.Add(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
// should never happen.
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event filters supported by the server.
|
||||
/// </summary>
|
||||
/// <returns>A bit mask of all event filters supported by the server.</returns>
|
||||
public int QueryAvailableFilters()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
filters_ = ((ITsCAeServer)Server).QueryAvailableFilters();
|
||||
|
||||
return filters_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event categories supported by the server for the specified event types.
|
||||
/// </summary>
|
||||
/// <param name="eventType">A bit mask for the event types of interest.</param>
|
||||
/// <returns>A collection of event categories.</returns>
|
||||
public TsCAeCategory[] QueryEventCategories(int eventType)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// fetch categories from server.
|
||||
var categories = ((ITsCAeServer)Server).QueryEventCategories(eventType);
|
||||
|
||||
// return result.
|
||||
return categories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition names supported by the server for the specified event categories.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">A bit mask for the event categories of interest.</param>
|
||||
/// <returns>A list of condition names.</returns>
|
||||
public string[] QueryConditionNames(int eventCategory)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// fetch condition names from the server.
|
||||
var conditions = ((ITsCAeServer)Server).QueryConditionNames(eventCategory);
|
||||
|
||||
// return result.
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sub-condition names supported by the server for the specified event condition.
|
||||
/// </summary>
|
||||
/// <param name="conditionName">The name of the condition.</param>
|
||||
/// <returns>A list of sub-condition names.</returns>
|
||||
public string[] QuerySubConditionNames(string conditionName)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// fetch sub-condition names from the server.
|
||||
var subConditions = ((ITsCAeServer)Server).QuerySubConditionNames(conditionName);
|
||||
|
||||
// return result.
|
||||
return subConditions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition names supported by the server for the specified event source.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The name of the event source.</param>
|
||||
/// <returns>A list of condition names.</returns>
|
||||
public string[] QueryConditionNames(string sourceName)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// fetch condition names from the server.
|
||||
var conditions = ((ITsCAeServer)Server).QueryConditionNames(sourceName);
|
||||
|
||||
// return result.
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the event attributes supported by the server for the specified event categories.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">A bit mask for the event categories of interest.</param>
|
||||
/// <returns>A collection of event attributes.</returns>
|
||||
public TsCAeAttribute[] QueryEventAttributes(int eventCategory)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// fetch attributes from server.
|
||||
var attributes = ((ITsCAeServer)Server).QueryEventAttributes(eventCategory);
|
||||
|
||||
// return result.
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DA item ids for a set of attribute ids belonging to events which meet the specified filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The event source of interest.</param>
|
||||
/// <param name="eventCategory">The id of the event category for the events of interest.</param>
|
||||
/// <param name="conditionName">The name of a condition within the event category.</param>
|
||||
/// <param name="subConditionName">The name of a sub-condition within a multi-state condition.</param>
|
||||
/// <param name="attributeIDs">The ids of the attributes to return item ids for.</param>
|
||||
/// <returns>A list of item urls for each specified attribute.</returns>
|
||||
public TsCAeItemUrl[] TranslateToItemIDs(
|
||||
string sourceName,
|
||||
int eventCategory,
|
||||
string conditionName,
|
||||
string subConditionName,
|
||||
int[] attributeIDs)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var itemUrls = ((ITsCAeServer)Server).TranslateToItemIDs(
|
||||
sourceName,
|
||||
eventCategory,
|
||||
conditionName,
|
||||
subConditionName,
|
||||
attributeIDs);
|
||||
|
||||
return itemUrls;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current state information for the condition instance corresponding to the source and condition name.
|
||||
/// </summary>
|
||||
/// <param name="sourceName">The source name</param>
|
||||
/// <param name="conditionName">A condition name for the source.</param>
|
||||
/// <param name="attributeIDs">The list of attributes to return with the condition state.</param>
|
||||
/// <returns>The current state of the connection.</returns>
|
||||
public TsCAeCondition GetConditionState(
|
||||
string sourceName,
|
||||
string conditionName,
|
||||
int[] attributeIDs)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var condition = ((ITsCAeServer)Server).GetConditionState(sourceName, conditionName, attributeIDs);
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the enabled state.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
public OpcResult[] EnableConditionByArea(string[] areas)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).EnableConditionByArea(areas);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the disabled state.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
public OpcResult[] DisableConditionByArea(string[] areas)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).DisableConditionByArea(areas);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the enabled state.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
public OpcResult[] EnableConditionBySource(string[] sources)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).EnableConditionBySource(sources);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified process areas into the disabled state.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
/// <returns>The results of the operation for each area.</returns>
|
||||
public OpcResult[] DisableConditionBySource(string[] sources)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).DisableConditionBySource(sources);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the enabled state for the specified process areas.
|
||||
/// </summary>
|
||||
/// <param name="areas">A list of fully qualified area names.</param>
|
||||
public TsCAeEnabledStateResult[] GetEnableStateByArea(string[] areas)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).GetEnableStateByArea(areas);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the enabled state for the specified event sources.
|
||||
/// </summary>
|
||||
/// <param name="sources">A list of fully qualified source names.</param>
|
||||
public TsCAeEnabledStateResult[] GetEnableStateBySource(string[] sources)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var results = ((ITsCAeServer)Server).GetEnableStateBySource(sources);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to acknowledge one or more conditions in the event server.
|
||||
/// </summary>
|
||||
/// <param name="acknowledgmentId">The identifier for who is acknowledging the condition.</param>
|
||||
/// <param name="comment">A comment associated with the acknowledgment.</param>
|
||||
/// <param name="conditions">The conditions being acknowledged.</param>
|
||||
/// <returns>A list of result id indicating whether each condition was successfully acknowledged.</returns>
|
||||
public OpcResult[] AcknowledgeCondition(
|
||||
string acknowledgmentId,
|
||||
string comment,
|
||||
TsCAeEventAcknowledgement[] conditions)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsCAeServer)Server).AcknowledgeCondition(acknowledgmentId, comment, conditions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Browses for all children of the specified area that meet the filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="areaId">The full-qualified id for the area.</param>
|
||||
/// <param name="browseType">The type of children to return.</param>
|
||||
/// <param name="browseFilter">The expression used to filter the names of children returned.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
public TsCAeBrowseElement[] Browse(
|
||||
string areaId,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsCAeServer)Server).Browse(areaId, browseType, browseFilter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Browses for all children of the specified area that meet the filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="areaId">The full-qualified id for the area.</param>
|
||||
/// <param name="browseType">The type of children to return.</param>
|
||||
/// <param name="browseFilter">The expression used to filter the names of children returned.</param>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
public TsCAeBrowseElement[] Browse(
|
||||
string areaId,
|
||||
TsCAeBrowseType browseType,
|
||||
string browseFilter,
|
||||
int maxElements,
|
||||
out IOpcBrowsePosition position)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsCAeServer)Server).Browse(areaId, browseType, browseFilter, maxElements, out position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Continues browsing the server's address space at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The position object used to continue a browse operation.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
public TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsCAeServer)Server).BrowseNext(maxElements, ref position);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
|
||||
/// <summary>
|
||||
/// Serializes a server into a stream.
|
||||
/// </summary>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
|
||||
info.AddValue(Names.Count, subscriptions_.Count);
|
||||
|
||||
for (var ii = 0; ii < subscriptions_.Count; ii++)
|
||||
{
|
||||
info.AddValue(Names.Subscription + ii, subscriptions_[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Called when a subscription object is disposed.
|
||||
/// </summary>
|
||||
/// <param name="subscription"></param>
|
||||
internal void SubscriptionDisposed(TsCAeSubscription subscription)
|
||||
{
|
||||
if (!disposing_)
|
||||
{
|
||||
subscriptions_.Remove(subscription);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Establishes a subscription based on the template provided.
|
||||
/// </summary>
|
||||
private TsCAeSubscription EstablishSubscription(TsCAeSubscription template)
|
||||
{
|
||||
ITsCAeSubscription remoteServer = null;
|
||||
|
||||
try
|
||||
{
|
||||
// create remote object.
|
||||
remoteServer = ((ITsCAeServer)Server).CreateSubscription(template.State);
|
||||
|
||||
if (remoteServer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// create wrapper.
|
||||
var subscription = new TsCAeSubscription(this, remoteServer, template.State);
|
||||
|
||||
// set filters.
|
||||
subscription.SetFilters(template.Filters);
|
||||
|
||||
// set attributes.
|
||||
var enumerator = template.Attributes.GetEnumerator();
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (enumerator.Key != null)
|
||||
subscription.SelectReturnedAttributes(
|
||||
(int)enumerator.Key,
|
||||
((TsCAeSubscription.AttributeCollection)enumerator.Value).ToArray());
|
||||
}
|
||||
|
||||
// return new subscription
|
||||
return subscription;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (remoteServer != null)
|
||||
{
|
||||
remoteServer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// return null.
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
68
Technosoftware/DaAeHdaClient/Ae/ServerState.cs
Normal file
68
Technosoftware/DaAeHdaClient/Ae/ServerState.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Current Status of an OPC AE server
|
||||
/// </summary>
|
||||
public enum TsCAeServerState
|
||||
{
|
||||
/// <summary>
|
||||
/// The server state is not known.
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// The server is running normally. This is the usual state for a server
|
||||
/// </summary>
|
||||
Running,
|
||||
|
||||
/// <summary>
|
||||
/// A vendor specific fatal error has occurred within the server. The server is no longer functioning. The recovery procedure from this situation is vendor specific. An error code of E_FAIL should generally be returned from any other server method.
|
||||
/// </summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// The server is running but has no configuration information loaded and thus cannot function normally. Note this state implies that the server needs configuration information in order to function. Servers which do not require configuration information should not return this state.
|
||||
/// </summary>
|
||||
NoConfig,
|
||||
|
||||
/// <summary>
|
||||
/// The server has been temporarily suspended via some vendor specific method and is not getting or sending data. Note that Quality will be returned as OPC_QUALITY_OUT_OF_SERVICE.
|
||||
/// </summary>
|
||||
Suspended,
|
||||
|
||||
/// <summary>
|
||||
/// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally.
|
||||
/// </summary>
|
||||
Test,
|
||||
|
||||
/// <summary>
|
||||
/// The server is in Test Mode. The outputs are disconnected from the real hardware but the server will otherwise behave normally. Inputs may be real or may be simulated depending on the vendor implementation. Quality will generally be returned normally.
|
||||
/// </summary>
|
||||
CommFault
|
||||
}
|
||||
}
|
||||
70
Technosoftware/DaAeHdaClient/Ae/StateMask.cs
Normal file
70
Technosoftware/DaAeHdaClient/Ae/StateMask.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines masks to be used when modifying the subscription or item state.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCAeStateMask
|
||||
{
|
||||
/// <summary>
|
||||
/// A name assigned to subscription.
|
||||
/// </summary>
|
||||
Name = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// The client assigned handle for the item or subscription.
|
||||
/// </summary>
|
||||
ClientHandle = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// Whether the subscription is active.
|
||||
/// </summary>
|
||||
Active = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum rate at which the server send event notifications.
|
||||
/// </summary>
|
||||
BufferTime = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// The requested maximum number of events that will be sent in a single callback.
|
||||
/// </summary>
|
||||
MaxSize = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum period between updates sent to the client.
|
||||
/// </summary>
|
||||
KeepAlive = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// All fields are valid.
|
||||
/// </summary>
|
||||
All = 0xFFFF
|
||||
}
|
||||
}
|
||||
83
Technosoftware/DaAeHdaClient/Ae/SubCondition.cs
Normal file
83
Technosoftware/DaAeHdaClient/Ae/SubCondition.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item sub-condition supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeSubCondition : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private int severity_ = 1;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The name assigned to the sub-condition.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A server-specific expression which defines the sub-state represented by the sub-condition.
|
||||
/// </summary>
|
||||
public string Definition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The severity of any event notifications generated on behalf of this sub-condition.
|
||||
/// </summary>
|
||||
public int Severity
|
||||
{
|
||||
get => severity_;
|
||||
set => severity_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text string to be included in any event notification generated on behalf of this sub-condition.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone() { return MemberwiseClone(); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
610
Technosoftware/DaAeHdaClient/Ae/Subscription.cs
Normal file
610
Technosoftware/DaAeHdaClient/Ae/Subscription.cs
Normal file
@@ -0,0 +1,610 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// An in-process object which provides access to AE subscription objects.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeSubscription : ITsCAeSubscription, ISerializable, ICloneable
|
||||
{
|
||||
#region CategoryCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection category ids.
|
||||
/// </summary>
|
||||
public class CategoryCollection : OpcReadOnlyCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal CategoryCollection() : base(new int[0]) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a collection containing the list of category ids.
|
||||
/// </summary>
|
||||
internal CategoryCollection(int[] categoryIDs) : base(categoryIDs) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new int this[int index] => (int)Array.GetValue(index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new int[] ToArray()
|
||||
{
|
||||
return (int[])OpcConvert.Clone(Array);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StringCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection of strings.
|
||||
/// </summary>
|
||||
public class StringCollection : OpcReadOnlyCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal StringCollection() : base(new string[0]) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a collection containing the specified strings.
|
||||
/// </summary>
|
||||
internal StringCollection(string[] strings) : base(strings) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new string this[int index] => (string)Array.GetValue(index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new string[] ToArray()
|
||||
{
|
||||
return (string[])OpcConvert.Clone(Array);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AttributeDictionary Class
|
||||
/// <summary>
|
||||
/// Contains a read-only dictionary of attribute lists indexed by category id.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AttributeDictionary : OpcReadOnlyDictionary
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal AttributeDictionary() : base(null) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an dictionary from a set of category ids.
|
||||
/// </summary>
|
||||
internal AttributeDictionary(Hashtable dictionary) : base(dictionary) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets or sets the attribute collection for the specified category.
|
||||
/// </summary>
|
||||
public AttributeCollection this[int categoryId] => (AttributeCollection)base[categoryId];
|
||||
|
||||
/// <summary>
|
||||
/// Adds or replaces the set of attributes associated with the category.
|
||||
/// </summary>
|
||||
internal void Update(int categoryId, int[] attributeIDs)
|
||||
{
|
||||
Dictionary[categoryId] = new AttributeCollection(attributeIDs);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Constructs an object by deserializing it from a stream.
|
||||
/// </summary>
|
||||
protected AttributeDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AttributeCollection Class
|
||||
/// <summary>
|
||||
/// Contains a read-only collection attribute ids.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AttributeCollection : OpcReadOnlyCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal AttributeCollection() : base(new int[0]) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a collection containing the specified attribute ids.
|
||||
/// </summary>
|
||||
internal AttributeCollection(int[] attributeIDs) : base(attributeIDs) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new int this[int index] => (int)Array.GetValue(index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new int[] ToArray()
|
||||
{
|
||||
return (int[])OpcConvert.Clone(Array);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Constructs an object by deserializing it from a stream.
|
||||
/// </summary>
|
||||
protected AttributeCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Names Class
|
||||
/// <summary>
|
||||
/// A set of names for fields used in serialization.
|
||||
/// </summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string State = "ST";
|
||||
internal const string Filters = "FT";
|
||||
internal const string Attributes = "AT";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private bool disposed_;
|
||||
private TsCAeServer server_;
|
||||
private ITsCAeSubscription subscription_;
|
||||
|
||||
// state
|
||||
private TsCAeSubscriptionState state_;
|
||||
private string name_;
|
||||
|
||||
// filters
|
||||
private TsCAeSubscriptionFilters subscriptionFilters_ = new TsCAeSubscriptionFilters();
|
||||
private CategoryCollection categories_ = new CategoryCollection();
|
||||
private StringCollection areas_ = new StringCollection();
|
||||
private StringCollection sources_ = new StringCollection();
|
||||
|
||||
// returned attributes
|
||||
private AttributeDictionary attributes_ = new AttributeDictionary();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with default values.
|
||||
/// </summary>
|
||||
public TsCAeSubscription(TsCAeServer server, ITsCAeSubscription subscription, TsCAeSubscriptionState state)
|
||||
{
|
||||
server_ = server ?? throw new ArgumentNullException(nameof(server));
|
||||
subscription_ = subscription ?? throw new ArgumentNullException(nameof(subscription));
|
||||
state_ = (TsCAeSubscriptionState)state.Clone();
|
||||
name_ = state.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The finalizer implementation.
|
||||
/// </summary>
|
||||
~TsCAeSubscription()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
// Take yourself off the Finalization queue
|
||||
// to prevent finalization code for this object
|
||||
// from executing a second time.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose(bool disposing) executes in two distinct scenarios.
|
||||
/// If disposing equals true, the method has been called directly
|
||||
/// or indirectly by a user's code. Managed and unmanaged resources
|
||||
/// can be disposed.
|
||||
/// If disposing equals false, the method has been called by the
|
||||
/// runtime from inside the finalizer and you should not reference
|
||||
/// other objects. Only unmanaged resources can be disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if(!disposed_)
|
||||
{
|
||||
// If disposing equals true, dispose all managed
|
||||
// and unmanaged resources.
|
||||
if(disposing)
|
||||
{
|
||||
if (subscription_ != null)
|
||||
{
|
||||
server_.SubscriptionDisposed(this);
|
||||
subscription_.Dispose();
|
||||
}
|
||||
}
|
||||
// Release unmanaged resources. If disposing is false,
|
||||
// only the following code is executed.
|
||||
}
|
||||
disposed_ = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The server that the subscription object belongs to.
|
||||
/// </summary>
|
||||
public TsCAeServer Server => server_;
|
||||
|
||||
/// <summary>
|
||||
/// A descriptive name for the subscription.
|
||||
/// </summary>
|
||||
public string Name => state_.Name;
|
||||
|
||||
/// <summary>
|
||||
/// A unique identifier for the subscription assigned by the client.
|
||||
/// </summary>
|
||||
public object ClientHandle => state_.ClientHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the subscription is monitoring for events to send to the client.
|
||||
/// </summary>
|
||||
public bool Active => state_.Active;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum rate at which the server send event notifications.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public int BufferTime => state_.BufferTime;
|
||||
|
||||
/// <summary>
|
||||
/// The requested maximum number of events that will be sent in a single callback.
|
||||
/// </summary>
|
||||
public int MaxSize => state_.MaxSize;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum period between updates sent to the client.
|
||||
/// </summary>
|
||||
public int KeepAlive => state_.KeepAlive;
|
||||
|
||||
/// <summary>
|
||||
/// A mask indicating which event types should be sent to the client.
|
||||
/// </summary>
|
||||
public int EventTypes => subscriptionFilters_.EventTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The highest severity for the events that should be sent to the client.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public int HighSeverity => subscriptionFilters_.HighSeverity;
|
||||
|
||||
/// <summary>
|
||||
/// The lowest severity for the events that should be sent to the client.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public int LowSeverity => subscriptionFilters_.LowSeverity;
|
||||
|
||||
/// <summary>
|
||||
/// The event category ids monitored by this subscription.
|
||||
/// </summary>
|
||||
public CategoryCollection Categories => categories_;
|
||||
|
||||
/// <summary>
|
||||
/// A list of full-qualified ids for process areas of interest - only events or conditions in these areas will be reported.
|
||||
/// </summary>
|
||||
public StringCollection Areas => areas_;
|
||||
|
||||
/// <summary>
|
||||
/// A list of full-qualified ids for sources of interest - only events or conditions from these sources will be reported.
|
||||
/// </summary>
|
||||
public StringCollection Sources => sources_;
|
||||
|
||||
/// <summary>
|
||||
/// The list of attributes returned for each event category.
|
||||
/// </summary>
|
||||
public AttributeDictionary Attributes => attributes_;
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns a writable copy of the current attributes.
|
||||
/// </summary>
|
||||
public TsCAeAttributeDictionary GetAttributes()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
var attributes = new TsCAeAttributeDictionary();
|
||||
|
||||
var enumerator = attributes_.GetEnumerator();
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (enumerator.Key != null)
|
||||
{
|
||||
var categoryId = (int)enumerator.Key;
|
||||
var attributeIDs = (AttributeCollection)enumerator.Value;
|
||||
|
||||
attributes.Add(categoryId, attributeIDs.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
protected TsCAeSubscription(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
state_ = (TsCAeSubscriptionState)info.GetValue(Names.State, typeof(TsCAeSubscriptionState));
|
||||
subscriptionFilters_ = (TsCAeSubscriptionFilters)info.GetValue(Names.Filters, typeof(TsCAeSubscriptionFilters));
|
||||
attributes_ = (AttributeDictionary)info.GetValue(Names.Attributes, typeof(AttributeDictionary));
|
||||
|
||||
name_ = state_.Name;
|
||||
|
||||
categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray());
|
||||
areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray());
|
||||
sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes a server into a stream.
|
||||
/// </summary>
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue(Names.State, state_);
|
||||
info.AddValue(Names.Filters, subscriptionFilters_);
|
||||
info.AddValue(Names.Attributes, attributes_);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Returns an unconnected copy of the subscription with the same items.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
// do a memberwise clone.
|
||||
var clone = (TsCAeSubscription)MemberwiseClone();
|
||||
|
||||
/*
|
||||
// place clone in disconnected state.
|
||||
clone.server = null;
|
||||
clone.subscription = null;
|
||||
clone.state = (SubscriptionState)state.Clone();
|
||||
|
||||
// clear server handles.
|
||||
clone.state.ServerHandle = null;
|
||||
|
||||
// always make cloned subscriptions inactive.
|
||||
clone.state.Active = false;
|
||||
|
||||
// clone items.
|
||||
if (clone.items != null)
|
||||
{
|
||||
ArrayList items = new ArrayList();
|
||||
|
||||
foreach (Item item in clone.items)
|
||||
{
|
||||
items.Add(item.Clone());
|
||||
}
|
||||
|
||||
clone.items = (Item[])items.ToArray(typeof(Item));
|
||||
}
|
||||
*/
|
||||
|
||||
// return clone.
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISubscription Members
|
||||
/// <summary>
|
||||
/// An event to receive data change updates.
|
||||
/// </summary>
|
||||
public event TsCAeDataChangedEventHandler DataChangedEvent
|
||||
{
|
||||
add => subscription_.DataChangedEvent += value;
|
||||
remove => subscription_.DataChangedEvent -= value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current state of the subscription.
|
||||
/// </summary>
|
||||
/// <returns>The current state of the subscription.</returns>
|
||||
public TsCAeSubscriptionState GetState()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
state_ = subscription_.GetState();
|
||||
state_.Name = name_;
|
||||
|
||||
return (TsCAeSubscriptionState)state_.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the state of a subscription.
|
||||
/// </summary>
|
||||
/// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
|
||||
/// <param name="state">The new subscription state.</param>
|
||||
/// <returns>The actual subscription state after applying the changes.</returns>
|
||||
public TsCAeSubscriptionState ModifyState(int masks, TsCAeSubscriptionState state)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
state_ = subscription_.ModifyState(masks, state);
|
||||
|
||||
if ((masks & (int)TsCAeStateMask.Name) != 0)
|
||||
{
|
||||
state_.Name = name_ = state.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
state_.Name = name_;
|
||||
}
|
||||
|
||||
return (TsCAeSubscriptionState)state_.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current filters for the subscription.
|
||||
/// </summary>
|
||||
/// <returns>The current filters for the subscription.</returns>
|
||||
public TsCAeSubscriptionFilters GetFilters()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
subscriptionFilters_ = subscription_.GetFilters();
|
||||
categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray());
|
||||
areas_ = new StringCollection(subscriptionFilters_.Areas.ToArray());
|
||||
sources_ = new StringCollection(subscriptionFilters_.Sources.ToArray());
|
||||
|
||||
return (TsCAeSubscriptionFilters)subscriptionFilters_.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current filters for the subscription.
|
||||
/// </summary>
|
||||
/// <param name="filters">The new filters to use for the subscription.</param>
|
||||
public void SetFilters(TsCAeSubscriptionFilters filters)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
subscription_.SetFilters(filters);
|
||||
|
||||
GetFilters();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the set of attributes to return with event notifications.
|
||||
/// </summary>
|
||||
/// <returns>The set of attributes to returned with event notifications.</returns>
|
||||
public int[] GetReturnedAttributes(int eventCategory)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
var attributeIDs = subscription_.GetReturnedAttributes(eventCategory);
|
||||
|
||||
attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs));
|
||||
|
||||
return attributeIDs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects the set of attributes to return with event notifications.
|
||||
/// </summary>
|
||||
/// <param name="eventCategory">The specific event category for which the attributes apply.</param>
|
||||
/// <param name="attributeIDs">The list of attribute ids to return.</param>
|
||||
public void SelectReturnedAttributes(int eventCategory, int[] attributeIDs)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
subscription_.SelectReturnedAttributes(eventCategory, attributeIDs);
|
||||
|
||||
attributes_.Update(eventCategory, (int[])OpcConvert.Clone(attributeIDs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force a refresh for all active conditions and inactive, unacknowledged conditions whose event notifications match the filter of the event subscription.
|
||||
/// </summary>
|
||||
public void Refresh()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
subscription_.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an outstanding refresh request.
|
||||
/// </summary>
|
||||
public void CancelRefresh()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
|
||||
if (subscription_ == null) throw new NotConnectedException();
|
||||
|
||||
subscription_.CancelRefresh();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
/// <summary>
|
||||
/// The current state.
|
||||
/// </summary>
|
||||
internal TsCAeSubscriptionState State => state_;
|
||||
|
||||
/// <summary>
|
||||
/// The current filters.
|
||||
/// </summary>
|
||||
internal TsCAeSubscriptionFilters Filters => subscriptionFilters_;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
232
Technosoftware/DaAeHdaClient/Ae/SubscriptionFilters.cs
Normal file
232
Technosoftware/DaAeHdaClient/Ae/SubscriptionFilters.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the event filters for a subscription.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeSubscriptionFilters : ICloneable, ISerializable
|
||||
{
|
||||
#region CategoryCollection Class
|
||||
/// <summary>
|
||||
/// Contains a writable collection category ids.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CategoryCollection : OpcWriteableCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal CategoryCollection() : base(null, typeof(int)) { }
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Constructs an object by deserializing it from a stream.
|
||||
/// </summary>
|
||||
protected CategoryCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new int this[int index] => (int)Array[index];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new int[] ToArray()
|
||||
{
|
||||
return (int[])Array.ToArray(typeof(int));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StringCollection Class
|
||||
/// <summary>
|
||||
/// Contains a writable collection of strings.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class StringCollection : OpcWriteableCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
internal StringCollection() : base(null, typeof(string)) { }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// An indexer for the collection.
|
||||
/// </summary>
|
||||
public new string this[int index] => (string)Array[index];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the collection as an array.
|
||||
/// </summary>
|
||||
public new string[] ToArray()
|
||||
{
|
||||
return (string[])Array.ToArray(typeof(string));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Constructs an object by deserializing it from a stream.
|
||||
/// </summary>
|
||||
protected StringCollection(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Names Class
|
||||
/// <summary>
|
||||
/// A set of names for fields used in serialization.
|
||||
/// </summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string EventTypes = "ET";
|
||||
internal const string Categories = "CT";
|
||||
internal const string HighSeverity = "HS";
|
||||
internal const string LowSeverity = "LS";
|
||||
internal const string Areas = "AR";
|
||||
internal const string Sources = "SR";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private int eventTypes_ = (int)TsCAeEventType.All;
|
||||
private CategoryCollection categories_ = new CategoryCollection();
|
||||
private int highSeverity_ = 1000;
|
||||
private int lowSeverity_ = 1;
|
||||
private StringCollection areas_ = new StringCollection();
|
||||
private StringCollection sources_ = new StringCollection();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with default values.
|
||||
/// </summary>
|
||||
public TsCAeSubscriptionFilters() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
protected TsCAeSubscriptionFilters(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
eventTypes_ = (int)info.GetValue(Names.EventTypes, typeof(int));
|
||||
categories_ = (CategoryCollection)info.GetValue(Names.Categories, typeof(CategoryCollection));
|
||||
highSeverity_ = (int)info.GetValue(Names.HighSeverity, typeof(int));
|
||||
lowSeverity_ = (int)info.GetValue(Names.LowSeverity, typeof(int));
|
||||
areas_ = (StringCollection)info.GetValue(Names.Areas, typeof(StringCollection));
|
||||
sources_ = (StringCollection)info.GetValue(Names.Sources, typeof(StringCollection));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A mask indicating which event types should be sent to the client.
|
||||
/// </summary>
|
||||
public int EventTypes
|
||||
{
|
||||
get => eventTypes_;
|
||||
set => eventTypes_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The highest severity for the events that should be sent to the client.
|
||||
/// </summary>
|
||||
public int HighSeverity
|
||||
{
|
||||
get => highSeverity_;
|
||||
set => highSeverity_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lowest severity for the events that should be sent to the client.
|
||||
/// </summary>
|
||||
public int LowSeverity
|
||||
{
|
||||
get => lowSeverity_;
|
||||
set => lowSeverity_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The category ids for the events that should be sent to the client.
|
||||
/// </summary>
|
||||
public CategoryCollection Categories => categories_;
|
||||
|
||||
/// <summary>
|
||||
/// A list of full-qualified ids for process areas of interest - only events or conditions in these areas will be reported.
|
||||
/// </summary>
|
||||
public StringCollection Areas => areas_;
|
||||
|
||||
/// <summary>
|
||||
/// A list of full-qualified ids for sources of interest - only events or conditions from these sources will be reported.
|
||||
/// </summary>
|
||||
public StringCollection Sources => sources_;
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Serializes a server into a stream.
|
||||
/// </summary>
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue(Names.EventTypes, eventTypes_);
|
||||
info.AddValue(Names.Categories, categories_);
|
||||
info.AddValue(Names.HighSeverity, highSeverity_);
|
||||
info.AddValue(Names.LowSeverity, lowSeverity_);
|
||||
info.AddValue(Names.Areas, areas_);
|
||||
info.AddValue(Names.Sources, sources_);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var filters = (TsCAeSubscriptionFilters)MemberwiseClone();
|
||||
|
||||
filters.categories_ = (CategoryCollection)categories_.Clone();
|
||||
filters.areas_ = (StringCollection)areas_.Clone();
|
||||
filters.sources_ = (StringCollection)sources_.Clone();
|
||||
|
||||
return filters;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
88
Technosoftware/DaAeHdaClient/Ae/SubscriptionState.cs
Normal file
88
Technosoftware/DaAeHdaClient/Ae/SubscriptionState.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Ae
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the state of a subscription.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCAeSubscriptionState : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private bool active_ = true;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A descriptive name for the subscription.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A unique identifier for the subscription assigned by the client.
|
||||
/// </summary>
|
||||
public object ClientHandle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the subscription is monitoring for events to send to the client.
|
||||
/// </summary>
|
||||
public bool Active
|
||||
{
|
||||
get => active_;
|
||||
set => active_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The maximum rate at which the server send event notifications.
|
||||
/// </summary>
|
||||
public int BufferTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The requested maximum number of events that will be sent in a single callback.
|
||||
/// </summary>
|
||||
public int MaxSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum period between updates sent to the client.
|
||||
/// </summary>
|
||||
public int KeepAlive { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
66
Technosoftware/DaAeHdaClient/ApplicationInstance.cs
Normal file
66
Technosoftware/DaAeHdaClient/ApplicationInstance.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using Technosoftware.DaAeHdaClient.Utilities;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the license to enable the different product versions.
|
||||
/// </summary>
|
||||
public partial class ApplicationInstance
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// This flag suppresses the conversion to local time done during marshalling.
|
||||
/// </summary>
|
||||
public static bool TimeAsUtc { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets the log file directory and ensures it is writable.
|
||||
/// </summary>
|
||||
public static string GetLogFileDirectory()
|
||||
{
|
||||
return ConfigUtils.GetLogFileDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the trace.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to use.</param>
|
||||
/// <param name="filename">The filename.</param>
|
||||
public static void EnableTrace(string path, string filename)
|
||||
{
|
||||
ConfigUtils.EnableTrace(path, filename);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Fields
|
||||
internal static bool InitializeSecurityCalled = false;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
715
Technosoftware/DaAeHdaClient/Cpx/ComplexItem.cs
Normal file
715
Technosoftware/DaAeHdaClient/Cpx/ComplexItem.cs
Normal file
@@ -0,0 +1,715 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that contains complex data related properties for an item.
|
||||
/// </summary>
|
||||
public class TsCCpxComplexItem : OpcItem
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Constants
|
||||
|
||||
/// <summary>
|
||||
/// The reserved name for complex data branch in the server namespace.
|
||||
/// </summary>
|
||||
public const string CPX_BRANCH = "CPX";
|
||||
|
||||
/// <summary>
|
||||
/// The reserved name for the data filters branch in the CPX namespace.
|
||||
/// </summary>
|
||||
public const string CPX_DATA_FILTERS = "DataFilters";
|
||||
|
||||
/// <summary>
|
||||
/// The set of all complex data item properties.
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID[] CPX_PROPERTIES = new TsDaPropertyID[]
|
||||
{
|
||||
TsDaProperty.TYPE_SYSTEM_ID,
|
||||
TsDaProperty.DICTIONARY_ID,
|
||||
TsDaProperty.TYPE_ID,
|
||||
TsDaProperty.UNCONVERTED_ITEM_ID,
|
||||
TsDaProperty.UNFILTERED_ITEM_ID,
|
||||
TsDaProperty.DATA_FILTER_VALUE
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Fields
|
||||
|
||||
private string _typeSystemID;
|
||||
private string _dictionaryID;
|
||||
private string _typeID;
|
||||
private OpcItem _dictionaryItemID;
|
||||
private OpcItem _typeItemID;
|
||||
private OpcItem _unconvertedItemID;
|
||||
private OpcItem _unfilteredItemID;
|
||||
private OpcItem _filterItem;
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Constructors, Destructor, Initialization
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the default values.
|
||||
/// </summary>
|
||||
public TsCCpxComplexItem() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object from an item identifier.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item id.</param>
|
||||
public TsCCpxComplexItem(OpcItem itemID)
|
||||
{
|
||||
ItemPath = itemID.ItemPath;
|
||||
ItemName = itemID.ItemName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The name of the item in the server address space.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type system id for the complex item.
|
||||
/// </summary>
|
||||
public string TypeSystemID => _typeSystemID;
|
||||
|
||||
/// <summary>
|
||||
/// The dictionary id for the complex item.
|
||||
/// </summary>
|
||||
public string DictionaryID => _dictionaryID;
|
||||
|
||||
/// <summary>
|
||||
/// The type id for the complex item.
|
||||
/// </summary>
|
||||
public string TypeID => _typeID;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the item containing the dictionary for the item.
|
||||
/// </summary>
|
||||
public OpcItem DictionaryItemID => _dictionaryItemID;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the item containing the type description for the item.
|
||||
/// </summary>
|
||||
public OpcItem TypeItemID => _typeItemID;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the unconverted version of the item. Only valid for items which apply type conversions to the item.
|
||||
/// </summary>
|
||||
public OpcItem UnconvertedItemID => _unconvertedItemID;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the unfiltered version of the item. Only valid for items apply data filters to the item.
|
||||
/// </summary>
|
||||
public OpcItem UnfilteredItemID => _unfilteredItemID;
|
||||
|
||||
/// <summary>
|
||||
/// The item used to create new data filters for the complex data item (null is item does not support it).
|
||||
/// </summary>
|
||||
public OpcItem DataFilterItem => _filterItem;
|
||||
|
||||
/// <summary>
|
||||
/// The current data filter value. Only valid for items apply data filters to the item.
|
||||
/// </summary>
|
||||
public string DataFilterValue { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns an appropriate string representation of the object.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
if (Name != null || Name.Length != 0)
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
return ItemName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the root complex data item for the object.
|
||||
/// </summary>
|
||||
public TsCCpxComplexItem GetRootItem()
|
||||
{
|
||||
if (_unconvertedItemID != null)
|
||||
{
|
||||
return TsCCpxComplexTypeCache.GetComplexItem(_unconvertedItemID);
|
||||
}
|
||||
|
||||
if (_unfilteredItemID != null)
|
||||
{
|
||||
return TsCCpxComplexTypeCache.GetComplexItem(_unfilteredItemID);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current complex data item properties from the server.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public void Update(TsCDaServer server)
|
||||
{
|
||||
// clear the existing state.
|
||||
Clear();
|
||||
|
||||
// check if the item supports any of the complex data properties.
|
||||
var results = server.GetProperties(
|
||||
new OpcItem[] { this },
|
||||
CPX_PROPERTIES,
|
||||
true);
|
||||
|
||||
// unexpected return value.
|
||||
if (results == null || results.Length != 1)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "Unexpected results returned from server.");
|
||||
}
|
||||
|
||||
// update object.
|
||||
if (!Init((TsCDaItemProperty[])results[0].ToArray(typeof(TsCDaItemProperty))))
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.E_INVALIDARG.Code, OpcResult.FuncCallType.SysFuncCall, null), "Not a valid complex item.");
|
||||
}
|
||||
|
||||
// check if data filters are suppported for the item.
|
||||
GetDataFilterItem(server);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the set of type conversions from the server.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public TsCCpxComplexItem[] GetTypeConversions(TsCDaServer server)
|
||||
{
|
||||
// only the root item can have type conversions.
|
||||
if (_unconvertedItemID != null || _unfilteredItemID != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
TsCDaBrowsePosition position = null;
|
||||
|
||||
try
|
||||
{
|
||||
// look for the 'CPX' branch.
|
||||
var filters = new TsCDaBrowseFilters { ElementNameFilter = CPX_BRANCH, BrowseFilter = TsCDaBrowseFilter.Branch, ReturnAllProperties = false, PropertyIDs = null, ReturnPropertyValues = false };
|
||||
|
||||
var elements = server.Browse(this, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// release the browse position object.
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
position = null;
|
||||
}
|
||||
|
||||
// browse for type conversions.
|
||||
var itemID = new OpcItem(elements[0].ItemPath, elements[0].ItemName);
|
||||
|
||||
filters.ElementNameFilter = null;
|
||||
filters.BrowseFilter = TsCDaBrowseFilter.Item;
|
||||
filters.ReturnAllProperties = false;
|
||||
filters.PropertyIDs = CPX_PROPERTIES;
|
||||
filters.ReturnPropertyValues = true;
|
||||
|
||||
elements = server.Browse(itemID, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
return new TsCCpxComplexItem[0];
|
||||
}
|
||||
|
||||
// contruct an array of complex data items for each available conversion.
|
||||
var conversions = new ArrayList(elements.Length);
|
||||
|
||||
Array.ForEach(elements, element =>
|
||||
{
|
||||
if (element.Name != CPX_DATA_FILTERS)
|
||||
{
|
||||
var item = new TsCCpxComplexItem();
|
||||
if (item.Init(element))
|
||||
{
|
||||
// check if data filters supported for type conversion.
|
||||
item.GetDataFilterItem(server);
|
||||
conversions.Add(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// return the set of available conversions.
|
||||
return (TsCCpxComplexItem[])conversions.ToArray(typeof(TsCCpxComplexItem));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
position = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the set of data filters from the server.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public TsCCpxComplexItem[] GetDataFilters(TsCDaServer server)
|
||||
{
|
||||
// not a valid operation for data filter items.
|
||||
if (_unfilteredItemID != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// data filters not supported by the item.
|
||||
if (_filterItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
TsCDaBrowsePosition position = null;
|
||||
|
||||
try
|
||||
{
|
||||
// browse any existing filter instances.
|
||||
var filters = new TsCDaBrowseFilters { ElementNameFilter = null, BrowseFilter = TsCDaBrowseFilter.Item, ReturnAllProperties = false, PropertyIDs = CPX_PROPERTIES, ReturnPropertyValues = true };
|
||||
|
||||
var elements = server.Browse(_filterItem, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
return new TsCCpxComplexItem[0];
|
||||
}
|
||||
|
||||
// contruct an array of complex data items for each available data filter.
|
||||
var dataFilters = new ArrayList(elements.Length);
|
||||
|
||||
Array.ForEach(elements, element =>
|
||||
{
|
||||
var item = new TsCCpxComplexItem();
|
||||
if (item.Init(element))
|
||||
dataFilters.Add(item);
|
||||
});
|
||||
|
||||
// return the set of available data filters.
|
||||
return (TsCCpxComplexItem[])dataFilters.ToArray(typeof(TsCCpxComplexItem));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
position = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new data filter.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
/// <param name="filterName">The name of the filter</param>
|
||||
/// <param name="filterValue">The value of the filter</param>
|
||||
public TsCCpxComplexItem CreateDataFilter(TsCDaServer server, string filterName, string filterValue)
|
||||
{
|
||||
// not a valid operation for data filter items.
|
||||
if (_unfilteredItemID != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// data filters not supported by the item.
|
||||
if (_filterItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
TsCDaBrowsePosition position = null;
|
||||
|
||||
try
|
||||
{
|
||||
// write the desired filter to the server.
|
||||
var item = new TsCDaItemValue(_filterItem);
|
||||
|
||||
// create the filter parameters document.
|
||||
using (var ostrm = new StringWriter())
|
||||
{
|
||||
using (var writer = new XmlTextWriter(ostrm))
|
||||
{
|
||||
writer.WriteStartElement("DataFilters");
|
||||
writer.WriteAttributeString("Name", filterName);
|
||||
writer.WriteString(filterValue);
|
||||
writer.WriteEndElement();
|
||||
writer.Close();
|
||||
}
|
||||
// create the value to write.
|
||||
item.Value = ostrm.ToString();
|
||||
}
|
||||
item.Quality = TsCDaQuality.Bad;
|
||||
item.QualitySpecified = false;
|
||||
item.Timestamp = DateTime.MinValue;
|
||||
item.TimestampSpecified = false;
|
||||
|
||||
// write the value.
|
||||
var result = server.Write(new TsCDaItemValue[] { item });
|
||||
|
||||
if (result == null || result.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "Unexpected results returned from server.");
|
||||
}
|
||||
|
||||
if (result[0].Result.Failed())
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not create new data filter.");
|
||||
}
|
||||
|
||||
// browse for new data filter item.
|
||||
var filters = new TsCDaBrowseFilters { ElementNameFilter = filterName, BrowseFilter = TsCDaBrowseFilter.Item, ReturnAllProperties = false, PropertyIDs = CPX_PROPERTIES, ReturnPropertyValues = true };
|
||||
|
||||
var elements = server.Browse(_filterItem, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not browse to new data filter.");
|
||||
}
|
||||
|
||||
var filterItem = new TsCCpxComplexItem();
|
||||
|
||||
if (!filterItem.Init(elements[0]))
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not initialize to new data filter.");
|
||||
}
|
||||
|
||||
// return the new data filter.
|
||||
return filterItem;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a data filter.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
/// <param name="filterValue">The value of the filter</param>
|
||||
public void UpdateDataFilter(TsCDaServer server, string filterValue)
|
||||
{
|
||||
// not a valid operation for non data filter items.
|
||||
if (_unfilteredItemID == null)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Cannot update the data filter for this item.");
|
||||
}
|
||||
|
||||
// create the value to write.
|
||||
var item = new TsCDaItemValue(this) { Value = filterValue, Quality = TsCDaQuality.Bad, QualitySpecified = false, Timestamp = DateTime.MinValue, TimestampSpecified = false };
|
||||
|
||||
// write the value.
|
||||
var result = server.Write(new TsCDaItemValue[] { item });
|
||||
|
||||
if (result == null || result.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "Unexpected results returned from server.");
|
||||
}
|
||||
|
||||
if (result[0].Result.Failed())
|
||||
{
|
||||
throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not update data filter.");
|
||||
}
|
||||
|
||||
// update locale copy of the filter value.
|
||||
DataFilterValue = filterValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the type dictionary for the item.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public string GetTypeDictionary(TsCDaServer server)
|
||||
{
|
||||
var results = server.GetProperties(
|
||||
new OpcItem[] { _dictionaryItemID },
|
||||
new TsDaPropertyID[] { TsDaProperty.DICTIONARY },
|
||||
true);
|
||||
|
||||
if (results == null || results.Length == 0 || results[0].Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var property = results[0][0];
|
||||
|
||||
if (!property.Result.Succeeded())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)property.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the type description for the item.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public string GetTypeDescription(TsCDaServer server)
|
||||
{
|
||||
var results = server.GetProperties(
|
||||
new OpcItem[] { _typeItemID },
|
||||
new TsDaPropertyID[] { TsDaProperty.TYPE_DESCRIPTION },
|
||||
true);
|
||||
|
||||
if (results == null || results.Length == 0 || results[0].Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var property = results[0][0];
|
||||
|
||||
if (!property.Result.Succeeded())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)property.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the item id for the data filters items and stores it in the internal cache.
|
||||
/// </summary>
|
||||
/// <param name="server">The server object</param>
|
||||
public void GetDataFilterItem(TsCDaServer server)
|
||||
{
|
||||
_filterItem = null;
|
||||
|
||||
// not a valid operation for data filter items.
|
||||
if (_unfilteredItemID != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TsCDaBrowsePosition position = null;
|
||||
|
||||
try
|
||||
{
|
||||
var itemID = new OpcItem(this);
|
||||
|
||||
// browse any existing filter instances.
|
||||
var filters = new TsCDaBrowseFilters { ElementNameFilter = CPX_DATA_FILTERS, BrowseFilter = TsCDaBrowseFilter.All, ReturnAllProperties = false, PropertyIDs = null, ReturnPropertyValues = false };
|
||||
|
||||
TsCDaBrowseElement[] elements = null;
|
||||
|
||||
// browse for the 'CPX' branch first.
|
||||
if (_unconvertedItemID == null)
|
||||
{
|
||||
filters.ElementNameFilter = CPX_BRANCH;
|
||||
|
||||
elements = server.Browse(itemID, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// release the position object.
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
position = null;
|
||||
}
|
||||
|
||||
// update the item for the next browse operation.
|
||||
itemID = new OpcItem(elements[0].ItemPath, elements[0].ItemName);
|
||||
|
||||
filters.ElementNameFilter = CPX_DATA_FILTERS;
|
||||
}
|
||||
|
||||
// browse for the 'DataFilters' branch.
|
||||
elements = server.Browse(itemID, filters, out position);
|
||||
|
||||
// nothing found.
|
||||
if (elements == null || elements.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_filterItem = new OpcItem(elements[0].ItemPath, elements[0].ItemName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (position != null)
|
||||
{
|
||||
position.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Sets all object properties to their default values.
|
||||
/// </summary>
|
||||
private void Clear()
|
||||
{
|
||||
_typeSystemID = null;
|
||||
_dictionaryID = null;
|
||||
_typeID = null;
|
||||
_dictionaryItemID = null;
|
||||
_typeItemID = null;
|
||||
_unconvertedItemID = null;
|
||||
_unfilteredItemID = null;
|
||||
_filterItem = null;
|
||||
DataFilterValue = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object from a browse element.
|
||||
/// </summary>
|
||||
private bool Init(TsCDaBrowseElement element)
|
||||
{
|
||||
// update the item id.
|
||||
ItemPath = element.ItemPath;
|
||||
ItemName = element.ItemName;
|
||||
Name = element.Name;
|
||||
|
||||
return Init(element.Properties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object from a list of properties.
|
||||
/// </summary>
|
||||
private bool Init(TsCDaItemProperty[] properties)
|
||||
{
|
||||
// put the object into default state.
|
||||
Clear();
|
||||
|
||||
// must have at least three properties defined.
|
||||
if (properties == null || properties.Length < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
// continue - ignore invalid properties.
|
||||
if (!property.Result.Succeeded())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// type system id.
|
||||
if (property.ID == TsDaProperty.TYPE_SYSTEM_ID)
|
||||
{
|
||||
_typeSystemID = (string)property.Value;
|
||||
continue;
|
||||
}
|
||||
|
||||
// dictionary id
|
||||
if (property.ID == TsDaProperty.DICTIONARY_ID)
|
||||
{
|
||||
_dictionaryID = (string)property.Value;
|
||||
_dictionaryItemID = new OpcItem(property.ItemPath, property.ItemName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// type id
|
||||
if (property.ID == TsDaProperty.TYPE_ID)
|
||||
{
|
||||
_typeID = (string)property.Value;
|
||||
_typeItemID = new OpcItem(property.ItemPath, property.ItemName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// unconverted item id
|
||||
if (property.ID == TsDaProperty.UNCONVERTED_ITEM_ID)
|
||||
{
|
||||
_unconvertedItemID = new OpcItem(ItemPath, (string)property.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
// unfiltered item id
|
||||
if (property.ID == TsDaProperty.UNFILTERED_ITEM_ID)
|
||||
{
|
||||
_unfilteredItemID = new OpcItem(ItemPath, (string)property.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
// data filter value.
|
||||
if (property.ID == TsDaProperty.DATA_FILTER_VALUE)
|
||||
{
|
||||
DataFilterValue = (string)property.Value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// validate object.
|
||||
if (_typeSystemID == null || _dictionaryID == null || _typeID == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
207
Technosoftware/DaAeHdaClient/Cpx/ComplexTypeCache.cs
Normal file
207
Technosoftware/DaAeHdaClient/Cpx/ComplexTypeCache.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
using System.Collections;
|
||||
|
||||
using Technosoftware.DaAeHdaClient.Da;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that caches properties of complex data items.
|
||||
/// </summary>
|
||||
public class TsCCpxComplexTypeCache
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// The active server for the application.
|
||||
/// </summary>
|
||||
private static TsCDaServer _server;
|
||||
|
||||
/// <summary>
|
||||
/// A cache of item properties fetched from the active server.
|
||||
/// </summary>
|
||||
private static Hashtable _items = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// A cache of type dictionaries fetched from the active server.
|
||||
/// </summary>
|
||||
private static Hashtable _dictionaries = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// A cache of type descriptions fetched from the active server.
|
||||
/// </summary>
|
||||
private static Hashtable _descriptions = new Hashtable();
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Constructors, Destructor, Initialization
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the complex type cache with defaults.
|
||||
/// </summary>
|
||||
public TsCCpxComplexTypeCache() { }
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the server to use for the cache.
|
||||
/// </summary>
|
||||
public static TsCDaServer Server
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
return _server;
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
_server = value;
|
||||
_items.Clear();
|
||||
_dictionaries.Clear();
|
||||
_descriptions.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns the complex item for the specified item id.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item id.</param>
|
||||
public static TsCCpxComplexItem GetComplexItem(OpcItem itemID)
|
||||
{
|
||||
if (itemID == null) return null;
|
||||
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
var item = new TsCCpxComplexItem(itemID);
|
||||
|
||||
try
|
||||
{
|
||||
item.Update(_server);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// item is not a valid complex data item.
|
||||
item = null;
|
||||
}
|
||||
|
||||
_items[itemID.Key] = item;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the complex item for the specified item browse element.
|
||||
/// </summary>
|
||||
/// <param name="element">The item browse element.</param>
|
||||
public static TsCCpxComplexItem GetComplexItem(TsCDaBrowseElement element)
|
||||
{
|
||||
if (element == null) return null;
|
||||
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
return GetComplexItem(new OpcItem(element.ItemPath, element.ItemName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the type dictionary for the item.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item id.</param>
|
||||
public static string GetTypeDictionary(OpcItem itemID)
|
||||
{
|
||||
if (itemID == null) return null;
|
||||
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
var dictionary = (string)_dictionaries[itemID.Key];
|
||||
|
||||
if (dictionary != null)
|
||||
{
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
var item = GetComplexItem(itemID);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
dictionary = item.GetTypeDictionary(_server);
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the type description for the item.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item id.</param>
|
||||
public static string GetTypeDescription(OpcItem itemID)
|
||||
{
|
||||
if (itemID == null) return null;
|
||||
|
||||
lock (typeof(TsCCpxComplexTypeCache))
|
||||
{
|
||||
string description = null;
|
||||
|
||||
var item = GetComplexItem(itemID);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
description = (string)_descriptions[item.TypeItemID.Key];
|
||||
|
||||
if (description != null)
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
_descriptions[item.TypeItemID.Key] = description = item.GetTypeDescription(_server);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
49
Technosoftware/DaAeHdaClient/Cpx/ComplexValue.cs
Normal file
49
Technosoftware/DaAeHdaClient/Cpx/ComplexValue.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores a value with an associated name and/or type.
|
||||
/// </summary>
|
||||
public class TsCCpxComplexValue
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the value.
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// The complex or simple data type of the value.
|
||||
/// </summary>
|
||||
public string Type;
|
||||
|
||||
/// <summary>
|
||||
/// The actual value.
|
||||
/// </summary>
|
||||
public object Value;
|
||||
}
|
||||
}
|
||||
71
Technosoftware/DaAeHdaClient/Cpx/Context.cs
Normal file
71
Technosoftware/DaAeHdaClient/Cpx/Context.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores the current serialization context.
|
||||
/// </summary>
|
||||
internal struct TsCCpxContext
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Constructors, Destructor, Initialization
|
||||
|
||||
public TsCCpxContext(byte[] buffer)
|
||||
{
|
||||
Buffer = buffer;
|
||||
Index = 0;
|
||||
Dictionary = null;
|
||||
Type = null;
|
||||
BigEndian = false;
|
||||
CharWidth = 2;
|
||||
StringEncoding = STRING_ENCODING_UCS2;
|
||||
FloatFormat = FLOAT_FORMAT_IEEE754;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Public Fields
|
||||
|
||||
public byte[] Buffer;
|
||||
public int Index;
|
||||
public TypeDictionary Dictionary;
|
||||
public TypeDescription Type;
|
||||
public bool BigEndian;
|
||||
public int CharWidth;
|
||||
public string StringEncoding;
|
||||
public string FloatFormat;
|
||||
|
||||
|
||||
public const string STRING_ENCODING_ACSII = "ASCII";
|
||||
public const string STRING_ENCODING_UCS2 = "UCS-2";
|
||||
public const string FLOAT_FORMAT_IEEE754 = "IEEE-754";
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised if the data in buffer is not consistent with the schema.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCCpxInvalidDataInBufferException : ApplicationException
|
||||
{
|
||||
private const string Default = "The data in the buffer cannot be read because it is not consistent with the schema.";
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataInBufferException() : base(Default) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataInBufferException(string message) : base(Default + Environment.NewLine + message) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataInBufferException(Exception e) : base(Default, e) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataInBufferException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
|
||||
/// <remarks/>
|
||||
protected TsCCpxInvalidDataInBufferException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised if the data in buffer is not consistent with the schema.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCCpxInvalidDataToWriteException : ApplicationException
|
||||
{
|
||||
private const string Default = "The object cannot be written because it is not consistent with the schema.";
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataToWriteException() : base(Default) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataToWriteException(string message) : base(Default + Environment.NewLine + message) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataToWriteException(Exception e) : base(Default, e) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidDataToWriteException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
|
||||
/// <remarks/>
|
||||
protected TsCCpxInvalidDataToWriteException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
48
Technosoftware/DaAeHdaClient/Cpx/InvalidSchemaException.cs
Normal file
48
Technosoftware/DaAeHdaClient/Cpx/InvalidSchemaException.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised if the schema contains errors or inconsistencies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCCpxInvalidSchemaException : ApplicationException
|
||||
{
|
||||
private const string Default = "The schema cannot be used because it contains errors or inconsitencies.";
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidSchemaException() : base(Default) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidSchemaException(string message) : base(Default + Environment.NewLine + message) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidSchemaException(Exception e) : base(Default, e) { }
|
||||
/// <remarks/>
|
||||
public TsCCpxInvalidSchemaException(string message, Exception innerException) : base(Default + Environment.NewLine + message, innerException) { }
|
||||
/// <remarks/>
|
||||
protected TsCCpxInvalidSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
269
Technosoftware/DaAeHdaClient/Cpx/OPCBinary.cs
Normal file
269
Technosoftware/DaAeHdaClient/Cpx/OPCBinary.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version: 1.1.4322.573
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// This source code was auto-generated by xsd, Version=1.1.4322.573.
|
||||
//
|
||||
namespace Technosoftware.DaAeHdaClient.Cpx
|
||||
{
|
||||
using System.Xml.Serialization;
|
||||
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
[XmlRootAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/", IsNullable=false)]
|
||||
public class TypeDictionary {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlElementAttribute("TypeDescription")]
|
||||
public TypeDescription[] TypeDescription;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string DictionaryName;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
[System.ComponentModel.DefaultValueAttribute(true)]
|
||||
public bool DefaultBigEndian = true;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
[System.ComponentModel.DefaultValueAttribute("UCS-2")]
|
||||
public string DefaultStringEncoding = "UCS-2";
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
[System.ComponentModel.DefaultValueAttribute(2)]
|
||||
public int DefaultCharWidth = 2;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
[System.ComponentModel.DefaultValueAttribute("IEEE-754")]
|
||||
public string DefaultFloatFormat = "IEEE-754";
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class TypeDescription {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlElementAttribute("Field")]
|
||||
public FieldType[] Field;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string TypeID;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public bool DefaultBigEndian;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlIgnoreAttribute()]
|
||||
public bool DefaultBigEndianSpecified;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string DefaultStringEncoding;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public int DefaultCharWidth;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlIgnoreAttribute()]
|
||||
public bool DefaultCharWidthSpecified;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string DefaultFloatFormat;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
[XmlIncludeAttribute(typeof(TypeReference))]
|
||||
[XmlIncludeAttribute(typeof(CharString))]
|
||||
[XmlIncludeAttribute(typeof(Unicode))]
|
||||
[XmlIncludeAttribute(typeof(Ascii))]
|
||||
[XmlIncludeAttribute(typeof(FloatingPoint))]
|
||||
[XmlIncludeAttribute(typeof(Double))]
|
||||
[XmlIncludeAttribute(typeof(Single))]
|
||||
[XmlIncludeAttribute(typeof(Integer))]
|
||||
[XmlIncludeAttribute(typeof(UInt64))]
|
||||
[XmlIncludeAttribute(typeof(UInt32))]
|
||||
[XmlIncludeAttribute(typeof(UInt16))]
|
||||
[XmlIncludeAttribute(typeof(UInt8))]
|
||||
[XmlIncludeAttribute(typeof(Int64))]
|
||||
[XmlIncludeAttribute(typeof(Int32))]
|
||||
[XmlIncludeAttribute(typeof(Int16))]
|
||||
[XmlIncludeAttribute(typeof(Int8))]
|
||||
[XmlIncludeAttribute(typeof(BitString))]
|
||||
public class FieldType {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string Name;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string Format;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public int Length;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlIgnoreAttribute()]
|
||||
public bool LengthSpecified;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public int ElementCount;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlIgnoreAttribute()]
|
||||
public bool ElementCountSpecified;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string ElementCountRef;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string FieldTerminator;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class TypeReference : FieldType {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string TypeID;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
[XmlIncludeAttribute(typeof(Unicode))]
|
||||
[XmlIncludeAttribute(typeof(Ascii))]
|
||||
public class CharString : FieldType {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public int CharWidth;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlIgnoreAttribute()]
|
||||
public bool CharWidthSpecified;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string StringEncoding;
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string CharCountRef;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Unicode : CharString {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Ascii : CharString {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
[XmlIncludeAttribute(typeof(Double))]
|
||||
[XmlIncludeAttribute(typeof(Single))]
|
||||
public class FloatingPoint : FieldType {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
public string FloatFormat;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Double : FloatingPoint {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Single : FloatingPoint {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
[XmlIncludeAttribute(typeof(UInt64))]
|
||||
[XmlIncludeAttribute(typeof(UInt32))]
|
||||
[XmlIncludeAttribute(typeof(UInt16))]
|
||||
[XmlIncludeAttribute(typeof(UInt8))]
|
||||
[XmlIncludeAttribute(typeof(Int64))]
|
||||
[XmlIncludeAttribute(typeof(Int32))]
|
||||
[XmlIncludeAttribute(typeof(Int16))]
|
||||
[XmlIncludeAttribute(typeof(Int8))]
|
||||
public class Integer : FieldType {
|
||||
|
||||
/// <remarks/>
|
||||
[XmlAttributeAttribute()]
|
||||
[System.ComponentModel.DefaultValueAttribute(true)]
|
||||
public bool Signed = true;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class UInt64 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class UInt32 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class UInt16 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class UInt8 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Int64 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Int32 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Int16 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class Int8 : Integer {
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[XmlTypeAttribute(Namespace="http://opcfoundation.org/OPCBinary/1.0/")]
|
||||
public class BitString : FieldType {
|
||||
}
|
||||
}
|
||||
165
Technosoftware/DaAeHdaClient/Cpx/OPCBinary.xsd
Normal file
165
Technosoftware/DaAeHdaClient/Cpx/OPCBinary.xsd
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<xs:schema id="OPCBinary" targetNamespace="http://opcfoundation.org/OPCBinary/1.0/" elementFormDefault="qualified"
|
||||
xmlns="http://opcfoundation.org/OPCBinary/1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="TypeDictionary">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="TypeDescription" type="TypeDescription" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="DictionaryName" type="xs:string" use="required" />
|
||||
<xs:attribute name="DefaultBigEndian" type="xs:boolean" default="true" />
|
||||
<xs:attribute name="DefaultStringEncoding" type="xs:string" default="UCS-2" />
|
||||
<xs:attribute name="DefaultCharWidth" type="xs:int" default="2" />
|
||||
<xs:attribute name="DefaultFloatFormat" type="xs:string" default="IEEE-754" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:complexType name="TypeDescription">
|
||||
<xs:sequence>
|
||||
<xs:element name="Field" type="FieldType" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="TypeID" type="xs:string" use="required" />
|
||||
<xs:attribute name="DefaultBigEndian" type="xs:boolean" use="optional" />
|
||||
<xs:attribute name="DefaultStringEncoding" type="xs:string" use="optional" />
|
||||
<xs:attribute name="DefaultCharWidth" type="xs:int" use="optional" />
|
||||
<xs:attribute name="DefaultFloatFormat" type="xs:string" use="optional" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="FieldType">
|
||||
<xs:attribute name="Name" type="xs:string" use="optional" />
|
||||
<xs:attribute name="Format" type="xs:string" use="optional" />
|
||||
<xs:attribute name="Length" type="xs:int" use="optional" />
|
||||
<xs:attribute name="ElementCount" type="xs:int" use="optional" />
|
||||
<xs:attribute name="ElementCountRef" type="xs:string" use="optional" />
|
||||
<xs:attribute name="FieldTerminator" type="xs:string" use="optional" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="BitString">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="FieldType"></xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Integer">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="FieldType">
|
||||
<xs:attribute name="Signed" type="xs:boolean" default="true" />
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="FloatingPoint">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="FieldType">
|
||||
<xs:attribute name="FloatFormat" type="xs:string" />
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="CharString">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="FieldType">
|
||||
<xs:attribute name="CharWidth" type="xs:int" />
|
||||
<xs:attribute name="StringEncoding" type="xs:string" />
|
||||
<xs:attribute name="CharCountRef" type="xs:string" />
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="TypeReference">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="FieldType">
|
||||
<xs:attribute name="TypeID" type="xs:string" />
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Int8">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="1" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="true" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Int16">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="2" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="true" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Int32">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="4" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="true" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Int64">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="8" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="true" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="UInt8">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="1" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="false" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="UInt16">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="2" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="false" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="UInt32">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="4" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="false" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="UInt64">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="Integer">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="8" />
|
||||
<xs:attribute name="Signed" type="xs:boolean" fixed="false" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Single">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="FloatingPoint">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="4" />
|
||||
<xs:attribute name="FloatFormat" type="xs:string" fixed="IEEE-754" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Double">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="FloatingPoint">
|
||||
<xs:attribute name="Length" type="xs:int" fixed="8" />
|
||||
<xs:attribute name="FloatFormat" type="xs:string" fixed="IEEE-754" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Ascii">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="CharString">
|
||||
<xs:attribute name="CharWidth" type="xs:int" fixed="1" />
|
||||
<xs:attribute name="StringEncoding" type="xs:string" fixed="ASCII" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Unicode">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="CharString">
|
||||
<xs:attribute name="CharWidth" type="xs:int" fixed="2" />
|
||||
<xs:attribute name="StringEncoding" type="xs:string" fixed="UCS-2" />
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
45
Technosoftware/DaAeHdaClient/Da/AccessRight.cs
Normal file
45
Technosoftware/DaAeHdaClient/Da/AccessRight.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Defines possible item access rights.</para>
|
||||
/// <para align="left">Indicates if this item is read only, write only or read/write.
|
||||
/// This is NOT related to security but rather to the nature of the underlying
|
||||
/// hardware.</para>
|
||||
/// </summary>
|
||||
public enum TsDaAccessRights
|
||||
{
|
||||
/// <summary>The access rights for this item are server.</summary>
|
||||
Unknown = 0x00,
|
||||
/// <summary>The client can read the data item's value.</summary>
|
||||
Readable = 0x01,
|
||||
/// <summary>The client can change the data item's value.</summary>
|
||||
Writable = 0x02,
|
||||
/// <summary>The client can read and change the data item's value.</summary>
|
||||
ReadWritable = 0x03
|
||||
}
|
||||
}
|
||||
93
Technosoftware/DaAeHdaClient/Da/Browse.cs
Normal file
93
Technosoftware/DaAeHdaClient/Da/Browse.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores the state of a browse operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaBrowsePosition : IOpcBrowsePosition
|
||||
{
|
||||
#region Fields
|
||||
private TsCDaBrowseFilters browseFilters_;
|
||||
private OpcItem itemId_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Saves the parameters for an incomplete browse information.
|
||||
/// </summary>
|
||||
public TsCDaBrowsePosition(OpcItem itemId, TsCDaBrowseFilters filters)
|
||||
{
|
||||
if (filters == null) throw new ArgumentNullException(nameof(filters));
|
||||
|
||||
itemId_ = (OpcItem)itemId?.Clone();
|
||||
browseFilters_ = (TsCDaBrowseFilters)filters.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources held by the object.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The item identifier of the branch being browsed.
|
||||
/// </summary>
|
||||
public OpcItem ItemID => itemId_;
|
||||
|
||||
/// <summary>
|
||||
/// The filters applied during the browse operation.
|
||||
/// </summary>
|
||||
public TsCDaBrowseFilters Filters => (TsCDaBrowseFilters)browseFilters_.Clone();
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of elements that may be returned in a single browse.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public int MaxElementsReturned
|
||||
{
|
||||
get => browseFilters_.MaxElementsReturned;
|
||||
set => browseFilters_.MaxElementsReturned = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return (TsCDaBrowsePosition)MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
87
Technosoftware/DaAeHdaClient/Da/BrowseElement.cs
Normal file
87
Technosoftware/DaAeHdaClient/Da/BrowseElement.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a description of an element in the server address space.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaBrowseElement : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private TsCDaItemProperty[] itemProperties_ = new TsCDaItemProperty[0];
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A descriptive name for element that is unique within a branch.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The primary identifier for the element within the server namespace.
|
||||
/// </summary>
|
||||
public string ItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An secondary identifier for the element within the server namespace.
|
||||
/// </summary>
|
||||
public string ItemPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the element refers to an item with data that can be accessed.
|
||||
/// </summary>
|
||||
public bool IsItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the element has children.
|
||||
/// </summary>
|
||||
public bool HasChildren { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The set of properties for the element.
|
||||
/// </summary>
|
||||
public TsCDaItemProperty[] Properties
|
||||
{
|
||||
get => itemProperties_;
|
||||
set => itemProperties_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCDaBrowseElement)MemberwiseClone();
|
||||
clone.itemProperties_ = (TsCDaItemProperty[])OpcConvert.Clone(itemProperties_);
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
48
Technosoftware/DaAeHdaClient/Da/BrowseFilter.cs
Normal file
48
Technosoftware/DaAeHdaClient/Da/BrowseFilter.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of browse elements to return during a browse.
|
||||
/// </summary>
|
||||
public enum TsCDaBrowseFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Return all types of browse elements.
|
||||
/// </summary>
|
||||
All,
|
||||
|
||||
/// <summary>
|
||||
/// Return only elements that contain other elements.
|
||||
/// </summary>
|
||||
Branch,
|
||||
|
||||
/// <summary>
|
||||
/// Return only elements that represent items.
|
||||
/// </summary>
|
||||
Item
|
||||
}
|
||||
}
|
||||
97
Technosoftware/DaAeHdaClient/Da/BrowseFilters.cs
Normal file
97
Technosoftware/DaAeHdaClient/Da/BrowseFilters.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a set of filters to apply when browsing.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaBrowseFilters : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private TsCDaBrowseFilter browseFilter_ = TsCDaBrowseFilter.All;
|
||||
private TsDaPropertyID[] propertyIds_;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The maximum number of elements to return. Zero means no limit.
|
||||
/// </summary>
|
||||
public int MaxElementsReturned { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of element to return.
|
||||
/// </summary>
|
||||
public TsCDaBrowseFilter BrowseFilter
|
||||
{
|
||||
get => browseFilter_;
|
||||
set => browseFilter_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An expression used to match the name of the element.
|
||||
/// </summary>
|
||||
public string ElementNameFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A filter which has semantics that defined by the server.
|
||||
/// </summary>
|
||||
public string VendorFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether all supported properties to return with each element.
|
||||
/// </summary>
|
||||
public bool ReturnAllProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of names of the properties to return with each element.
|
||||
/// </summary>
|
||||
public TsDaPropertyID[] PropertyIDs
|
||||
{
|
||||
get => propertyIds_;
|
||||
set => propertyIds_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether property values should be returned with the properties.
|
||||
/// </summary>
|
||||
public bool ReturnPropertyValues { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCDaBrowseFilters)MemberwiseClone();
|
||||
clone.PropertyIDs = (TsDaPropertyID[])PropertyIDs?.Clone();
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
45
Technosoftware/DaAeHdaClient/Da/EuType.cs
Normal file
45
Technosoftware/DaAeHdaClient/Da/EuType.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary><para>Defines possible item engineering unit types</para></summary>
|
||||
public enum TsDaEuType
|
||||
{
|
||||
/// <summary>No engineering unit information available</summary>
|
||||
NoEnum = 0x01,
|
||||
/// <summary>
|
||||
/// Analog engineering unit - will contain a SAFE ARRAY of exactly two doubles
|
||||
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
|
||||
/// </summary>
|
||||
Analog = 0x02,
|
||||
/// <summary>
|
||||
/// Enumerated engineering unit - will contain a SAFE ARRAY of strings (VT_ARRAY |
|
||||
/// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN TRANSIT”,
|
||||
/// etc.) corresponding to sequential numeric values (0, 1, 2, etc.)
|
||||
/// </summary>
|
||||
Enumerated = 0x03
|
||||
}
|
||||
}
|
||||
109
Technosoftware/DaAeHdaClient/Da/IServer.cs
Normal file
109
Technosoftware/DaAeHdaClient/Da/IServer.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines functionality that is common to all OPC Data Access servers.
|
||||
/// </summary>
|
||||
public interface ITsDaServer : IOpcServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the filters applied by the server to any item results returned to the client.
|
||||
/// </summary>
|
||||
/// <returns>A bit mask indicating which fields should be returned in any item results.</returns>
|
||||
int GetResultFilters();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the filters applied by the server to any item results returned to the client.
|
||||
/// </summary>
|
||||
/// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param>
|
||||
void SetResultFilters(int filters);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current server status.
|
||||
/// </summary>
|
||||
/// <returns>The current server status.</returns>
|
||||
OpcServerStatus GetServerStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current values for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of items to read.</param>
|
||||
/// <returns>The results of the read operation for each item.</returns>
|
||||
TsCDaItemValueResult[] Read(TsCDaItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the value, quality and timestamp for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="values">The set of item values to write.</param>
|
||||
/// <returns>The results of the write operation for each item.</returns>
|
||||
OpcItemResult[] Write(TsCDaItemValue[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new subscription.
|
||||
/// </summary>
|
||||
/// <param name="state">The initial state of the subscription.</param>
|
||||
/// <returns>The new subscription object.</returns>
|
||||
ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a subscription and releases all resources allocated for it.
|
||||
/// </summary>
|
||||
/// <param name="subscription">The subscription to cancel.</param>
|
||||
void CancelSubscription(ITsCDaSubscription subscription);
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the children of a branch that meet the filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The identifier of branch which is the target of the search.</param>
|
||||
/// <param name="filters">The filters to use to limit the set of child elements returned.</param>
|
||||
/// <param name="position">An object used to continue a browse that could not be completed.</param>
|
||||
/// <returns>The set of elements found.</returns>
|
||||
TsCDaBrowseElement[] Browse(
|
||||
OpcItem itemId,
|
||||
TsCDaBrowseFilters filters,
|
||||
out TsCDaBrowsePosition position);
|
||||
|
||||
/// <summary>
|
||||
/// Continues a browse operation with previously specified search criteria.
|
||||
/// </summary>
|
||||
/// <param name="position">An object containing the browse operation state information.</param>
|
||||
/// <returns>The set of elements found.</returns>
|
||||
TsCDaBrowseElement[] BrowseNext(ref TsCDaBrowsePosition position);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the item properties for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="itemIds">A list of item identifiers.</param>
|
||||
/// <param name="propertyIDs">A list of properties to fetch for each item.</param>
|
||||
/// <param name="returnValues">Whether the property values should be returned with the properties.</param>
|
||||
/// <returns>A list of properties for each item.</returns>
|
||||
TsCDaItemPropertyCollection[] GetProperties(
|
||||
OpcItem[] itemIds,
|
||||
TsDaPropertyID[] propertyIDs,
|
||||
bool returnValues);
|
||||
}
|
||||
}
|
||||
226
Technosoftware/DaAeHdaClient/Da/ISubscription.cs
Normal file
226
Technosoftware/DaAeHdaClient/Da/ISubscription.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A subscription for a set of items on a single OPC server.
|
||||
/// </summary>
|
||||
public interface ITsCDaSubscription : IDisposable
|
||||
{
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// An event to receive data change updates.
|
||||
/// </summary>
|
||||
event TsCDaDataChangedEventHandler DataChangedEvent;
|
||||
#endregion
|
||||
|
||||
#region Result Filters
|
||||
/// <summary>
|
||||
/// Returns the filters applied by the server to any item results returned to the client.
|
||||
/// </summary>
|
||||
/// <returns>A bit mask indicating which fields should be returned in any item results.</returns>
|
||||
int GetResultFilters();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the filters applied by the server to any item results returned to the client.
|
||||
/// </summary>
|
||||
/// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param>
|
||||
void SetResultFilters(int filters);
|
||||
#endregion
|
||||
|
||||
#region State Management
|
||||
/// <summary>
|
||||
/// Returns the current state of the subscription.
|
||||
/// </summary>
|
||||
/// <returns>The current state of the subscription.</returns>
|
||||
TsCDaSubscriptionState GetState();
|
||||
|
||||
/// <summary>
|
||||
/// Changes the state of a subscription.
|
||||
/// </summary>
|
||||
/// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
|
||||
/// <param name="state">The new subscription state.</param>
|
||||
/// <returns>The actual subscription state after applying the changes.</returns>
|
||||
TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state);
|
||||
#endregion
|
||||
|
||||
#region Item Management
|
||||
/// <summary>
|
||||
/// Adds items to the subscription.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of items to add to the subscription.</param>
|
||||
/// <returns>The results of the add item operation for each item.</returns>
|
||||
TsCDaItemResult[] AddItems(TsCDaItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the state of items in the subscription
|
||||
/// </summary>
|
||||
/// <param name="masks">Specifies which item state parameters are being modified.</param>
|
||||
/// <param name="items">The new state for each item.</param>
|
||||
/// <returns>The results of the modify item operation for each item.</returns>
|
||||
TsCDaItemResult[] ModifyItems(int masks, TsCDaItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Removes items from the subscription.
|
||||
/// </summary>
|
||||
/// <param name="items">The identifiers (i.e. server handles) for the items being removed.</param>
|
||||
/// <returns>The results of the remove item operation for each item.</returns>
|
||||
OpcItemResult[] RemoveItems(OpcItem[] items);
|
||||
#endregion
|
||||
|
||||
#region Synchronous I/O
|
||||
/// <summary>
|
||||
/// Reads the values for a set of items in the subscription.
|
||||
/// </summary>
|
||||
/// <param name="items">The identifiers (i.e. server handles) for the items being read.</param>
|
||||
/// <returns>The value for each of items.</returns>
|
||||
TsCDaItemValueResult[] Read(TsCDaItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the value, quality and timestamp for a set of items in the subscription.
|
||||
/// </summary>
|
||||
/// <param name="items">The item values to write.</param>
|
||||
/// <returns>The results of the write operation for each item.</returns>
|
||||
OpcItemResult[] Write(TsCDaItemValue[] items);
|
||||
#endregion
|
||||
|
||||
#region Asynchronous I/O
|
||||
/// <summary>
|
||||
/// Begins an asynchronous read operation for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] Read(
|
||||
TsCDaItem[] items,
|
||||
object requestHandle,
|
||||
TsCDaReadCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Begins an asynchronous write operation for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of item values to write (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] Write(
|
||||
TsCDaItemValue[] items,
|
||||
object requestHandle,
|
||||
TsCDaWriteCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an asynchronous read or write operation.
|
||||
/// </summary>
|
||||
/// <param name="request">The object returned from the BeginRead or BeginWrite request.</param>
|
||||
/// <param name="callback">The function to invoke when the cancel completes.</param>
|
||||
void Cancel(IOpcRequest request, TsCDaCancelCompleteEventHandler callback);
|
||||
|
||||
/// <summary>
|
||||
/// Causes the server to send a data changed notification for all active items.
|
||||
/// </summary>
|
||||
void Refresh();
|
||||
|
||||
/// <summary>
|
||||
/// Causes the server to send a data changed notification for all active items.
|
||||
/// </summary>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
void Refresh(
|
||||
object requestHandle,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables data change notifications from the server.
|
||||
/// </summary>
|
||||
/// <param name="enabled">Whether data change notifications are enabled.</param>
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether data change notifications from the server are enabled.
|
||||
/// </summary>
|
||||
/// <returns>Whether data change notifications are enabled.</returns>
|
||||
bool GetEnabled();
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Delegate Declarations
|
||||
/// <summary>
|
||||
/// A delegate to receive data change updates from the server.
|
||||
/// </summary>
|
||||
/// <param name="subscriptionHandle">
|
||||
/// A unique identifier for the subscription assigned by the client. If the parameter
|
||||
/// <see cref="TsCDaSubscriptionState.ClientHandle">ClientHandle</see> is not defined this
|
||||
/// parameter is empty.
|
||||
/// </param>
|
||||
/// <param name="requestHandle">
|
||||
/// An identifier for the request assigned by the caller. This parameter is empty if
|
||||
/// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined.
|
||||
/// Can be used to Cancel an outstanding operation.
|
||||
/// </param>
|
||||
/// <param name="values">
|
||||
/// <para class="MsoBodyText" style="MARGIN: 1pt 0in">The set of changed values.</para>
|
||||
/// <para class="MsoBodyText" style="MARGIN: 1pt 0in">Each value will always have
|
||||
/// item’s ClientHandle field specified.</para>
|
||||
/// </param>
|
||||
public delegate void TsCDaDataChangedEventHandler(object subscriptionHandle, object requestHandle, TsCDaItemValueResult[] values);
|
||||
|
||||
/// <summary>
|
||||
/// A delegate to receive asynchronous read completed notifications.
|
||||
/// </summary>
|
||||
/// <param name="requestHandle">
|
||||
/// An identifier for the request assigned by the caller. This parameter is empty if
|
||||
/// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined.
|
||||
/// Can be used to Cancel an outstanding operation.
|
||||
/// </param>
|
||||
/// <param name="results">The results of the last asynchronous read operation.</param>
|
||||
public delegate void TsCDaReadCompleteEventHandler(object requestHandle, TsCDaItemValueResult[] results);
|
||||
|
||||
/// <summary>
|
||||
/// A delegate to receive asynchronous write completed notifications.
|
||||
/// </summary>
|
||||
/// <param name="requestHandle">
|
||||
/// An identifier for the request assigned by the caller. This parameter is empty if
|
||||
/// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined.
|
||||
/// Can be used to Cancel an outstanding operation.
|
||||
/// </param>
|
||||
/// <param name="results">The results of the last asynchronous write operation.</param>
|
||||
public delegate void TsCDaWriteCompleteEventHandler(object requestHandle, OpcItemResult[] results);
|
||||
|
||||
/// <summary>
|
||||
/// A delegate to receive asynchronous cancel completed notifications.
|
||||
/// </summary>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
public delegate void TsCDaCancelCompleteEventHandler(object requestHandle);
|
||||
#endregion
|
||||
}
|
||||
150
Technosoftware/DaAeHdaClient/Da/Item.cs
Normal file
150
Technosoftware/DaAeHdaClient/Da/Item.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes how an item in the server address space should be accessed.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItem : OpcItem
|
||||
{
|
||||
#region Fields
|
||||
private bool active_ = true;
|
||||
private float deadband_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCDaItem() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCDaItem(OpcItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItemName = item.ItemName;
|
||||
ItemPath = item.ItemPath;
|
||||
ClientHandle = item.ClientHandle;
|
||||
ServerHandle = item.ServerHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCDaItem(TsCDaItem item)
|
||||
: base(item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ReqType = item.ReqType;
|
||||
MaxAge = item.MaxAge;
|
||||
MaxAgeSpecified = item.MaxAgeSpecified;
|
||||
Active = item.Active;
|
||||
ActiveSpecified = item.ActiveSpecified;
|
||||
Deadband = item.Deadband;
|
||||
DeadbandSpecified = item.DeadbandSpecified;
|
||||
SamplingRate = item.SamplingRate;
|
||||
SamplingRateSpecified = item.SamplingRateSpecified;
|
||||
EnableBuffering = item.EnableBuffering;
|
||||
EnableBufferingSpecified = item.EnableBufferingSpecified;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The data type to use when returning the item value.
|
||||
/// </summary>
|
||||
public Type ReqType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The oldest (in milliseconds) acceptable cached value when reading an item.
|
||||
/// </summary>
|
||||
public int MaxAge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Max Age is specified.
|
||||
/// </summary>
|
||||
public bool MaxAgeSpecified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server should send data change updates.
|
||||
/// </summary>
|
||||
public bool Active
|
||||
{
|
||||
get => active_;
|
||||
set => active_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Active state is specified.
|
||||
/// </summary>
|
||||
public bool ActiveSpecified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The minimum percentage change required to trigger a data update for an item.
|
||||
/// </summary>
|
||||
public float Deadband
|
||||
{
|
||||
get => deadband_;
|
||||
set => deadband_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Deadband is specified.
|
||||
/// </summary>
|
||||
public bool DeadbandSpecified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How frequently the server should sample the item value.
|
||||
/// </summary>
|
||||
public int SamplingRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Sampling Rate is specified.
|
||||
/// </summary>
|
||||
public bool SamplingRateSpecified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server should buffer multiple data changes between data updates.
|
||||
/// </summary>
|
||||
public bool EnableBuffering { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Enable Buffering is specified.
|
||||
/// </summary>
|
||||
public bool EnableBufferingSpecified { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
313
Technosoftware/DaAeHdaClient/Da/ItemCollection.cs
Normal file
313
Technosoftware/DaAeHdaClient/Da/ItemCollection.cs
Normal file
@@ -0,0 +1,313 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of items.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemCollection : ICloneable, IList
|
||||
{
|
||||
#region Fields
|
||||
private ArrayList items_ = new ArrayList();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCDaItemCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ResultCollection object.
|
||||
/// </summary>
|
||||
public TsCDaItemCollection(TsCDaItemCollection items)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (TsCDaItem item in items)
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the item at the specified index.
|
||||
/// </summary>
|
||||
public TsCDaItem this[int index]
|
||||
{
|
||||
get => (TsCDaItem)items_[index];
|
||||
set => items_[index] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first item with the specified item id.
|
||||
/// </summary>
|
||||
public TsCDaItem this[OpcItem itemId]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (TsCDaItem item in items_)
|
||||
{
|
||||
if (itemId.Key == item.Key)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCDaItemCollection)MemberwiseClone();
|
||||
|
||||
clone.items_ = new ArrayList();
|
||||
|
||||
foreach (TsCDaItem item in items_)
|
||||
{
|
||||
clone.items_.Add(item.Clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => items_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
items_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCDaItem[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return items_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => items_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!typeof(TsCDaItem).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
items_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
items_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!typeof(TsCDaItem).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
items_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
items_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return items_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
items_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return items_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!typeof(TsCDaItem).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
return items_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCDaItem value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCDaItem value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCDaItem value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCDaItem value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCDaItem value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
100
Technosoftware/DaAeHdaClient/Da/ItemProperty.cs
Normal file
100
Technosoftware/DaAeHdaClient/Da/ItemProperty.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a description of a single item property.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemProperty : ICloneable, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The property identifier.
|
||||
/// </summary>
|
||||
public TsDaPropertyID ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the property.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The data type of the property.
|
||||
/// </summary>
|
||||
public Type DataType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The value of the property.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The primary identifier for the property if it is directly accessible as an item.
|
||||
/// </summary>
|
||||
public string ItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The secondary identifier for the property if it is directly accessible as an item.
|
||||
/// </summary>
|
||||
public string ItemPath { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The <see cref="OpcResult" /> object with the result of an operation on an property.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCDaItemProperty)MemberwiseClone();
|
||||
clone.Value = OpcConvert.Clone(Value);
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
175
Technosoftware/DaAeHdaClient/Da/ItemPropertyCollection.cs
Normal file
175
Technosoftware/DaAeHdaClient/Da/ItemPropertyCollection.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// A list of properties for a single item.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemPropertyCollection : ArrayList, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with its default values.
|
||||
/// </summary>
|
||||
public TsCDaItemPropertyCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified item identifier.
|
||||
/// </summary>
|
||||
public TsCDaItemPropertyCollection(OpcItem itemId)
|
||||
{
|
||||
if (itemId != null)
|
||||
{
|
||||
ItemName = itemId.ItemName;
|
||||
ItemPath = itemId.ItemPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified item identifier and result.
|
||||
/// </summary>
|
||||
public TsCDaItemPropertyCollection(OpcItem itemId, OpcResult result)
|
||||
{
|
||||
if (itemId != null)
|
||||
{
|
||||
ItemName = itemId.ItemName;
|
||||
ItemPath = itemId.ItemPath;
|
||||
}
|
||||
|
||||
result_ = result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The primary identifier for the item within the server namespace.
|
||||
/// </summary>
|
||||
public string ItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An secondary identifier for the item within the server namespace.
|
||||
/// </summary>
|
||||
public string ItemPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Accesses the items at the specified index.
|
||||
/// </summary>
|
||||
public new TsCDaItemProperty this[int index]
|
||||
{
|
||||
get => (TsCDaItemProperty)base[index];
|
||||
set => base[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCDaItemProperty[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCDaItemProperty value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCDaItemProperty value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCDaItemProperty value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCDaItemProperty value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCDaItemProperty value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
104
Technosoftware/DaAeHdaClient/Da/ItemResult.cs
Normal file
104
Technosoftware/DaAeHdaClient/Da/ItemResult.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// The results of an operation on a uniquely identifiable item.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemResult : TsCDaItem, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCDaItemResult() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCDaItemResult(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemIdentifier object and Result.
|
||||
/// </summary>
|
||||
public TsCDaItemResult(OpcItem item, OpcResult resultId)
|
||||
: base(item)
|
||||
{
|
||||
Result = resultId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an Item object.
|
||||
/// </summary>
|
||||
public TsCDaItemResult(TsCDaItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an Item object and Result.
|
||||
/// </summary>
|
||||
public TsCDaItemResult(TsCDaItem item, OpcResult resultId)
|
||||
: base(item)
|
||||
{
|
||||
Result = resultId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemResult object.
|
||||
/// </summary>
|
||||
public TsCDaItemResult(TsCDaItemResult item)
|
||||
: base(item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
Result = item.Result;
|
||||
DiagnosticInfo = item.DiagnosticInfo;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an property.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
137
Technosoftware/DaAeHdaClient/Da/ItemValue.cs
Normal file
137
Technosoftware/DaAeHdaClient/Da/ItemValue.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains the value for a single item.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemValue : OpcItem
|
||||
{
|
||||
#region Fields
|
||||
private TsCDaQuality daQuality_ = TsCDaQuality.Bad;
|
||||
private DateTime timestamp_ = DateTime.MinValue;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCDaItemValue() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with and ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCDaItemValue(OpcItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItemName = item.ItemName;
|
||||
ItemPath = item.ItemPath;
|
||||
ClientHandle = item.ClientHandle;
|
||||
ServerHandle = item.ServerHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified item name.
|
||||
/// </summary>
|
||||
public TsCDaItemValue(string itemName)
|
||||
: base(itemName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemValue object.
|
||||
/// </summary>
|
||||
public TsCDaItemValue(TsCDaItemValue item)
|
||||
: base(item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Value = OpcConvert.Clone(item.Value);
|
||||
Quality = item.Quality;
|
||||
QualitySpecified = item.QualitySpecified;
|
||||
Timestamp = item.Timestamp;
|
||||
TimestampSpecified = item.TimestampSpecified;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The item value.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The quality of the item value.
|
||||
/// </summary>
|
||||
public TsCDaQuality Quality
|
||||
{
|
||||
get => daQuality_;
|
||||
set => daQuality_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the quality is specified.
|
||||
/// </summary>
|
||||
public bool QualitySpecified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timestamp for the item value.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get => timestamp_;
|
||||
set => timestamp_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the timestamp is specified.
|
||||
/// </summary>
|
||||
public bool TimestampSpecified { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var clone = (TsCDaItemValue)MemberwiseClone();
|
||||
clone.Value = OpcConvert.Clone(Value);
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
123
Technosoftware/DaAeHdaClient/Da/ItemValueResult.cs
Normal file
123
Technosoftware/DaAeHdaClient/Da/ItemValueResult.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// The results of an operation on a uniquely identifiable item value.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaItemValueResult : TsCDaItemValue, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with an ItemValue object.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(TsCDaItemValue item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemValueResult object.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(TsCDaItemValueResult item)
|
||||
: base(item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
Result = item.Result;
|
||||
DiagnosticInfo = item.DiagnosticInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified item name and result code.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(string itemName, OpcResult resultId)
|
||||
: base(itemName)
|
||||
{
|
||||
Result = resultId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified item name, result code and diagnostic info.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(string itemName, OpcResult resultId, string diagnosticInfo)
|
||||
: base(itemName)
|
||||
{
|
||||
Result = resultId;
|
||||
DiagnosticInfo = diagnosticInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize object with the specified ItemIdentifier and result code.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(OpcItem item, OpcResult resultId)
|
||||
: base(item)
|
||||
{
|
||||
Result = resultId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified ItemIdentifier, result code and diagnostic info.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult(OpcItem item, OpcResult resultId, string diagnosticInfo)
|
||||
: base(item)
|
||||
{
|
||||
Result = resultId;
|
||||
DiagnosticInfo = diagnosticInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an property.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
44
Technosoftware/DaAeHdaClient/Da/LimitBits.cs
Normal file
44
Technosoftware/DaAeHdaClient/Da/LimitBits.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Defines the possible limit status bits.</para>
|
||||
/// <para>The Limit Field is valid regardless of the Quality and Substatus. In some
|
||||
/// cases such as Sensor Failure it can provide useful diagnostic information.</para>
|
||||
/// </summary>
|
||||
public enum TsDaLimitBits
|
||||
{
|
||||
/// <summary>The value is free to move up or down</summary>
|
||||
None = 0x0,
|
||||
/// <summary>The value has ‘pegged’ at some lower limit</summary>
|
||||
Low = 0x1,
|
||||
/// <summary>The value has ‘pegged’ at some high limit</summary>
|
||||
High = 0x2,
|
||||
/// <summary>The value is a constant and cannot move</summary>
|
||||
Constant = 0x3
|
||||
}
|
||||
}
|
||||
328
Technosoftware/DaAeHdaClient/Da/Property.cs
Normal file
328
Technosoftware/DaAeHdaClient/Da/Property.cs
Normal file
@@ -0,0 +1,328 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines identifiers for well-known properties.
|
||||
/// </summary>
|
||||
public class TsDaProperty
|
||||
{
|
||||
#region Data Access Properties
|
||||
|
||||
/// <summary><para>Item Canonical DataType</para></summary>
|
||||
public static readonly TsDaPropertyID DATATYPE = new TsDaPropertyID("dataType", 1, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Item Value</para></summary>
|
||||
/// <remarks>
|
||||
/// Note the type of value returned is as indicated by the "Item Canonical DataType"
|
||||
/// and depends on the item. This will behave like a read from DEVICE.
|
||||
/// </remarks>
|
||||
public static readonly TsDaPropertyID VALUE = new TsDaPropertyID("value", 2, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Item Quality</para></summary>
|
||||
/// <remarks>(OPCQUALITY stored in an I2). This will behave like a read from DEVICE.</remarks>
|
||||
public static readonly TsDaPropertyID QUALITY = new TsDaPropertyID("quality", 3, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Item Timestamp</para></summary>
|
||||
/// <remarks>
|
||||
/// (will be converted from FILETIME). This will behave like a read from
|
||||
/// DEVICE.
|
||||
/// </remarks>
|
||||
public static readonly TsDaPropertyID TIMESTAMP = new TsDaPropertyID("timestamp", 4, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Item Access Rights</para></summary>
|
||||
/// <remarks>(OPCACCESSRIGHTS stored in an I4)</remarks>
|
||||
public static readonly TsDaPropertyID ACCESSRIGHTS = new TsDaPropertyID("accessRights", 5, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Server Scan Rate</para></summary>
|
||||
/// <remarks>
|
||||
/// In Milliseconds. This represents the fastest rate at which the server could
|
||||
/// obtain data from the underlying data source. The nature of this source is not defined
|
||||
/// but is typically a DCS system, a SCADA system, a PLC via a COMM port or network, a
|
||||
/// Device Network, etc. This value generally represents the ‘best case’ fastest
|
||||
/// RequestedUpdateRate which could be used if this item were added to an OPCGroup.<br/>
|
||||
/// The accuracy of this value (the ability of the server to attain ‘best case’
|
||||
/// performance) can be greatly affected by system load and other factors.
|
||||
/// </remarks>
|
||||
public static readonly TsDaPropertyID SCANRATE = new TsDaPropertyID("scanRate", 6, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <remarks>
|
||||
/// <para>Indicate the type of Engineering Units (EU) information (if any) contained in
|
||||
/// EUINFO.</para>
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// 0 - No EU information available (EUINFO will be VT_EMPTY).
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// 1 - Analog - EUINFO will contain a SAFEARRAY of exactly two doubles
|
||||
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
|
||||
/// </item>
|
||||
/// <item>2 - Enumerated - EUINFO will contain a SAFEARRAY of strings (VT_ARRAY |
|
||||
/// VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”, “IN
|
||||
/// TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2,
|
||||
/// etc.)</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <summary><para>Item EU Type</para></summary>
|
||||
public static readonly TsDaPropertyID EUTYPE = new TsDaPropertyID("euType", 7, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary><para>Item EUInfo</para></summary>
|
||||
/// <value>
|
||||
/// <para>
|
||||
/// If EUTYPE is “Analog” EUINFO will contain a SAFEARRAY of exactly two doubles
|
||||
/// (VT_ARRAY | VT_R8) corresponding to the LOW and HI EU range.
|
||||
/// </para>
|
||||
/// <para>If EUTYPE is “Enumerated” - EUINFO will contain a SAFEARRAY of strings
|
||||
/// (VT_ARRAY | VT_BSTR) which contains a list of strings (Example: “OPEN”, “CLOSE”,
|
||||
/// “IN TRANSIT”, etc.) corresponding to sequential numeric values (0, 1, 2,
|
||||
/// etc.)</para>
|
||||
/// </value>
|
||||
public static readonly TsDaPropertyID EUINFO = new TsDaPropertyID("euInfo", 8, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>EU Units</para>
|
||||
/// <para>e.g. "DEGC" or "GALLONS"</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID ENGINEERINGUINTS = new TsDaPropertyID("engineeringUnits", 100, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Item Description</para>
|
||||
/// <para>e.g. "Evaporator 6 Coolant Temp"</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID DESCRIPTION = new TsDaPropertyID("description", 101, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>High EU</para>
|
||||
/// <para>Present only for 'analog' data. This represents the highest value likely to
|
||||
/// be obtained in normal operation and is intended for such use as automatically
|
||||
/// scaling a bargraph display.</para>
|
||||
/// <para>e.g. 1400.0</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID HIGHEU = new TsDaPropertyID("highEU", 102, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Low EU</para>
|
||||
/// <para>Present only for 'analog' data. This represents the lowest value likely to be
|
||||
/// obtained in normal operation and is intended for such use as automatically scaling
|
||||
/// a bargraph display.</para>
|
||||
/// <para>e.g. -200.0</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID LOWEU = new TsDaPropertyID("lowEU", 103, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>High Instrument Range</para>
|
||||
/// <para>Present only for ‘analog’ data. This represents the highest value that can be
|
||||
/// returned by the instrument.</para>
|
||||
/// <para>e.g. 9999.9</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID HIGHIR = new TsDaPropertyID("highIR", 104, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Low Instrument Range</para>
|
||||
/// <para>Present only for ‘analog’ data. This represents the lowest value that can be
|
||||
/// returned by the instrument.</para>
|
||||
/// <para>e.g. -9999.9</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID LOWIR = new TsDaPropertyID("lowIR", 105, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contact Close Label</para>
|
||||
/// <para>Present only for ‘discrete' data. This represents a string to be associated
|
||||
/// with this contact when it is in the closed (non-zero) state</para>
|
||||
/// <para>e.g. "RUN", "CLOSE", "ENABLE", "SAFE" ,etc.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID CLOSELABEL = new TsDaPropertyID("closeLabel", 106, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contact Open Label</para>
|
||||
/// <para>Present only for ‘discrete' data. This represents a string to be associated
|
||||
/// with this contact when it is in the open (zero) state</para>
|
||||
/// <para>e.g. "STOP", "OPEN", "DISABLE", "UNSAFE" ,etc.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID OPENLABEL = new TsDaPropertyID("openLabel", 107, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Item Timezone</para>
|
||||
/// <para>The difference in minutes between the items UTC Timestamp and the local time
|
||||
/// in which the item value was obtained.</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the OPCGroup TimeBias property. Also see the WIN32 TIME_ZONE_INFORMATION
|
||||
/// structure.
|
||||
/// </remarks>
|
||||
public static readonly TsDaPropertyID TIMEZONE = new TsDaPropertyID("timeZone", 108, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Condition Status</para>
|
||||
/// <para>The current alarm or condition status associated with the Item<br/>
|
||||
/// e.g. "NORMAL", "ACTIVE", "HI ALARM", etc</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID CONDITION_STATUS = new TsDaPropertyID("conditionStatus", 300, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Alarm Quick Help</para>
|
||||
/// <para>A short text string providing a brief set of instructions for the operator to
|
||||
/// follow when this alarm occurs.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID ALARM_QUICK_HELP = new TsDaPropertyID("alarmQuickHelp", 301, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Alarm Area List</para>
|
||||
/// <para>An array of stings indicating the plant or alarm areas which include this
|
||||
/// ItemID.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID ALARM_AREA_LIST = new TsDaPropertyID("alarmAreaList", 302, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Primary Alarm Area</para>
|
||||
/// <para>A string indicating the primary plant or alarm area including this
|
||||
/// ItemID</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID PRIMARY_ALARM_AREA = new TsDaPropertyID("primaryAlarmArea", 303, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Condition Logic</para>
|
||||
/// <para>An arbitrary string describing the test being performed.</para>
|
||||
/// <para>e.g. "High Limit Exceeded" or "TAG.PV >= TAG.HILIM"</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID CONDITION_LOGIC = new TsDaPropertyID("conditionLogic", 304, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Limit Exceeded</para>
|
||||
/// <para>For multistate alarms, the condition exceeded</para>
|
||||
/// <para>e.g. HIHI, HI, LO, LOLO</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID LIMIT_EXCEEDED = new TsDaPropertyID("limitExceeded", 305, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>Deadband</summary>
|
||||
public static readonly TsDaPropertyID DEADBAND = new TsDaPropertyID("deadband", 306, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>HiHi limit</summary>
|
||||
public static readonly TsDaPropertyID HIHI_LIMIT = new TsDaPropertyID("hihiLimit", 307, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>Hi Limit</summary>
|
||||
public static readonly TsDaPropertyID HI_LIMIT = new TsDaPropertyID("hiLimit", 308, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>Lo Limit</summary>
|
||||
public static readonly TsDaPropertyID LO_LIMIT = new TsDaPropertyID("loLimit", 309, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>LoLo Limit</summary>
|
||||
public static readonly TsDaPropertyID LOLO_LIMIT = new TsDaPropertyID("loloLimit", 310, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>Rate of Change Limit</summary>
|
||||
public static readonly TsDaPropertyID RATE_CHANGE_LIMIT = new TsDaPropertyID("rangeOfChangeLimit", 311, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>Deviation Limit</summary>
|
||||
public static readonly TsDaPropertyID DEVIATION_LIMIT = new TsDaPropertyID("deviationLimit", 312, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Sound File</para>
|
||||
/// <para>e.g. C:\MEDIA\FIC101.WAV, or .MID</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID SOUNDFILE = new TsDaPropertyID("soundFile", 313, OpcNamespace.OPC_DATA_ACCESS);
|
||||
#endregion
|
||||
|
||||
#region Complex Data Properties
|
||||
/// <summary>
|
||||
/// <para>Type System ID</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID TYPE_SYSTEM_ID = new TsDaPropertyID("typeSystemID", 600, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Dictionary ID</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID DICTIONARY_ID = new TsDaPropertyID("dictionaryID", 601, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Type ID</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID TYPE_ID = new TsDaPropertyID("typeID", 602, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Dictionary</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID DICTIONARY = new TsDaPropertyID("dictionary", 603, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Type description</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID TYPE_DESCRIPTION = new TsDaPropertyID("typeDescription", 604, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Consistency Window</para>
|
||||
/// <para>Complex Data Property</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID CONSISTENCY_WINDOW = new TsDaPropertyID("consistencyWindow", 605, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Write Behaviour</para>
|
||||
/// <para>Complex Data Property, defaults to “All or Nothing” if the complex data item
|
||||
/// is writable. Not used for Read-Only items.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID WRITE_BEHAVIOR = new TsDaPropertyID("writeBehavior", 606, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Unconverted Item ID</para>
|
||||
/// <para>Complex Data Property, the ID of the item that exposes the same complex data
|
||||
/// value in its native format. This property is mandatory for items that implement
|
||||
/// complex data type conversions.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID UNCONVERTED_ITEM_ID = new TsDaPropertyID("unconvertedItemID", 607, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>Unfiltered Item ID</para>
|
||||
/// <para>Complex Data Property, the ID the item that exposes the same complex data
|
||||
/// value without any data filter or with the default query applied to it. It is
|
||||
/// mandatory for items that implement complex data filters or queries.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID UNFILTERED_ITEM_ID = new TsDaPropertyID("unfilteredItemID", 608, OpcNamespace.OPC_DATA_ACCESS);
|
||||
|
||||
/// <summary>
|
||||
/// <para>Data Filter Value</para>
|
||||
/// <para>Complex Data Property, the value of the filter that is currently applied to
|
||||
/// the item. It is mandatory for items that implement complex data filters or
|
||||
/// queries.</para>
|
||||
/// </summary>
|
||||
public static readonly TsDaPropertyID DATA_FILTER_VALUE = new TsDaPropertyID("dataFilterValue", 609, OpcNamespace.OPC_DATA_ACCESS);
|
||||
#endregion
|
||||
|
||||
#region XML Data Access Properties
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyID MINIMUM_VALUE = new TsDaPropertyID("minimumValue", 109, OpcNamespace.OPC_DATA_ACCESS);
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyID MAXIMUM_VALUE = new TsDaPropertyID("maximumValue", 110, OpcNamespace.OPC_DATA_ACCESS);
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyID VALUE_PRECISION = new TsDaPropertyID("valuePrecision", 111, OpcNamespace.OPC_DATA_ACCESS);
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
200
Technosoftware/DaAeHdaClient/Da/PropertyDescription.cs
Normal file
200
Technosoftware/DaAeHdaClient/Da/PropertyDescription.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item property.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsDaPropertyDescription
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified values.
|
||||
/// </summary>
|
||||
public TsDaPropertyDescription(TsDaPropertyID id, Type type, string name)
|
||||
{
|
||||
ID = id;
|
||||
Type = type;
|
||||
Name = name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The unique identifier for the property.
|
||||
/// </summary>
|
||||
public TsDaPropertyID ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The .NET data type for the property.
|
||||
/// </summary>
|
||||
public Type Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The short description defined in the OPC specifications.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Data Access Properties
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DATATYPE = new TsDaPropertyDescription(TsDaProperty.DATATYPE, typeof(Type), "Item Canonical DataType");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription VALUE = new TsDaPropertyDescription(TsDaProperty.VALUE, typeof(object), "Item Value");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription QUALITY = new TsDaPropertyDescription(TsDaProperty.QUALITY, typeof(TsCDaQuality), "Item Quality");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription TIMESTAMP = new TsDaPropertyDescription(TsDaProperty.TIMESTAMP, typeof(DateTime), "Item Timestamp");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription ACCESSRIGHTS = new TsDaPropertyDescription(TsDaProperty.ACCESSRIGHTS, typeof(TsDaAccessRights), "Item Access Rights");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription SCANRATE = new TsDaPropertyDescription(TsDaProperty.SCANRATE, typeof(float), "Server Scan Rate");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription EUTYPE = new TsDaPropertyDescription(TsDaProperty.EUTYPE, typeof(TsDaEuType), "Item EU Type");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription EUINFO = new TsDaPropertyDescription(TsDaProperty.EUINFO, typeof(string[]), "Item EU Info");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription ENGINEERINGUINTS = new TsDaPropertyDescription(TsDaProperty.ENGINEERINGUINTS, typeof(string), "EU Units");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.DESCRIPTION, typeof(string), "Item Description");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription HIGHEU = new TsDaPropertyDescription(TsDaProperty.HIGHEU, typeof(double), "High EU");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription LOWEU = new TsDaPropertyDescription(TsDaProperty.LOWEU, typeof(double), "Low EU");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription HIGHIR = new TsDaPropertyDescription(TsDaProperty.HIGHIR, typeof(double), "High Instrument Range");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription LOWIR = new TsDaPropertyDescription(TsDaProperty.LOWIR, typeof(double), "Low Instrument Range");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription CLOSELABEL = new TsDaPropertyDescription(TsDaProperty.CLOSELABEL, typeof(string), "Contact Close Label");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription OPENLABEL = new TsDaPropertyDescription(TsDaProperty.OPENLABEL, typeof(string), "Contact Open Label");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription TIMEZONE = new TsDaPropertyDescription(TsDaProperty.TIMEZONE, typeof(int), "Timezone");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription CONDITION_STATUS = new TsDaPropertyDescription(TsDaProperty.CONDITION_STATUS, typeof(string), "Condition Status");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription ALARM_QUICK_HELP = new TsDaPropertyDescription(TsDaProperty.ALARM_QUICK_HELP, typeof(string), "Alarm Quick Help");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription ALARM_AREA_LIST = new TsDaPropertyDescription(TsDaProperty.ALARM_AREA_LIST, typeof(string), "Alarm Area List");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription PRIMARY_ALARM_AREA = new TsDaPropertyDescription(TsDaProperty.PRIMARY_ALARM_AREA, typeof(string), "Primary Alarm Area");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription CONDITION_LOGIC = new TsDaPropertyDescription(TsDaProperty.CONDITION_LOGIC, typeof(string), "Condition Logic");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription LIMIT_EXCEEDED = new TsDaPropertyDescription(TsDaProperty.LIMIT_EXCEEDED, typeof(string), "Limit Exceeded");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DEADBAND = new TsDaPropertyDescription(TsDaProperty.DEADBAND, typeof(double), "Deadband");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription HIHI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HIHI_LIMIT, typeof(double), "HiHi Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription HI_LIMIT = new TsDaPropertyDescription(TsDaProperty.HI_LIMIT, typeof(double), "Hi Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription LO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LO_LIMIT, typeof(double), "Lo Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription LOLO_LIMIT = new TsDaPropertyDescription(TsDaProperty.LOLO_LIMIT, typeof(double), "LoLo Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription RATE_CHANGE_LIMIT = new TsDaPropertyDescription(TsDaProperty.RATE_CHANGE_LIMIT, typeof(double), "Rate of Change Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DEVIATION_LIMIT = new TsDaPropertyDescription(TsDaProperty.DEVIATION_LIMIT, typeof(double), "Deviation Limit");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription SOUNDFILE = new TsDaPropertyDescription(TsDaProperty.SOUNDFILE, typeof(string), "Sound File");
|
||||
#endregion
|
||||
|
||||
#region Complex Data Properties
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription TYPE_SYSTEM_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_SYSTEM_ID, typeof(string), "Type System ID");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DICTIONARY_ID = new TsDaPropertyDescription(TsDaProperty.DICTIONARY_ID, typeof(string), "Dictionary ID");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription TYPE_ID = new TsDaPropertyDescription(TsDaProperty.TYPE_ID, typeof(string), "Type ID");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DICTIONARY = new TsDaPropertyDescription(TsDaProperty.DICTIONARY, typeof(object), "Dictionary");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription TYPE_DESCRIPTION = new TsDaPropertyDescription(TsDaProperty.TYPE_DESCRIPTION, typeof(string), "Type Description");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription CONSISTENCY_WINDOW = new TsDaPropertyDescription(TsDaProperty.CONSISTENCY_WINDOW, typeof(string), "Consistency Window");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription WRITE_BEHAVIOR = new TsDaPropertyDescription(TsDaProperty.WRITE_BEHAVIOR, typeof(string), "Write Behavior");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription UNCONVERTED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNCONVERTED_ITEM_ID, typeof(string), "Unconverted Item ID");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription UNFILTERED_ITEM_ID = new TsDaPropertyDescription(TsDaProperty.UNFILTERED_ITEM_ID, typeof(string), "Unfiltered Item ID");
|
||||
/// <remarks/>
|
||||
public static readonly TsDaPropertyDescription DATA_FILTER_VALUE = new TsDaPropertyDescription(TsDaProperty.DATA_FILTER_VALUE, typeof(string), "Data Filter Value");
|
||||
#endregion
|
||||
|
||||
#region Object Member Overrides
|
||||
/// <summary>
|
||||
/// Converts the description to a string.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns the description for the specified property.
|
||||
/// </summary>
|
||||
public static TsDaPropertyDescription Find(TsDaPropertyID id)
|
||||
{
|
||||
var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public);
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var property = (TsDaPropertyDescription)field.GetValue(typeof(TsDaPropertyDescription));
|
||||
|
||||
if (property.ID == id)
|
||||
{
|
||||
return property;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of all well-known property descriptions.
|
||||
/// </summary>
|
||||
public static TsDaPropertyDescription[] Enumerate()
|
||||
{
|
||||
var values = new ArrayList();
|
||||
|
||||
var fields = typeof(TsDaPropertyDescription).GetFields(BindingFlags.Static | BindingFlags.Public);
|
||||
|
||||
Array.ForEach(fields, field => values.Add(field.GetValue(typeof(TsDaPropertyDescription))));
|
||||
|
||||
return (TsDaPropertyDescription[])values.ToArray(typeof(TsDaPropertyDescription));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
198
Technosoftware/DaAeHdaClient/Da/PropertyID.cs
Normal file
198
Technosoftware/DaAeHdaClient/Da/PropertyID.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a unique identifier for a property.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TsDaPropertyID : ISerializable
|
||||
{
|
||||
#region Names Class
|
||||
/// <summary>
|
||||
/// A set of names for fields used in serialization.
|
||||
/// </summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string Name = "NA";
|
||||
internal const string Namespace = "NS";
|
||||
internal const string Code = "CO";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private int code_;
|
||||
private XmlQualifiedName qualifiedName_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a property identified by a qualified name.
|
||||
/// </summary>
|
||||
public TsDaPropertyID(XmlQualifiedName name) { qualifiedName_ = name; code_ = 0; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a property identified by an integer.
|
||||
/// </summary>
|
||||
public TsDaPropertyID(int code) { qualifiedName_ = null; code_ = code; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a property identified by a property description.
|
||||
/// </summary>
|
||||
public TsDaPropertyID(string name, int code, string ns) { qualifiedName_ = new XmlQualifiedName(name, ns); code_ = code; }
|
||||
|
||||
///<remarks>
|
||||
/// During deserialization, SerializationInfo is passed to the class using the constructor provided for this purpose. Any visibility
|
||||
/// constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public,
|
||||
/// protected, internal, or private. However, it is best practice to make the constructor protected unless the class is sealed, in which case
|
||||
/// the constructor should be marked private. The constructor should also perform thorough input validation. To avoid misuse by malicious code,
|
||||
/// the constructor should enforce the same security checks and permissions required to obtain an instance of the class using any other
|
||||
/// constructor.
|
||||
/// </remarks>
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
private TsDaPropertyID(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
var enumerator = info.GetEnumerator();
|
||||
var name = "";
|
||||
var ns = "";
|
||||
enumerator.Reset();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (enumerator.Current.Name.Equals(Names.Name))
|
||||
{
|
||||
name = (string)enumerator.Current.Value;
|
||||
continue;
|
||||
}
|
||||
if (enumerator.Current.Name.Equals(Names.Namespace))
|
||||
{
|
||||
ns = (string)enumerator.Current.Value;
|
||||
}
|
||||
}
|
||||
qualifiedName_ = new XmlQualifiedName(name, ns);
|
||||
code_ = (int)info.GetValue(Names.Code, typeof(int));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Used for properties identified by a qualified name.
|
||||
/// </summary>
|
||||
public XmlQualifiedName Name => qualifiedName_;
|
||||
|
||||
/// <summary>
|
||||
/// Used for properties identified by a integer.
|
||||
/// </summary>
|
||||
public int Code => code_;
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns true if the objects are equal.
|
||||
/// </summary>
|
||||
public static bool operator ==(TsDaPropertyID a, TsDaPropertyID b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the objects are not equal.
|
||||
/// </summary>
|
||||
public static bool operator !=(TsDaPropertyID a, TsDaPropertyID b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Serialization Functions
|
||||
/// <summary>
|
||||
/// Serializes a server into a stream.
|
||||
/// </summary>
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (qualifiedName_ != null)
|
||||
{
|
||||
info.AddValue(Names.Name, qualifiedName_.Name);
|
||||
info.AddValue(Names.Namespace, qualifiedName_.Namespace);
|
||||
}
|
||||
info.AddValue(Names.Code, code_);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Object Member Overrides
|
||||
/// <summary>
|
||||
/// Returns true if the target object is equal to the object.
|
||||
/// </summary>
|
||||
public override bool Equals(object target)
|
||||
{
|
||||
if (target != null && target.GetType() == typeof(TsDaPropertyID))
|
||||
{
|
||||
var propertyId = (TsDaPropertyID)target;
|
||||
|
||||
// compare by integer if both specify valid integers.
|
||||
if (propertyId.Code != 0 && Code != 0)
|
||||
{
|
||||
return (propertyId.Code == Code);
|
||||
}
|
||||
|
||||
// compare by name if both specify valid names.
|
||||
if (propertyId.Name != null && Name != null)
|
||||
{
|
||||
return (propertyId.Name == Name);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a useful hash code for the object.
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
if (Code != 0) return Code.GetHashCode();
|
||||
if (Name != null) return Name.GetHashCode();
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the property id to a string.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
if (Name != null && Code != 0) return $"{Name.Name} ({Code})";
|
||||
if (Name != null) return Name.Name;
|
||||
if (Code != 0) return $"{Code}";
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
251
Technosoftware/DaAeHdaClient/Da/Quality.cs
Normal file
251
Technosoftware/DaAeHdaClient/Da/Quality.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains the quality field for an item value.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TsCDaQuality
|
||||
{
|
||||
#region Fields
|
||||
private TsDaQualityBits qualityBits_;
|
||||
private TsDaLimitBits limitBits_;
|
||||
private byte vendorBits_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified quality.
|
||||
/// </summary>
|
||||
public TsCDaQuality(TsDaQualityBits quality)
|
||||
{
|
||||
qualityBits_ = quality;
|
||||
limitBits_ = TsDaLimitBits.None;
|
||||
vendorBits_ = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object from the contents of a 16 bit integer.
|
||||
/// </summary>
|
||||
public TsCDaQuality(short code)
|
||||
{
|
||||
qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask);
|
||||
limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask);
|
||||
vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The value in the quality bits field.
|
||||
/// </summary>
|
||||
public TsDaQualityBits QualityBits
|
||||
{
|
||||
get => qualityBits_;
|
||||
set => qualityBits_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value in the limit bits field.
|
||||
/// </summary>
|
||||
public TsDaLimitBits LimitBits
|
||||
{
|
||||
get => limitBits_;
|
||||
set => limitBits_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value in the quality bits field.
|
||||
/// </summary>
|
||||
public byte VendorBits
|
||||
{
|
||||
get => vendorBits_;
|
||||
set => vendorBits_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A 'good' quality value.
|
||||
/// </summary>
|
||||
public static readonly TsCDaQuality Good = new TsCDaQuality(TsDaQualityBits.Good);
|
||||
|
||||
/// <summary>
|
||||
/// An 'bad' quality value.
|
||||
/// </summary>
|
||||
public static readonly TsCDaQuality Bad = new TsCDaQuality(TsDaQualityBits.Bad);
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns the quality as a 16 bit integer.
|
||||
/// </summary>
|
||||
public short GetCode()
|
||||
{
|
||||
ushort code = 0;
|
||||
|
||||
code |= (ushort)QualityBits;
|
||||
code |= (ushort)LimitBits;
|
||||
code |= (ushort)(VendorBits << 8);
|
||||
|
||||
return (code <= short.MaxValue) ? (short)code : (short)-((ushort.MaxValue + 1 - code));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the quality from a 16 bit integer.
|
||||
/// </summary>
|
||||
public void SetCode(short code)
|
||||
{
|
||||
qualityBits_ = (TsDaQualityBits)(code & (short)TsDaQualityMasks.QualityMask);
|
||||
limitBits_ = (TsDaLimitBits)(code & (short)TsDaQualityMasks.LimitMask);
|
||||
vendorBits_ = (byte)((code & (short)TsDaQualityMasks.VendorMask) >> 8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the objects are equal.
|
||||
/// </summary>
|
||||
public static bool operator ==(TsCDaQuality a, TsCDaQuality b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the objects are not equal.
|
||||
/// </summary>
|
||||
public static bool operator !=(TsCDaQuality a, TsCDaQuality b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Object Member Overrides
|
||||
/// <summary>
|
||||
/// Converts a quality to a string with the format: 'quality[limit]:vendor'.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
string text = null;
|
||||
|
||||
switch (QualityBits)
|
||||
{
|
||||
case TsDaQualityBits.Good:
|
||||
text += "(Good";
|
||||
break;
|
||||
case TsDaQualityBits.GoodLocalOverride:
|
||||
text += "(Good:Local Override";
|
||||
break;
|
||||
case TsDaQualityBits.Bad:
|
||||
text += "(Bad";
|
||||
break;
|
||||
case TsDaQualityBits.BadConfigurationError:
|
||||
text += "(Bad:Configuration Error";
|
||||
break;
|
||||
case TsDaQualityBits.BadNotConnected:
|
||||
text += "(Bad:Not Connected";
|
||||
break;
|
||||
case TsDaQualityBits.BadDeviceFailure:
|
||||
text += "(Bad:Device Failure";
|
||||
break;
|
||||
case TsDaQualityBits.BadSensorFailure:
|
||||
text += "(Bad:Sensor Failure";
|
||||
break;
|
||||
case TsDaQualityBits.BadLastKnownValue:
|
||||
text += "(Bad:Last Known Value";
|
||||
break;
|
||||
case TsDaQualityBits.BadCommFailure:
|
||||
text += "(Bad:Communication Failure";
|
||||
break;
|
||||
case TsDaQualityBits.BadOutOfService:
|
||||
text += "(Bad:Out of Service";
|
||||
break;
|
||||
case TsDaQualityBits.BadWaitingForInitialData:
|
||||
text += "(Bad:Waiting for Initial Data";
|
||||
break;
|
||||
case TsDaQualityBits.Uncertain:
|
||||
text += "(Uncertain";
|
||||
break;
|
||||
case TsDaQualityBits.UncertainLastUsableValue:
|
||||
text += "(Uncertain:Last Usable Value";
|
||||
break;
|
||||
case TsDaQualityBits.UncertainSensorNotAccurate:
|
||||
text += "(Uncertain:Sensor not Accurate";
|
||||
break;
|
||||
case TsDaQualityBits.UncertainEUExceeded:
|
||||
text += "(Uncertain:Engineering Unit exceeded";
|
||||
break;
|
||||
case TsDaQualityBits.UncertainSubNormal:
|
||||
text += "(Uncertain:Sub Normal";
|
||||
break;
|
||||
}
|
||||
|
||||
if (LimitBits != TsDaLimitBits.None)
|
||||
{
|
||||
text += $":[{LimitBits.ToString()}]";
|
||||
}
|
||||
else
|
||||
{
|
||||
text += ":Not Limited";
|
||||
}
|
||||
|
||||
if (VendorBits != 0)
|
||||
{
|
||||
text += $":{VendorBits,0:X})";
|
||||
}
|
||||
else
|
||||
{
|
||||
text += ")";
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified Object is equal to the current Quality
|
||||
/// </summary>
|
||||
public override bool Equals(object target)
|
||||
{
|
||||
if (target == null || target.GetType() != typeof(TsCDaQuality)) return false;
|
||||
|
||||
var quality = (TsCDaQuality)target;
|
||||
|
||||
if (QualityBits != quality.QualityBits) return false;
|
||||
if (LimitBits != quality.LimitBits) return false;
|
||||
if (VendorBits != quality.VendorBits) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns hash code for the current Quality.
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetCode();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
114
Technosoftware/DaAeHdaClient/Da/QualityBits.cs
Normal file
114
Technosoftware/DaAeHdaClient/Da/QualityBits.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Defines the possible quality status bits.</para>
|
||||
/// <para>These flags represent the quality state for an item's data value. This is
|
||||
/// intended to be similar to but slightly simpler than the Field-bus Data Quality
|
||||
/// Specification (section 4.4.1 in the H1 Final Specifications). This design makes it
|
||||
/// fairly easy for both servers and client applications to determine how much
|
||||
/// functionality they want to implement.</para>
|
||||
/// </summary>
|
||||
public enum TsDaQualityBits
|
||||
{
|
||||
/// <summary>The Quality of the value is Good.</summary>
|
||||
Good = 0x000000C0,
|
||||
/// <summary>The value has been Overridden. Typically this means the input has been disconnected and a manually entered value has been 'forced'.</summary>
|
||||
GoodLocalOverride = 0x000000D8,
|
||||
/// <summary>The value is bad but no specific reason is known.</summary>
|
||||
Bad = 0x00000000,
|
||||
/// <summary>
|
||||
/// There is some server specific problem with the configuration. For example the
|
||||
/// item in question has been deleted from the configuration.
|
||||
/// </summary>
|
||||
BadConfigurationError = 0x00000004,
|
||||
/// <summary>
|
||||
/// The input is required to be logically connected to something but is not. This
|
||||
/// quality may reflect that no value is available at this time, for reasons like the value
|
||||
/// may have not been provided by the data source.
|
||||
/// </summary>
|
||||
BadNotConnected = 0x00000008,
|
||||
/// <summary>A device failure has been detected.</summary>
|
||||
BadDeviceFailure = 0x0000000c,
|
||||
/// <summary>
|
||||
/// A sensor failure had been detected (the ’Limits’ field can provide additional
|
||||
/// diagnostic information in some situations).
|
||||
/// </summary>
|
||||
BadSensorFailure = 0x00000010,
|
||||
/// <summary>
|
||||
/// Communications have failed. However, the last known value is available. Note that
|
||||
/// the ‘age’ of the value may be determined from the time stamp in the item state.
|
||||
/// </summary>
|
||||
BadLastKnownValue = 0x00000014,
|
||||
/// <summary>Communications have failed. There is no last known value is available.</summary>
|
||||
BadCommFailure = 0x00000018,
|
||||
/// <summary>
|
||||
/// The block is off scan or otherwise locked. This quality is also used when the
|
||||
/// active state of the item or the subscription containing the item is InActive.
|
||||
/// </summary>
|
||||
BadOutOfService = 0x0000001C,
|
||||
/// <summary>
|
||||
/// After Items are added to a subscription, it may take some time for the server to
|
||||
/// actually obtain values for these items. In such cases the client might perform a read
|
||||
/// (from cache), or establish a ConnectionPoint based subscription and/or execute a
|
||||
/// Refresh on such a subscription before the values are available. This sub-status is only
|
||||
/// available from OPC DA 3.0 or newer servers.
|
||||
/// </summary>
|
||||
BadWaitingForInitialData = 0x00000020,
|
||||
/// <summary>There is no specific reason why the value is uncertain.</summary>
|
||||
Uncertain = 0x00000040,
|
||||
/// <summary>
|
||||
/// Whatever was writing this value has stopped doing so. The returned value should
|
||||
/// be regarded as ‘stale’. Note that this differs from a BAD value with sub-status
|
||||
/// badLastKnownValue (Last Known Value). That status is associated specifically with a
|
||||
/// detectable communications error on a ‘fetched’ value. This error is associated with the
|
||||
/// failure of some external source to ‘put’ something into the value within an acceptable
|
||||
/// period of time. Note that the ‘age’ of the value can be determined from the time stamp
|
||||
/// in the item state.
|
||||
/// </summary>
|
||||
UncertainLastUsableValue = 0x00000044,
|
||||
/// <summary>
|
||||
/// Either the value has ‘pegged’ at one of the sensor limits (in which case the
|
||||
/// limit field should be set to low or high) or the sensor is otherwise known to be out of
|
||||
/// calibration via some form of internal diagnostics (in which case the limit field should
|
||||
/// be none).
|
||||
/// </summary>
|
||||
UncertainSensorNotAccurate = 0x00000050,
|
||||
/// <summary>
|
||||
/// The returned value is outside the limits defined for this parameter. Note that in
|
||||
/// this case (per the Field-bus Specification) the ‘Limits’ field indicates which limit has
|
||||
/// been exceeded but does NOT necessarily imply that the value cannot move farther out of
|
||||
/// range.
|
||||
/// </summary>
|
||||
UncertainEUExceeded = 0x00000054,
|
||||
/// <summary>
|
||||
/// The value is derived from multiple sources and has less than the required number
|
||||
/// of Good sources.
|
||||
/// </summary>
|
||||
UncertainSubNormal = 0x00000058
|
||||
}
|
||||
}
|
||||
40
Technosoftware/DaAeHdaClient/Da/QualityMasks.cs
Normal file
40
Technosoftware/DaAeHdaClient/Da/QualityMasks.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines bit masks for the quality.
|
||||
/// </summary>
|
||||
public enum TsDaQualityMasks : int
|
||||
{
|
||||
/// <summary>Quality related bits</summary>
|
||||
QualityMask = +0x00FC,
|
||||
/// <summary>Limit related bits</summary>
|
||||
LimitMask = +0x0003,
|
||||
/// <summary>Vendor specific bits</summary>
|
||||
VendorMask = -0x00FD
|
||||
}
|
||||
}
|
||||
70
Technosoftware/DaAeHdaClient/Da/Request.cs
Normal file
70
Technosoftware/DaAeHdaClient/Da/Request.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the state of a subscription.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaRequest : IOpcRequest
|
||||
{
|
||||
#region Fields
|
||||
private ITsCDaSubscription subscription_;
|
||||
private object handle_;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with a subscription and a unique id.
|
||||
/// </summary>
|
||||
public TsCDaRequest(ITsCDaSubscription subscription, object handle)
|
||||
{
|
||||
subscription_ = subscription;
|
||||
handle_ = handle;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The subscription processing the request.
|
||||
/// </summary>
|
||||
public ITsCDaSubscription Subscription => subscription_;
|
||||
|
||||
/// <summary>
|
||||
/// An unique identifier, assigned by the client, for the request.
|
||||
/// </summary>
|
||||
public object Handle => handle_;
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Cancels the request, if possible.
|
||||
/// </summary>
|
||||
public void Cancel(TsCDaCancelCompleteEventHandler callback) { subscription_.Cancel(this, callback); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
75
Technosoftware/DaAeHdaClient/Da/ResultFilter.cs
Normal file
75
Technosoftware/DaAeHdaClient/Da/ResultFilter.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Filters applied by the server before returning item results.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCDaResultFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Include the ItemName in the ItemIdentifier if bit is set.
|
||||
/// </summary>
|
||||
ItemName = 0x01,
|
||||
|
||||
/// <summary>
|
||||
/// Include the ItemPath in the ItemIdentifier if bit is set.
|
||||
/// </summary>
|
||||
ItemPath = 0x02,
|
||||
|
||||
/// <summary>
|
||||
/// Include the ClientHandle in the ItemIdentifier if bit is set.
|
||||
/// </summary>
|
||||
ClientHandle = 0x04,
|
||||
|
||||
/// <summary>
|
||||
/// Include the Timestamp in the ItemValue if bit is set.
|
||||
/// </summary>
|
||||
ItemTime = 0x08,
|
||||
|
||||
/// <summary>
|
||||
/// Include verbose, localized error text with result if bit is set.
|
||||
/// </summary>
|
||||
ErrorText = 0x10,
|
||||
|
||||
/// <summary>
|
||||
/// Include additional diagnostic information with result if bit is set.
|
||||
/// </summary>
|
||||
DiagnosticInfo = 0x20,
|
||||
|
||||
/// <summary>
|
||||
/// Include the ItemName and Timestamp if bit is set.
|
||||
/// </summary>
|
||||
Minimal = ItemName | ItemTime,
|
||||
|
||||
/// <summary>
|
||||
/// Include all information in the results if bit is set.
|
||||
/// </summary>
|
||||
All = 0x3F
|
||||
}
|
||||
}
|
||||
500
Technosoftware/DaAeHdaClient/Da/Server.cs
Normal file
500
Technosoftware/DaAeHdaClient/Da/Server.cs
Normal file
@@ -0,0 +1,500 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This class is the main interface to access an OPC Data Access server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaServer : OpcServer, ITsDaServer
|
||||
{
|
||||
#region Names Class
|
||||
/// <summary>A set of names for fields used in serialization.</summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string Filters = "Filters";
|
||||
internal const string Subscriptions = "Subscription";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// A list of subscriptions for the server.
|
||||
/// </summary>
|
||||
private TsCDaSubscriptionCollection subscriptions_ = new TsCDaSubscriptionCollection();
|
||||
|
||||
/// <summary>
|
||||
/// The local copy of the result filters.
|
||||
/// </summary>
|
||||
private int filters_ = (int)TsCDaResultFilter.All | (int)TsCDaResultFilter.ClientHandle;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object.
|
||||
/// </summary>
|
||||
public TsCDaServer()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with a factory and a default OpcUrl.
|
||||
/// </summary>
|
||||
/// <param name="factory">The OpcFactory used to connect to remote servers.</param>
|
||||
/// <param name="url">The network address of a remote server.</param>
|
||||
public TsCDaServer(OpcFactory factory, OpcUrl url)
|
||||
:
|
||||
base(factory, url)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
protected TsCDaServer(SerializationInfo info, StreamingContext context)
|
||||
:
|
||||
base(info, context)
|
||||
{
|
||||
filters_ = (int)info.GetValue(Names.Filters, typeof(int));
|
||||
|
||||
var subscriptions = (TsCDaSubscription[])info.GetValue(Names.Subscriptions, typeof(TsCDaSubscription[]));
|
||||
|
||||
if (subscriptions != null)
|
||||
{
|
||||
Array.ForEach(subscriptions, subscription => subscriptions_.Add(subscription));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Returns an array of all subscriptions for the server.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionCollection Subscriptions => subscriptions_;
|
||||
|
||||
/// <summary>
|
||||
/// The current result filters applied by the server.
|
||||
/// </summary>
|
||||
public int Filters => filters_;
|
||||
#endregion
|
||||
|
||||
#region Class properties serialization helpers
|
||||
/// <summary>Serializes a server into a stream.</summary>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
|
||||
info.AddValue(Names.Filters, filters_);
|
||||
|
||||
TsCDaSubscription[] subscriptions = null;
|
||||
|
||||
if (subscriptions_.Count > 0)
|
||||
{
|
||||
subscriptions = new TsCDaSubscription[subscriptions_.Count];
|
||||
|
||||
for (var ii = 0; ii < subscriptions.Length; ii++)
|
||||
{
|
||||
subscriptions[ii] = subscriptions_[ii];
|
||||
}
|
||||
}
|
||||
|
||||
info.AddValue(Names.Subscriptions, subscriptions);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>Returns an unconnected copy of the server with the same OpcUrl.</summary>
|
||||
public override object Clone()
|
||||
{
|
||||
// clone the base object.
|
||||
var clone = (TsCDaServer)base.Clone();
|
||||
|
||||
// clone subscriptions.
|
||||
if (clone.subscriptions_ != null)
|
||||
{
|
||||
var subscriptions = new TsCDaSubscriptionCollection();
|
||||
|
||||
foreach (TsCDaSubscription subscription in clone.subscriptions_)
|
||||
{
|
||||
subscriptions.Add(subscription.Clone());
|
||||
}
|
||||
|
||||
clone.subscriptions_ = subscriptions;
|
||||
}
|
||||
|
||||
// return clone.
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>Connects to the server with the specified OpcUrl and credentials.</summary>
|
||||
/// <exception caption="OpcResultException Class" cref="OpcResultException">If an OPC specific error occur this exception is raised. The Result field includes then the OPC specific code.</exception>
|
||||
/// <param name="url">The network address of the remote server.</param>
|
||||
/// <param name="connectData">Any protocol configuration or user authentication information.</param>
|
||||
public override void Connect(OpcUrl url, OpcConnectData connectData)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
// connect to server.
|
||||
base.Connect(url, connectData);
|
||||
|
||||
// all done if no subscriptions.
|
||||
if (subscriptions_ == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create subscriptions (should only happen if server has been deserialized).
|
||||
var subscriptions = new TsCDaSubscriptionCollection();
|
||||
|
||||
foreach (TsCDaSubscription template in subscriptions_)
|
||||
{
|
||||
// create subscription for template.
|
||||
try
|
||||
{
|
||||
subscriptions.Add(EstablishSubscription(template));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore exceptions here
|
||||
}
|
||||
}
|
||||
|
||||
// save new set of subscriptions.
|
||||
subscriptions_ = subscriptions;
|
||||
}
|
||||
|
||||
/// <summary>Disconnects from the server and releases all network resources.</summary>
|
||||
public override void Disconnect()
|
||||
{
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// dispose of all subscriptions first.
|
||||
if (subscriptions_ != null)
|
||||
{
|
||||
foreach (TsCDaSubscription subscription in subscriptions_)
|
||||
{
|
||||
subscription.Dispose();
|
||||
}
|
||||
|
||||
subscriptions_ = null;
|
||||
}
|
||||
|
||||
// disconnect from server.
|
||||
base.Disconnect();
|
||||
}
|
||||
|
||||
/// <summary>Returns the filters applied by the server to any item results returned to the client.</summary>
|
||||
/// <returns>A bit mask indicating which fields should be returned in any item results.</returns>
|
||||
public int GetResultFilters()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// update local cache.
|
||||
filters_ = ((ITsDaServer)Server).GetResultFilters();
|
||||
|
||||
// return filters.
|
||||
return filters_;
|
||||
}
|
||||
|
||||
/// <summary>Sets the filters applied by the server to any item results returned to the client.</summary>
|
||||
/// <param name="filters">A bit mask indicating which fields should be returned in any item results.</param>
|
||||
public void SetResultFilters(int filters)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// set filters on server.
|
||||
((ITsDaServer)Server).SetResultFilters(filters);
|
||||
|
||||
// cache updated filters.
|
||||
filters_ = filters;
|
||||
}
|
||||
|
||||
/// <summary>Returns the current server status.</summary>
|
||||
/// <returns>The current server status.</returns>
|
||||
public OpcServerStatus GetServerStatus()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
var status = ((ITsDaServer)Server).GetServerStatus();
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
if (status.StatusInfo == null)
|
||||
{
|
||||
status.StatusInfo = GetString($"serverState.{status.ServerState}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/// <summary>Reads the current values for a set of items.</summary>
|
||||
/// <returns>The results of the read operation for each item.</returns>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V3.x</requirements>
|
||||
/// <param name="items">The set of items to read.</param>
|
||||
public TsCDaItemValueResult[] Read(TsCDaItem[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsDaServer)Server).Read(items);
|
||||
}
|
||||
|
||||
/// <summary>Writes the value, quality and timestamp for a set of items.</summary>
|
||||
/// <returns>The results of the write operation for each item.</returns>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V3.x</requirements>
|
||||
/// <param name="items">The set of item values to write.</param>
|
||||
public OpcItemResult[] Write(TsCDaItemValue[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
return ((ITsDaServer)Server).Write(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new subscription.
|
||||
/// </summary>
|
||||
/// <returns>The new subscription object.</returns>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
|
||||
/// <param name="state">The initial state of the subscription.</param>
|
||||
public virtual ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// create subscription on server.
|
||||
var subscription = ((ITsDaServer)Server).CreateSubscription(state);
|
||||
|
||||
// set filters.
|
||||
subscription.SetResultFilters(filters_);
|
||||
|
||||
// append new subscription to existing list.
|
||||
var subscriptions = new TsCDaSubscriptionCollection();
|
||||
|
||||
if (subscriptions_ != null)
|
||||
{
|
||||
foreach (TsCDaSubscription value in subscriptions_)
|
||||
{
|
||||
subscriptions.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
subscriptions.Add(CreateSubscription(subscription));
|
||||
|
||||
// save new subscription list.
|
||||
subscriptions_ = subscriptions;
|
||||
|
||||
// return new subscription.
|
||||
return subscriptions_[subscriptions_.Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the appropriate subscription object.
|
||||
/// </summary>
|
||||
/// <param name="subscription">The remote subscription object.</param>
|
||||
protected virtual TsCDaSubscription CreateSubscription(ITsCDaSubscription subscription)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
return new TsCDaSubscription(this, subscription);
|
||||
}
|
||||
|
||||
/// <summary>Cancels a subscription and releases all resources allocated for it.</summary>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
|
||||
/// <param name="subscription">The subscription to cancel.</param>
|
||||
public virtual void CancelSubscription(ITsCDaSubscription subscription)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (subscription == null) throw new ArgumentNullException(nameof(subscription));
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
|
||||
// validate argument.
|
||||
if (!typeof(TsCDaSubscription).IsInstanceOfType(subscription))
|
||||
{
|
||||
throw new ArgumentException(@"Incorrect object type.", nameof(subscription));
|
||||
}
|
||||
|
||||
if (!Equals(((TsCDaSubscription)subscription).Server))
|
||||
{
|
||||
throw new ArgumentException(@"Server subscription.", nameof(subscription));
|
||||
}
|
||||
|
||||
// search for subscription in list of subscriptions.
|
||||
var subscriptions = new TsCDaSubscriptionCollection();
|
||||
|
||||
foreach (TsCDaSubscription current in subscriptions_)
|
||||
{
|
||||
if (!subscription.Equals(current))
|
||||
{
|
||||
subscriptions.Add(current);
|
||||
}
|
||||
}
|
||||
|
||||
// check if subscription was not found.
|
||||
if (subscriptions.Count == subscriptions_.Count)
|
||||
{
|
||||
throw new ArgumentException(@"Subscription not found.", nameof(subscription));
|
||||
}
|
||||
|
||||
// remove subscription from list of subscriptions.
|
||||
subscriptions_ = subscriptions;
|
||||
|
||||
// cancel subscription on server.
|
||||
((ITsDaServer)Server).CancelSubscription(((TsCDaSubscription)subscription).Subscription);
|
||||
}
|
||||
|
||||
/// <summary>Fetches all the children of the root branch that meet the filter criteria.</summary>
|
||||
/// <returns>The set of elements found.</returns>
|
||||
/// <requirements>OPC Data Access Server V2.x / V3.x</requirements>
|
||||
/// <param name="filters">The filters to use to limit the set of child elements returned.</param>
|
||||
private TsCDaBrowseElement[] Browse(
|
||||
TsCDaBrowseFilters filters)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
TsCDaBrowsePosition position;
|
||||
var elementsList = new List<TsCDaBrowseElement>();
|
||||
|
||||
var elements = ((ITsDaServer)Server).Browse(null, filters, out position);
|
||||
|
||||
if (elements != null)
|
||||
{
|
||||
Browse(elements, filters, ref elementsList);
|
||||
}
|
||||
|
||||
return elementsList.ToArray();
|
||||
}
|
||||
|
||||
private void Browse(TsCDaBrowseElement[] elements, TsCDaBrowseFilters filters, ref List<TsCDaBrowseElement> elementsList)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
TsCDaBrowsePosition position;
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.HasChildren)
|
||||
{
|
||||
var itemId = new OpcItem(element.ItemPath, element.ItemName);
|
||||
|
||||
var childElements = ((ITsDaServer)Server).Browse(itemId, filters, out position);
|
||||
if (childElements != null)
|
||||
{
|
||||
Browse(childElements, filters, ref elementsList);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
elementsList.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Fetches the children of a branch that meet the filter criteria.</summary>
|
||||
/// <returns>The set of elements found.</returns>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
|
||||
/// <param name="itemId">The identifier of branch which is the target of the search.</param>
|
||||
/// <param name="filters">The filters to use to limit the set of child elements returned.</param>
|
||||
/// <param name="position">An object used to continue a browse that could not be completed.</param>
|
||||
public TsCDaBrowseElement[] Browse(
|
||||
OpcItem itemId,
|
||||
TsCDaBrowseFilters filters,
|
||||
out TsCDaBrowsePosition position)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
return ((ITsDaServer)Server).Browse(itemId, filters, out position);
|
||||
}
|
||||
|
||||
/// <summary>Continues a browse operation with previously specified search criteria.</summary>
|
||||
/// <returns>The set of elements found.</returns>
|
||||
/// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
|
||||
/// <param name="position">An object containing the browse operation state information.</param>
|
||||
public TsCDaBrowseElement[] BrowseNext(ref TsCDaBrowsePosition position)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
return ((ITsDaServer)Server).BrowseNext(ref position);
|
||||
}
|
||||
|
||||
/// <summary>Returns the item properties for a set of items.</summary>
|
||||
/// <param name="itemIds">A list of item identifiers.</param>
|
||||
/// <param name="propertyIDs">A list of properties to fetch for each item.</param>
|
||||
/// <param name="returnValues">Whether the property values should be returned with the properties.</param>
|
||||
/// <returns>A list of properties for each item.</returns>
|
||||
public TsCDaItemPropertyCollection[] GetProperties(
|
||||
OpcItem[] itemIds,
|
||||
TsDaPropertyID[] propertyIDs,
|
||||
bool returnValues)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (Server == null) throw new NotConnectedException();
|
||||
return ((ITsDaServer)Server).GetProperties(itemIds, propertyIDs, returnValues);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Establishes a subscription based on the template provided.
|
||||
/// </summary>
|
||||
private TsCDaSubscription EstablishSubscription(TsCDaSubscription template)
|
||||
{
|
||||
// create subscription.
|
||||
var subscription = new TsCDaSubscription(this, ((ITsDaServer)Server).CreateSubscription(template.State));
|
||||
|
||||
// set filters.
|
||||
subscription.SetResultFilters(template.Filters);
|
||||
|
||||
// add items.
|
||||
try
|
||||
{
|
||||
subscription.AddItems(template.Items);
|
||||
}
|
||||
catch
|
||||
{
|
||||
subscription.Dispose();
|
||||
subscription = null;
|
||||
}
|
||||
|
||||
// return new subscription.
|
||||
return subscription;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
68
Technosoftware/DaAeHdaClient/Da/ServerState.cs
Normal file
68
Technosoftware/DaAeHdaClient/Da/ServerState.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// The set of possible server states.
|
||||
/// </summary>
|
||||
public enum TsCDaServerState
|
||||
{
|
||||
/// <summary>
|
||||
/// The server state is not known.
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// The server is running normally.
|
||||
/// </summary>
|
||||
Running,
|
||||
|
||||
/// <summary>
|
||||
/// The server is not functioning due to a fatal error.
|
||||
/// </summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// The server cannot load its configuration information.
|
||||
/// </summary>
|
||||
NoConfig,
|
||||
|
||||
/// <summary>
|
||||
/// The server has halted all communication with the underlying hardware.
|
||||
/// </summary>
|
||||
Suspended,
|
||||
|
||||
/// <summary>
|
||||
/// The server is disconnected from the underlying hardware.
|
||||
/// </summary>
|
||||
Test,
|
||||
|
||||
/// <summary>
|
||||
/// The server cannot communicate with the underlying hardware.
|
||||
/// </summary>
|
||||
CommFault
|
||||
}
|
||||
}
|
||||
92
Technosoftware/DaAeHdaClient/Da/StateMask.cs
Normal file
92
Technosoftware/DaAeHdaClient/Da/StateMask.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines masks to be used when modifying the subscription or item state.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCDaStateMask
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the subscription.
|
||||
/// </summary>
|
||||
Name = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// The client assigned handle for the item or subscription.
|
||||
/// </summary>
|
||||
ClientHandle = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// The locale to use for results returned to the client from the subscription.
|
||||
/// </summary>
|
||||
Locale = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// Whether the item or subscription is active.
|
||||
/// </summary>
|
||||
Active = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum rate at which data update notifications are sent.
|
||||
/// </summary>
|
||||
UpdateRate = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// The longest period between data update notifications.<br/>
|
||||
/// <strong>Note:</strong> This feature is only supported with OPC Data Access 3.0
|
||||
/// Servers.
|
||||
/// </summary>
|
||||
KeepAlive = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// The requested data type for the item.
|
||||
/// </summary>
|
||||
ReqType = 0x0040,
|
||||
|
||||
/// <summary>
|
||||
/// The deadband for the item or subscription.
|
||||
/// </summary>
|
||||
Deadband = 0x0080,
|
||||
|
||||
/// <summary>
|
||||
/// The rate at which the server should check for changes to an item value.
|
||||
/// </summary>
|
||||
SamplingRate = 0x0100,
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server should buffer multiple changes to a single item.
|
||||
/// </summary>
|
||||
EnableBuffering = 0x0200,
|
||||
|
||||
/// <summary>
|
||||
/// All fields are valid.
|
||||
/// </summary>
|
||||
All = 0xFFFF
|
||||
}
|
||||
}
|
||||
571
Technosoftware/DaAeHdaClient/Da/Subscription.cs
Normal file
571
Technosoftware/DaAeHdaClient/Da/Subscription.cs
Normal file
@@ -0,0 +1,571 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// An in-process object used to access subscriptions on OPC Data Access servers.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaSubscription : ITsCDaSubscription, ISerializable, ICloneable
|
||||
{
|
||||
#region Names Class
|
||||
|
||||
/// <summary>
|
||||
/// A set of names for fields used in serialization.
|
||||
/// </summary>
|
||||
private class Names
|
||||
{
|
||||
internal const string State = "State";
|
||||
internal const string Filters = "Filters";
|
||||
internal const string Items = "Items";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private bool disposed_;
|
||||
|
||||
/// <summary>
|
||||
/// The containing server object.
|
||||
/// </summary>
|
||||
private TsCDaServer server_;
|
||||
|
||||
/// <summary>
|
||||
/// The remote subscription object.
|
||||
/// </summary>
|
||||
internal ITsCDaSubscription Subscription;
|
||||
|
||||
/// <summary>
|
||||
/// The local copy of the subscription state.
|
||||
/// </summary>
|
||||
private TsCDaSubscriptionState subscriptionState_ = new TsCDaSubscriptionState();
|
||||
|
||||
/// <summary>
|
||||
/// The local copy of all subscription items.
|
||||
/// </summary>
|
||||
private TsCDaItem[] daItems_;
|
||||
|
||||
/// <summary>
|
||||
/// Whether data callbacks are enabled.
|
||||
/// </summary>
|
||||
private bool enabled_ = true;
|
||||
|
||||
/// <summary>
|
||||
/// The local copy of the result filters.
|
||||
/// </summary>
|
||||
private int filters_ = (int)TsCDaResultFilter.All | (int)TsCDaResultFilter.ClientHandle;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with default values.
|
||||
/// </summary>
|
||||
public TsCDaSubscription(TsCDaServer server, ITsCDaSubscription subscription)
|
||||
{
|
||||
server_ = server ?? throw new ArgumentNullException(nameof(server));
|
||||
Subscription = subscription ?? throw new ArgumentNullException(nameof(subscription));
|
||||
|
||||
GetResultFilters();
|
||||
GetState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a server by de-serializing its OpcUrl from the stream.
|
||||
/// </summary>
|
||||
protected TsCDaSubscription(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
subscriptionState_ = (TsCDaSubscriptionState)info.GetValue(Names.State, typeof(TsCDaSubscriptionState));
|
||||
filters_ = (int)info.GetValue(Names.Filters, typeof(int));
|
||||
daItems_ = (TsCDaItem[])info.GetValue(Names.Items, typeof(TsCDaItem[]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The finalizer implementation.
|
||||
/// </summary>
|
||||
~TsCDaSubscription()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This must be called explicitly by clients to ensure the remote server is released.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
// Take yourself off the Finalization queue
|
||||
// to prevent finalization code for this object
|
||||
// from executing a second time.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose(bool disposing) executes in two distinct scenarios.
|
||||
/// If disposing equals true, the method has been called directly
|
||||
/// or indirectly by a user's code. Managed and unmanaged resources
|
||||
/// can be disposed.
|
||||
/// If disposing equals false, the method has been called by the
|
||||
/// runtime from inside the finalizer and you should not reference
|
||||
/// other objects. Only unmanaged resources can be disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if (!disposed_)
|
||||
{
|
||||
// If disposing equals true, dispose all managed
|
||||
// and unmanaged resources.
|
||||
if (disposing)
|
||||
{
|
||||
if (Subscription != null)
|
||||
{
|
||||
Subscription.Dispose();
|
||||
|
||||
server_ = null;
|
||||
Subscription = null;
|
||||
daItems_ = null;
|
||||
}
|
||||
}
|
||||
// Release unmanaged resources. If disposing is false,
|
||||
// only the following code is executed.
|
||||
}
|
||||
disposed_ = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The server that the subscription is attached to.
|
||||
/// </summary>
|
||||
public TsCDaServer Server => server_;
|
||||
|
||||
/// <summary>
|
||||
/// The name assigned to the subscription by the client.
|
||||
/// </summary>
|
||||
public string Name => subscriptionState_.Name;
|
||||
|
||||
/// <summary>
|
||||
/// The handle assigned to the subscription by the client.
|
||||
/// </summary>
|
||||
public object ClientHandle => subscriptionState_.ClientHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The handle assigned to the subscription by the server.
|
||||
/// </summary>
|
||||
public object ServerHandle => subscriptionState_.ServerHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the subscription is active.
|
||||
/// </summary>
|
||||
public bool Active => subscriptionState_.Active;
|
||||
|
||||
/// <summary>
|
||||
/// Whether data callbacks are enabled.
|
||||
/// </summary>
|
||||
public bool Enabled => enabled_;
|
||||
|
||||
/// <summary>
|
||||
/// The current locale used by the subscription.
|
||||
/// </summary>
|
||||
public string Locale => subscriptionState_.Locale;
|
||||
|
||||
/// <summary>
|
||||
/// The current result filters applied by the subscription.
|
||||
/// </summary>
|
||||
public int Filters => filters_;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the current subscription state.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionState State => (TsCDaSubscriptionState)subscriptionState_.Clone();
|
||||
|
||||
/// <summary>
|
||||
/// The items belonging to the subscription.
|
||||
/// </summary>
|
||||
public TsCDaItem[] Items {
|
||||
get {
|
||||
if (daItems_ == null) return new TsCDaItem[0];
|
||||
var items = new TsCDaItem[daItems_.Length];
|
||||
for (var ii = 0; ii < daItems_.Length; ii++) items[ii] = (TsCDaItem)daItems_[ii].Clone();
|
||||
return items;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Serializes a server into a stream.
|
||||
/// </summary>
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue(Names.State, subscriptionState_);
|
||||
info.AddValue(Names.Filters, filters_);
|
||||
info.AddValue(Names.Items, daItems_);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an unconnected copy of the subscription with the same items.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
// do a memberwise clone.
|
||||
var clone = (TsCDaSubscription)MemberwiseClone();
|
||||
|
||||
// place clone in disconnected state.
|
||||
clone.server_ = null;
|
||||
clone.Subscription = null;
|
||||
clone.subscriptionState_ = (TsCDaSubscriptionState)subscriptionState_.Clone();
|
||||
|
||||
// clear server handles.
|
||||
clone.subscriptionState_.ServerHandle = null;
|
||||
|
||||
// always make cloned subscriptions inactive.
|
||||
clone.subscriptionState_.Active = false;
|
||||
|
||||
// clone items.
|
||||
if (clone.daItems_ != null)
|
||||
{
|
||||
var items = new ArrayList();
|
||||
|
||||
Array.ForEach(clone.daItems_, item => items.Add(item.Clone()));
|
||||
|
||||
clone.daItems_ = (TsCDaItem[])items.ToArray(typeof(TsCDaItem));
|
||||
}
|
||||
|
||||
// return clone.
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets default result filters for the server.
|
||||
/// </summary>
|
||||
public int GetResultFilters()
|
||||
{
|
||||
filters_ = Subscription.GetResultFilters();
|
||||
return filters_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets default result filters for the server.
|
||||
/// </summary>
|
||||
public void SetResultFilters(int filters)
|
||||
{
|
||||
Subscription.SetResultFilters(filters);
|
||||
filters_ = filters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current subscription state.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionState GetState()
|
||||
{
|
||||
subscriptionState_ = Subscription.GetState();
|
||||
return subscriptionState_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the current subscription state.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state)
|
||||
{
|
||||
subscriptionState_ = Subscription.ModifyState(masks, state);
|
||||
return subscriptionState_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds items to the subscription.
|
||||
/// </summary>
|
||||
public virtual TsCDaItemResult[] AddItems(TsCDaItem[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (items == null) throw new ArgumentNullException(nameof(items));
|
||||
|
||||
// check if there is nothing to do.
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return new TsCDaItemResult[0];
|
||||
}
|
||||
|
||||
// add items.
|
||||
var results = Subscription.AddItems(items);
|
||||
|
||||
if (results == null || results.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult(OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The browse operation cannot continue");
|
||||
}
|
||||
|
||||
// update locale item list.
|
||||
var itemList = new ArrayList();
|
||||
if (daItems_ != null) itemList.AddRange(daItems_);
|
||||
|
||||
for (var ii = 0; ii < results.Length; ii++)
|
||||
{
|
||||
// check for failure.
|
||||
if (results[ii].Result.Failed())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// create locale copy of the item.
|
||||
// item name, item path and client handle may not be returned by server.
|
||||
var item = new TsCDaItem(results[ii]) { ItemName = items[ii].ItemName, ItemPath = items[ii].ItemPath, ClientHandle = items[ii].ClientHandle };
|
||||
|
||||
itemList.Add(item);
|
||||
}
|
||||
|
||||
// save the new item list.
|
||||
daItems_ = (TsCDaItem[])itemList.ToArray(typeof(TsCDaItem));
|
||||
|
||||
// update the local state.
|
||||
GetState();
|
||||
|
||||
// return results.
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifies items that are already part of the subscription.
|
||||
/// </summary>
|
||||
public virtual TsCDaItemResult[] ModifyItems(int masks, TsCDaItem[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (items == null) throw new ArgumentNullException(nameof(items));
|
||||
|
||||
// check if there is nothing to do.
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return new TsCDaItemResult[0];
|
||||
}
|
||||
|
||||
// modify items.
|
||||
var results = Subscription.ModifyItems(masks, items);
|
||||
|
||||
if (results == null || results.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult(OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The browse operation cannot continue");
|
||||
}
|
||||
|
||||
// update local item - modify item success means all fields were updated successfully.
|
||||
for (var ii = 0; ii < results.Length; ii++)
|
||||
{
|
||||
// check for failure.
|
||||
if (results[ii].Result.Failed())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// search local item list.
|
||||
for (var jj = 0; jj < daItems_.Length; jj++)
|
||||
{
|
||||
if (daItems_[jj].ServerHandle.Equals(items[ii].ServerHandle))
|
||||
{
|
||||
// update locale copy of the item.
|
||||
// item name, item path and client handle may not be returned by server.
|
||||
var item = new TsCDaItem(results[ii]) { ItemName = daItems_[jj].ItemName, ItemPath = daItems_[jj].ItemPath, ClientHandle = daItems_[jj].ClientHandle };
|
||||
|
||||
daItems_[jj] = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the local state.
|
||||
GetState();
|
||||
|
||||
// return results.
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes items from a subscription.
|
||||
/// </summary>
|
||||
public virtual OpcItemResult[] RemoveItems(OpcItem[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
if (items == null) throw new ArgumentNullException(nameof(items));
|
||||
|
||||
// check if there is nothing to do.
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return new OpcItemResult[0];
|
||||
}
|
||||
|
||||
// remove items from server.
|
||||
var results = Subscription.RemoveItems(items);
|
||||
|
||||
if (results == null || results.Length == 0)
|
||||
{
|
||||
throw new OpcResultException(new OpcResult(OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The browse operation cannot continue");
|
||||
}
|
||||
|
||||
// remove items from local list if successful.
|
||||
var itemList = new ArrayList();
|
||||
|
||||
foreach (var item in daItems_)
|
||||
{
|
||||
var removed = false;
|
||||
|
||||
for (var ii = 0; ii < results.Length; ii++)
|
||||
{
|
||||
if (item.ServerHandle.Equals(items[ii].ServerHandle))
|
||||
{
|
||||
removed = results[ii].Result.Succeeded();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!removed) itemList.Add(item);
|
||||
}
|
||||
|
||||
// update local list.
|
||||
daItems_ = (TsCDaItem[])itemList.ToArray(typeof(TsCDaItem));
|
||||
|
||||
// update the local state.
|
||||
GetState();
|
||||
|
||||
// return results.
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a set of subscription items.
|
||||
/// </summary>
|
||||
public TsCDaItemValueResult[] Read(TsCDaItem[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
return Subscription.Read(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a set of subscription items.
|
||||
/// </summary>
|
||||
public OpcItemResult[] Write(TsCDaItemValue[] items)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
return Subscription.Write(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begins an asynchronous read operation for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
public OpcItemResult[] Read(
|
||||
TsCDaItem[] items,
|
||||
object requestHandle,
|
||||
TsCDaReadCompleteEventHandler callback,
|
||||
out IOpcRequest request)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
return Subscription.Read(items, requestHandle, callback, out request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begins an asynchronous write operation for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of item values to write (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
public OpcItemResult[] Write(
|
||||
TsCDaItemValue[] items,
|
||||
object requestHandle,
|
||||
TsCDaWriteCompleteEventHandler callback,
|
||||
out IOpcRequest request)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
return Subscription.Write(items, requestHandle, callback, out request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an asynchronous request.
|
||||
/// </summary>
|
||||
public void Cancel(IOpcRequest request, TsCDaCancelCompleteEventHandler callback)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
Subscription.Cancel(request, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells the server to send an data change update for all subscription items.
|
||||
/// </summary>
|
||||
public void Refresh() { Subscription.Refresh(); }
|
||||
|
||||
/// <summary>
|
||||
/// Causes the server to send a data changed notification for all active items.
|
||||
/// </summary>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
public void Refresh(
|
||||
object requestHandle,
|
||||
out IOpcRequest request)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
Subscription.Refresh(requestHandle, out request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether data change callbacks are enabled.
|
||||
/// </summary>
|
||||
public void SetEnabled(bool enabled)
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
Subscription.SetEnabled(enabled);
|
||||
enabled_ = enabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether data change callbacks are enabled.
|
||||
/// </summary>
|
||||
public bool GetEnabled()
|
||||
{
|
||||
LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
|
||||
enabled_ = Subscription.GetEnabled();
|
||||
return enabled_;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISubscription
|
||||
/// <summary>
|
||||
/// An event to receive data change updates.
|
||||
/// </summary>
|
||||
public event TsCDaDataChangedEventHandler DataChangedEvent {
|
||||
add => Subscription.DataChangedEvent += value;
|
||||
remove => Subscription.DataChangedEvent -= value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
316
Technosoftware/DaAeHdaClient/Da/SubscriptionCollection.cs
Normal file
316
Technosoftware/DaAeHdaClient/Da/SubscriptionCollection.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>A collection of subscriptions.</summary>
|
||||
[Serializable]
|
||||
public class TsCDaSubscriptionCollection : ICollection, ICloneable, IList
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Fields
|
||||
|
||||
private ArrayList _subscriptions = new ArrayList();
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Constructors, Destructor, Initialization
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified SubscriptionCollection object.
|
||||
/// </summary>
|
||||
public TsCDaSubscriptionCollection(TsCDaSubscriptionCollection subscriptions)
|
||||
{
|
||||
if (subscriptions != null)
|
||||
{
|
||||
foreach (TsCDaSubscription subscription in subscriptions)
|
||||
{
|
||||
Add(subscription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item at the specified index.
|
||||
/// </summary>
|
||||
public TsCDaSubscription this[int index]
|
||||
{
|
||||
get => (TsCDaSubscription)_subscriptions[index];
|
||||
set => _subscriptions[index] = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region ICloneable Members
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCDaSubscriptionCollection)MemberwiseClone();
|
||||
|
||||
clone._subscriptions = new ArrayList();
|
||||
|
||||
foreach (TsCDaSubscription subscription in _subscriptions)
|
||||
{
|
||||
clone._subscriptions.Add(subscription.Clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region ICollection Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => (_subscriptions != null) ? _subscriptions.Count : 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
if (_subscriptions != null)
|
||||
{
|
||||
_subscriptions.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCDaSubscription[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region IEnumerable Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return _subscriptions.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
#region IList Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => _subscriptions[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!typeof(TsCDaSubscription).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Subscription objects into the collection.");
|
||||
}
|
||||
|
||||
_subscriptions[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList subscription at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the subscription to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
_subscriptions.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an subscription to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!typeof(TsCDaSubscription).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Subscription objects into the collection.");
|
||||
}
|
||||
|
||||
_subscriptions.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
_subscriptions.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return _subscriptions.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all subscriptions from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
_subscriptions.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific subscription in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return _subscriptions.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an subscription to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!typeof(TsCDaSubscription).IsInstanceOfType(value))
|
||||
{
|
||||
throw new ArgumentException("May only add Subscription objects into the collection.");
|
||||
}
|
||||
|
||||
return _subscriptions.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an subscription to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCDaSubscription value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCDaSubscription value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCDaSubscription value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific subscription in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCDaSubscription value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an subscription to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCDaSubscription value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
172
Technosoftware/DaAeHdaClient/Da/SubscriptionState.cs
Normal file
172
Technosoftware/DaAeHdaClient/Da/SubscriptionState.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Da
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the state of a subscription.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCDaSubscriptionState : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private bool active_ = true;
|
||||
private int updateRate_ = 500;
|
||||
private float deadband_;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique name for the subscription controlled by the client.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A unique identifier for the subscription assigned by the client.
|
||||
/// </summary>
|
||||
public object ClientHandle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A unique subscription identifier assigned by the server.
|
||||
/// </summary>
|
||||
public object ServerHandle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The locale used for any error messages or results returned to the client.
|
||||
/// </summary>
|
||||
public string Locale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the subscription is scanning for updates to send to the client.
|
||||
/// </summary>
|
||||
public bool Active
|
||||
{
|
||||
get => active_;
|
||||
set => active_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rate in milliseconds at which the server checks of updates to send to the
|
||||
/// client.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Client Specifies the fastest rate at which data changes may be sent to the
|
||||
/// <see cref="TsCDaDataChangedEventHandler">DataChangedHandler</see>
|
||||
/// for items in this subscription. This also indicates the desired accuracy of Cached
|
||||
/// Data. This is intended only to control the behavior of the interface. How the
|
||||
/// server deals with the update rate and how often it actually polls the hardware
|
||||
/// internally is an implementation detail. Passing 0 indicates the server should use
|
||||
/// the fastest practical rate.
|
||||
/// </remarks>
|
||||
public int UpdateRate
|
||||
{
|
||||
get => updateRate_;
|
||||
set => updateRate_ = value;
|
||||
}
|
||||
|
||||
/// <summary><para>The maximum period in milliseconds between updates sent to the client.</para></summary>
|
||||
/// <remarks>
|
||||
/// <para>Clients can set the keep-alive time for a subscription to cause the server to
|
||||
/// provide client callbacks on the subscription when there are no new events to
|
||||
/// report. Clients can then be assured of the health of the server and subscription
|
||||
/// without resorting to pinging the server with calls to GetStatus().</para>
|
||||
/// <para>Using this facility, a client can expect a callback (data or keep-alive)
|
||||
/// within the specified keep-alive time.</para>
|
||||
/// <para>Servers shall reset their keep-alive timers when real data is sent (i.e. it
|
||||
/// is not acceptable to constantly send the keep-alive callback at a fixed period
|
||||
/// equal to the keep-alive time irrespective of data callbacks).</para>
|
||||
/// <para>
|
||||
/// The keep-alive callback consists of a call to the
|
||||
/// <see cref="TsCDaDataChangedEventHandler">DataChangedEventHandler</see>
|
||||
/// with an empty value list.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Keep-alive callbacks will not occur when the subscription is inactive.
|
||||
/// Keep-alive callbacks do not affect the value of the
|
||||
/// <see cref="OpcServerStatus.LastUpdateTime">LastUpdateTime</see> returned by
|
||||
/// <see cref="TsCDaServer.GetServerStatus">GetServerStatus()</see> .
|
||||
/// </para>
|
||||
/// <para><strong>Available only for OPC Data Access 3.0 and OPC XML-DA
|
||||
/// servers.</strong></para>
|
||||
/// </remarks>
|
||||
public int KeepAlive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The minimum percentage change from 0.0 to 100.0 required to trigger a data update
|
||||
/// for an item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The range of the Deadband is from 0.0 to 100.0 Percent. Deadband will only
|
||||
/// apply to items in the subscription that have a dwEUType of Analog available. If the
|
||||
/// EU Type is Analog, then the EU Low and EU High values for the item can be used to
|
||||
/// calculate the range for the item. This range will be multiplied with the Deadband
|
||||
/// to generate an exception limit. An exception is determined as follows:</para>
|
||||
/// <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
|
||||
/// <para>Exception if (absolute value of (last cached value - current value) >
|
||||
/// (pPercentDeadband/100.0) * (EU High - EU Low) )</para>
|
||||
/// </blockquote>
|
||||
/// <para>The PercentDeadband can be set when CreateSubscription is called, allowing
|
||||
/// the same PercentDeadband to be used for all items within that particular
|
||||
/// subscription. However, with OPC DA 3.0, it is allowable to set the PercentDeadband
|
||||
/// on a per item basis. This means that each item can potentially override the
|
||||
/// PercentDeadband set for the subscription it resides within.</para>
|
||||
/// <para>If the exception limit is exceeded, then the last cached value is updated
|
||||
/// with the new value and a notification will be sent to the client’s callback (if
|
||||
/// any). The PercentDeadband is an optional behavior for the server. If the client
|
||||
/// does not specify this value on a server that does support the behavior, the default
|
||||
/// value of 0 (zero) will be assumed, and all value changes will update the CACHE.
|
||||
/// Note that the timestamp will be updated regardless of whether the cached value is
|
||||
/// updated. A server which does not support deadband should return an error
|
||||
/// (OPC_E_DEADBANDNOTSUPPORTED) if the client requests a deadband other than
|
||||
/// 0.0.</para>
|
||||
/// <para>The UpdateRate for a subscription or the sampling rate of the item, if set,
|
||||
/// determines time between when a value is checked to see if the exception limit has
|
||||
/// been exceeded. The PercentDeadband is used to keep noisy signals from updating the
|
||||
/// client unnecessarily.</para>
|
||||
/// </remarks>
|
||||
public float Deadband
|
||||
{
|
||||
get => deadband_;
|
||||
set => deadband_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TimeZone Bias of Group (in minutes).
|
||||
/// </summary>
|
||||
public int TimeBias { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
70
Technosoftware/DaAeHdaClient/Hda/Aggregate.cs
Normal file
70
Technosoftware/DaAeHdaClient/Hda/Aggregate.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item aggregate supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAggregate : ICloneable
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the aggregate.
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique name for the aggregate.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the aggregate.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone() { return MemberwiseClone(); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
178
Technosoftware/DaAeHdaClient/Hda/AggregateCollection.cs
Normal file
178
Technosoftware/DaAeHdaClient/Hda/AggregateCollection.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item aggregate supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAggregateCollection : ICloneable, ICollection
|
||||
{
|
||||
#region Fields
|
||||
private TsCHdaAggregate[] hdaAggregates_ = new TsCHdaAggregate[0];
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
public TsCHdaAggregateCollection()
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any Aggregates contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing aggregate descriptions.</param>
|
||||
public TsCHdaAggregateCollection(ICollection collection)
|
||||
{
|
||||
Init(collection);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Returns the aggregate at the specified index.
|
||||
/// </summary>
|
||||
public TsCHdaAggregate this[int index]
|
||||
{
|
||||
get => hdaAggregates_[index];
|
||||
set => hdaAggregates_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns the first aggregate with the specified id.
|
||||
/// </summary>
|
||||
public TsCHdaAggregate Find(int id)
|
||||
{
|
||||
foreach (var aggregate in hdaAggregates_)
|
||||
{
|
||||
if (aggregate.Id == id)
|
||||
{
|
||||
return aggregate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any aggregates contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing aggregate descriptions.</param>
|
||||
public void Init(ICollection collection)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (collection != null)
|
||||
{
|
||||
var aggregates = new ArrayList(collection.Count);
|
||||
|
||||
foreach (var value in collection)
|
||||
{
|
||||
if (value.GetType() == typeof(TsCHdaAggregate))
|
||||
{
|
||||
aggregates.Add(OpcConvert.Clone(value));
|
||||
}
|
||||
}
|
||||
|
||||
hdaAggregates_ = (TsCHdaAggregate[])aggregates.ToArray(typeof(TsCHdaAggregate));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all aggregates in the collection.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
hdaAggregates_ = new TsCHdaAggregate[0];
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return new TsCHdaAggregateCollection(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => hdaAggregates_?.Length ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
hdaAggregates_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaAggregate[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return hdaAggregates_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
141
Technosoftware/DaAeHdaClient/Hda/AggregateId.cs
Normal file
141
Technosoftware/DaAeHdaClient/Hda/AggregateId.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines constants for well-known item aggregates.
|
||||
/// </summary>
|
||||
/// <remarks>This indicates the aggregate to be used when retrieving processed history. The precise meaning of each aggregate may be server specific. Aggregates not supported by the server shall return E_INVALIDARG in the error code for that aggregate. Additional aggregates may be defined by vendors. Server specific aggregates must be defined with values beginning at 0x80000000. The OPC foundation reserves all aggregates IDs from 0 to 0x7fffffff.</remarks>
|
||||
public class TsCHdaAggregateID
|
||||
{
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// Do not retrieve an aggregate.
|
||||
/// </summary>
|
||||
public const int NoAggregate = 0;
|
||||
/// <summary>
|
||||
/// Do not retrieve an aggregate. This is used for retrieving interpolated values.
|
||||
/// </summary>
|
||||
public const int Interpolative = 1;
|
||||
/// <summary>
|
||||
/// Retrieve the totalized value (time integral) of the data over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Total = 2;
|
||||
/// <summary>
|
||||
/// Retrieve the average data over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Average = 3;
|
||||
/// <summary>
|
||||
/// Retrieve the time weighted average data over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int TimeAverage = 4;
|
||||
/// <summary>
|
||||
/// Retrieve the number of raw values over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Count = 5;
|
||||
/// <summary>
|
||||
/// Retrieve the standard deviation over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int StandardDeviation = 6;
|
||||
/// <summary>
|
||||
/// Retrieve the minimum value in the re-sample interval and the timestamp of the minimum value.
|
||||
/// </summary>
|
||||
public const int MinimumActualTime = 7;
|
||||
/// <summary>
|
||||
/// Retrieve the minimum value in the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Minimum = 8;
|
||||
/// <summary>
|
||||
/// Retrieve the maximum value in the re-sample interval and the timestamp of the maximum value.
|
||||
/// </summary>
|
||||
public const int MaximumActualTime = 9;
|
||||
/// <summary>
|
||||
/// Retrieve the maximum value in the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Maximum = 10;
|
||||
/// <summary>
|
||||
/// Retrieve the value at the beginning of the re-sample interval. The time stamp is the time stamp of the beginning of the interval.
|
||||
/// </summary>
|
||||
public const int Start = 11;
|
||||
/// <summary>
|
||||
/// Retrieve the value at the end of the re-sample interval. The time stamp is the time stamp of the end of the interval.
|
||||
/// </summary>
|
||||
public const int End = 12;
|
||||
/// <summary>
|
||||
/// Retrieve the difference between the first and last value in the re-sample interval.
|
||||
/// </summary>
|
||||
public const int Delta = 13;
|
||||
/// <summary>
|
||||
/// Retrieve the slope of the regression line over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int RegSlope = 14;
|
||||
/// <summary>
|
||||
/// Retrieve the intercept of the regression line over the re-sample interval. This is the value of the regression line at the start of the interval.
|
||||
/// </summary>
|
||||
public const int RegConst = 15;
|
||||
/// <summary>
|
||||
/// Retrieve the standard deviation of the regression line over the re-sample interval.
|
||||
/// </summary>
|
||||
public const int RegDev = 16;
|
||||
/// <summary>
|
||||
/// Retrieve the variance over the sample interval.
|
||||
/// </summary>
|
||||
public const int Variance = 17;
|
||||
/// <summary>
|
||||
/// Retrieve the difference between the minimum and maximum value over the sample interval.
|
||||
/// </summary>
|
||||
public const int Range = 18;
|
||||
/// <summary>
|
||||
/// Retrieve the duration (in seconds) of time in the interval during which the data is good.
|
||||
/// </summary>
|
||||
public const int DurationGood = 19;
|
||||
/// <summary>
|
||||
/// Retrieve the duration (in seconds) of time in the interval during which the data is bad.
|
||||
/// </summary>
|
||||
public const int DurationBad = 20;
|
||||
/// <summary>
|
||||
/// Retrieve the percent of data (1 equals 100 percent) in the interval which has good quality.
|
||||
/// </summary>
|
||||
public const int PercentGood = 21;
|
||||
/// <summary>
|
||||
/// Retrieve the percent of data (1 equals 100 percent) in the interval which has bad quality.
|
||||
/// </summary>
|
||||
public const int PercentBad = 22;
|
||||
/// <summary>
|
||||
/// Retrieve the worst quality of data in the interval.
|
||||
/// </summary>
|
||||
public const int WorstQuality = 23;
|
||||
/// <summary>
|
||||
/// Retrieve the number of annotations in the interval.
|
||||
/// </summary>
|
||||
public const int Annotations = 24;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
private TsCHdaAggregateID() { }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
84
Technosoftware/DaAeHdaClient/Hda/AnnotationValue.cs
Normal file
84
Technosoftware/DaAeHdaClient/Hda/AnnotationValue.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// An annotation associated with an item.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAnnotationValue : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private DateTime timestamp_ = DateTime.MinValue;
|
||||
private DateTime creationTime_ = DateTime.MinValue;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The timestamp for the annotation.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get => timestamp_;
|
||||
set => timestamp_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text of the annotation.
|
||||
/// </summary>
|
||||
public string Annotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time when the annotation was created.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime CreationTime
|
||||
{
|
||||
get => creationTime_;
|
||||
set => creationTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user who created the annotation.
|
||||
/// </summary>
|
||||
public string User { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
348
Technosoftware/DaAeHdaClient/Hda/AnnotationValueCollection.cs
Normal file
348
Technosoftware/DaAeHdaClient/Hda/AnnotationValueCollection.cs
Normal file
@@ -0,0 +1,348 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of item values passed to write or returned from a read operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAnnotationValueCollection : TsCHdaItem, IOpcResult, ITsCHdaActualTime, IList
|
||||
{
|
||||
#region Fields
|
||||
private ArrayList values_ = new ArrayList();
|
||||
private DateTime startTime_ = DateTime.MinValue;
|
||||
private DateTime endTime_ = DateTime.MinValue;
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaAnnotationValueCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaAnnotationValueCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCHdaAnnotationValueCollection(TsCHdaItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemValueCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaAnnotationValueCollection(TsCHdaAnnotationValueCollection item)
|
||||
: base(item)
|
||||
{
|
||||
values_ = new ArrayList(item.values_.Count);
|
||||
|
||||
foreach (TsCHdaItemValue value in item.values_)
|
||||
{
|
||||
values_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public TsCHdaAnnotationValue this[int index]
|
||||
{
|
||||
get => (TsCHdaAnnotationValue)values_[index];
|
||||
set => values_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IActualTime Members
|
||||
/// <summary>
|
||||
/// The actual start time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime StartTime
|
||||
{
|
||||
get => startTime_;
|
||||
set => startTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual end time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get => endTime_;
|
||||
set => endTime_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var collection = (TsCHdaAnnotationValueCollection)base.Clone();
|
||||
|
||||
collection.values_ = new ArrayList(values_.Count);
|
||||
|
||||
foreach (TsCHdaAnnotationValue value in values_)
|
||||
{
|
||||
collection.values_.Add(value.Clone());
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => values_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
values_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaAnnotationValue[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return values_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => values_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaAnnotationValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AnnotationValue objects into the collection.");
|
||||
}
|
||||
|
||||
values_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
values_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaAnnotationValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AnnotationValue objects into the collection.");
|
||||
}
|
||||
|
||||
values_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
values_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return values_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
values_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return values_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaAnnotationValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AnnotationValue objects into the collection.");
|
||||
}
|
||||
|
||||
return values_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaAnnotationValue value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaAnnotationValue value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaAnnotationValue value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaAnnotationValue value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaAnnotationValue value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
75
Technosoftware/DaAeHdaClient/Hda/Attribute.cs
Normal file
75
Technosoftware/DaAeHdaClient/Hda/Attribute.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item attribute supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAttribute : ICloneable
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the attribute.
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique name for the attribute.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the attribute.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The data type of the attribute.
|
||||
/// </summary>
|
||||
public Type DataType { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone() { return MemberwiseClone(); }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
174
Technosoftware/DaAeHdaClient/Hda/AttributeCollection.cs
Normal file
174
Technosoftware/DaAeHdaClient/Hda/AttributeCollection.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The description of an item attribute supported by the server.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAttributeCollection : ICloneable, ICollection
|
||||
{
|
||||
#region Fields
|
||||
private TsCHdaAttribute[] hdaAttributes_ = new TsCHdaAttribute[0];
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any Attributes contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing attribute descriptions.</param>
|
||||
public TsCHdaAttributeCollection(ICollection collection)
|
||||
{
|
||||
Init(collection);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Returns the attribute at the specified index.
|
||||
/// </summary>
|
||||
public TsCHdaAttribute this[int index]
|
||||
{
|
||||
get => hdaAttributes_[index];
|
||||
set => hdaAttributes_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns the first attribute with the specified id.
|
||||
/// </summary>
|
||||
public TsCHdaAttribute Find(int id)
|
||||
{
|
||||
foreach (var attribute in hdaAttributes_)
|
||||
{
|
||||
if (attribute.ID == id)
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any attributes contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing attribute descriptions.</param>
|
||||
public void Init(ICollection collection)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (collection != null)
|
||||
{
|
||||
var attributes = new ArrayList(collection.Count);
|
||||
|
||||
foreach (var value in collection)
|
||||
{
|
||||
if (value.GetType() == typeof(TsCHdaAttribute))
|
||||
{
|
||||
attributes.Add(OpcConvert.Clone(value));
|
||||
}
|
||||
}
|
||||
hdaAttributes_ = (TsCHdaAttribute[])attributes.ToArray(typeof(TsCHdaAttribute));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all attributes in the collection.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
hdaAttributes_ = new TsCHdaAttribute[0];
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return new TsCHdaAttributeCollection(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => hdaAttributes_?.Length ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
hdaAttributes_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Attribute[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return hdaAttributes_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
72
Technosoftware/DaAeHdaClient/Hda/AttributeID.cs
Normal file
72
Technosoftware/DaAeHdaClient/Hda/AttributeID.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines constants for well-known item attributes.
|
||||
/// </summary>
|
||||
public class TsCHdaAttributeID
|
||||
{
|
||||
/// <remarks/>
|
||||
public const int DATA_TYPE = 0x01;
|
||||
/// <remarks/>
|
||||
public const int DESCRIPTION = 0x02;
|
||||
/// <remarks/>
|
||||
public const int ENG_UNITS = 0x03;
|
||||
/// <remarks/>
|
||||
public const int STEPPED = 0x04;
|
||||
/// <remarks/>
|
||||
public const int ARCHIVING = 0x05;
|
||||
/// <remarks/>
|
||||
public const int DERIVE_EQUATION = 0x06;
|
||||
/// <remarks/>
|
||||
public const int NODE_NAME = 0x07;
|
||||
/// <remarks/>
|
||||
public const int PROCESS_NAME = 0x08;
|
||||
/// <remarks/>
|
||||
public const int SOURCE_NAME = 0x09;
|
||||
/// <remarks/>
|
||||
public const int SOURCE_TYPE = 0x0a;
|
||||
/// <remarks/>
|
||||
public const int NORMAL_MAXIMUM = 0x0b;
|
||||
/// <remarks/>
|
||||
public const int NORMAL_MINIMUM = 0x0c;
|
||||
/// <remarks/>
|
||||
public const int ITEMID = 0x0d;
|
||||
/// <remarks/>
|
||||
public const int MAX_TIME_INT = 0x0e;
|
||||
/// <remarks/>
|
||||
public const int MIN_TIME_INT = 0x0f;
|
||||
/// <remarks/>
|
||||
public const int EXCEPTION_DEV = 0x10;
|
||||
/// <remarks/>
|
||||
public const int EXCEPTION_DEV_TYPE = 0x11;
|
||||
/// <remarks/>
|
||||
public const int HIGH_ENTRY_LIMIT = 0x12;
|
||||
/// <remarks/>
|
||||
public const int LOW_ENTRY_LIMIT = 0x13;
|
||||
}
|
||||
}
|
||||
69
Technosoftware/DaAeHdaClient/Hda/AttributeValue.cs
Normal file
69
Technosoftware/DaAeHdaClient/Hda/AttributeValue.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The value of an attribute at a point in time.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAttributeValue : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private DateTime timestamp_ = DateTime.MinValue;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The value of the data.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timestamp associated with the value.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get => timestamp_;
|
||||
set => timestamp_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCHdaAttributeValue)MemberwiseClone();
|
||||
clone.Value = OpcConvert.Clone(Value);
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
323
Technosoftware/DaAeHdaClient/Hda/AttributeValueCollection.cs
Normal file
323
Technosoftware/DaAeHdaClient/Hda/AttributeValueCollection.cs
Normal file
@@ -0,0 +1,323 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The set of values for an item attribute over a period of time.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaAttributeValueCollection : IOpcResult, ICollection, ICloneable, IList
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
private ArrayList attributeValues_ = new ArrayList();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValueCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValueCollection(TsCHdaAttribute attribute)
|
||||
{
|
||||
AttributeID = attribute.ID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified AttributeValueCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValueCollection(TsCHdaAttributeValueCollection collection)
|
||||
{
|
||||
attributeValues_ = new ArrayList(collection.attributeValues_.Count);
|
||||
|
||||
foreach (TsCHdaAttributeValue value in collection.attributeValues_)
|
||||
{
|
||||
attributeValues_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// A unique identifier for the attribute.
|
||||
/// </summary>
|
||||
public int AttributeID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValue this[int index]
|
||||
{
|
||||
get => (TsCHdaAttributeValue)attributeValues_[index];
|
||||
set => attributeValues_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var collection = (TsCHdaAttributeValueCollection)MemberwiseClone();
|
||||
|
||||
collection.attributeValues_ = new ArrayList(attributeValues_.Count);
|
||||
|
||||
foreach (TsCHdaAttributeValue value in attributeValues_)
|
||||
{
|
||||
collection.attributeValues_.Add(value.Clone());
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => attributeValues_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
attributeValues_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaAttributeValue[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return attributeValues_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => attributeValues_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValue objects into the collection.");
|
||||
}
|
||||
|
||||
attributeValues_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
attributeValues_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValue objects into the collection.");
|
||||
}
|
||||
|
||||
attributeValues_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
attributeValues_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return attributeValues_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
attributeValues_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return attributeValues_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValue))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValue objects into the collection.");
|
||||
}
|
||||
|
||||
return attributeValues_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaAttributeValue value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaAttributeValue value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaAttributeValue value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaAttributeValue value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaAttributeValue value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
75
Technosoftware/DaAeHdaClient/Hda/BrowseElement.cs
Normal file
75
Technosoftware/DaAeHdaClient/Hda/BrowseElement.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the description of an element in the server's address space.
|
||||
/// </summary>
|
||||
public class TsCHdaBrowseElement : OpcItem
|
||||
{
|
||||
#region Fields
|
||||
private TsCHdaAttributeValueCollection attributes_ = new TsCHdaAttributeValueCollection();
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The name of element within its branch.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the element is an item with associated data in the archive.
|
||||
/// </summary>
|
||||
public bool IsItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the element has child elements.
|
||||
/// </summary>
|
||||
public bool HasChildren { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The current values of any attributes associated with the item.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValueCollection Attributes
|
||||
{
|
||||
get => attributes_;
|
||||
set => attributes_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep-copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var element = (TsCHdaBrowseElement)MemberwiseClone();
|
||||
element.Attributes = (TsCHdaAttributeValueCollection)attributes_.Clone();
|
||||
return element;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
72
Technosoftware/DaAeHdaClient/Hda/BrowseFilter.cs
Normal file
72
Technosoftware/DaAeHdaClient/Hda/BrowseFilter.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a filter to apply to an item attribute when browsing.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaBrowseFilter : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private TsCHdaOperator filterOperator_ = TsCHdaOperator.Equal;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The attribute id to use when filtering.
|
||||
/// </summary>
|
||||
public int AttributeID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The operator to use when testing if the filter condition is met.
|
||||
/// </summary>
|
||||
public TsCHdaOperator Operator
|
||||
{
|
||||
get => filterOperator_;
|
||||
set => filterOperator_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value of the filter. The '*' and '?' wildcard characters are permitted.
|
||||
/// </summary>
|
||||
public object FilterValue { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep-copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var filter = (TsCHdaBrowseFilter)MemberwiseClone();
|
||||
filter.FilterValue = OpcConvert.Clone(FilterValue);
|
||||
return filter;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
178
Technosoftware/DaAeHdaClient/Hda/BrowseFilterCollection.cs
Normal file
178
Technosoftware/DaAeHdaClient/Hda/BrowseFilterCollection.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of attribute filters used when browsing the server address space.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaBrowseFilterCollection : OpcItem, ICollection
|
||||
{
|
||||
#region Fields
|
||||
private TsCHdaBrowseFilter[] browseFilters_ = new TsCHdaBrowseFilter[0];
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Creates an empty collection.
|
||||
/// </summary>
|
||||
public TsCHdaBrowseFilterCollection()
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any BrowseFilter contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing browse filters.</param>
|
||||
public TsCHdaBrowseFilterCollection(ICollection collection)
|
||||
{
|
||||
Init(collection);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Returns the browse filter at the specified index.
|
||||
/// </summary>
|
||||
public TsCHdaBrowseFilter this[int index]
|
||||
{
|
||||
get => browseFilters_[index];
|
||||
set => browseFilters_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Returns the browse filter for the specified attribute id.
|
||||
/// </summary>
|
||||
public TsCHdaBrowseFilter Find(int id)
|
||||
{
|
||||
foreach (var filter in browseFilters_)
|
||||
{
|
||||
if (filter.AttributeID == id)
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with any attribute values contained in the collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">A collection containing attribute values.</param>
|
||||
public void Init(ICollection collection)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (collection != null)
|
||||
{
|
||||
var values = new ArrayList(collection.Count);
|
||||
|
||||
foreach (var value in collection)
|
||||
{
|
||||
if (value.GetType() == typeof(TsCHdaBrowseFilter))
|
||||
{
|
||||
values.Add(OpcConvert.Clone(value));
|
||||
}
|
||||
}
|
||||
|
||||
browseFilters_ = (TsCHdaBrowseFilter[])values.ToArray(typeof(TsCHdaBrowseFilter));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all attribute values in the collection.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
browseFilters_ = new TsCHdaBrowseFilter[0];
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
return new TsCHdaBrowseFilterCollection(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => browseFilters_?.Length ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects in to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
browseFilters_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaBrowseFilter[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return browseFilters_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
52
Technosoftware/DaAeHdaClient/Hda/BrowsePosition.cs
Normal file
52
Technosoftware/DaAeHdaClient/Hda/BrowsePosition.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores the state of a browse operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaBrowsePosition : IOpcBrowsePosition
|
||||
{
|
||||
#region IDisposable Members
|
||||
/// <summary>
|
||||
/// Releases any unmanaged resources held by the object.
|
||||
/// </summary>
|
||||
public virtual void Dispose() { }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a shallow copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
return (TsCHdaBrowsePosition)MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
53
Technosoftware/DaAeHdaClient/Hda/EditType.cs
Normal file
53
Technosoftware/DaAeHdaClient/Hda/EditType.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of modifications that can be applied to an item.
|
||||
/// </summary>
|
||||
public enum TsCHdaEditType
|
||||
{
|
||||
/// <summary>
|
||||
/// The item was inserted.
|
||||
/// </summary>
|
||||
Insert = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The item was replaced.
|
||||
/// </summary>
|
||||
Replace = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The item was inserted or replaced during an insert/replace operation.
|
||||
/// </summary>
|
||||
InsertReplace = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The item was deleted.
|
||||
/// </summary>
|
||||
Delete = 4
|
||||
}
|
||||
}
|
||||
44
Technosoftware/DaAeHdaClient/Hda/IActualTime.cs
Normal file
44
Technosoftware/DaAeHdaClient/Hda/IActualTime.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A interface used to actual time information associated with a result.
|
||||
/// </summary>
|
||||
public interface ITsCHdaActualTime
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual start time used by a server while processing a request.
|
||||
/// </summary>
|
||||
DateTime StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actual end time used by a server while processing a request.
|
||||
/// </summary>
|
||||
DateTime EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
63
Technosoftware/DaAeHdaClient/Hda/IBrowser.cs
Normal file
63
Technosoftware/DaAeHdaClient/Hda/IBrowser.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines functionality that is common to all OPC Data Access servers.
|
||||
/// </summary>
|
||||
public interface ITsCHdaBrowser : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the set of attribute filters used by the browser.
|
||||
/// </summary>
|
||||
TsCHdaBrowseFilterCollection Filters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Browses the server's address space at the specified branch.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item id of the branch to search.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCHdaBrowseElement[] Browse(OpcItem itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Begins a browsing the server's address space at the specified branch.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item id of the branch to search.</param>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The position object used to continue a browse operation.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCHdaBrowseElement[] Browse(OpcItem itemId, int maxElements, out IOpcBrowsePosition position);
|
||||
|
||||
/// <summary>
|
||||
/// Continues browsing the server's address space at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="maxElements">The maximum number of elements to return.</param>
|
||||
/// <param name="position">The position object used to continue a browse operation.</param>
|
||||
/// <returns>The set of elements that meet the filter criteria.</returns>
|
||||
TsCHdaBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position);
|
||||
}
|
||||
}
|
||||
546
Technosoftware/DaAeHdaClient/Hda/IServer.cs
Normal file
546
Technosoftware/DaAeHdaClient/Hda/IServer.cs
Normal file
@@ -0,0 +1,546 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines functionality that is common to all OPC Historical Data Access servers.
|
||||
/// </summary>
|
||||
public interface ITsCHdaServer : IOpcServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current server status.
|
||||
/// </summary>
|
||||
/// <returns>The current server status.</returns>
|
||||
OpcServerStatus GetServerStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the item attributes supported by the server.
|
||||
/// </summary>
|
||||
/// <returns>The a set of item attributes and their descriptions.</returns>
|
||||
TsCHdaAttribute[] GetAttributes();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the aggregates supported by the server.
|
||||
/// </summary>
|
||||
/// <returns>The a set of aggregates and their descriptions.</returns>
|
||||
TsCHdaAggregate[] GetAggregates();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a object used to browse the server address space.
|
||||
/// </summary>
|
||||
/// <param name="filters">The set of attribute filters to use when browsing.</param>
|
||||
/// <param name="results">A result code for each individual filter.</param>
|
||||
/// <returns>A browser object that must be released by calling Dispose().</returns>
|
||||
ITsCHdaBrowser CreateBrowser(TsCHdaBrowseFilter[] filters, out OpcResult[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The identifiers for the items to create.</param>
|
||||
/// <returns>The results for each item containing the server handle and result code.</returns>
|
||||
OpcItemResult[] CreateItems(OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Releases a set of previously created items.
|
||||
/// </summary>
|
||||
/// <param name="items">The server handles for the items to release.</param>
|
||||
/// <returns>The results for each item containing the result code.</returns>
|
||||
OpcItemResult[] ReleaseItems(OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a set of items.
|
||||
/// </summary>
|
||||
/// <param name="items">The identifiers for the items to validate.</param>
|
||||
/// <returns>The results for each item containing the result code.</returns>
|
||||
OpcItemResult[] ValidateItems(OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Reads raw (unprocessed) data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="maxValues">The number of values to be read for each item.</param>
|
||||
/// <param name="includeBounds">Whether the bounding item values should be returned.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <returns>A set of values, qualities and timestamps within the requested time range for each item.</returns>
|
||||
TsCHdaItemValueCollection[] ReadRaw(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
int maxValues,
|
||||
bool includeBounds,
|
||||
OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read raw data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="maxValues">The number of values to be read for each item.</param>
|
||||
/// <param name="includeBounds">Whether the bounding item values should be returned.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] ReadRaw(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
int maxValues,
|
||||
bool includeBounds,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaReadValuesCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Requests that the server periodically send notifications when new data becomes available for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="updateInterval">The frequency, in seconds, that the server should check for new data.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] AdviseRaw(
|
||||
TsCHdaTime startTime,
|
||||
decimal updateInterval,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaDataUpdateEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Begins the playback raw data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="maxValues">The number of values to be read for each item.</param>
|
||||
/// <param name="updateInterval">The frequency, in seconds, that the server send data.</param>
|
||||
/// <param name="playbackDuration">The duration, in seconds, of the timespan returned with each update.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] PlaybackRaw(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
int maxValues,
|
||||
decimal updateInterval,
|
||||
decimal playbackDuration,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaDataUpdateEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Reads processed data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="resampleInterval">The interval between returned values.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <returns>A set of values, qualities and timestamps within the requested time range for each item.</returns>
|
||||
TsCHdaItemValueCollection[] ReadProcessed(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
decimal resampleInterval,
|
||||
TsCHdaItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read processed data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="resampleInterval">The interval between returned values.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] ReadProcessed(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
decimal resampleInterval,
|
||||
TsCHdaItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaReadValuesCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Requests that the server periodically send notifications when new data becomes available for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="resampleInterval">The interval between returned values.</param>
|
||||
/// <param name="numberOfIntervals">The number of resample intervals that the server should return in each callback.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] AdviseProcessed(
|
||||
TsCHdaTime startTime,
|
||||
decimal resampleInterval,
|
||||
int numberOfIntervals,
|
||||
TsCHdaItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaDataUpdateEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Begins the playback of processed data from the historian database for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="resampleInterval">The interval between returned values.</param>
|
||||
/// <param name="numberOfIntervals">The number of resample intervals that the server should return in each callback.</param>
|
||||
/// <param name="updateInterval">The frequency, in seconds, that the server send data.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] PlaybackProcessed(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
decimal resampleInterval,
|
||||
int numberOfIntervals,
|
||||
decimal updateInterval,
|
||||
TsCHdaItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaDataUpdateEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Reads data from the historian database for a set of items at specific times.
|
||||
/// </summary>
|
||||
/// <param name="timestamps">The set of timestamps to use when reading items values.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <returns>A set of values, qualities and timestamps within the requested time range for each item.</returns>
|
||||
TsCHdaItemValueCollection[] ReadAtTime(DateTime[] timestamps, OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read item values at specific times.
|
||||
/// </summary>
|
||||
/// <param name="timestamps">The set of timestamps to use when reading items values.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] ReadAtTime(
|
||||
DateTime[] timestamps,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaReadValuesCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads item values that have been deleted or replaced.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="maxValues">The number of values to be read for each item.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <returns>A set of values, qualities and timestamps within the requested time range for each item.</returns>
|
||||
TsCHdaModifiedValueCollection[] ReadModified(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
int maxValues,
|
||||
OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read item values that have been deleted or replaced.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="maxValues">The number of values to be read for each item.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] ReadModified(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
int maxValues,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaReadValuesCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current or historical values for the attributes of an item.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="item">The item to read (must include the item name).</param>
|
||||
/// <param name="attributeIDs">The attributes to read.</param>
|
||||
/// <returns>A set of attribute values for each requested attribute.</returns>
|
||||
TsCHdaItemAttributeCollection ReadAttributes(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem item,
|
||||
int[] attributeIDs);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read the attributes of an item.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="item">The item to read (must include the item name).</param>
|
||||
/// <param name="attributeIDs">The attributes to read.</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the attribute ids.</returns>
|
||||
TsCHdaResultCollection ReadAttributes(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem item,
|
||||
int[] attributeIDs,
|
||||
object requestHandle,
|
||||
TsCHdaReadAttributesCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Reads any annotations for an item within the a time interval.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <returns>A set of annotations within the requested time range for each item.</returns>
|
||||
TsCHdaAnnotationValueCollection[] ReadAnnotations(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to read the annotations for a set of items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to read.</param>
|
||||
/// <param name="endTime">The end of the history period to be read.</param>
|
||||
/// <param name="items">The set of items to read (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] ReadAnnotations(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaReadAnnotationsCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts annotations for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">A list of annotations to add for each item (must include the item name).</param>
|
||||
/// <returns>The results of the insert operation for each annotation set.</returns>
|
||||
TsCHdaResultCollection[] InsertAnnotations(TsCHdaAnnotationValueCollection[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to inserts annotations for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">A list of annotations to add for each item (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] InsertAnnotations(
|
||||
TsCHdaAnnotationValueCollection[] items,
|
||||
object requestHandle,
|
||||
TsCHdaUpdateCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the values into the history database for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of values to insert.</param>
|
||||
/// <param name="replace">Whether existing values should be replaced.</param>
|
||||
/// <returns></returns>
|
||||
TsCHdaResultCollection[] Insert(TsCHdaItemValueCollection[] items, bool replace);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to inserts values for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of values to insert.</param>
|
||||
/// <param name="replace">Whether existing values should be replaced.</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] Insert(
|
||||
TsCHdaItemValueCollection[] items,
|
||||
bool replace,
|
||||
object requestHandle,
|
||||
TsCHdaUpdateCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Replace the values into the history database for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of values to replace.</param>
|
||||
/// <returns></returns>
|
||||
TsCHdaResultCollection[] Replace(TsCHdaItemValueCollection[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to replace values for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of values to replace.</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] Replace(
|
||||
TsCHdaItemValueCollection[] items,
|
||||
object requestHandle,
|
||||
TsCHdaUpdateCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the values with the specified time domain for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to delete.</param>
|
||||
/// <param name="endTime">The end of the history period to be delete.</param>
|
||||
/// <param name="items">The set of items to delete (must include the item name).</param>
|
||||
/// <returns>The results of the delete operation for each item.</returns>
|
||||
OpcItemResult[] Delete(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to delete values for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The beginning of the history period to delete.</param>
|
||||
/// <param name="endTime">The end of the history period to be delete.</param>
|
||||
/// <param name="items">The set of items to delete (must include the item name).</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] Delete(
|
||||
TsCHdaTime startTime,
|
||||
TsCHdaTime endTime,
|
||||
OpcItem[] items,
|
||||
object requestHandle,
|
||||
TsCHdaUpdateCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the values at the specified times for one or more items.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of timestamps to delete for one or more items.</param>
|
||||
/// <returns>The results of the operation for each timestamp.</returns>
|
||||
TsCHdaResultCollection[] DeleteAtTime(TsCHdaItemTimeCollection[] items);
|
||||
|
||||
/// <summary>
|
||||
/// Sends an asynchronous request to delete values for one or more items at a specified times.
|
||||
/// </summary>
|
||||
/// <param name="items">The set of timestamps to delete for one or more items.</param>
|
||||
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
|
||||
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
|
||||
OpcItemResult[] DeleteAtTime(
|
||||
TsCHdaItemTimeCollection[] items,
|
||||
object requestHandle,
|
||||
TsCHdaUpdateCompleteEventHandler callback,
|
||||
out IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an asynchronous request.
|
||||
/// </summary>
|
||||
/// <param name="request">The state object for the request to cancel.</param>
|
||||
void CancelRequest(IOpcRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels an asynchronous request.
|
||||
/// </summary>
|
||||
/// <param name="request">The state object for the request to cancel.</param>
|
||||
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
|
||||
void CancelRequest(IOpcRequest request, TsCHdaCancelCompleteEventHandler callback);
|
||||
|
||||
}
|
||||
|
||||
#region Delegate Declarations
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when an exception occurs while processing a callback.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="exception">Exception which occured.</param>
|
||||
public delegate void TsCHdaCallbackExceptionEventHandler(IOpcRequest request, Exception exception);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive data update notifications.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="results">A collection of results.</param>
|
||||
public delegate void TsCHdaDataUpdateEventHandler(IOpcRequest request, TsCHdaItemValueCollection[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when a read values request completes.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="results">A collection of results.</param>
|
||||
public delegate void TsCHdaReadValuesCompleteEventHandler(IOpcRequest request, TsCHdaItemValueCollection[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when a read attributes request completes.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="results">A collection of results.</param>
|
||||
public delegate void TsCHdaReadAttributesCompleteEventHandler(IOpcRequest request, TsCHdaItemAttributeCollection results);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when a read annotations request completes.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="results">A collection of results.</param>
|
||||
public delegate void TsCHdaReadAnnotationsCompleteEventHandler(IOpcRequest request, TsCHdaAnnotationValueCollection[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when an update request completes.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
/// <param name="results">A collection of results.</param>
|
||||
public delegate void TsCHdaUpdateCompleteEventHandler(IOpcRequest request, TsCHdaResultCollection[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Used to receive notifications when a request is cancelled.
|
||||
/// </summary>
|
||||
/// <param name="request">An identifier for the request assigned by the caller.</param>
|
||||
public delegate void TsCHdaCancelCompleteEventHandler(IOpcRequest request);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
74
Technosoftware/DaAeHdaClient/Hda/Item.cs
Normal file
74
Technosoftware/DaAeHdaClient/Hda/Item.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item used in a request for processed or raw data.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItem : OpcItem
|
||||
{
|
||||
#region Fields
|
||||
private int aggregate_ = TsCHdaAggregateID.NoAggregate;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaItem() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaItem(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCHdaItem(TsCHdaItem item)
|
||||
: base(item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
Aggregate = item.Aggregate;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The aggregate to use to process the data.
|
||||
/// </summary>
|
||||
public int Aggregate
|
||||
{
|
||||
get => aggregate_;
|
||||
set => aggregate_ = value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
345
Technosoftware/DaAeHdaClient/Hda/ItemAttributeCollection.cs
Normal file
345
Technosoftware/DaAeHdaClient/Hda/ItemAttributeCollection.cs
Normal file
@@ -0,0 +1,345 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of item attribute values passed to write or returned from a read operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemAttributeCollection : OpcItem, IOpcResult, ITsCHdaActualTime, IList
|
||||
{
|
||||
#region Fields
|
||||
private DateTime startTime_ = DateTime.MinValue;
|
||||
private DateTime endTime_ = DateTime.MinValue;
|
||||
private ArrayList attributes_ = new ArrayList();
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaItemAttributeCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaItemAttributeCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemAttributeCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaItemAttributeCollection(TsCHdaItemAttributeCollection item)
|
||||
: base(item)
|
||||
{
|
||||
attributes_ = new ArrayList(item.attributes_.Count);
|
||||
|
||||
foreach (TsCHdaAttributeValueCollection value in item.attributes_)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
attributes_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public TsCHdaAttributeValueCollection this[int index]
|
||||
{
|
||||
get => (TsCHdaAttributeValueCollection)attributes_[index];
|
||||
set => attributes_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IActualTime Members
|
||||
/// <summary>
|
||||
/// The actual start time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime StartTime
|
||||
{
|
||||
get => startTime_;
|
||||
set => startTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual end time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get => endTime_;
|
||||
set => endTime_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var collection = (TsCHdaItemAttributeCollection)base.Clone();
|
||||
|
||||
collection.attributes_ = new ArrayList(attributes_.Count);
|
||||
|
||||
foreach (TsCHdaAttributeValueCollection value in attributes_)
|
||||
{
|
||||
collection.attributes_.Add(value.Clone());
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => attributes_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
attributes_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaAttributeValueCollection[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return attributes_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => attributes_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValueCollection))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValueCollection objects into the collection.");
|
||||
}
|
||||
|
||||
attributes_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
attributes_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValueCollection))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValueCollection objects into the collection.");
|
||||
}
|
||||
|
||||
attributes_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
attributes_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return attributes_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
attributes_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return attributes_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaAttributeValueCollection))
|
||||
{
|
||||
throw new ArgumentException("May only add AttributeValueCollection objects into the collection.");
|
||||
}
|
||||
|
||||
return attributes_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaAttributeValueCollection value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaAttributeValueCollection value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaAttributeValueCollection value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaAttributeValueCollection value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaAttributeValueCollection value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
315
Technosoftware/DaAeHdaClient/Hda/ItemCollection.cs
Normal file
315
Technosoftware/DaAeHdaClient/Hda/ItemCollection.cs
Normal file
@@ -0,0 +1,315 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of items.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemCollection : ICloneable, IList
|
||||
{
|
||||
#region Fields
|
||||
private ArrayList items_ = new ArrayList();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaItemCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ResultCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaItemCollection(TsCHdaItemCollection items)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (TsCHdaItem item in items)
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item at the specified index.
|
||||
/// </summary>
|
||||
public TsCHdaItem this[int index]
|
||||
{
|
||||
get => (TsCHdaItem)items_[index];
|
||||
set => items_[index] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first item with the specified item id.
|
||||
/// </summary>
|
||||
public TsCHdaItem this[OpcItem itemId]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (TsCHdaItem item in items_)
|
||||
{
|
||||
if (itemId.Key == item.Key)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public virtual object Clone()
|
||||
{
|
||||
var clone = (TsCHdaItemCollection)MemberwiseClone();
|
||||
|
||||
clone.items_ = new ArrayList();
|
||||
|
||||
foreach (TsCHdaItem item in items_)
|
||||
{
|
||||
clone.items_.Add(item.Clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => items_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
items_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaItem[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return items_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => items_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaItem))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
items_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
items_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaItem))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
items_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
items_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return items_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
items_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return items_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaItem))
|
||||
{
|
||||
throw new ArgumentException("May only add Item objects into the collection.");
|
||||
}
|
||||
|
||||
return items_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaItem value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaItem value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaItem value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaItem value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaItem value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
85
Technosoftware/DaAeHdaClient/Hda/ItemResult.cs
Normal file
85
Technosoftware/DaAeHdaClient/Hda/ItemResult.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the results for an item used in a read processed or raw data request.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemResult : TsCHdaItem, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initialize object with default values.
|
||||
/// </summary>
|
||||
public TsCHdaItemResult() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaItemResult(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCHdaItemResult(TsCHdaItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize object with the specified ItemResult object.
|
||||
/// </summary>
|
||||
public TsCHdaItemResult(TsCHdaItemResult item)
|
||||
: base(item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
Result = item.Result;
|
||||
DiagnosticInfo = item.DiagnosticInfo;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
299
Technosoftware/DaAeHdaClient/Hda/ItemTimeCollection.cs
Normal file
299
Technosoftware/DaAeHdaClient/Hda/ItemTimeCollection.cs
Normal file
@@ -0,0 +1,299 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of results passed to write or returned from an insert, replace or delete operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemTimeCollection : OpcItem, IList
|
||||
{
|
||||
#region Fields
|
||||
private ArrayList times_ = new ArrayList();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaItemTimeCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaItemTimeCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemTimeCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaItemTimeCollection(TsCHdaItemTimeCollection item)
|
||||
: base(item)
|
||||
{
|
||||
times_ = new ArrayList(item.times_.Count);
|
||||
|
||||
foreach (DateTime value in item.times_)
|
||||
{
|
||||
times_.Add(value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public DateTime this[int index]
|
||||
{
|
||||
get => (DateTime)times_[index];
|
||||
set => times_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var collection = (TsCHdaItemTimeCollection)base.Clone();
|
||||
|
||||
collection.times_ = new ArrayList(times_.Count);
|
||||
|
||||
foreach (DateTime value in times_)
|
||||
{
|
||||
collection.times_.Add(value);
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => times_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
times_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(DateTime[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return times_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => times_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is DateTime))
|
||||
{
|
||||
throw new ArgumentException("May only add DateTime objects into the collection.");
|
||||
}
|
||||
|
||||
times_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
times_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is DateTime))
|
||||
{
|
||||
throw new ArgumentException("May only add DateTime objects into the collection.");
|
||||
}
|
||||
|
||||
times_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
times_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return times_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
times_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return times_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is DateTime))
|
||||
{
|
||||
throw new ArgumentException("May only add DateTime objects into the collection.");
|
||||
}
|
||||
|
||||
return times_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, DateTime value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(DateTime value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(DateTime value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(DateTime value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(DateTime value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
93
Technosoftware/DaAeHdaClient/Hda/ItemValue.cs
Normal file
93
Technosoftware/DaAeHdaClient/Hda/ItemValue.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
#pragma warning disable 618
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A value of an item at in instant of time.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemValue : ICloneable
|
||||
{
|
||||
#region Fields
|
||||
private DateTime timestamp_ = DateTime.MinValue;
|
||||
private Da.TsCDaQuality daQuality_ = Da.TsCDaQuality.Bad;
|
||||
private TsCHdaQuality historianQuality_ = TsCHdaQuality.NoData;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The value of the item.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timestamp associated with the value.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get => timestamp_;
|
||||
set => timestamp_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The quality associated with the value when it was acquired from the data source.
|
||||
/// </summary>
|
||||
public Da.TsCDaQuality Quality
|
||||
{
|
||||
get => daQuality_;
|
||||
set => daQuality_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The quality associated with the value when it was retrieved from the hiatorian database.
|
||||
/// </summary>
|
||||
public TsCHdaQuality HistorianQuality
|
||||
{
|
||||
get => historianQuality_;
|
||||
set => historianQuality_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public object Clone()
|
||||
{
|
||||
var value = (TsCHdaItemValue)MemberwiseClone();
|
||||
value.Value = OpcConvert.Clone(Value);
|
||||
return value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
369
Technosoftware/DaAeHdaClient/Hda/ItemValueCollection.cs
Normal file
369
Technosoftware/DaAeHdaClient/Hda/ItemValueCollection.cs
Normal file
@@ -0,0 +1,369 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of item values passed to write or returned from a read operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaItemValueCollection : TsCHdaItem, IOpcResult, ITsCHdaActualTime, ICollection, ICloneable, IList
|
||||
{
|
||||
#region Fields
|
||||
private DateTime startTime_ = DateTime.MinValue;
|
||||
private DateTime endTime_ = DateTime.MinValue;
|
||||
private ArrayList values_ = new ArrayList();
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaItemValueCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaItemValueCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCHdaItemValueCollection(TsCHdaItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemValueCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaItemValueCollection(TsCHdaItemValueCollection item)
|
||||
: base(item)
|
||||
{
|
||||
values_ = new ArrayList(item.values_.Count);
|
||||
|
||||
foreach (TsCHdaItemValue value in item.values_)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
values_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public TsCHdaItemValue this[int index]
|
||||
{
|
||||
get => (TsCHdaItemValue)values_[index];
|
||||
set => values_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Appends another value collection to the collection.
|
||||
/// </summary>
|
||||
public void AddRange(TsCHdaItemValueCollection collection)
|
||||
{
|
||||
if (collection != null)
|
||||
{
|
||||
foreach (TsCHdaItemValue value in collection)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
values_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region IActualTime Members
|
||||
/// <summary>
|
||||
/// The actual start time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime StartTime
|
||||
{
|
||||
get => startTime_;
|
||||
set => startTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual end time used by a server while processing a request.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get => endTime_;
|
||||
set => endTime_ = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var collection = (TsCHdaItemValueCollection)base.Clone();
|
||||
|
||||
collection.values_ = new ArrayList(values_.Count);
|
||||
|
||||
foreach (TsCHdaItemValue value in values_)
|
||||
{
|
||||
collection.values_.Add(value.Clone());
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => values_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
values_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaItemValue[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return values_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => values_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaItemValue))
|
||||
{
|
||||
throw new ArgumentException("May only add ItemValue objects into the collection.");
|
||||
}
|
||||
|
||||
values_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
values_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaItemValue))
|
||||
{
|
||||
throw new ArgumentException("May only add ItemValue objects into the collection.");
|
||||
}
|
||||
|
||||
values_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
values_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return values_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
values_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return values_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaItemValue))
|
||||
{
|
||||
throw new ArgumentException("May only add ItemValue objects into the collection.");
|
||||
}
|
||||
|
||||
return values_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaItemValue value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaItemValue value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaItemValue value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaItemValue value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaItemValue value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
90
Technosoftware/DaAeHdaClient/Hda/ItemValueResult.cs
Normal file
90
Technosoftware/DaAeHdaClient/Hda/ItemValueResult.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A result associated with a single item value.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaResult : ICloneable, IOpcResult
|
||||
{
|
||||
#region Fields
|
||||
private OpcResult result_ = OpcResult.S_OK;
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes the object with default values.
|
||||
/// </summary>
|
||||
public TsCHdaResult() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified result id.
|
||||
/// </summary>
|
||||
public TsCHdaResult(OpcResult resultId)
|
||||
{
|
||||
Result = resultId;
|
||||
DiagnosticInfo = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the object with the specified result object.
|
||||
/// </summary>
|
||||
public TsCHdaResult(IOpcResult result)
|
||||
{
|
||||
Result = result.Result;
|
||||
DiagnosticInfo = result.DiagnosticInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOpcResult Members
|
||||
/// <summary>
|
||||
/// The error id for the result of an operation on an item.
|
||||
/// </summary>
|
||||
public OpcResult Result
|
||||
{
|
||||
get => result_;
|
||||
set => result_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vendor specific diagnostic information (not the localized error text).
|
||||
/// </summary>
|
||||
public string DiagnosticInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
67
Technosoftware/DaAeHdaClient/Hda/ModifiedValue.cs
Normal file
67
Technosoftware/DaAeHdaClient/Hda/ModifiedValue.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A value of an item at in instant of time that has be deleted or replaced.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaModifiedValue : TsCHdaItemValue
|
||||
{
|
||||
#region Fields
|
||||
private DateTime modificationTime_ = DateTime.MinValue;
|
||||
private TsCHdaEditType editType_ = TsCHdaEditType.Insert;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The time when the value was deleted or replaced.
|
||||
/// The <see cref="ApplicationInstance.TimeAsUtc">ApplicationInstance.TimeAsUtc</see> property defines
|
||||
/// the time format (UTC or local time).
|
||||
/// </summary>
|
||||
public DateTime ModificationTime
|
||||
{
|
||||
get => modificationTime_;
|
||||
set => modificationTime_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the value was deleted or replaced.
|
||||
/// </summary>
|
||||
public TsCHdaEditType EditType
|
||||
{
|
||||
get => editType_;
|
||||
set => editType_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user who modified the item value.
|
||||
/// </summary>
|
||||
public string User { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
68
Technosoftware/DaAeHdaClient/Hda/ModifiedValueCollection.cs
Normal file
68
Technosoftware/DaAeHdaClient/Hda/ModifiedValueCollection.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of modified item values with a result code indicating the results of a read operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaModifiedValueCollection : TsCHdaItemValueCollection
|
||||
{
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initialize object with default values.
|
||||
/// </summary>
|
||||
public TsCHdaModifiedValueCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaModifiedValueCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified Item object.
|
||||
/// </summary>
|
||||
public TsCHdaModifiedValueCollection(TsCHdaItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemValueCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaModifiedValueCollection(TsCHdaItemValueCollection item) : base(item) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public new TsCHdaModifiedValue this[int index]
|
||||
{
|
||||
get => (TsCHdaModifiedValue)this[index];
|
||||
set => this[index] = value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
64
Technosoftware/DaAeHdaClient/Hda/Operator.cs
Normal file
64
Technosoftware/DaAeHdaClient/Hda/Operator.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// The set of possible operators to use when applying an item attribute filter.
|
||||
/// </summary>
|
||||
public enum TsCHdaOperator
|
||||
{
|
||||
/// <summary>
|
||||
/// The attribute value is equal (or matches) to the filter.
|
||||
/// </summary>
|
||||
Equal = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value is less than the filter.
|
||||
/// </summary>
|
||||
Less,
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value is less than or equal to the filter.
|
||||
/// </summary>
|
||||
LessEqual,
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value is greater than the filter.
|
||||
/// </summary>
|
||||
Greater,
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value is greater than or equal to the filter.
|
||||
/// </summary>
|
||||
GreaterEqual,
|
||||
|
||||
/// <summary>
|
||||
/// The attribute value is not equal (or does not match)to the filter.
|
||||
/// </summary>
|
||||
NotEqual
|
||||
}
|
||||
}
|
||||
80
Technosoftware/DaAeHdaClient/Hda/Quality.cs
Normal file
80
Technosoftware/DaAeHdaClient/Hda/Quality.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines possible HDA quality codes.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TsCHdaQuality
|
||||
{
|
||||
/// <summary>
|
||||
/// More than one piece of data that may be hidden exists at same timestamp.
|
||||
/// </summary>
|
||||
ExtraData = 0x00010000,
|
||||
|
||||
/// <summary>
|
||||
/// Interpolated data value.
|
||||
/// </summary>
|
||||
Interpolated = 0x00020000,
|
||||
|
||||
/// <summary>
|
||||
/// Raw data
|
||||
/// </summary>
|
||||
Raw = 0x00040000,
|
||||
|
||||
/// <summary>
|
||||
/// Calculated data value, as would be returned from a ReadProcessed call.
|
||||
/// </summary>
|
||||
Calculated = 0x00080000,
|
||||
|
||||
/// <summary>
|
||||
/// No data found to provide upper or lower bound value.
|
||||
/// </summary>
|
||||
NoBound = 0x00100000,
|
||||
|
||||
/// <summary>
|
||||
/// Bad No data collected. Archiving not active (for item or all items).
|
||||
/// </summary>
|
||||
NoData = 0x00200000,
|
||||
|
||||
/// <summary>
|
||||
/// Collection started/stopped/lost.
|
||||
/// </summary>
|
||||
DataLost = 0x00400000,
|
||||
|
||||
/// <summary>
|
||||
/// Scaling or conversion error.
|
||||
/// </summary>
|
||||
Conversion = 0x00800000,
|
||||
|
||||
/// <summary>
|
||||
/// Aggregate value is for an incomplete interval.
|
||||
/// </summary>
|
||||
Partial = 0x01000000
|
||||
}
|
||||
}
|
||||
74
Technosoftware/DaAeHdaClient/Hda/RelativeTime.cs
Normal file
74
Technosoftware/DaAeHdaClient/Hda/RelativeTime.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible base or offset types for relative times.
|
||||
/// </summary>
|
||||
public enum TsCHdaRelativeTime
|
||||
{
|
||||
/// <summary>
|
||||
/// Start from the current time.
|
||||
/// </summary>
|
||||
Now,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current second or an offset in seconds.
|
||||
/// </summary>
|
||||
Second,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current minutes or an offset in minutes.
|
||||
/// </summary>
|
||||
Minute,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current hour or an offset in hours.
|
||||
/// </summary>
|
||||
Hour,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current day or an offset in days.
|
||||
/// </summary>
|
||||
Day,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current week or an offset in weeks.
|
||||
/// </summary>
|
||||
Week,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current month or an offset in months.
|
||||
/// </summary>
|
||||
Month,
|
||||
|
||||
/// <summary>
|
||||
/// The start of the current year or an offset in years.
|
||||
/// </summary>
|
||||
Year
|
||||
}
|
||||
}
|
||||
299
Technosoftware/DaAeHdaClient/Hda/ResultCollection.cs
Normal file
299
Technosoftware/DaAeHdaClient/Hda/ResultCollection.cs
Normal file
@@ -0,0 +1,299 @@
|
||||
#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
// Web: https://www.technosoftware.com
|
||||
//
|
||||
// The source code in this file is covered under a dual-license scenario:
|
||||
// - Owner of a purchased license: SCLA 1.0
|
||||
// - GPL V3: everybody else
|
||||
//
|
||||
// SCLA license terms accompanied with this source code.
|
||||
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
|
||||
//
|
||||
// GNU General Public License as published by the Free Software Foundation;
|
||||
// version 3 of the License are accompanied with this source code.
|
||||
// See https://technosoftware.com/license/GPLv3License.txt
|
||||
//
|
||||
// This source code is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
|
||||
|
||||
#region Using Directives
|
||||
using System;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace Technosoftware.DaAeHdaClient.Hda
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of results passed to write or returned from an insert, replace or delete operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TsCHdaResultCollection : OpcItem, ICollection, ICloneable, IList
|
||||
{
|
||||
#region Fields
|
||||
private ArrayList results_ = new ArrayList();
|
||||
#endregion
|
||||
|
||||
#region Constructors, Destructor, Initialization
|
||||
/// <summary>
|
||||
/// Initializes object with the default values.
|
||||
/// </summary>
|
||||
public TsCHdaResultCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ItemIdentifier object.
|
||||
/// </summary>
|
||||
public TsCHdaResultCollection(OpcItem item) : base(item) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes object with the specified ResultCollection object.
|
||||
/// </summary>
|
||||
public TsCHdaResultCollection(TsCHdaResultCollection item)
|
||||
: base(item)
|
||||
{
|
||||
results_ = new ArrayList(item.results_.Count);
|
||||
|
||||
foreach (TsCHdaResult value in item.results_)
|
||||
{
|
||||
results_.Add(value.Clone());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Accessor for elements in the collection.
|
||||
/// </summary>
|
||||
public TsCHdaResult this[int index]
|
||||
{
|
||||
get => (TsCHdaResult)results_[index];
|
||||
set => results_[index] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates a deep copy of the object.
|
||||
/// </summary>
|
||||
public override object Clone()
|
||||
{
|
||||
var collection = (TsCHdaResultCollection)base.Clone();
|
||||
|
||||
collection.results_ = new ArrayList(results_.Count);
|
||||
|
||||
foreach (TsCHdaResultCollection value in results_)
|
||||
{
|
||||
collection.results_.Add(value.Clone());
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of objects in the collection.
|
||||
/// </summary>
|
||||
public int Count => results_?.Count ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
results_?.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the objects to an Array, starting at a the specified index.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination for the objects.</param>
|
||||
/// <param name="index">The zero-based index in the Array at which copying begins.</param>
|
||||
public void CopyTo(TsCHdaResult[] array, int index)
|
||||
{
|
||||
CopyTo((Array)array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether access to the ICollection is synchronized (thread-safe).
|
||||
/// </summary>
|
||||
public object SyncRoot => this;
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through a collection.
|
||||
/// </summary>
|
||||
/// <returns>An IEnumerator that can be used to iterate through the collection.</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return results_.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the IList is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
object IList.this[int index]
|
||||
{
|
||||
get => results_[index];
|
||||
|
||||
set
|
||||
{
|
||||
if (!(value is TsCHdaResult))
|
||||
{
|
||||
throw new ArgumentException("May only add Result objects into the collection.");
|
||||
}
|
||||
|
||||
results_[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the IList item at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the item to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
results_.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, object value)
|
||||
{
|
||||
if (!(value is TsCHdaResult))
|
||||
{
|
||||
throw new ArgumentException("May only add Result objects into the collection.");
|
||||
}
|
||||
|
||||
results_.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(object value)
|
||||
{
|
||||
results_.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return results_.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the IList.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
results_.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return results_.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(object value)
|
||||
{
|
||||
if (!(value is TsCHdaResult))
|
||||
{
|
||||
throw new ArgumentException("May only add Result objects into the collection.");
|
||||
}
|
||||
|
||||
return results_.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the IList has a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the IList at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Object to insert into the IList. </param>
|
||||
public void Insert(int index, TsCHdaResult value)
|
||||
{
|
||||
Insert(index, (object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to remove from the IList.</param>
|
||||
public void Remove(TsCHdaResult value)
|
||||
{
|
||||
Remove((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the IList contains a specific value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>true if the Object is found in the IList; otherwise, false.</returns>
|
||||
public bool Contains(TsCHdaResult value)
|
||||
{
|
||||
return Contains((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of a specific item in the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to locate in the IList.</param>
|
||||
/// <returns>The index of value if found in the list; otherwise, -1.</returns>
|
||||
public int IndexOf(TsCHdaResult value)
|
||||
{
|
||||
return IndexOf((object)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the IList.
|
||||
/// </summary>
|
||||
/// <param name="value">The Object to add to the IList. </param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TsCHdaResult value)
|
||||
{
|
||||
return Add((object)value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
1072
Technosoftware/DaAeHdaClient/Hda/Server.cs
Normal file
1072
Technosoftware/DaAeHdaClient/Hda/Server.cs
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user