public void Push(DataPointDto newDataPointDto)
        {
            if (this.startIndex == -1)
            {
                Debug.Assert(this.endIndex == -1);
                Debug.Assert(this.currentSize == 0);

                // Empty case
                this.startIndex = this.endIndex = 0;
                this.currentSize++;
            }
            else if (this.currentSize < this.maxSize)
            {
                Debug.Assert(this.startIndex == 0);

                // Not full yet case, still filling up prior to wrapping around
                this.endIndex++;
                this.currentSize++;
            }
            else
            {
                Debug.Assert(this.startIndex != this.endIndex);
                Debug.Assert(this.currentSize == this.maxSize);

                // "Full" case, may require wrap around
                this.startIndex++;
                this.endIndex++;

                // Check for wrap around of either start or end
                if (this.endIndex == this.maxSize)
                {
                    this.endIndex = 0;
                }
                else if (this.startIndex == this.maxSize)
                {
                    this.startIndex = 0;
                }
            }

            Debug.Assert(GetAt(this.endIndex) != null);

            BinaryFileDataPointDao dataPointDao = GetAt(this.endIndex);

            // The data point DAO must know where it is on disk from when it was either created or read
            Debug.Assert(dataPointDao.Position != BinaryFileDao.UnknownOffset);
            dataPointDao.Write(newDataPointDto);
            newDataPointDto.Dao = (IDataPointDao)dataPointDao;

            // Write the updated archive state back to disk
            WriteState();
        }
        private void ReadDataPoints()
        {
            ReadState();

            BinaryFileDataPointDao[] unorderedDataPointDao = new BinaryFileDataPointDao[this.dto.MaxDataPoints];
            DataPointDto[]           unorderedDataPointDto = new DataPointDto[this.dto.MaxDataPoints];

            // Read the whole array of data points into unordered list
            for (int i = 0; i < this.dto.MaxDataPoints; i++)
            {
                BinaryFileDataPointDao newDataPointDao = new BinaryFileDataPointDao(archiveDao);
                DataPointDto           newDataPointDto = newDataPointDao.Read();
                newDataPointDto.Dao      = (IDataPointDao)newDataPointDao;
                unorderedDataPointDao[i] = newDataPointDao;
                unorderedDataPointDto[i] = newDataPointDto;
            }

            if (this.startIndex != UnknownIndex)
            {
                // Read from the first data point to the end of the array
                for (int i = this.startIndex; i < this.dto.MaxDataPoints; i++)
                {
                    this.dataPoints.Add(unorderedDataPointDao[i]);
                    if (unorderedDataPointDto[i].Empty != true)
                    {
                        this.dto.Add(unorderedDataPointDto[i]);
                    }
                }

                // Read from the beginning of the array to the end of the wrap around
                for (int i = 0; i < this.startIndex; i++)
                {
                    this.dataPoints.Add(unorderedDataPointDao[i]);
                    if (unorderedDataPointDto[i].Empty != true)
                    {
                        this.dto.Add(unorderedDataPointDto[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < this.dto.MaxDataPoints; i++)
                {
                    this.dataPoints.Add(unorderedDataPointDao[i]);
                }
            }
        }
        private void CreateEmptyDataPoints(DataPointCircularQueueDto dto)
        {
            Debug.Assert(dto.MaxDataPoints >= dto.DataPoints.Length);

            // Write out the balance of empty data points
            for (int i = 0; i < dto.MaxDataPoints; i++)
            {
                DataPointDto emptyDataPointDto = new DataPointDto();
                emptyDataPointDto.Empty     = true;
                emptyDataPointDto.Timestamp = DateTime.Now;
                emptyDataPointDto.Value     = Double.NaN;

                BinaryFileDataPointDao dataPointDao = new BinaryFileDataPointDao(this.archiveDao);
                dataPointDao.Write(emptyDataPointDto);
                this.dataPoints.Add(dataPointDao);
            }
        }