This commit is contained in:
luosheng
2023-07-12 06:42:28 +08:00
parent 25555cad18
commit db591e0367
188 changed files with 56088 additions and 9 deletions

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
};
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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 conditions active state has changed.
/// </summary>
ActiveState = 0x0001,
/// <summary>
/// The conditions acknowledgment state has changed.
/// </summary>
AcknowledgeState = 0x0002,
/// <summary>
/// The conditions 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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);
}
}

View 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
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View 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
}
}