using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPCSupport.Streaming
{
    public class PartialArrayIntAvailableEventArgs : EventArgs
    {
/*        const int PACKET_MAX30101 = 0x10;
        const int PACKET_LIS2DH = 0x20;
        const int PACKET_MAX30001_ECG = 0x30;
        const int PACKET_MAX30001_PACE = 0x31;
        const int PACKET_MAX30001_RTOR = 0x32;
        const int PACKET_MAX30001_BIOZ = 0x33;
        const int PACKET_MAX30001_LEADOFF_DC = 0x34;
        //#define PACKET_MAX30001_LEADOFF_DC_BIOZ 	0x36
        const int PACKET_MAX30001_LEADOFF_AC = 0x35;
        const int PACKET_MAX30001_BCGMON = 0x36;
        const int PACKET_MAX31725_TEMP1 = 0x40;
        const int PACKET_MAX31725_TEMP2 = 0x50;
        const int PACKET_BMP280_PRESSURE = 0x60;
        const int PACKET_LSM6DS3_ACCEL = 0x70;
        const int PACKET_MAX30205_TEMP = 0x80;

        */
        public const int PACKET_MAX30101   =           0x10;

        public const int PACKET_LIS2DH = 0x20;

        public const int PACKET_MAX30001_ECG = 0x30;
        public const int PACKET_MAX30001_PACE = 0x31;
        public const int PACKET_MAX30001_RTOR = 0x32;
        public const int PACKET_MAX30001_BIOZ = 0x33;
        public const int PACKET_MAX30001_LEADOFF_DC = 0x34;
//#define PACKET_MAX30001_LEADOFF_DC_BIOZ   0x36
        public const int PACKET_MAX30001_LEADOFF_AC = 0x35;
        public const int PACKET_MAX30001_BCGMON = 0x36;

        public const int PACKET_MAX31725_TEMP1 = 0x40;
        public const int PACKET_MAX31725_TEMP2 = 0x50;
        public const int PACKET_BMP280_PRESSURE = 0x60;
        public const int PACKET_LSM6DS3_ACCEL = 0x70;

        public const int PACKET_DATALOGGING_PARAMETERS = 0xF0;
        public const int PACKET_DATALOGGING_RESUME_TABLE = 0xF1;
        public const int PACKET_END_OF_STREAM = 0xF2;

        /// <summary>
        /// Sequential index of the first sample.
        /// </summary>
        public int reportID { get; set; }
        public int sampleNumberOffset { get; set; }

        public int timestamp { get; set; }
        public int[] array1 { get; set; }
        public int[] array2 { get; set; }
        public int[] array3 { get; set; }

        public static bool ValidatePacketID(int id)
        {
            bool valid = false;

            uint idMasked = (uint)(id & 0xFF);
            uint magicValue55 = (uint)(id & 0xFF000000) >> 24;
            uint magicValueAA = (uint)(id & 0xFF0000) >> 16;
            uint incomingChecksum = (uint)(id & 0xFF00) >> 8;
            uint sum;
            sum = 0x55;
            sum += 0xAA;
            sum += idMasked;
            sum &= 0xFF;
            if (sum == incomingChecksum && magicValue55 == 0x55 && magicValueAA == 0xAA) valid = true;

/*            switch (id)
            {
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30101: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_LIS2DH: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_ECG: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_PACE: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_RTOR: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_BIOZ: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_LEADOFF_DC: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_LEADOFF_AC: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX30001_BCGMON: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX31725_TEMP1: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_MAX31725_TEMP2: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_BMP280_PRESSURE: valid = true; break;
                case PartialArrayIntAvailableEventArgs.PACKET_LSM6DS3_ACCEL: valid = true; break;
            }*/
            return valid;
        }
    }

}
