Esempio n. 1
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket sp = (ShortPacket)payload;

            _unkData = sp.Data;
            _unkShortDatum = sp.ShortDatum;
        }
Esempio n. 2
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket sp = (ShortPacket)payload;

            SessionId = StringUtils.ASCIIBytesToString(sp.Data, 1, sp.Data.Length - 1);
            EventType = (EventType)sp.ShortDatum;
        }
Esempio n. 3
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket sp = (ShortPacket)payload;

            DetailedType = (WeatherType)sp.ShortDatum;
            BaseData = (sp.Data == null) ? String.Empty : StringUtils.ASCIIBytesToString(sp.Data);

            OnDeserialiseComplete();
        }
Esempio n. 4
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket sp = (ShortPacket)payload;

            Debug.Assert(sp.Data.Length == 2);

            FrameNumber = (sp.Data[1] << 8 & 0xff00) | (sp.Data[0] & 0xff);

            _unkShortDatum = sp.ShortDatum;
        }
        public void Deserialise(Header header, Packet payload)
        {
            LongPacket p = (LongPacket)payload;

            CarId = header.CarId;

            PositionHistory = new int[ p.Data.Length ];

            p.Data.CopyTo(PositionHistory, 0);
        }
Esempio n. 6
0
        public LongPacket(Header header, Stream input)
            : base(input)
        {
            int longPacketSize = header.Datum;

            if (longPacketSize > 0 && longPacketSize < 128)
            {
                AcquirePayload(longPacketSize);
            }
        }
Esempio n. 7
0
        public ShortPacket(Header header, Stream input)
            : base(input)
        {
            /*  6 5 4 3 2 1 0
             * [ | | | | | | ]
             *  +-len-+ +-d-+
             */

            int size = (header.Datum >> 3);

            if (size != NO_DATA && size > 0)
            {
                //  Instruct the Packet to begin the data read
                AcquirePayload(size);
            }

            ShortDatum = (header.Datum & 0x07);
        }
Esempio n. 8
0
        public void Deserialise(Header header, Packet payload)
        {
            LongPacket sp = (LongPacket)payload;

            if( sp.Data[0] >= 32 )
            {
                // old style commentary message (i.e. no magic 2 bytes)
                Encoding oldEncoding = Encoding.GetEncoding("ISO-8859-1");
                Message = oldEncoding.GetString(sp.Data, 0, sp.Data.Length);
            }
            else if( (sp.Data[1] & 0x02) == 0x02 )
            {
                // Unicode string
                Message = Encoding.Unicode.GetString(sp.Data, 2, sp.Data.Length - 2);
            }
            else
            {
                // Not unicode, but new UTF8 style of message.
                Message = Encoding.UTF8.GetString(sp.Data, 2, sp.Data.Length - 2);
            }

            EndMessage = ((int)sp.Data[1] > 0);
        }
Esempio n. 9
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket sp = (ShortPacket)payload;

            if (sp.ShortDatum == 1)
            {
                int status = int.Parse(StringUtils.ASCIIBytesToString(sp.Data), CultureInfo.InvariantCulture);
                switch (status)
                {
                    case 1:
                        Status = Colour.Green;
                        break;
                    case 2:
                        Status = Colour.Yellow;
                        break;
                    case 3:
                        Status = Colour.Yellow;
                        Message = "SCS";
                        break;
                    case 4:
                        Status = Colour.Yellow;
                        Message = "SCD";
                        break;
                    case 5:
                        Status = Colour.Red;
                        break;
                    default:
                        throw new DeserialiseException("Unknown track status, status: " + status);
                }
            }
            else
            {
                throw new DeserialiseException("Unknown track status, short: " + sp.ShortDatum + ", data: " + HexString.BytesToHex(sp.Data));
            }
        }
Esempio n. 10
0
 public Packet CreatePacketType(Header header, Stream rawStream, Stream decryptStream)
 {
     return null;
 }
Esempio n. 11
0
 public void Deserialise(Header header, Packet payload)
 {
     _unkDatum = header.Datum;
 }
Esempio n. 12
0
        public void Deserialise(Header header, Packet payload)
        {
            ShortPacket p = (ShortPacket) payload;

            CarId = header.CarId;
            CarType = header.CarType;
            BaseShort = p.ShortDatum;
            BaseData = (p.Data == null) ? String.Empty : StringUtils.ASCIIBytesToString(p.Data);

            OnDeserialiseComplete();
        }
Esempio n. 13
0
        public void Deserialise(Header header, Packet payload)
        {
            LongPacket sp = (LongPacket)payload;

            Message = StringUtils.ASCIIBytesToString(sp.Data, 0, sp.Data.Length);
        }
Esempio n. 14
0
 public void Deserialise(Header header, Packet payload)
 {
 }
Esempio n. 15
0
        public void Deserialise(Header header, Packet payload)
        {
            LongPacket lp = (LongPacket)payload;

            int col = lp.Data[0] - 1;

            Column = (ColumnType)(col);

            string decoded = StringUtils.ASCIIBytesToString(lp.Data, 1, lp.Data.Length - 1);

            if( col >= 0 && col <= 3 && lp.Data.Length > 0 )
            {
                string[] pairs = decoded.Split('\r');

                List<SpeedPair> fsSectorBuilder = new List<SpeedPair>();

                for( int i=0; i < pairs.Length / 2; ++i )
                {
                    if (!string.IsNullOrEmpty(pairs[i * 2]) && !string.IsNullOrEmpty(pairs[(i * 2) + 1]))
                    {
                        fsSectorBuilder.Add(new SpeedPair
                                                {
                                                    Driver = pairs[i*2],
                                                    Speed = double.Parse(pairs[(i*2) + 1], CultureInfo.InvariantCulture)
                                                });
                    }
                    else
                    {
                        break;
                    }
                }

                FastestSectors = fsSectorBuilder.ToArray();
            }
            else if( decoded.Length > 0 )
            {
                MetaData = decoded;
            }
        }
Esempio n. 16
0
 public Packet CreatePacketType(Header header, Stream rawStream, Stream decryptStream)
 {
     return new LongPacket(header, decryptStream);
 }
Esempio n. 17
0
 public void Deserialise(Header header, Packet payload)
 {
     CarId = header.CarId;
     Position = header.Datum;
 }
Esempio n. 18
0
 public void Deserialise(Header header, Packet payload)
 {
     Rate = header.Datum;
 }
Esempio n. 19
0
 public Packet CreatePacketType(Header header, Stream rawStream, Stream decryptStream)
 {
     return new SimplePacket(2, decryptStream);
 }
Esempio n. 20
0
        public void Deserialise(Header header, Packet payload)
        {
            SimplePacket sp = (SimplePacket) payload;

            Time = sp.Data[1] << 8 & 0xff00 | (sp.Data[0] & 0xff | header.Datum << 16 & 0xff0000);
        }
Esempio n. 21
0
        public void Deserialise(Header header, Packet payload)
        {
            LongPacket lp = (LongPacket)payload;

            Message = StringUtils.ASCIIBytesToString(lp.Data);
        }
Esempio n. 22
0
        void Run()
        {
            IMessage msg;
            Header h;
            while (true)
            {
                h = new Header(_infile);

                msg = null;
                if (h.IsSystemMessage)
                {
                    msg = MessageFactory.CreateMessage(h.SystemType, h.Datum);
                    UpdateEventType(msg);
                }
                else
                {
                    msg = MessageFactory.CreateMessage(h.CarType, _evtType);
                }

                try
                {
                    Packet p = msg.CreatePacketType(h, _infile, null);

                    msg.Deserialise(h, p);

                    //Console.WriteLine(msg);
                }
                catch (NullReferenceException)
                {
                    //Console.WriteLine("*" + msg);
                    break;
                }
            }

            if( msg is F1.Messages.System.Notice )
            {
                LongPacket packet = new LongPacket(h, _infile);

                Test((byte[])packet.Data.Clone(), StringUtils.StringToASCIIBytes(_rawMessage));
                Crack(packet.Data, StringUtils.StringToASCIIBytes(_rawMessage));
            }
            else
            {
                Console.WriteLine("Notice is not the first encrypted packet.");
            }
        }