Esempio n. 1
0
        public static float[] GenerateWave(uint waveLength, double samplePeriod, double timeOffset, DummyScopeChannelConfig config)
        {
            WaveForm waveForm  = config.waveform;
            double   frequency = config.frequency;
            double   amplitude = config.amplitude;
            double   phase     = config.phase;
            double   dutyCycle = config.dutyCycle;
            double   dcOffset  = config.dcOffset;

            float[] wave = new float[waveLength];
            switch (waveForm)
            {
            case WaveForm.SINE:
                wave = DummyScope.WaveSine(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;

            case WaveForm.COSINE:
                wave = DummyScope.WaveCosine(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;

            case WaveForm.SQUARE:
                wave = DummyScope.WaveSquare(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase, dutyCycle);
                break;

            case WaveForm.SAWTOOTH:
                wave = DummyScope.WaveSawTooth(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;

            case WaveForm.TRIANGLE:
                wave = DummyScope.WaveTriangle(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;

            case WaveForm.SAWTOOTH_SINE:
                wave = DummyScope.WaveSawtoothSine(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;

            case WaveForm.MULTISINE:
                wave = DummyScope.WaveMultiCosine(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase, new float[] { 1, 2, 4, 8 });
                break;

#if DEBUG
            case WaveForm.HALF_BIG_HALF_UGLY:
                wave = DummyScope.WaveHalfBigHalfUgly(waveLength, samplePeriod, timeOffset, frequency, amplitude, phase);
                break;
#endif
            default:
                throw new NotImplementedException();
            }
            Func <float, float> offsetAdder = x => (float)(x + dcOffset);
            wave = Utils.TransformArray(wave, offsetAdder);
            return(wave);
        }
Esempio n. 2
0
        public static float[] WaveHalfBigHalfUgly(uint awgPoints, double awgSamplePeriod, double timeOffset, double frequency, double amplitude, double phase)
        {
            float[] wave1 = DummyScope.WaveSine(awgPoints, awgSamplePeriod, timeOffset, frequency * 21f, amplitude, phase + 0 * 168);
            float[] wave2 = DummyScope.WaveSine(awgPoints, awgSamplePeriod, timeOffset, frequency * 21f, amplitude * 0.4f, phase + 0 * 168);

            float[] wave3 = DummyScope.WaveSawTooth(awgPoints, awgSamplePeriod, timeOffset, 50f, amplitude * 1f, phase + 0);
            float[] wave4 = DummyScope.WaveSawTooth(awgPoints, awgSamplePeriod, timeOffset, 50f, amplitude * 0.4f, phase + 0);

            float[] wave5 = DummyScope.WaveSquare(awgPoints, awgSamplePeriod, timeOffset, frequency * 31, amplitude, phase + 0 * 912);
            float[] wave6 = DummyScope.WaveSquare(awgPoints, awgSamplePeriod, timeOffset, frequency * 31f, amplitude * 0.5f, phase + 0 * 912);

            float[] wave7 = DummyScope.WaveSquare(awgPoints, awgSamplePeriod, timeOffset, frequency * 60, amplitude, phase + 0 * 912);
            float[] wave8 = DummyScope.WaveSquare(awgPoints, awgSamplePeriod, timeOffset, frequency * 60f, amplitude * 0.5f, phase + 0 * 912);

            float[] wave9  = DummyScope.WaveSine(awgPoints, awgSamplePeriod, timeOffset, frequency * 800f, amplitude, 0 * 168);
            float[] wave10 = DummyScope.WaveSine(awgPoints, awgSamplePeriod, timeOffset, frequency * 800f, amplitude * 0.4f, phase + 0 * 168);

            float[] finalWave = new float[wave1.Length];

            for (int i = 0; i < wave1.Length; i++)
            {
                if (i < 1 * 1600)
                {
                    finalWave[i] = wave1[i];
                }
                else if (i < 2 * 1600)
                {
                    finalWave[i] = wave2[i];
                }
                else if (i < 3 * 1600)
                {
                    finalWave[i] = wave3[i];
                }
                else if (i < 4 * 1600)
                {
                    finalWave[i] = wave4[i];
                }
                else if (i < 5 * 1600)
                {
                    finalWave[i] = wave5[i];
                }
                else if (i < 6 * 1600)
                {
                    finalWave[i] = wave6[i];
                }
                else if (i < 7 * 1600)
                {
                    finalWave[i] = wave7[i];
                }
                else if (i < 8 * 1600)
                {
                    finalWave[i] = wave8[i];
                }
                else if (i < 9 * 1600)
                {
                    finalWave[i] = wave9[i];
                }
                else if (i < 10 * 1600)
                {
                    finalWave[i] = wave10[i];
                }
            }

            return(finalWave);
        }