コード例 #1
0
        void BufferedSnapshotRead(object sender, BufferReceivedEventArgs args)
        {
            byte[] buffer = args.Data.Buffer;
            int    offset = 0;

            if (args.Data.Offset != CurrentPos.Position)
            {
                offset = 0x10;
            }
            Count--;
            WeatherSnapshot snapshot = new WeatherSnapshot(buffer, offset);

            SnapshotDate      -= new TimeSpan(0, snapshot.Interval, 0);
            snapshot.Timestamp = SnapshotDate;


            if (Count <= 0 || snapshot.Timestamp <= LimitDate)
            {
                // Finished reading
                this.BufferReceived   -= BufferedSnapshotRead;
                device.BufferReceived -= HandleBufferReceived;

                OnAllSnapshotsRead(newSnapshots);
                newSnapshots.Clear();
            }
            else
            {
                newSnapshots.Add(snapshot);

                GetBlock(--CurrentPos);
            }
        }
コード例 #2
0
        void ActiveSnapshotRead(object sender, BufferReceivedEventArgs args)
        {
            this.BufferReceived -= ActiveSnapshotRead;

            byte[] buffer = args.Data.Buffer;
            int    offset = 0;

            if (args.Data.Offset != CurrentPos.Position)
            {
                offset = 0x10;
            }

            int delay = buffer[offset];

            SnapshotDate -= new TimeSpan(0, delay, 0);
            if (SnapshotDate < LimitDate)
            {
                // TODO: Handle wrong LimitDate
            }
            else
            {
                CurrentPos--;
                this.BufferReceived += BufferedSnapshotRead;
                GetBlock(CurrentPos);
            }
        }
コード例 #3
0
        /// <summary>
        /// Handle the received global data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void GlobalBufferRead(object sender, BufferReceivedEventArgs args)
        {
            this.BufferReceived -= GlobalBufferRead;
            byte[] globalBuffer = args.Data.Buffer;
            Count        = ToUShort(globalBuffer, DATA_COUNT) - 1; // The active buffer is also in Count
            SnapshotDate = toDateTime(globalBuffer, DATE_TIME);
            ushort pos = ToUShort(globalBuffer, CURRENT_POS);

            CurrentPos    = new BufferPos(pos);
            CurrentBuffer = null;

            this.BufferReceived += ActiveSnapshotRead;
            GetBlock(CurrentPos);
        }
コード例 #4
0
 void HandleBufferReceived(object sender, BufferReceivedEventArgs args)
 {
     CurrentBuffer = WS4000Buffer.Clone(args.Data);
     OnBufferReceived(CurrentBuffer);
 }