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

namespace FLY.Thick.Base.OBJ_INTERFACE
{
    public class SCANWARNING_OBJ_INTERFACE
    {
        public const UInt32 ID = OBJ_INTERFACE_ID.SCANWARNING_ID;

        #region Pack
        public class Pack_Params : IPack
        {
            public bool enable;
            public double alarmline;
            public int alarmcnt;
            public int mix;

            /// <summary>
            /// 转换为8个bytes
            /// </summary>
            /// <returns></returns>
            public byte[] ToBytes()
            {
                List<byte> buf = new List<byte>();

                buf.AddRange(BitConverter.GetBytes(enable));
                buf.AddRange(BitConverter.GetBytes(alarmline));
                buf.AddRange(BitConverter.GetBytes(alarmcnt));
                buf.AddRange(BitConverter.GetBytes(mix));
                return buf.ToArray();
            }
            /// <summary>
            /// 由8个bytes 转换为 CustomBolt
            /// </summary>
            /// <param name="value"></param>
            /// <returns></returns>
            public bool TryParse(byte[] value)
            {
                if (value.Length < (1+8+4+4))
                    return false;
                int idx = 0;
                enable = BitConverter.ToBoolean(value, idx);
                idx++;
                alarmline = BitConverter.ToDouble(value, idx);
                idx += 8;
                alarmcnt = BitConverter.ToInt32(value, idx);
                idx += 4;
                mix = BitConverter.ToInt32(value, idx);
                idx += 4;
                return true;
            }
        }
        #endregion

        #region GetValue
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 GET_PARAMS = 0;
        #endregion
        #region SetValue
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 SET_PARAMS = 0;
        #endregion
        #region PushMsg
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 PUSH_PARAMS = 0;
        #endregion

    }
}
