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

namespace INT89DB_26.Int_Modbus
{
    public class Modbus_30000_LaneData
    {
        #region Field
        private ushort m_Update;
        private ushort m_Grade;
        private double m_WeightDouble;
        private UInt32 m_UnderCount;
        private UInt32 m_PassCount;
        private UInt32 m_OverCount;
        private UInt32 m_ExNGCount;
        private double m_FeedbackWeightDouble;
        private int m_FeedbackWeightInt;
        private int m_WeightInt;
        private ushort m_UpdateFeedbackData;
        #endregion

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

        #region Property
        public ushort Update
        {
            get { return this.m_Update; }
            set { this.m_Update = value; }
        }
        public ushort Grade
        {
            get { return this.m_Grade; }
            set { this.m_Grade = value; }
        }
        public double WeightDouble
        {
            get { return this.m_WeightDouble; }
            set { this.m_WeightDouble = value; }
        }
        public UInt32 UnderCount
        {
            get { return this.m_UnderCount; }
            set { this.m_UnderCount = value; }
        }
        public UInt32 PassCount
        {
            get { return this.m_PassCount; }
            set { this.m_PassCount = value; }
        }
        public UInt32 OverCount
        {
            get { return this.m_OverCount; }
            set { this.m_OverCount = value; }
        }
        public UInt32 ExNGCount
        {
            get { return this.m_ExNGCount; }
            set { this.m_ExNGCount = value; }
        }
        public UInt32 NGCount
        {
            get { return this.m_UnderCount + this.m_OverCount + this.m_ExNGCount; }
        }
        public UInt32 TotalCount
        {
            get { return this.m_UnderCount + this.m_PassCount + this.m_OverCount + this.m_ExNGCount; }
        }
        public double FeedbackWeightDouble
        {
            get { return this.m_FeedbackWeightDouble; }
            set { this.m_FeedbackWeightDouble = value; }
        }
        public int FeedbackWeightInt
        {
            get { return int.Parse((this.FeedbackWeightDouble.ToString()).Replace(".", "")); }
        }
        public int WeightInt
        {
            get { return int.Parse((this.WeightDouble.ToString()).Replace(".", "")); }
        }
        public ushort UpdateFeedbackData
        {
            get { return this.m_UpdateFeedbackData; }
            set { this.m_UpdateFeedbackData = value; }
        }

        public string HexStringUpdate
        {
            get
            {
                string hexString = this.Update.ToString("X8");
                return hexString;
            }
        }
        public string HexStringGrade
        {
            get
            {
                string hexString = this.Grade.ToString("X8");
                return hexString;
            }
        }
        public string HexStringWeightDouble
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.WeightDouble);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }
        public string HexStringUnderCount
        {
            get
            {
                string hexString = this.UnderCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringPassCount
        {
            get
            {
                string hexString = this.PassCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringOverCount
        {
            get
            {
                string hexString = this.OverCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringExNGCount
        {
            get
            {
                string hexString = this.ExNGCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringNGCount
        {
            get
            {
                string hexString = this.NGCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringTotalCount
        {
            get
            {
                string hexString = this.TotalCount.ToString("X8");
                return hexString;
            }
        }
        public string HexStringFeedbackWeightDouble
        {
            get
            {
                byte[] bytes = BitConverter.GetBytes((float)this.FeedbackWeightDouble);
                Array.Reverse(bytes);
                string hexString = BitConverter.ToString(bytes);
                hexString = hexString.Replace("-", "");

                return hexString;
            }
        }
        public string HexStringFeedbackWeigntInt
        {
            get
            {
                string hexString = this.FeedbackWeightInt.ToString("X8");
                return hexString;
            }
        }
        public string HexStringWeightInt
        {
            get
            {
                string hexString = this.WeightInt.ToString("X8");
                return hexString;
            }
        }
        public string HexStringUpdateFeedbackData
        {
            get
            {
                string hexString = this.UpdateFeedbackData.ToString("X8");
                return hexString;
            }
        }
        #endregion

        #region Method
        public void Initialization()
        {
            this.Update = 0;
            this.Grade = 0;
            this.WeightDouble = 0.0;
            this.UnderCount = 0;
            this.PassCount = 0;
            this.OverCount = 0;
            this.ExNGCount = 0;
            this.FeedbackWeightDouble = 0.0;
            this.UpdateFeedbackData = 0;
        }
        #endregion
    }
}
