using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Parser.BinaryParser.Util;

namespace WayneChina_IcCardReader_SinoChem.MessageEntity.Outgoing
{
    public class DisplayRequest : IcCardReaderMessageBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="textWithFormat">max 64 bytes ASCII chars. less than 64 will auto padding right with space.  the `format control chars` are device dependency, pls refer device spec.
        /// 西文ASCII / 中文GB码,中文码的第一字节必须是在奇数位上</param>
        /// <param name="howLongToStayOnScreen">the expecting time that the device will keep this text on screen for how long, by second
        /// 0 indicates display forever, and during this time, all keyboard event will be routed and need to be handled by FC as well</param>
        public DisplayRequest(byte[] textWithFormat, int howLongToStayOnScreen)
        {
            if (textWithFormat.Length > 64) throw new ArgumentOutOfRangeException("textWithFormat length must <=64");
            if (howLongToStayOnScreen > 65536) throw new ArgumentOutOfRangeException("howLongToStayOnScreen must <=65536");
            base.RawData = new List<byte>();
            base.RawData.Add(0x03);
            base.RawData.AddRange(howLongToStayOnScreen.GetBCDBytes(2));
            var displayData = textWithFormat;
            base.RawData.AddRange(displayData);
        }
    }
}