Exemple #1
0
        private bool RunTask(InOutPortFlags flags)
        {
            if (flags.HasFlag(InOutPortFlags.UseInput))
            {
                var result = NidaQmxHelper.DAQmxStartTask(_device.InputTaskHandle);
                if (result < 0)
                {
                    NidaQmxHelper.DAQmxClearTask(_device.InputTaskHandle);
                    _device.ReportError(new DeviceErrorArgs(NidaQmxHelper.GetError(result)));
                    return(false);
                }
            }

            //if (flags.HasFlag(InOutPortFlags.UseOutput)) {
            //    var result = NidaQmxHelper.DAQmxStartTask(_device.OutputTaskHandle);
            //    if (result < 0) {
            //        NidaQmxHelper.DAQmxStopTask(_device.InputTaskHandle);
            //        NidaQmxHelper.DAQmxClearTask(_device.InputTaskHandle);
            //        NidaQmxHelper.DAQmxClearTask(_device.OutputTaskHandle);
            //        _device.ReportError(new DeviceErrorArgs(NidaQmxHelper.GetError(result)));
            //        return false;
            //    }
            //}

            return(true);
        }
        public void Start()
        {
            if (TaskHandle == 0)
            {
                throw new InvalidOperationException("Task not yet created. First create a task");
            }

            var result = NidaQmxHelper.DAQmxStartTask(TaskHandle);

            if (result < 0)
            {
                CleanupAndThrow(result);
            }

            State = SessionTaskState.Running;
        }
Exemple #3
0
        public void Start()
        {
            if (TaskHandle == 0)
            {
                throw new InvalidOperationException("Task not yet created. First create a task");
            }

            try {
                _counter.Run();
            } catch (NationalInstruments.DAQmx.DaqException e) {
                CleanupAndThrow(e.Error);
            }

            var result = NidaQmxHelper.DAQmxStartTask(TaskHandle);

            if (result < 0)
            {
                CleanupAndThrow(result);
            }

            State = SessionTaskState.Running;
        }