当前位置: 首页>>代码示例>>C#>>正文


C# Task.Start方法代码示例

本文整理汇总了C#中System.Threading.Task.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Start方法的具体用法?C# Task.Start怎么用?C# Task.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Task的用法示例。


在下文中一共展示了Task.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnsureIDidNotMessUpTasks

        public void EnsureIDidNotMessUpTasks()
        {
            var task = new Task("do stuff");
            task.Start();
            task.Stop();

            task.Start();
            task.Stop();

            var description = task.Description;

            // just make sure it doesn't blow up
        }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:13,代码来源:TasksTests.cs

示例2: RepositoryWorks

        public void RepositoryWorks()
        {
            var taskRepository = new TaskRepository() { Configuration = new CoreConfiguration(".", ".") };

            var task = new Task("do stuff");
            task.Start();
            task.Stop();

            task.Start();
            task.Stop();

            taskRepository.CreateTask(task);

            var loadedTask = taskRepository.FromFileName(task.FileName);
            Assert.Equal(task.Durations.Count, loadedTask.Durations.Count);
            Assert.Equal(task.Name, loadedTask.Name);
        }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:17,代码来源:TasksTests.cs

示例3: CanStartSaveGetAndStop

        public void CanStartSaveGetAndStop()
        {
            var taskRepository = new TaskRepository() { Configuration = new CoreConfiguration(".",".") };

            var task = new Task("do stuff");
            task.Start();

            taskRepository.CreateTask(task);

            Thread.Sleep(TimeSpan.FromSeconds(1)); // TODO: remove this sleep
            var loadedTask = taskRepository.FromFileName(task.FileName);
            loadedTask.Stop();

            Assert.Equal(1, loadedTask.Durations.Count);
        }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:15,代码来源:TasksTests.cs

示例4: ConfigureSetLaserVoltage

 //This takes in a voltage. A bit cheezy, but I needed the laser
 // voltage to be set as soon value as soon as it gets configured.
 public void ConfigureSetLaserVoltage(double voltage)
 {
     outputLaserTask = new Task("FeedbackToLaser");
     laserChannel =
             (AnalogOutputChannel)Environs.Hardware.AnalogOutputChannels[laserChannelName];
     laserChannel.AddToTask(outputLaserTask, -10, 10);
     outputLaserTask.Control(TaskAction.Verify);
     laserWriter = new AnalogSingleChannelWriter(outputLaserTask.Stream);
     laserWriter.WriteSingleSample(true, voltage);
     outputLaserTask.Start();
 }
开发者ID:akaushik1,项目名称:EDMSuite,代码行数:13,代码来源:DAQMxTCL2012HelperExtTriggeredMultiRead.cs

示例5: TestReservedToInProgressActualOwner

        public void TestReservedToInProgressActualOwner()
        {
            IdentityId actualId = new IdentityId();
            ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent>());
            Task task = new Task(
                         new TaskId(), TaskStatus.Reserved, string.Empty,
                         string.Empty, Priority.Normal, false,
                         DateTime.UtcNow, new IdentityId().GetIdentity(),
                         DateTime.UtcNow, null, actualId.GetIdentity())
            {
                LoggingService = loggingService
            };

            Assert.IsNotNull(task);
            IPrincipal actualOwner = new ClaimsPrincipal(actualId.GetIdentity());
            Thread.CurrentPrincipal = actualOwner;
            task.Start();
            Assert.AreEqual(TaskStatus.InProgress, task.Status);
            Assert.AreEqual(actualId.GetIdentity(), task.ActualOwner);
            Assert.IsNotNull(task.History);
            Assert.AreEqual(1, task.History.Count());
            TaskHistoryEvent history = task.History.ElementAt(0);
            Assert.IsNotNull(history);
            Assert.AreEqual(TaskStatus.Reserved, history.OldStatus);
            Assert.AreEqual(TaskStatus.InProgress, history.NewStatus);
            Assert.AreEqual(actualId, history.UserId);
        }
开发者ID:KlaudWerk,项目名称:WSHumanTask,代码行数:27,代码来源:TaskStateTransitionsTest.cs

示例6: startButton_Click

        private static void startButton_Click()
        {
            try
            {
                continuousTask = DaqSystem.Local.LoadTask(taskName);

                runningTask = continuousTask;
                continuousTask.Start();
                reader = new AnalogMultiChannelReader(continuousTask.Stream);

                callBack = new AsyncCallback(ReadCallBack);

                reader.SynchronizeCallbacks = true;
                reader.BeginReadWaveform(Convert.ToInt32(continuousTask.Timing.SamplesPerChannel), callBack, continuousTask);
                while (true)
                {
                }

            }
            catch (DaqException ex)
            {
                continuousTask.Dispose();
            }
        }
开发者ID:psweeney-YU,项目名称:NEVP-conveyor,代码行数:24,代码来源:MainForm.cs

示例7: TestTaskReady

        public void TestTaskReady()
        {
            TaskEntity entity = new TaskEntity
            {
                TaskId = new TaskId(),
                Initiator = new IdentityId().GetIdentity(),
                Priority = Priority.Normal,
                Status = TaskStatus.Created,
                Created = DateTime.UtcNow,
                Name = "Name",
                Subject = "Subject"
            };

            Task task = new Task(entity)
            {
                LoggingService = new Mock<ILoggingService>().Object,
                Priority = Priority.High

            };

            TaskDao dao = new TaskDao(SessionFactory);
            task.Accept(dao);
            Task loaded;
            using (ISession session = SessionFactory.OpenSession())
            {
                TaskEntity te = session.Query<TaskEntity>().Where(t => t.TaskId == entity.TaskId).FirstOrDefault();
                loaded=new Task(te);
            }
            Thread.GetDomain().SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            IPrincipal p = Thread.CurrentPrincipal;
            loaded.Start();
            task.Accept(dao);
            loaded.Claim();
            task.Accept(dao);
        }
开发者ID:KlaudWerk,项目名称:WSHumanTask,代码行数:35,代码来源:HibernateTaskPersistenceTest.cs

示例8: ConfigureScanTrigger

 public void ConfigureScanTrigger()
 {
     sendScanTriggerTask = new Task("Send Cavity UnlockCavity Trigger");
     sendTriggerChannel = (DigitalOutputChannel)Environs.Hardware.DigitalOutputChannels[triggerOutput];
     sendTriggerChannel.AddToTask(sendScanTriggerTask);
     sendScanTriggerTask.Control(TaskAction.Verify);
     triggerWriter = new DigitalSingleChannelWriter(sendScanTriggerTask.Stream);
     triggerWriter.WriteSingleSampleSingleLine(true, false);
     sendScanTriggerTask.Start();
 }
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:10,代码来源:DAQMxTransferCavityLockHelper.cs

示例9: IV_AcquireDataWithoutMoving

        /// <summary>
        /// Perform IV cycles while standing in place
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="worker"></param>
        /// <param name="e"></param>
        public void IV_AcquireDataWithoutMoving(IVSettings settings, BackgroundWorker worker, DoWorkEventArgs e)
        {
            int finalFileNumber = settings.IVGeneralSettings.CurrentFileNumber;
            double[,] dataAcquired;
            List<IDataChannel> physicalChannels = new List<IDataChannel>();

            //
            // Save this run settings if desired
            //
            SaveSettingsIfNeeded(settings, settings.IVGeneralSettings.IsFileSavingRequired, settings.IVGeneralSettings.Path);

            //
            // apply initial voltage on the EM if needed
            //
            ApplyVoltageOnElectroMagnetIfNeeded(settings.IVSteppingMethodSettings.SteppingDevice == SteppingDevice.ElectroMagnet);


            //
            // create the input and output tasks
            //
            m_ivInputTask = GetContinuousAITask(settings.IVGeneralSettings.SampleRate, settings.ChannelsSettings.ActiveChannels, null);
            m_ivInputTask.Stream.ReadRelativeTo = ReadRelativeTo.FirstSample;
            m_outputTask = GetContinuousAOTask(settings);

            //
            // initiate writer for the output and set initial bias
            //
            InitiateOutputWriter(m_outputTask, settings);

            //
            // Main loop for data aquisition
            //
            for (int i = 0; i < settings.IVGeneralSettings.TotalNumberOfCycles; i++)
            {
                //
                // Cancel the operatin if user asked for
                //
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                m_quitRealTimeOperation = false;

                //
                // we set the votlage to triangle wave and then open the junction by the EM
                //
                writer.BeginWriteMultiSample(false, m_functionGenerator.TriangleWave, null, null);

                //
                // Start the input task.
                //
                try
                {
                    m_ivInputTask.Start();
                }
                catch (DaqException ex)
                {
                    throw new SBJException("Error occured when tryin to start DAQ input task", ex);
                }

                //
                // start reading continuously. 
                // when the junction is opened, the opening thread will change m_quitJuncctionOpeningOperation to true.
                // set dataAquired to null otherwise it saves last cycle's data. 
                //
                reader = new AnalogMultiChannelReader(m_ivInputTask.Stream);
                dataAcquired = null;
                try
                {
                    while (!m_quitRealTimeOperation)
                    {
                        try
                        {
                            dataAcquired = reader.ReadMultiSample(-1);
                        }
                        catch (DaqException)
                        {
                            continue;
                        }
                    }

                    if (dataAcquired != null)
                    {
                        if (settings.ChannelsSettings.ActiveChannels.Count != dataAcquired.GetLength(0))
                        {
                            throw new SBJException("Number of data channels doesn't fit the recieved data.");
                        }
                    }
                }
                catch (DaqException ex)
                {
                    //
//.........这里部分代码省略.........
开发者ID:nnirit,项目名称:sbj-controller,代码行数:101,代码来源:SBJControllerIV.cs

示例10: IV_AcquireData


//.........这里部分代码省略.........
                        // we are on the first cycle and wish to open the junction by the stepper motor.
                        //
                        ObtainOpenJunctionByStepperMotor(settings.IVGeneralSettings.TriggerVoltage, worker, e);

                        //
                        // from now on we will be using the electroMagnet, so lets turn the stepper motor off and move to the next cycle
                        //
                        m_stepperMotor.Shutdown();
                        continue;
                    }
                    else
                    {
                        //
                        // we set the votlage to triangle wave and then open the junction by the EM
                        //
                        writer.BeginWriteMultiSample(false, m_functionGenerator.TriangleWave, null, null);
                        IV_EMBeginOpenJunction(settings);
                    }
                }
                else
                {
                    //
                    // we set the voltage to triangle wave and then open the junction by stepper motor
                    //
                    writer.BeginWriteMultiSample(false, m_functionGenerator.TriangleWave, null, null);
                    IV_StepperMotorBeginOpenJunction(settings);
                }

                //
                // Start the input task.
                //
                try
                {
                    m_ivInputTask.Start();
                }
                catch (DaqException ex)
                {
                    throw new SBJException("Error occured when tryin to start DAQ input task", ex);
                }

                //
                // start reading continuously. 
                // when the junction is opened, the opening thread will change m_quitJuncctionOpeningOperation to true.
                // set dataAquired to null otherwise it saves last cycle's data. 
                //
                reader = new AnalogMultiChannelReader(m_ivInputTask.Stream);
                dataAcquired = null;
                try
                {
                    while (!m_quitJunctionOpenningOperation)
                    {
                        dataAcquired = reader.ReadMultiSample(-1);
                    }

                    if (dataAcquired != null)
                    {
                        if (settings.ChannelsSettings.ActiveChannels.Count != dataAcquired.GetLength(0))
                        {
                            throw new SBJException("Number of data channels doesn't fit the recieved data.");
                        }
                    }
                }
                catch (DaqException)
                {
                    //
                    // Probably timeout.
开发者ID:nnirit,项目名称:sbj-controller,代码行数:67,代码来源:SBJControllerIV.cs

示例11: AquireDataContinuously

        /// <summary>
        /// Manually aquire data
        /// This method continuously poll the buffer for data until it is stopped by the user.
        /// </summary>
        /// <param name="settings">The settings for running the aquisition</param>
        /// <returns>True whether the operation was cacled by the user. False otherwise.</returns>
        public bool AquireDataContinuously(SBJControllerSettings settings, BackgroundWorker worker, DoWorkEventArgs e)
        {
            //
            // Apply voltage with desired tool: Task or Keithley
            //
            ApplyVoltageIfNeeded(settings.GeneralSettings.UseKeithley,
                                 settings.GeneralSettings.Bias,
                                 settings.GeneralSettings.BiasError,
                                 settings.GeneralSettings.Range,
                                 settings.GeneralSettings.AutoRange);
            bool isCancelled = false;
            int finalFileNumber = settings.GeneralSettings.CurrentFileNumber;

            //
            // The array is intialized with size for 1 minute sampling.
            //
            double[,] dataAquired = new double[1000, 1000];

            List<IDataChannel> physicalChannels = new List<IDataChannel>();

            //
            // Configure the laser if needed for this run
            //
            ConfigureLaserIfNeeded(settings);

            //
            // Save this run settings if desired
            //
            SaveSettingsIfNeeded(settings, settings.GeneralSettings.IsFileSavingRequired, settings.GeneralSettings.Path);

            //
            //apply initial voltage on the EM
            //
            ApplyVoltageOnElectroMagnetIfNeeded(settings.ElectromagnetSettings.IsEMEnable);

            //
            // Create the task
            //
            m_activeTriggeredTask = GetContinuousAITask(settings.GeneralSettings.SampleRate, settings.ChannelsSettings.ActiveChannels, null);

            //
            // If EM is enabled, and we are asked to skip the first cycle (that is done by the stepper motor), 
            // then return.
            //
            if (settings.ElectromagnetSettings.IsEMEnable && settings.ElectromagnetSettings.IsEMSkipFirstCycleEnable)
            {
                m_stepperMotor.Shutdown();
                return false;
            } 

            if (settings.LaserSettings.IsLaserOn)
            {
                m_LaserController.TurnOn();
            }
           

            //
            // Start the task and wait for the data
            //
            try
            {
                m_activeTriggeredTask.Start();
            }
            catch (DaqException ex)
            {
                throw new SBJException("Error occured when tryin to start DAQ task", ex);
            }

            AnalogMultiChannelReader reader = new AnalogMultiChannelReader(m_activeTriggeredTask.Stream);
            List<List<double>> fullData = new List<List<double>>(settings.ChannelsSettings.ActiveChannels.Count);

            for (int i = 0; i < fullData.Capacity; i++)
            {
                fullData.Add(new List<double>());
            }

            try
            {
                //
                // Before getting all the data clear the lists.
                //
                ClearRawData(settings.ChannelsSettings.ActiveChannels);

                //
                // As long as the user didn't ask to stop the acquisition 
                // (which is signaled by the stop of the stepper motion)
                // we coninue sampling.
                //
                while (!worker.CancellationPending)
                {
                    //
                    // Read all available data points in the buffer that
                    // were not read so far.
                    //
//.........这里部分代码省略.........
开发者ID:nnirit,项目名称:sbj-controller,代码行数:101,代码来源:SBJController.cs

示例12: AquireDataManually


//.........这里部分代码省略.........
            //
            if (settings.GeneralSettings.UseDefaultGain)
            {
                int gainPower;
                Int32.TryParse(settings.GeneralSettings.Gain, out gainPower);
                m_amplifier.ChangeGain(gainPower);
            }


            if (settings.LaserSettings.IsLaserOn)
            {
                m_LaserController.TurnOn();
            }

            //
            // Start openning the junction.
            // If EM is enabled then use it.
            //
            if (settings.ElectromagnetSettings.IsEMEnable)
            {
                m_stepperMotor.Shutdown();
                EMBeginOpenJunction(settings, worker, e);                
            }
            else
            {
                BeginOpenJunction(settings, worker, e);
            }

            //
            // Start the task and wait for the data
            //
            try
            {
                m_activeTriggeredTask.Start();
            }
            catch (DaqException ex)
            {
                throw new SBJException("Error occured when tryin to start DAQ task", ex);
            }

            AnalogMultiChannelReader reader = new AnalogMultiChannelReader(m_activeTriggeredTask.Stream);
            List<List<double>> averagedData = new List<List<double>>(settings.ChannelsSettings.ActiveChannels.Count);

            for (int i = 0; i < averagedData.Capacity; i++)
            {
                averagedData.Add(new List<double>());
            }

            try
            {
                //
                // Before getting all the data clear the lists.
                //
                ClearRawData(settings.ChannelsSettings.ActiveChannels);              

                //
                // As long as the user didn't ask to stop the acquisition 
                // (which is signaled by the stop of the stepper motion)
                // we coninue sampling.
                //
                while (!m_quitJunctionOpenningOperation)
                {
                    //
                    // Read all available data points in the buffer that
                    // were not read so far.
                    //
开发者ID:nnirit,项目名称:sbj-controller,代码行数:67,代码来源:SBJController.cs

示例13: ReachToPositionByMovingUp

        /// <summary>
        /// Reach to position specified by conductance value and then stop and aqcuire data until asked to stop.
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="worker"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private bool ReachToPositionByMovingUp(SBJControllerSettings settings, BackgroundWorker worker, DoWorkEventArgs e)
        {
            double[,] dataAcquired = new double[1000, 1000];
            int finalFileNumber = settings.GeneralSettings.CurrentFileNumber;
            List<IDataChannel> physicalChannels = new List<IDataChannel>();


            for (int i = 0; i < settings.GeneralSettings.TotalNumberOfCycles; i++)
            {
                //
                // Cancel the operatin if user asked for
                //
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                //
                // This flag is used to signal us when the user asked to stop the real time data acquisition
                //
                m_quitRealTimeOperation = false;
                m_activeTriggeredTask = GetMultipleChannelsTriggeredTask(settings, null, RunDirection.Break, m_triggerSlope, m_triggerVoltage, worker, e);
                m_activeTriggeredTask.EveryNSamplesReadEventInterval = settings.GeneralSettings.TotalSamples;
                m_activeTriggeredTask.Done += new TaskDoneEventHandler(OnTaskDoneOpenning);
                m_activeTriggeredTask.Control(TaskAction.Verify);
                m_triggerSlope = m_activeTriggeredTask.Triggers.ReferenceTrigger.AnalogEdge.Slope;
                m_triggerVoltage = m_activeTriggeredTask.Triggers.ReferenceTrigger.AnalogEdge.Level;

                //
                // physical channel will include both simple and complex channels. 
                // 
                physicalChannels = GetChannelsForDisplay(settings.ChannelsSettings.ActiveChannels);

                //
                // Assign the aquired data for each channel.
                // First clear all data from previous interation.
                //                
                ClearRawData(settings.ChannelsSettings.ActiveChannels);

                //
                // Create the tasks: One for triggering us to stop and the other for start monitoring the data
                //
                m_realTimeTask = GetContinuousAITask(settings.GeneralSettings.SampleRate, settings.ChannelsSettings.ActiveChannels, null);
                AnalogMultiChannelReader realTimeReader = new AnalogMultiChannelReader(m_realTimeTask.Stream);

                //
                // Start closing the junction.
                // If EM is enabled use the EM.
                //
                if (settings.ElectromagnetSettings.IsEMEnable)
                {
                    EMTryObtainShortCircuit(settings.ElectromagnetSettings.EMShortCircuitDelayTime, settings.GeneralSettings.ShortCircuitVoltage, worker, e);
                }
                else
                {
                    TryObtainShortCircuit(settings.GeneralSettings.ShortCircuitVoltage, settings.GeneralSettings.UseShortCircuitDelayTime,settings.GeneralSettings.ShortCircuitDelayTime, worker, e);
                }

                //
                // Start openning the junction. ASync operation.
                // If EM is enabled use the EM.
                //
                if (settings.ElectromagnetSettings.IsEMEnable)
                {
                    EMBeginOpenJunction(settings, worker, e);
                }
                else
                {
                    BeginOpenJunction(settings, worker, e);
                }

                //
                // Cancel the operatin if user asked for
                //
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                //
                // Start the triggered task. 
                //
                m_activeTriggeredTask.Start();

                //
                // If the user asked to stop the operation on the external thread then
                // WaitUntilDone will throw an expection. We can ignore that and return.
                //
                try
                {
                    m_activeTriggeredTask.WaitUntilDone();
//.........这里部分代码省略.........
开发者ID:nnirit,项目名称:sbj-controller,代码行数:101,代码来源:SBJController.cs

示例14: UpdateRecordingSettings

        // Look at the recording hardware settings and create NI Tasks that reflect the user's choices
        private void UpdateRecordingSettings()
        {
            //resets channel counts for input streams
            updateChannelCount();

            // update the recordingSettings object
            recordingSettings.RefreshForm();

            // Set spike buffer lengths
            spikeBufferLength = Convert.ToInt32(Properties.Settings.Default.ADCPollingPeriodSec * Properties.Settings.Default.RawSampleFrequency);
            lfpBufferLength = Convert.ToInt32(Properties.Settings.Default.ADCPollingPeriodSec * Properties.Settings.Default.LFPSampleFrequency);
            eegBufferLength = Convert.ToInt32(Properties.Settings.Default.ADCPollingPeriodSec * Properties.Settings.Default.EEGSamplingRate);
            // Enable spike detector saving while stopped
            spikeDet.EnableFileMenu();

            // update recording type to nominal
            isNormalRecording = true;

            // Refresh all the NI Tasks
            try
            {

                if (spikeTask != null)
                {
                    bool cantReset = true;

                    //Hack to prevent lock up
                    DateTime startTime = DateTime.Now;
                    while (cantReset)
                    {
                        cantReset = false;
                        for (int i = 0; i < spikeTask.Count; i++)
                            cantReset = cantReset || bwIsRunning[i];
                        System.Threading.Thread.Sleep(100);

                        // Exit the loop if we are waiting for more than a second
                        if ((DateTime.Now - startTime).TotalSeconds > 0.5)
                            break;
                    }
                    for (int i = 0; i < spikeTask.Count; ++i)
                        spikeTask[i].Dispose();
                    spikeTask.Clear(); spikeTask = null;
                }
                if (stimTimeTask != null) { stimTimeTask.Dispose(); stimTimeTask = null; }
                if (stimIvsVTask != null) { stimIvsVTask.Dispose(); stimIvsVTask = null; }
                if (serialOut != null) { serialOut.Close(); serialOut.Dispose(); }
                if (Properties.Settings.Default.UseCineplex)
                {
                    if (videoTask == null)
                    {
                        videoTask = new Task("videoTask");
                        videoTask.COChannels.CreatePulseChannelFrequency(Properties.Settings.Default.CineplexDevice + "/ctr0", "",
                            COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 1000, 0.5);
                        videoTask.Control(TaskAction.Verify);
                        videoTask.Timing.ReferenceClockSource = "OnboardClock";
                        videoTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 10);
                        videoTask.Start();
                    }
                    checkBox_video.Enabled = true;
                }
                else
                    checkBox_video.Enabled = false;

                try
                {
                    if (Properties.Settings.Default.UseProgRef)
                    {
                        string serialOutPort = Properties.Settings.Default.SerialPortDevice;
                        serialOut = new SerialPort(serialOutPort, 38400, Parity.None, 8, StopBits.One);
                        serialOut.Open();
                        serialOut.Write("#0140/0\r"); //Reset everything to power-up state
                        groupBox_plexonProgRef.Visible = true;
                    }
                    else
                    {
                        groupBox_plexonProgRef.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was a problem when setting up the serial communicaiton port to the Plexon device:\r\n\r\n" + ex.Message);
                    groupBox_plexonProgRef.Visible = false;
                }

                this.drawOpenLoopStimPulse();

                //Add LFP tab, if applicable
                if (Properties.Settings.Default.UseLFPs && !tabControl.TabPages.Contains(tabPage_LFPs))
                {
                    tabPage_LFPs = new TabPage("LFPs");
                    tabControl.TabPages.Insert(2, tabPage_LFPs);
                }
                else if (!Properties.Settings.Default.UseLFPs && tabControl.TabPages.Contains(tabPage_LFPs))
                    tabControl.TabPages.Remove(tabPage_LFPs);

                //Add MUA tab, if applicable
                if (Properties.Settings.Default.ProcessMUA && !tabControl.TabPages.Contains(tabPage_MUA))
                {
                    tabPage_MUA = new TabPage("MUA");
//.........这里部分代码省略.........
开发者ID:rzellertownson,项目名称:neurorighter,代码行数:101,代码来源:clnup.cs

示例15: Configure

        public void Configure( double clockFrequency, bool loop, bool fullWidth,
                                    bool lowGroup, int length, bool internalClock, bool triggered)
        {
            this.clockFrequency = clockFrequency;
            this.length = length;

            pgTask = new Task("pgTask");

            /**** Configure the output lines ****/

            // The underscore notation is the way to address more than 8 of the PatternList generator
            // lines at once. This is really buried in the NI-DAQ documentation !
            String chanString = "";
            if ((string)Environs.Hardware.GetInfo("PGType") == "dedicated")
            {
                if (fullWidth) chanString = device + "/port0_32";
                else
                {
                    if (lowGroup) chanString = device + "/port0_16";
                    else chanString = device + "/port3_16";
                }
            }
            // as far as I know you can only address the whole 32-bit port on the 6229 type integrated PatternList generators
            if ((string)Environs.Hardware.GetInfo("PGType") == "integrated")
            {
                chanString = device + "/port0";
            }

            DOChannel doChan = pgTask.DOChannels.CreateChannel(
                chanString,
                "pg",
                ChannelLineGrouping.OneChannelForAllLines
                );

            /**** Configure the clock ****/

            String clockSource = "";
            if ((string)Environs.Hardware.GetInfo("PGType") == "dedicated")
            {
                if (!internalClock) clockSource = (string)Environment.Environs.Hardware.GetInfo("PGClockLine");
                else clockSource = "";
            }

            if ((string)Environs.Hardware.GetInfo("PGType") == "integrated")
            {
                // clocking is more complicated for the 6229 style PG boards as they don't have their own internal clock.

                // if external clocking is required it's easy:
                if (!internalClock) clockSource = (string)Environment.Environs.Hardware.GetInfo("PGClockLine");
                else
                {
                    // if an internal clock is requested we generate it using the card's timer/counters.
                    counterTask = new Task();
                    counterTask.COChannels.CreatePulseChannelFrequency(
                        device + (string)Environs.Hardware.GetInfo("PGClockCounter"),
                        "PG Clock",
                        COPulseFrequencyUnits.Hertz,
                        COPulseIdleState.Low,
                        0.0,
                        clockFrequency,
                        0.5
                        );
                    counterTask.Timing.SampleQuantityMode = SampleQuantityMode.ContinuousSamples;
                    counterTask.Start();

                    clockSource = device + (string)Environs.Hardware.GetInfo("PGClockCounter") + "InternalOutput";
                }
            }

            /**** Configure regeneration ****/

            SampleQuantityMode sqm;
            if (loop)
            {
                sqm = SampleQuantityMode.ContinuousSamples;
                pgTask.Stream.WriteRegenerationMode = WriteRegenerationMode.AllowRegeneration;

            }
            else
            {
                sqm = SampleQuantityMode.FiniteSamples;
                pgTask.Stream.WriteRegenerationMode = WriteRegenerationMode.DoNotAllowRegeneration;

            }

            pgTask.Timing.ConfigureSampleClock(
                clockSource,
                clockFrequency,
                SampleClockActiveEdge.Rising,
                sqm,
                length
                );

            /**** Configure buffering ****/

            if ((string)Environs.Hardware.GetInfo("PGType") == "dedicated")
            {
                // these lines are critical - without them DAQMx copies the data you provide
                // as many times as it can into the on board FIFO (the cited reason being stability).
                // This has the annoying side effect that you have to wait for the on board buffer
//.........这里部分代码省略.........
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:101,代码来源:DAQMxPatternGenerator.cs


注:本文中的System.Threading.Task.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。