Exemplo n.º 1
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue numerator   = frame.Measurements["Numerator"];
            ITimeSeriesValue denominator = frame.Measurements["Denominator"];

            return(new AdaptValue[] { new AdaptValue("Division", numerator.Value / denominator.Value, frame.Timestamp) });
        }
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue signal1 = frame.Measurements["Signal 1"];
            ITimeSeriesValue signal2 = frame.Measurements["Signal 2"];

            return(new AdaptValue[] { new AdaptValue("Addition", signal1.Value + signal2.Value, frame.Timestamp) });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Compares the <see cref="Measurement"/> with an <see cref="ITimeSeriesValue"/>.
        /// </summary>
        /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="Measurement"/>.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <remarks>Measurement implementations should compare by hash code.</remarks>
        public int CompareTo(ITimeSeriesValue other)
        {
            if ((object)other != null)
            {
                return(GetHashCode().CompareTo(other.GetHashCode()));
            }

            return(1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Compares the <see cref="Measurement"/> with the specified <see cref="Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="Object"/> to compare with the current <see cref="Measurement"/>.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException"><paramref name="obj"/> is not an <see cref="IMeasurement"/>.</exception>
        /// <remarks>Measurement implementations should compare by hash code.</remarks>
        public int CompareTo(object obj)
        {
            ITimeSeriesValue other = obj as ITimeSeriesValue;

            if ((object)other != null)
            {
                return(CompareTo(other));
            }

            throw new ArgumentException("Measurement can only be compared with other measurements or time-series values");
        }
Exemplo n.º 5
0
 private AdaptEvent processEvent(ITimeSeriesValue val)
 {
     try
     {
         return((AdaptEvent)val);
     }
     catch (Exception ex)
     {
         return(new AdaptEvent(val.ID, val.Timestamp, val.Value));
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="Measurement"/>.
        /// </summary>
        /// <param name="obj">The <see cref="Object"/> to compare with the current <see cref="Measurement"/>.</param>
        /// <returns>
        /// true if the specified <see cref="Object"/> is equal to the current <see cref="Measurement"/>;
        /// otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            ITimeSeriesValue other = obj as ITimeSeriesValue;

            if ((object)other != null)
            {
                return(Equals(other));
            }

            return(false);
        }
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];

            if (m_settings.Unit == AngleUnit.Degrees)
            {
                return new AdaptValue[] { new AdaptValue("Converted", (Math.PI / 180) * original.Value, frame.Timestamp) }
            }
            ;
            else
            {
                return new AdaptValue[] { new AdaptValue("Converted", (180 / Math.PI) * original.Value, frame.Timestamp) }
            };
        }
Exemplo n.º 8
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue magnitude = frame.Measurements["Magnitude"];
            ITimeSeriesValue phase     = frame.Measurements["Phase"];

            if (m_settings.Unit == AngleUnit.Degrees)
            {
                return(new AdaptValue[] { new AdaptValue("Imaginary", magnitude.Value * Math.Sin(phase.Value), frame.Timestamp) });
            }
            else
            {
                return new AdaptValue[] { new AdaptValue("Imaginary", magnitude.Value * Math.Sin((180 / Math.PI) * phase.Value), frame.Timestamp) }
            };
        }
        public Complex GetComplex(IFrame frame)
        {
            ITimeSeriesValue magnitude = frame.Measurements["Magnitude"];
            ITimeSeriesValue phase     = frame.Measurements["Phase"];

            if (m_settings.Unit == AngleUnit.Degrees)
            {
                return(new Complex(magnitude.Value * Math.Cos(phase.Value), magnitude.Value * Math.Sin(phase.Value)));
            }
            else
            {
                return(new Complex(magnitude.Value * Math.Cos((180 / Math.PI) * phase.Value), magnitude.Value * Math.Sin((180 / Math.PI) * phase.Value)));
            }
        }
Exemplo n.º 10
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue zeros = frame.Measurements["Original"];

            if (zeros.Value == 0)
            {
                return new AdaptValue[] { new AdaptValue("Filtered", double.NaN, frame.Timestamp) }
            }
            ;
            else
            {
                return new AdaptValue[] { new AdaptValue("Filtered", zeros.Value, frame.Timestamp) }
            };
        }
Exemplo n.º 11
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];
            ITimeSeriesValue flag     = frame.Measurements["Flag"];

            if (!double.IsNaN(flag.Value) && flag.Value > 0.0D)
            {
                return new AdaptValue[] { new AdaptValue("Cleaned", double.NaN, frame.Timestamp) }
            }
            ;
            else
            {
                return new AdaptValue[] { new AdaptValue("Cleaned", original.Value, frame.Timestamp) }
            };
        }
Exemplo n.º 12
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue s1 = frame.Measurements["Original 1"];
            ITimeSeriesValue s2 = frame.Measurements["Original 2"];

            if (!double.IsNaN(s1.Value) && !double.IsNaN(s2.Value))
            {
                return new AdaptValue[] { new AdaptValue("Cleaned 1", s1.Value, frame.Timestamp), new AdaptValue("Cleaned 2", s2.Value, frame.Timestamp) }
            }
            ;
            else
            {
                return new AdaptValue[] { new AdaptValue("Cleaned 1", double.NaN, frame.Timestamp), new AdaptValue("Cleaned 2", double.NaN, frame.Timestamp) }
            };
        }
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue frequency = frame.Measurements["Original"];
            double           v         = frequency.Value;

            if (v > m_settings.Max)
            {
                v = m_settings.Max;
            }
            if (v < m_settings.Min)
            {
                v = m_settings.Min;
            }

            return(new AdaptValue[] { new AdaptValue("Filtered", v, frame.Timestamp) });
        }
Exemplo n.º 14
0
 private ITimeSeriesValue AdjustSignal(ITimeSeriesValue original, string key)
 {
     if (original.IsEvent)
     {
         try
         {
             AdaptEvent originalEvt = (AdaptEvent)original;
             return(new AdaptEvent(key, original.Timestamp, originalEvt.Value,
                                   originalEvt.ParameterNames
                                   .Select(item => new KeyValuePair <string, double>(item, originalEvt[item])).ToArray()
                                   ));
         }
         catch
         {
             return(new AdaptValue(key, original.Value, original.Timestamp));
         }
     }
     return(new AdaptValue(key, original.Value, original.Timestamp));
 }
        public Complex GetComplex(IFrame frame)
        {
            ITimeSeriesValue voltage_mag = frame.Measurements["Voltage Magnitude"];
            ITimeSeriesValue voltage_pha = frame.Measurements["Voltage Phase"];
            ITimeSeriesValue current_mag = frame.Measurements["Current Magnitude"];
            ITimeSeriesValue current_pha = frame.Measurements["Current Phase"];

            if (m_settings.Unit == AngleUnit.Degrees)
            {
                Complex volt = new Complex(voltage_mag.Value * Math.Cos(voltage_pha.Value), voltage_mag.Value * Math.Sin(voltage_pha.Value));
                Complex curr = new Complex(current_mag.Value * Math.Cos(current_pha.Value), current_mag.Value * Math.Sin(current_pha.Value));
                return(Complex.Multiply(volt, Complex.Conjugate(curr)));
            }
            else
            {
                Complex volt = new Complex(voltage_mag.Value * Math.Cos((180 / Math.PI) * voltage_pha.Value), voltage_mag.Value * Math.Sin((180 / Math.PI) * voltage_pha.Value));
                Complex curr = new Complex(current_mag.Value * Math.Cos((180 / Math.PI) * current_pha.Value), current_mag.Value * Math.Sin((180 / Math.PI) * current_pha.Value));
                return(Complex.Multiply(volt, Complex.Conjugate(curr)));
            }
        }
Exemplo n.º 16
0
        private void CleanupEvent(ITimeSeriesValue Value)
        {
            m_isEvent         = false;
            m_eventParameters = new List <string>();
            if (!Value.IsEvent)
            {
                return;
            }
            try
            {
                m_isEvent = true;
                AdaptEvent evt = (AdaptEvent)Value;
                m_eventParameters = evt.ParameterNames;

                if (File.Exists($"{m_rootFolder}{Path.DirectorySeparatorChar}Root.config"))
                {
                    File.Delete($"{m_rootFolder}{Path.DirectorySeparatorChar}Root.config");
                }
            }
            catch (Exception ex)
            {
                m_isEvent = false;
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Compares the <see cref="ChannelValueMeasurement{T}"/> with an <see cref="ITimeSeriesValue"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="ChannelValueMeasurement{T}"/>.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
 /// <remarks>Measurement implementations should compare by hash code.</remarks>
 public int CompareTo(ITimeSeriesValue other)
 {
     return(GetHashCode().CompareTo(other.GetHashCode()));
 }
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other) => m_measurement.Equals(other);
Exemplo n.º 19
0
 /// <summary>
 /// Adds a <see cref="ITimeSeriesValue"/> to be processed by this <see cref="SignalWritter"/>
 /// </summary>
 /// <param name="Value">The <see cref="ITimeSeriesValue"/> to be written to the Files</param>
 public async void AddPoint(ITimeSeriesValue Value)
 {
     await m_queue.Writer.WriteAsync(Value);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="Measurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="Measurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="Measurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other)
 {
     return(CompareTo(other) == 0);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Compares the <see cref="SignalReferenceMeasurement"/> with an <see cref="ITimeSeriesValue"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
 /// <remarks>Measurement implementations should compare by hash code.</remarks>
 public int CompareTo(ITimeSeriesValue other)
 {
     return(m_measurement.CompareTo(other));
 }
Exemplo n.º 22
0
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other)
 {
     return(m_measurement.Equals(other));
 }
Exemplo n.º 23
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];

            return(new AdaptValue[] { new AdaptValue("Reversed", original.Value * -1, frame.Timestamp) });
        }
Exemplo n.º 24
0
 /// <summary>
 /// Compares the <see cref="SignalReferenceMeasurement"/> with an <see cref="ITimeSeriesValue"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
 /// <remarks>Measurement implementations should compare by hash code.</remarks>
 public int CompareTo(ITimeSeriesValue other)
 {
     return m_measurement.CompareTo(other);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other)
 {
     return m_measurement.Equals(other);
 }
Exemplo n.º 26
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];

            return(new AdaptValue[] { new AdaptValue("Exponential", Math.Pow(original.Value, m_settings.Exponent), frame.Timestamp) });
        }
Exemplo n.º 27
0
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="SignalReferenceMeasurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other) => m_measurement.Equals(other);
Exemplo n.º 28
0
 /// <summary>
 /// Compares the <see cref="SignalReferenceMeasurement"/> with an <see cref="ITimeSeriesValue"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="SignalReferenceMeasurement"/>.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
 /// <remarks>Measurement implementations should compare by hash code.</remarks>
 public int CompareTo(ITimeSeriesValue other) => m_measurement.CompareTo(other);
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];

            return(new AdaptValue[] { new AdaptValue("Absolute Value", Math.Abs(original.Value), frame.Timestamp) });
        }
Exemplo n.º 30
0
 /// <summary>
 /// Determines whether the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="Measurement"/>.
 /// </summary>
 /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="Measurement"/>.</param>
 /// <returns>
 /// true if the specified <see cref="ITimeSeriesValue"/> is equal to the current <see cref="Measurement"/>;
 /// otherwise, false.
 /// </returns>
 public bool Equals(ITimeSeriesValue other)
 {
     return CompareTo(other) == 0;
 }
Exemplo n.º 31
0
        public override ITimeSeriesValue[] Compute(IFrame frame, IFrame[] prev, IFrame[] future)
        {
            ITimeSeriesValue original = frame.Measurements["Original"];

            return(new AdaptValue[] { new AdaptValue("Scaled", original.Value * m_settings.Multiplier, frame.Timestamp) });
        }
Exemplo n.º 32
0
        /// <summary>
        /// Compares the <see cref="Measurement"/> with an <see cref="ITimeSeriesValue"/>.
        /// </summary>
        /// <param name="other">The <see cref="ITimeSeriesValue"/> to compare with the current <see cref="Measurement"/>.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <remarks>Measurement implementations should compare by hash code.</remarks>
        public int CompareTo(ITimeSeriesValue other)
        {
            if ((object)other != null)
                return GetHashCode().CompareTo(other.GetHashCode());

            return 1;
        }