using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Rds.Messages
{
    [RdsMessage(0x46,RdsMessageHeaderType.Mel)]
    class OdaDataCommand : RdsMessage
    {
        public OdaDataCommand(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer, false);
            //buffer.Length == msg element 1
            AID = ms.ReadUInt16BE();    //msg element 2 + 3

            byte med = ms.ReadUInt8();  //msg element 4
            ShortMessageFlag = (med & 0x40) != 0; 
            BufferConfiguration = (med & 0x3); 
            OdaData = ms.ReadBytes(ms.GetAvailableBytes()); //msg element 5
        }

        public byte[] OdaData { get; private set; }

        public int BufferConfiguration { get; private set; }

        public bool ShortMessageFlag { get; private set; }

        public ushort AID { get; private set; }
    }
}
