private static int NonZeroRight(AnalogFilter analog, double scale) { int right = Convert.ToInt32(Math.Floor(analog.Right * scale)); while (analog[right / scale] == 0) { right--; } return(right); }
private static void AssertFiltersEqual(AnalogFilter actual, AnalogFilter expected, double granularity) { Assert.That(actual.Left, Is.EqualTo(expected.Left)); Assert.That(actual.Right, Is.EqualTo(expected.Right)); Assert.That(actual.Radius, Is.EqualTo(expected.Radius)); for (double x = actual.Left - granularity; x <= actual.Right + granularity; x += granularity) { Assert.That(actual[x], Is.EqualTo(expected[x]).Within(1E-15)); } }
private static int NonZeroLeft(AnalogFilter analog, double scale) { int left = Convert.ToInt32(Math.Ceiling(analog.Left * scale)); while (analog[left / scale] == 0) { left++; } return(left); }
private static void AssertCoefficients(AnalogFilter filter, double scale, double[] coeffs) { Assert.That(new DigitalFilter(filter, scale).Coefficients, Is.EqualTo(coeffs).Within(1E-15)); }
/// <summary> /// Set the active analog filter /// </summary> /// <param name="filter">Analog Filter to use</param> public void SetAnalogFilter(AnalogFilter filter) { SendCommandWithErrorOnlyResponse("PM:ANALOGFILTER " + (int)filter); }
public DigitalFilter(AnalogFilter analog, double scale) { Left = NonZeroLeft(analog, scale); Right = NonZeroRight(analog, scale); Coefficients = Arrays.New(Right - Left + 1, i => analog[(i + Left) / scale]); }
private void cmbAnalogFilter_SelectedIndexChanged(object sender, EventArgs e) { AnalogFilter filter = (AnalogFilter)cmbAnalogFilter.SelectedIndex; Newport.SetAnalogFilter(filter); }