using System;
using System.Linq;
using System.Runtime.Serialization;

namespace WCS.Entity.Protocol.DataStructure
{
    /// <summary>
    /// 设备数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [DataContract]
    public class DeviceDataCollection<T> where T : DeviceData
    {
        /// <summary>
        /// 确认时间
        /// </summary>
        [DataMember(Order = 3)]
        public DateTime Frame { get; set; }

        /// <summary>
        /// 数据集
        /// </summary>
        [DataMember(Order = 4)]
        public T[] Datas { get; set; }

        /// <summary>
        ///  默认构造函数
        /// </summary>
        public DeviceDataCollection()
        {
        }

        /// <summary>
        ///  构造函数
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="datas"></param>
        public DeviceDataCollection(DateTime frame, object[] datas)
        {
            this.Frame = frame;
            this.Datas = datas.OfType<T>().ToArray();
        }
    }
}
