using System;

namespace IOB_WIN_OPC_UA
{
    /// <summary>
    /// Classe di estensione x oggetti DataItems OPC-UA con struttura e valori
    /// </summary>
    [Serializable]
    public class OpcUaDataItemExt : Opc.Ua.Client.MonitoredItem
    {
        #region Public Constructors

        public OpcUaDataItemExt(Opc.Ua.Client.MonitoredItem MonIt)
        {
            if (MonIt != null)
            {
                AttributeId = MonIt.AttributeId;
                CacheQueueSize = MonIt.CacheQueueSize > 0 ? MonIt.CacheQueueSize : 1;
                Handle = MonIt.Handle;
                DiscardOldest = MonIt.DiscardOldest;
                DisplayName = MonIt.DisplayName;
                Encoding = MonIt.Encoding;
                Filter = MonIt.Filter;
                IndexRange = MonIt.IndexRange;
                MonitoringMode = MonIt.MonitoringMode;
                NodeClass = MonIt.NodeClass;
                QueueSize = MonIt.QueueSize;
                RelativePath = MonIt.RelativePath;
                SamplingInterval = MonIt.SamplingInterval;
                StartNodeId = MonIt.StartNodeId;
            }
        }

        #endregion Public Constructors

        #region Public Properties

        /// <summary>
        /// NodeId univoco dell'oggetto x subscription (StartNodeId)
        /// </summary>
        public string nodeId { get; set; } = "";

        /// <summary>
        /// Valore Registrato in formato byte array
        /// </summary>
        public byte[] rawByte { get; set; } = new byte[1];

        /// <summary>
        /// Valore (in sec) del periodo di downsampling (0 --> NON usato)
        /// </summary>
        public int samplePeriod { get; set; } = 60;

        /// <summary>
        /// Valore soglia DeadBand (0 --> non usata)
        /// </summary>
        public double thresholdDeadBand { get; set; } = 0;

        /// <summary>
        /// UUID univoco dell'oggetto --> flusso (DisplayName)
        /// </summary>
        public string uid { get; set; } = "";

        /// <summary>
        /// Valore Registrato in formato stringa
        /// </summary>
        public string value { get; set; } = "";

        /// <summary>
        /// Timestamp data-ora evento registrato
        /// </summary>
        public DateTime valueTimestamp { get; set; } = DateTime.Now;

        #endregion Public Properties
    }
}