Exemple #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            bool _bStop = false;

            this.m_clock = new NISampleClock("Dev1", "Ctr2");

            this.m_APD = new SIS.Hardware.APD("Dev1", "Ctr0", 100, "Ctr2InternalOutput", "Ctr1", "PFI15", false);

            this.m_APD.SetupAPDCountAndTiming(100.0, 100000);
            this.m_APD.StartAPDAcquisition();

            this.m_clock.Start(0.1);

            uint[] data;

            while (!_bStop)
            {
                if (backgroundWorker1.CancellationPending)
                {
                    e.Cancel = true;
                    _bStop = true;
                }
                else
                {
                    data = this.m_APD.Read();

                    foreach (uint sample in data)
                    {
                        if (!this.Disposing && InvokeRequired)
                        {
                            Invoke((MethodInvoker)delegate { this.label1.Text = (sample * 10).ToString("E3"); });
                        }
                    }
                }

                Thread.Sleep(50);
            }
        }
Exemple #2
0
        public void Configure(double __dCycleTimeMilisec, int __iSteps, bool master, bool continuous)
        {
            _logger.Info("Configuring stage timing....");

            this.m_samplePeriod = __dCycleTimeMilisec / 1000;

            if (this.m_bMaster && this.m_sampleClock == null)
            {
                this.m_sampleClock = new NISampleClock(this.m_sDevice, "Ctr2");
            }

            if (this.m_daqtskLineTrigger != null)
            {
                if (this.m_daqtskLineTrigger.IsDone != true)
                {
                    this.m_daqtskLineTrigger.Stop();
                }

                this.m_daqtskLineTrigger.Control(TaskAction.Unreserve);
            }

            Task _lineTask = new Task();

            try
            {

                if (this.m_daqtskMoveStage == null)
                {
                    this.Initialize();
                }

                this.m_daqtskMoveStage.Timing.SampleTimingType = SampleTimingType.SampleClock;

                this.m_daqtskMoveStage.Timing.ConfigureSampleClock(
                    this.m_bMaster ? this.m_sampleClock.Terminal : this.m_sTimingSource,
                    1000 / __dCycleTimeMilisec,
                    SampleClockActiveEdge.Rising,
                    continuous ? SampleQuantityMode.ContinuousSamples : SampleQuantityMode.FiniteSamples,
                    __iSteps);

                _lineTask.DOChannels.CreateChannel(
                    this.m_sDevice + "/port0",
                    "test",
                    ChannelLineGrouping.OneChannelForAllLines);

                _lineTask.Timing.SampleTimingType = SampleTimingType.SampleClock;

                _lineTask.Timing.ConfigureSampleClock(
                    this.m_bMaster ? this.m_sampleClock.Terminal : this.m_sTimingSource,
                    1000 / __dCycleTimeMilisec,
                    SampleClockActiveEdge.Rising,
                    continuous ? SampleQuantityMode.ContinuousSamples : SampleQuantityMode.FiniteSamples,
                    __iSteps);

                _lineTask.Control(TaskAction.Verify);
                _lineTask.Control(TaskAction.Commit);
            }

            catch (DaqException ex)
            {
                if (_lineTask != null)
                {
                    _lineTask.Dispose();
                }

                _logger.Error("Error while setting timing!", ex);
            }

            if (_lineTask != null)
            {
                this.m_daqtskLineTrigger = _lineTask;
            }
        }