Beispiel #1
0
            internal void RenameArchiveTemplate(string oldName, string newName)
            {
                ArchiveTemplate templateToRename = this.archives[oldName];

                this.archives.Remove(oldName);
                this.archives.Add(newName, templateToRename);
            }
        /// <summary>
        /// Add an archive template. Each archive is added to all data sources
        /// </summary>
        /// <param name="newArchiveTemplate">New archive template</param>
        public void AddArchive(ArchiveTemplate newArchiveTemplate)
        {
            // Validate the archive template info
            if (newArchiveTemplate.Name.Length == 0 || newArchiveTemplate.Name.Length > ArchiveTemplate.MaxNameLength)
            {
                throw new ArgumentException(string.Format("Invalid archive name: {0}", newArchiveTemplate.Name));
            }
            else if (newArchiveTemplate.ConsolidationFunction != ArchiveTemplate.ConsolidationFunctionType.Average &&
                     newArchiveTemplate.ConsolidationFunction != ArchiveTemplate.ConsolidationFunctionType.Min &&
                     newArchiveTemplate.ConsolidationFunction != ArchiveTemplate.ConsolidationFunctionType.Max &&
                     newArchiveTemplate.ConsolidationFunction != ArchiveTemplate.ConsolidationFunctionType.Last)
            {
                throw new ArgumentException(string.Format("Invalid archive type: {0}", newArchiveTemplate.ConsolidationFunction));
            }
            else if (newArchiveTemplate.XFactor < 1 || newArchiveTemplate.XFactor >= 100)
            {
                throw new ArgumentException(string.Format("Invalid XFactor: {0}", newArchiveTemplate.XFactor));
            }
            else if (archives.ContainsKey(newArchiveTemplate.Name.ToLower()))
            {
                throw new ArgumentException(string.Format("Duplicate archive name: {0}", newArchiveTemplate.Name));
            }

            newArchiveTemplate.SequenceNumber = this.sequenceNumberCounter++;

            // Template info is ok, add it and index by its name
            this.archives[newArchiveTemplate.Name.ToLower()] = newArchiveTemplate;
        }
Beispiel #3
0
 private void FixupArchiveTemplatesFromDto(TimeSeriesDatabaseDto dto)
 {
     foreach (ArchiveTemplateDto archiveTemplateDto in dto.ArchiveTemplates)
     {
         ArchiveTemplate newArchiveTemplate = new ArchiveTemplate(this, archiveTemplateDto);
         this.archiveTemplates.Add(newArchiveTemplate);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Initialises an archive attached to the given data source
 /// </summary>
 /// <param name="dataSource">Data source to which the archive belongs</param>
 /// <param name="template">Template the archive</param>
 internal Archive(DataSource dataSource, ArchiveTemplate template)
 {
     this.dataSource             = dataSource;
     this.template               = template;
     this.dataPointCircularQueue = new DataPoint.DataPointCircularCollection(this, template.MaxDataPoints);
     this.accumulatedReadings    = new Reading.ReadingCollection(this, template.ReadingsPerDataPoint);
     this.slotExpiryTimestamp    = CalcNextSlotExpiryTime(this.dataSource.StartTime);
 }
Beispiel #5
0
            /// <summary>
            /// Returns the archive template at the given index
            /// </summary>
            /// <param name="index">The index of the template</param>
            /// <returns>Archive template</returns>
            public ArchiveTemplate GetArchiveTemplateByIndex(int index)
            {
                int             counter = 1;
                ArchiveTemplate foundArchiveTemplate = null;

                foreach (ArchiveTemplate archiveTemplate in this.archives.Values)
                {
                    if (counter++ == index)
                    {
                        foundArchiveTemplate = archiveTemplate;
                        break;
                    }
                }
                return(foundArchiveTemplate);
            }
Beispiel #6
0
 private Archive CreateArchive(ArchiveTemplate template)
 {
     return(new Archive(this, template));
 }
Beispiel #7
0
 /// <summary>
 /// Add a new archive to the collection
 /// </summary>
 /// <param name="newArchiveTemplate">New archive to add</param>
 public void Add(ArchiveTemplate newArchiveTemplate)
 {
     this.archives.Add(newArchiveTemplate.Name, newArchiveTemplate);
 }