Пример #1
0
        private bool ProcessHistoryDataBlock(IEnumerable<byte> dataBytes)
        {
            var endOfStreamFound = false;
            var data = dataBytes.ToArray();

            for (var b = 0; b < DataReadLength; b += HistoryDataBlockLength)
            {
                var dataBlock = data.Skip(b).Take(HistoryDataBlockLength).ToArray();

                // If we find an "empty" data row, we are done.
                if (dataBlock.All(e => e == 0xFF))
                {
                    endOfStreamFound = true;
                    break;
                }

                var report = new Report(HistoryDataBlockLength);
                report.AddRawData(dataBlock);

                var historyData = report.GetObject<HistoryData>();
                _history.Add(historyData);

                OnHistoryData(this, historyData);
            }

            return !endOfStreamFound;
        }
Пример #2
0
        private void DownloadSettings()
        {
            var report = new Report(SettingsEndAddress - SettingsStartAddress);

            // Download settings from 0000h-0100h
            for (var a = SettingsStartAddress; a <= SettingsEndAddress; a += DataReadLength)
            {
                DownloadBlock(a, d =>
                {
                    report.AddRawData(d);
                    return true;
                });
            }

            // Create data object from report
            Settings = report.GetObject<Settings>();
            OnSettingsLoaded(this, Settings);
        }