protected virtual void OnValueChanged(AnalogValueChangedEventArgs e)
 {
     if (ValueChanged != null)
     {
         ValueChanged(this, e);
     }
 }
        public double Sample()
        {
            //log.DebugFormat("SPIAnalog.Sample() rawValue:{0} mV prevSample:{0} mV",RawValue, prevSample.Millivolts);
            Read();

            RawValue = sample.Millivolts;
            Value    = RawValue * Multiplier;

            //log.DebugFormat("SPIAnalog.Sample() rawValue:{0} mV prevSample:{0} mV", RawValue, prevSample.Millivolts);

            //check to see if new reading exceeds threshold
            double delta = Math.Abs(sample.Millivolts - prevSample.Millivolts);

            if (delta > Threshold)
            {
                AnalogValueChangedEventArgs e = new AnalogValueChangedEventArgs();
                e.Value = (decimal)Value;
                OnValueChanged(e);
            }

            return(Value);
        }