示例#1
0
        public object Clone()
        {
            DataSourceStats clone = new DataSourceStats(this.dataSource);

            clone.total     = this.total;
            clone.discarded = this.discarded;

            return(clone);
        }
示例#2
0
 internal DataSource(TimeSeriesDatabase database, DataSourceDto dto)
 {
     this.database = database;
     this.archives = new Archive.ArchiveCollection(this);
     this.stats    = new DataSourceStats(this);
     this.range    = new Range();
     FixupProperties(dto);
     FixupArchives(dto);
 }
示例#3
0
 /// <summary>
 /// Initialises a data source
 /// </summary>
 /// <param name="database">Database to exist within</param>
 /// <param name="template">Data source template</param>
 internal DataSource(TimeSeriesDatabase database, DataSourceTemplate template)
 {
     this.database           = database;
     this.Name               = template.Name;
     this.ConversionFunction = template.ConversionFunction;
     this.CreateConversionFunction();
     this.PollingInterval = template.PollingInterval;
     this.range           = new Range(template.MinThreshold, template.MaxThreshold);
     this.archives        = new Archive.ArchiveCollection(this);
     this.stats           = new DataSourceStats(this);
 }
示例#4
0
        /// <summary>
        /// Push a collection of readings into each archive for consolidation
        /// </summary>
        /// <param name="newReadings">Readings to be consolidated</param>
        public void Push(Reading[] newReadings)
        {
            List <Reading> validReadings = new List <Reading>();

            DataSourceStats originalStats = this.stats.Clone() as DataSourceStats;

            /*
             * Validate the new readings are within the thresholds specified
             * for the data source and are not timestamped as being recorded
             * prior to the most recent reading
             */
            foreach (Reading newReading in newReadings)
            {
                // Make sure the value is within the expected range
                if (this.range.IsValid(newReading.Value) != true)
                {
                    // ERROR: Reading is outside expected range
                    this.stats.IncrementDiscarded();
                    continue;
                }

                if (newReading.Timestamp <= this.LastUpdateTimestamp)
                {
                    /*
                     * ERROR: Reading timestamp is prior to the most recent
                     * timestamp seen by the data source
                     */
                    this.stats.IncrementDiscarded();
                    continue;
                }

                Reading processedReading = this.CreateConversionFunction().PreProcessReading(newReading);

                validReadings.Add(processedReading);

                /*
                 * The last reading should be the none-processed reading, not the one
                 * that has been processed by the conversion function
                 */
                this.lastReading = newReading;
                this.stats.IncrementTotal();
            }

            if (validReadings.Count > 0)
            {
                /*
                 * Push the new readings into each archive in turn...this will result
                 * in zero or more data points being consolidated inside each archive
                 */
                foreach (Archive archive in this.archives)
                {
                    archive.Push(validReadings.ToArray());
                }

                // Save the last reading
                PersistLastReading();
            }

            if (originalStats != this.stats)
            {
                // Save the new reading stats
                this.stats.Update();
            }
        }
示例#5
0
 internal void Add(DataSourceStats stats)
 {
     this.dataSourceStats.Add(stats);
 }