Beispiel #1
0
        /// <summary>
        /// creates a new read channel suckaz
        /// </summary>
        /// <param name="channelName"></param>
        /// <param name="isCounter"></param>
        public void CreateReadTask()
        {
            DestroyReaderTask();

            ReaderWaitHandle = new System.Threading.ManualResetEvent(true);
            ReaderTask       = new Task("IntensityReader");
            ReaderTask.SynchronizeCallbacks = SynchronizeCallbacks;
            ReaderTask.Stream.Timeout       = Timeout;


            // Creates Input Channel task after checking channel type
            string cname = new String(ChannelName.Where(Char.IsLetter).ToArray());

            if (!IsCounter)
            {
                this.ReaderTask.AIChannels.CreateVoltageChannel(ChannelName, "IntensityReader " + cname,
                                                                AITerminalConfiguration.Differential, -10, 10, AIVoltageUnits.Volts);

                AnalogReader = new AnalogMultiChannelReader(ReaderTask.Stream);
                AnalogReader.SynchronizeCallbacks = SynchronizeCallbacks;
            }
            else
            {
                this.ReaderTask.CIChannels.CreateCountEdgesChannel(ChannelName, "CounterReader " + cname,
                                                                   CICountEdgesActiveEdge.Rising, 10, CICountEdgesCountDirection.Up);

                this.ReaderTask.CIChannels.All.CountEdgesTerminal           = InputTerminal;
                this.ReaderTask.CIChannels.All.CountEdgesCountResetTerminal = "/CARD/PFI0";

                CounterReader = new CounterMultiChannelReader(ReaderTask.Stream);
                CounterReader.SynchronizeCallbacks = SynchronizeCallbacks;
            }

            LastReadDataChunk = null;
            // configureing the clock.
            ReaderTask.Timing.ConfigureSampleClock(TimeBaseTerminal,
                                                   SamplingFrequency, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples);
            ReaderTask.Control(TaskAction.Verify);
        }