예제 #1
0
파일: Reading.cs 프로젝트: openxtra/TimeTag
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Reading t = obj as Reading;

            if (t == null)
            {
                return(false);
            }

            if (this.value.CompareTo(t.value) == 0 &&
                this.timestamp.CompareTo(t.timestamp) == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// Pre-process a reading. The gauge doesn't do any pre-processing of the
 /// reading.
 /// </summary>
 /// <param name="newReading">Reading to process</param>
 /// <returns>Processed reading</returns>
 public Reading PreProcessReading(Reading newReading)
 {
     // Gauge's don't need to pre-process the raw reading
     return(newReading);
 }
예제 #3
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();
            }
        }
예제 #4
0
파일: Payload.cs 프로젝트: openxtra/TimeTag
 public static Payload MakePayload(DataSource dataSource, Reading newReading)
 {
     Reading[] reading = { newReading };
     return(new Payload(dataSource, reading));
 }
예제 #5
0
 protected override bool IsSelected(Reading newReading)
 {
     return(newReading.Value < SelectedReading.Value);
 }
 // Override for concrete selective archives
 protected abstract bool IsSelected(Reading newReading);
 public DataPoint CreateAccumulatedDataPoint(Reading newReading)
 {
     return(new DataPoint(CalcAverage(), newReading.Timestamp));
 }
예제 #8
0
 /// <summary>
 /// Push the new reading into the specified data source
 /// </summary>
 /// <param name="dataSourceName">Data source into which the reading should be pushed</param>
 /// <param name="newReading">New reading to be pushed into the database</param>
 public void Push(string dataSourceName, Reading newReading)
 {
     Reading[] reading = { newReading };
     Push(dataSourceName, reading);
 }