コード例 #1
0
ファイル: MainForm.cs プロジェクト: akaushik1/EDMSuite
        private void CounterCallBack(IAsyncResult result)
        {
            // read the latest data from the counter
            Int32[] data;

            if (!Environs.Debug)
            {
                data = counterReader.EndReadMultiSampleInt32(result);
            }
            else
            {
                Random r = new Random();
                data = new Int32[SAMPLE_MULTI_READ];
                for (int i = 0; i < SAMPLE_MULTI_READ; i++)
                {
                    data[i] = fakeCounterValue;

                    fakeCounterValue += (Int32)((oscillatorFrequency / SAMPLE_CLOCK_RATE) *
                                                (1 + (FAKE_DATA_SPREAD * (r.NextDouble() - 0.5)) +
                                                 (FAKE_DATA_MOD *
                                                  Math.Sin(((sampleCounter * SAMPLE_MULTI_READ) + i) / FAKE_DATA_PERIOD))));
                }
            }

            // start the counter reading again right away
            if (!Environs.Debug)
            {
                counterReader.BeginReadMultiSampleInt32(
                    SAMPLE_MULTI_READ,
                    new AsyncCallback(CounterCallBack),
                    null
                    );
            }

            // deal with the data
            StoreData(data);

            if (lockOscillator && (sampleCounter % LOCK_UPDATE_EVERY == 0))
            {
                UpdateLock();
            }

            // update the gui ?
            if (sampleCounter % GUI_UPDATE_EVERY == 0)
            {
                UpdateGUI();
            }
            sampleCounter++;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: akaushik1/EDMSuite
        // this method configures and starts the counter.
        private void StartCounter()
        {
            // set up the counter - the fast oscillator is fed into a counter's source input
            counterTask = new Task("PhaseLock task");
            CounterChannel oscillatorChannel =
                ((CounterChannel)Environs.Hardware.CounterChannels["phaseLockOscillator"]);

            counterTask.CIChannels.CreateCountEdgesChannel(
                oscillatorChannel.PhysicalChannel,
                oscillatorChannel.Name,
                CICountEdgesActiveEdge.Rising,
                0,
                CICountEdgesCountDirection.Up
                );

            // this counter is sample-clocked by the slow reference that we are locking to.
            // the buffer is set to be "large"
            CounterChannel referenceChannel =
                ((CounterChannel)Environs.Hardware.CounterChannels["phaseLockReference"]);

            counterTask.Timing.ConfigureSampleClock(
                referenceChannel.PhysicalChannel,
                SAMPLE_CLOCK_RATE,
                SampleClockActiveEdge.Rising,
                SampleQuantityMode.ContinuousSamples,
                1000
                );

            counterReader = new CounterReader(counterTask.Stream);
            counterReader.SynchronizeCallbacks = true;

            if (!Environs.Debug)
            {
                counterReader.BeginReadMultiSampleInt32(
                    SAMPLE_MULTI_READ,
                    new AsyncCallback(CounterCallBack),
                    null
                    );
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: akaushik1/EDMSuite
        // this method configures and starts the counter.
        private void StartCounter()
        {
            // set up the counter - the fast oscillator is fed into a counter's source input
            counterTask = new Task("PhaseLock task");
            CounterChannel oscillatorChannel =
                ((CounterChannel)Environs.Hardware.CounterChannels["phaseLockOscillator"]);
            counterTask.CIChannels.CreateCountEdgesChannel(
                oscillatorChannel.PhysicalChannel,
                oscillatorChannel.Name,
                CICountEdgesActiveEdge.Rising,
                0,
                CICountEdgesCountDirection.Up
                );

            // this counter is sample-clocked by the slow reference that we are locking to.
            // the buffer is set to be "large"
            CounterChannel referenceChannel =
                ((CounterChannel)Environs.Hardware.CounterChannels["phaseLockReference"]);

            counterTask.Timing.ConfigureSampleClock(
                referenceChannel.PhysicalChannel,
                SAMPLE_CLOCK_RATE,
                SampleClockActiveEdge.Rising,
                SampleQuantityMode.ContinuousSamples,
                1000
                );

            counterReader = new CounterReader(counterTask.Stream);
            counterReader.SynchronizeCallbacks = true;

            if (!Environs.Debug)
                counterReader.BeginReadMultiSampleInt32(
                    SAMPLE_MULTI_READ,
                    new AsyncCallback(CounterCallBack),
                    null
                    );
        }