Ejemplo n.º 1
0
 override protected void ProcessBuffer(byte[] buffer)
 {
     if (CompareFirstN(buffer, Header, Header.Length) && buffer.Length > 4 && (buffer.Length - 4) % 24 == 0)
     {
         int tracksCount = (buffer.Length - (Header.Length + 2 + 1)) / 24;
         _infos = new GH615MTrackInfo[tracksCount];
         int offset = Header.Length + 2;
         for (int i = 0; i < tracksCount; i++)
         {
             GH615MTrackInfo info = GH615MTrackInfo.FromByteArray(buffer, offset, null);
             _infos[i] = info;
             offset   += 24;
         }
     }
 }
Ejemplo n.º 2
0
        override protected void ProcessBuffer(byte[] buffer)
        {
            if (CompareFirstN(buffer, End, End.Length))
            {
                _status.FirstLoadedPointNumber = 0;
                _status.LastLoadedPointNumber  = -1;
                _status.IsFinished             = true;
                return;
            }
            if (buffer.Length >= 3 + 22)
            {
                _status.TrackInfo = GH615MTrackInfo.FromByteArray(buffer, 3, _status.Id);

                Int16 from = HexUtils.ToInt16(buffer, 3 + 22);
                Int16 to   = HexUtils.ToInt16(buffer, 3 + 22 + 2);
                if (_status.LastLoadedPointNumber + 1 != from)
                {
                    throw new GH615MCommunicationError(String.Format("Loading error! Expected points from {0}, but get from {1} to {2}!", _status.LastLoadedPointNumber + 1, from, to));
                }
                int      offset     = 3 + 22 + 4;
                DateTime timeOffset = _status.TrackInfo.Date;
                if (_status.TrackPoints.Count > 0)
                {
                    timeOffset = _status.TrackPoints[_status.TrackPoints.Count - 1].Time;
                }
                for (int i = 0; i <= to - from; i++)
                {
                    GH615MTrackPoint point = GH615MTrackPoint.FromByteArray(buffer, offset, timeOffset);
                    _status.TrackPoints.Add(point);
                    timeOffset = point.Time;
                    offset    += 15;
                }
                _status.FirstLoadedPointNumber = from;
                _status.LastLoadedPointNumber  = to;
            }
        }