#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 { /// /// The description of an item condition state supported by the server. /// [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 /// /// Contains a read-only collection of AttributeValues. /// public class AttributeValueCollection : OpcWriteableCollection { /// /// An indexer for the collection. /// public new TsCAeAttributeValue this[int index] => (TsCAeAttributeValue)Array[index]; /// /// Returns a copy of the collection as an array. /// public new TsCAeAttributeValue[] ToArray() { return (TsCAeAttributeValue[])Array.ToArray(); } /// /// Creates an empty collection. /// internal AttributeValueCollection() : base(null, typeof(TsCAeAttributeValue)) { } } #endregion #region SubConditionCollection Class /// /// Contains a read-only collection of SubConditions. /// public class SubConditionCollection : OpcWriteableCollection { /// /// An indexer for the collection. /// public new TsCAeSubCondition this[int index] => (TsCAeSubCondition)Array[index]; /// /// Returns a copy of the collection as an array. /// public new TsCAeSubCondition[] ToArray() { return (TsCAeSubCondition[])Array.ToArray(); } /// /// Creates an empty collection. /// internal SubConditionCollection() : base(null, typeof(TsCAeSubCondition)) { } } #endregion #region Properties /// /// A bit mask indicating the current state of the condition /// public int State { get; set; } /// /// 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. /// public TsCAeSubCondition ActiveSubCondition { get => _activeSubcondition; set => _activeSubcondition = value; } /// /// The quality associated with the condition state. /// public TsCDaQuality Quality { get => _quality; set => _quality = value; } /// /// The time of the most recent acknowledgment of this condition (of any sub-condition). /// The ApplicationInstance.TimeAsUtc property defines /// the time format (UTC or local time). /// public DateTime LastAckTime { get => _lastAckTime; set => _lastAckTime = value; } /// /// 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 ApplicationInstance.TimeAsUtc property defines /// the time format (UTC or local time). /// public DateTime SubCondLastActive { get => _subCondLastActive; set => _subCondLastActive = value; } /// /// 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 ApplicationInstance.TimeAsUtc property defines /// the time format (UTC or local time). /// public DateTime CondLastActive { get => _condLastActive; set => _condLastActive = value; } /// /// 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 ApplicationInstance.TimeAsUtc property defines /// the time format (UTC or local time). /// public DateTime CondLastInactive { get => _condLastInactive; set => _condLastInactive = value; } /// /// This is the ID of the client who last acknowledged this condition. /// This value is null if the condition has never been acknowledged. /// public string AcknowledgerID { get; set; } /// /// The comment string passed in by the client who last acknowledged this condition. /// This value is null if the condition has never been acknowledged. /// public string Comment { get; set; } /// /// The sub-conditions defined for this condition. /// For single-state conditions, the collection will contain one element, the value of which describes the condition. /// public SubConditionCollection SubConditions => _subconditions; /// /// The values of the attributes requested for this condition. /// public AttributeValueCollection Attributes => _attributes; #endregion #region ICloneable Members /// /// Creates a deep copy of the object. /// 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 } }