internal DataPointCircularQueueDto CreateDto() { DataPointCircularQueueDto dto = new DataPointCircularQueueDto(); dto.MaxDataPoints = this.maxSize; foreach (DataPoint dataPoint in this.dataPoints) { dto.Add(dataPoint.CreateDto()); } return(dto); }
/// <summary> /// Fix up the data point collection from the given DTOs /// </summary> /// <param name="readings">Data point DTO collection</param> internal void FixupFromDto(DataPointCircularQueueDto dataPointQueueDto) { this.dao = dataPointQueueDto.Dao; this.maxSize = dataPointQueueDto.MaxDataPoints; foreach (DataPointDto dataPointDto in dataPointQueueDto) { DataPoint newDataPoint = new DataPoint(); newDataPoint.FixupFromDto(dataPointDto); this.dataPoints.Add(newDataPoint); } }
private void WriteDataPoints(DataPointCircularQueueDto dto) { this.writer.WriteStartElement("DataPoints"); DataPointDto[] dataPoints = dto.DataPoints; foreach (DataPointDto dataPoint in dataPoints) { this.writer.WriteStartElement("DataPoint"); // Value this.writer.WriteStartElement("Value"); this.writer.WriteValue(dataPoint.Value); this.writer.WriteEndElement(); // Timestamp this.writer.WriteStartElement("Timestamp"); this.writer.WriteValue(dataPoint.Timestamp); this.writer.WriteEndElement(); this.writer.WriteEndElement(); } this.writer.WriteEndElement(); }
private DataPointCircularQueueDto ReadDataPoints(int sequenceNumber) { DataPointCircularQueueDto dto = new DataPointCircularQueueDto(); Debug.Assert(this.archiveTemplateIndex.ContainsKey(sequenceNumber)); dto.MaxDataPoints = this.archiveTemplateIndex[sequenceNumber].MaxDataPoints; if (this.reader.IsEmptyElement != true) { this.reader.Read(); do { this.reader.Read(); DataPointDto dataPoint = new DataPointDto(); // Value this.reader.ReadStartElement("Value"); dataPoint.Value = this.reader.ReadContentAsDouble(); this.reader.ReadEndElement(); // Timestamp this.reader.ReadStartElement("Timestamp"); dataPoint.Timestamp = this.reader.ReadContentAsDateTime(); this.reader.ReadEndElement(); dto.Add(dataPoint); } while (this.reader.ReadToNextSibling("DataPoint")); this.reader.ReadEndElement(); } else { this.reader.Read(); } return(dto); }