Example #1
0
        /// <summary>
        /// Create calibration task
        /// </summary>
        /// <param name="properties">The properties relevant for the task</param>
        /// <returns>The task to be activated</returns>
        public Task CreateCalibrationTask(TaskProperties properties)
        {
            Task analogInputTask = new Task();

            analogInputTask.AIChannels.CreateVoltageChannel(Settings.Default.DAQPhysicalChannelName0, string.Empty,
                                                             GetAITerminalConfiguration(),
                                                             -10, 0, AIVoltageUnits.Volts);

            analogInputTask.Timing.ConfigureSampleClock(string.Empty, properties.SampleRate,
                                                        SampleClockActiveEdge.Rising, 
                                                        SampleQuantityMode.ContinuousSamples, 
                                                        properties.SamplesPerChannel);

            analogInputTask.Timing.SampleTimingType = SampleTimingType.SampleClock;

            return analogInputTask;
        }
        /// <summary>
        /// Get continuous analog-in task (calibration task)
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="worker"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private Task GetCalibrationTask(CalibrationSettings settings, string taskName,BackgroundWorker worker, DoWorkEventArgs e)
        { 
            //
            // Create the task with its propertites
            //
            TaskProperties taskProperties = new TaskProperties(settings.CalibirationSettings.SampleRate, 
                                                               settings.ChannelsSettings.ActiveChannels, taskName);

            return m_daqController.CreateContinuousAITask(taskProperties);
        }
Example #3
0
        /// <summary>
        /// Creates a continuous read task.
        /// </summary>
        /// <param name="properties"></param>
        /// <returns></returns>
        public Task CreateContinuousAITask(TaskProperties properties)
        {
            //
            // Create anaglog input task with the specified name
            //
            Task analogInputTask = new Task(c_refContAITask);

            //
            // Construct the the physical channel name according to the desired inputs.
            //
            StringBuilder physicalChannelName = new StringBuilder();

            foreach (var channel in properties.ActiveChannels)
            {
                physicalChannelName.Append(channel.PhysicalName);
                physicalChannelName.Append(",");
            }

            //
            // Remove last ':' from channel name
            //
            physicalChannelName.Remove(physicalChannelName.Length - 1, 1);

            //
            // Define a voltage channel
            //
            AIChannel anaglogChannel = analogInputTask.AIChannels.CreateVoltageChannel(physicalChannelName.ToString(), string.Empty,
                                                            GetAITerminalConfiguration(),
                                                            -10, 10, AIVoltageUnits.Volts);
            //
            // Configure sampling timing. the buffer size is large enough for 10 minutes reading
            //
            analogInputTask.Timing.ConfigureSampleClock(string.Empty, properties.SampleRate, SampleClockActiveEdge.Rising,
                                                        SampleQuantityMode.ContinuousSamples, (int)properties.SampleRate * 600);

            //
            // Verify the task
            //
            analogInputTask.Control(TaskAction.Verify);
            
            //
            // read the data from the buffer from the last read point.
            //
            analogInputTask.Stream.ReadRelativeTo = ReadRelativeTo.CurrentReadPosition;
            analogInputTask.Stream.ReadOffset = 0;
            
            //
            // no time limitation for the reading process
            //
            analogInputTask.Stream.Timeout = -1;
            
            return analogInputTask;
         }
Example #4
0
        /// <summary>
        /// Get Continuous Analog Input Task
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        private Task GetContinuousAITask(int sampleRate, IList<IDataChannel> activeChannels, string taskName)
        {
            //
            // get the properties required for the input task
            //
            TaskProperties inputTaskProperties = new TaskProperties(sampleRate, activeChannels, taskName);

            //
            // return the input task
            //
            return m_daqController.CreateContinuousAITask(inputTaskProperties);
        }