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

namespace INT89DB_26.Int_Modbus
{
    public class Modbus_30000_Data
    {
        #region Field
        private short m_DecimalPoint;
        private int m_OperationStatus;
        private double m_UnderValue;
        private double m_PassValue;
        private double m_OverValue;
        private double m_TareValue;
        private double m_HighLimit;
        private double m_DeadZoneHighLimit;
        private double m_DeadZoneLowLimit;
        private double m_LowLimit;
        private UInt32 m_SampleCount;
        private UInt32 m_IgnoreCount;

        private Collection<Modbus_30000_LaneData> m_LaneModbusData;
        #endregion

        #region Constructor
        public Modbus_30000_Data()
        {
            this.Initialization();
        }
        #endregion

        #region Property
        public short DecimalPoint
        {
            get { return this.m_DecimalPoint; }
            set { this.m_DecimalPoint = value; }
        }
        public int OperationStatus
        {
            get { return this.m_OperationStatus; }
            set { this.m_OperationStatus = value; }
        }
        public double UnderValue
        {
            get { return this.m_UnderValue; }
            set { this.m_UnderValue = value; }
        }
        public double PassValue
        {
            get { return this.m_PassValue; }
            set { this.m_PassValue = value; }
        }
        public double OverValue
        {
            get { return this.m_OverValue; }
            set { this.m_OverValue = value; }
        }
        public double TareValue
        {
            get { return this.m_TareValue; }
            set { this.m_TareValue = value; }
        }

        public string HexStringOperationStatus
        {
            get
            {
                string hexString = this.OperationStatus.ToString("X8");
                return hexString;
            }
        }
        public string HexStringUnderValue
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.UnderValue);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }
        public string HexStringPassValue
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.PassValue);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }
        public string HexStringOverValue
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.OverValue);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }
        public string HexStringTareValue
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.TareValue);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }

        public double HighLimit
        {
            get { return this.m_HighLimit; }
            set { this.m_HighLimit = value; }
        }
        public double DeadZoneHighLimit
        {
            get { return this.m_DeadZoneHighLimit; }
            set { this.m_DeadZoneHighLimit = value; }
        }
        public double DeadZoneLowLimit
        {
            get { return this.m_DeadZoneLowLimit; }
            set { this.m_DeadZoneLowLimit = value; }
        }
        public double LowLimit
        {
            get { return this.m_LowLimit; }
            set { this.m_LowLimit = value; }
        }
        public UInt32 SampleCount
        {
            get { return this.m_SampleCount; }
            set { this.m_SampleCount = value; }
        }
        public UInt32 IgnoreCount
        {
            get { return this.m_IgnoreCount; }
            set { this.m_IgnoreCount = value; }
        }

        public Collection<Modbus_30000_LaneData> ModbusLaneData
        {
            get { return this.m_LaneModbusData; }
            set { this.m_LaneModbusData = value; }
        }
        #endregion

        #region Method
        public void Initialization()
        {
            this.DecimalPoint = 1;
            this.OperationStatus = 0;
            this.UnderValue = 100.0;
            this.PassValue = 200.0;
            this.OverValue = 300.0;
            this.TareValue = 0.0;
            this.HighLimit = 300.0;
            this.DeadZoneHighLimit = 0.0;
            this.DeadZoneLowLimit = 0.0;
            this.LowLimit = 100.0;
            this.SampleCount = 10;
            this.IgnoreCount = 5;

            this.ModbusLaneData = new Collection<Modbus_30000_LaneData>();
            this.ModbusLaneData.Clear();

            for (int i = 0; i < 15; i++)
                this.ModbusLaneData.Add(new Modbus_30000_LaneData());
        }
        #endregion
    }
}
