using Edge.Core.Parser.BinaryParser.MessageEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HengshanPaymentTerminal.MessageEntity.Incoming
{
    /// <summary>
    /// 油枪状态数据对象
    /// </summary>
    public class NozzleState : CommonMessage
    {
        public enum NozzleStateEnum
        {
            /// <summary>
            /// 离线
            /// </summary>
            OFF_LINE = 0x01,
            /// <summary>
            /// 锁枪
            /// </summary>
            LOCK = 0x02,
            /// <summary>
            /// 空闲
            /// </summary>
            IDLE = 0x03,
            /// <summary>
            /// 提枪
            /// </summary>
            LIFT = 0x04,
            /// <summary>
            /// 开始加油
            /// </summary>
            START = 0x05,
            /// <summary>
            /// 加油中
            /// </summary>
            FUELING = 0x06
        }

        /// <summary>
        /// 枪号
        /// </summary>
        public int nozzleNum {  get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public NozzleStateEnum stateEnum { get; set; }

        public override byte[] ToCommonByteArray()
        {
            byte[] content = new byte[] { 0x55, this.Handle, 0x00, ((byte)RESULT.OVER) };
            return content2data(content);
        }

        public override CommonMessage ToObject(byte[] datas)
        {
            getBaseData(datas);
            this.nozzleNum = datas[7];
            this.stateEnum = (NozzleStateEnum)datas[8];
            return this;
        }
    }
}
