public Measurement(PointCollection GraphSegment, double TimeRes, double ScaleFactor, int HighLevel) { Result = new StackPanel(); if (GraphSegment.Count != 0) { InputData = new PointCollection(); for (int PointIndex = 0; PointIndex < GraphSegment.Count; PointIndex++) { Point NewPoint = new Point(GraphSegment[PointIndex].X / ScaleFactor, GraphSegment[PointIndex].Y); InputData.Add(NewPoint); } TimeResolution = TimeRes; PulseHighLevel = HighLevel; Result.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFADFF2F")); Result.Name = "MeasureGrid"; Result.Opacity = 0.65;// 0.75; Result.Orientation = Orientation.Vertical; Result.RenderTransform = new ScaleTransform(1, -1); double Duration = GetDuration(InputData[0].X, InputData[InputData.Count - 1].X); AddData("Ширина: " + Duration.ToString("0.000") + " мкс"); int EdgeCount; int RisingEdgeCount; int FallingEdgeCount; int PulseCntResult = PulseCounter(out EdgeCount, out RisingEdgeCount, out FallingEdgeCount); if (PulseCntResult == ONE_PULSE) { double DutyCycle; double Frequency; double Period; double PulseWidth; Period = Duration; Frequency = 1000 / Period; //кГц GetPulseWidth(out PulseWidth); DutyCycle = 100 * PulseWidth / Period; //% AddData("Период: " + Period.ToString("0.000") + " мкс"); AddData("Частота: " + Frequency.ToString("0.000") + " кГц"); AddData("Длительность импульса: " + DutyCycle.ToString("0.000") + " % / " + PulseWidth.ToString("0.000") + " мкс"); } else if (PulseCntResult == MANY_PULSES) { AddData("Количество фронтов: " + EdgeCount.ToString()); AddData("Передних фронтов: " + RisingEdgeCount.ToString()); AddData("Задних фронтов: " + FallingEdgeCount.ToString()); } } }
public bool MergeDutyCycle(DutyCycle d) { double offset = d.mStartTime - mStartTime; if (d.mSegmentList.Count == 0) { return(true); } if (offset >= 0) { uint offs = (uint)(offset * Constants.cUIntScaleToMS); mSegmentList = DutyCycle.MergeDutyCycle(mSegmentList, d.mSegmentList, offs); return(true); } else { } return(false); }
public void Play(SynthPlayer synth, WaveType wave, float amplitude, DutyCycle dutyCycle = DutyCycle.Half) { //channel = synth.Play(WaveType.Square, ToFreq(), 0.2f); }
public void Play(SynthPlayer synth, WaveType waveType, float amplitude, DutyCycle dutyCycle = DutyCycle.Half) { this.waveType = waveType; channel = synth.Play(waveType, ToFreq(), amplitude, dutyCycle); }
public int Play(WaveType waveType, float freq, float amplitude, DutyCycle cycle = DutyCycle.Half) { int channel = -1; Wave wave = null; switch (waveType) { case WaveType.Square: for (int ch = 0; ch < SQUARE_CHANNELS; ch++) { if (usingSquare[ch]) { continue; } usingSquare[ch] = true; wave = square[ch]; channel = ch; square[ch].DutyCycle = ((int)cycle) * BaseDutyCycle; break; } break; case WaveType.Sawtooth: for (int ch = 0; ch < SAWTOOTH_CHANNELS; ch++) { if (usingSawtooth[ch]) { continue; } usingSawtooth[ch] = true; wave = sawtooth[ch]; channel = ch; break; } break; case WaveType.Triangle: for (int ch = 0; ch < TRIANGLE_CHANNELS; ch++) { if (usingTriangle[ch]) { continue; } usingTriangle[ch] = true; wave = triangle[ch]; channel = ch; break; } break; case WaveType.Noise: for (int ch = 0; ch < NOISE_CHANNELS; ch++) { if (usingNoise[ch]) { continue; } usingNoise[ch] = true; wave = noise[ch]; channel = ch; break; } break; default: break; } if (channel != -1) { wave.Amplitude = amplitude; wave.Frequency = freq; } return(channel); }