/// <summary> /// 启动所有任务 /// </summary> /// <returns></returns> private API_RETURN_CODE StartAllTasks() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; try { if (m_sysConfig.GetAcqDevice() == ACQ_DEVICE.PMT) { m_aiTask.Start(); } else { for (int i = 0; i < m_ciTasks.Length; i++) { if (m_ciTasks[i] != null) { m_ciTasks[i].Start(); } } } m_doTask.Start(); m_aoTask.Start(); } catch (DaqException e) { Logger.Error(string.Format("start ni tasks exception: [{0}].", e)); code = API_RETURN_CODE.API_FAILED_NI_START_TASK_EXCEPTION; } return(code); }
private void btnLaserRelease_Click(object sender, EventArgs e) { if (LaserDevice.IsConnected()) { for (int i = 0; i < m_config.GetChannelNum(); i++) { CHAN_ID id = (CHAN_ID)Enum.ToObject(typeof(CHAN_ID), i); if (m_config.GetLaserSwitch(id) == LASER_CHAN_SWITCH.ON) { LaserDevice.CloseChannel(id); m_config.SetLaserSwitch(id, LASER_CHAN_SWITCH.OFF); } } } API_RETURN_CODE code = LaserDevice.Release(); if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("断开激光器连接失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } else { m_config.SetLaserPortName(null); } UpdateControlers(); }
/// <summary> /// 配置CI采集任务 /// </summary> /// <returns></returns> private API_RETURN_CODE ConfigCiTasks() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; int channelNum = m_config.GetChannelNum(); m_ciTasks = new Task[channelNum]; m_ciChannelReaders = new CounterSingleChannelReader[channelNum]; for (int i = 0; i < channelNum; i++) { CHAN_ID id = (CHAN_ID)i; if (m_config.GetLaserSwitch(id) == LASER_CHAN_SWITCH.ON) { code = ConfigCiTask(m_sysConfig.GetApdCiChannel(id), m_sysConfig.GetApdCiSrcPfi(id), m_sysConfig.GetApdTriggerInPfi(), ref m_ciTasks[i], ref m_ciChannelReaders[i]); if (code != API_RETURN_CODE.API_SUCCESS) { return(code); } } else { m_ciTasks[i] = null; m_ciChannelReaders[i] = null; } } return(code); }
private void ConfigLaserDevice() { string portName = cbxSelectLaser.SelectedItem.ToString(); API_RETURN_CODE code = LaserDevice.Connect(portName); if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("连接激光器端口[{0}]失败,请检查接线是否正常,端口号是否正确。", portName)); } m_config.SetLaserPortName(portName); for (int i = 0; i < m_config.GetChannelNum(); i++) { CHAN_ID id = (CHAN_ID)i; if (m_config.GetLaserSwitch(id) != LASER_CHAN_SWITCH.ON) { continue; } if (LaserDevice.OpenChannel(id) != API_RETURN_CODE.API_SUCCESS) { m_config.SetLaserSwitch(id, LASER_CHAN_SWITCH.OFF); continue; } LaserDevice.SetChannelPower(id, (float)m_config.GetLaserPower(id)); } }
private void ConfigUsbDac() { API_RETURN_CODE code = UsbDac.Connect(); if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("配置激光器增益失败,请联系厂家。")); } }
private void btnLaserRelease_Click(object sender, EventArgs e) { API_RETURN_CODE code = LaserDevice.Release(); if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("断开激光器连接失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } }
public static API_RETURN_CODE Connect() { if (m_connected) { Logger.Info(string.Format("Usb Dac already connected.")); return(API_RETURN_CODE.API_SUCCESS); } // 打开设备 if (OpenUsbV40() != API_RETURN_SUCCESS) { Logger.Info(string.Format("Usb dac connect failed: [{0}].", API_RETURN_CODE.API_FAILED_USB_DAC_OPEN_FAILED)); return(API_RETURN_CODE.API_FAILED_USB_DAC_OPEN_FAILED); } // 设置寄存器初始值 // 量程: -15V/15V 不启动零点和满量程校准 API_RETURN_CODE code = SetDacRegister(0, m_register); if (code != API_RETURN_CODE.API_SUCCESS) { return(code); } code = SetDacRegister(1, m_register); if (code != API_RETURN_CODE.API_SUCCESS) { return(code); } // 设置被使用通道的零点 & 增益[不开启,不需要设置] //for (int i = 0; i < USB_DAC_CHANNEL_NUM_USED; i++) //{ // code |= SetZeroCalibration((uint)i, m_zeroList[i]); // code |= SetGainCalibration((uint)i, m_gainList[i]); //} //if (code != API_RETURN_CODE.API_SUCCESS) //{ // return code; //} // 设置各通道电压输出值 for (int i = 0; i < USB_DAC_CHANNEL_NUM_USED; i++) { short value = 0; VoutToWriteValue((uint)i, m_voutList[i], ref value); code |= SetDacOut((uint)i, value); } if (code != API_RETURN_CODE.API_SUCCESS) { return(code); } m_connected = true; Logger.Info(string.Format("Usb dac connect success: [{0}].", API_RETURN_CODE.API_SUCCESS)); return(API_RETURN_CODE.API_SUCCESS); }
private void btnLaserConnect_Click(object sender, EventArgs e) { string portName = cbxLaser.SelectedItem.ToString(); API_RETURN_CODE code = LaserDevice.Connect(portName); if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("连接激光器失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } }
/// <summary> /// 配置Ao输出任务 /// </summary> /// <returns></returns> private API_RETURN_CODE ConfigAoTask() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; try { m_aoTask = new Task(); m_aoTask.AOChannels.CreateVoltageChannel(GetAoPhysicalChannelName(), "", -10.0, 10.0, AOVoltageUnits.Volts); m_aoTask.Control(TaskAction.Verify); m_aoTask.Timing.SampleClockRate = m_params.AoSampleRate; m_aoTask.Timing.ConfigureSampleClock("", m_aoTask.Timing.SampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, m_params.AoSampleCountPerFrame); // 路由Ao Sample Clcok到PFI0 //if (m_config.Debugging) //{ // Logger.Info(string.Format("route ao sample clock to PFI0.")); // m_aoTask.ExportSignals.SampleClockOutputTerminal = string.Concat("/", NI_CARD_NAME_DEFAULT, "/", "PFI0"); //} //string source = m_sysConfig.GetStartSyncSignal(); //m_aoTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(source, DigitalEdgeStartTriggerEdge.Rising); // 写入波形 AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(m_aoTask.Stream); AnalogWaveform <double>[] waves; if (m_config.GetScanMirrorNum() == SCAN_MIRROR_NUM.THREEE) { waves = new AnalogWaveform <double> [3]; waves[2] = AnalogWaveform <double> .FromArray1D(m_waver.Y2Wave); } else { waves = new AnalogWaveform <double> [2]; } waves[0] = AnalogWaveform <double> .FromArray1D(m_waver.XWave); waves[1] = AnalogWaveform <double> .FromArray1D(m_waver.Y1Wave); writer.WriteWaveform(false, waves); } catch (Exception e) { Logger.Error(string.Format("config ao task exception: [{0}].", e)); code = API_RETURN_CODE.API_FAILED_NI_CONFIG_AO_TASK_EXCEPTION; } return(code); }
/// <summary> /// 配置Ai采集任务 /// </summary> /// <returns></returns> private API_RETURN_CODE ConfigAiTask() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; try { m_aiTask = new Task(); m_aiTask.AIChannels.CreateVoltageChannel(GetAiPhysicalChannelName(), "", AITerminalConfiguration.Differential, -5.0, 5.0, AIVoltageUnits.Volts); m_aiTask.Control(TaskAction.Verify); m_aiTask.Timing.SampleClockRate = m_params.AiSampleRate; m_aiTask.Timing.ConfigureSampleClock("", m_aiTask.Timing.SampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, m_params.ScanPixelsPerAcquisition); // 设置Ai Start Trigger源为PFIx,PFIx与Acq Trigger[一般是Do]物理直连,接收Do的输出信号,作为触发 string source = m_sysConfig.GetPmtTriggerInPfi(); m_aiTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(source, DigitalEdgeStartTriggerEdge.Rising); m_aiTask.Triggers.StartTrigger.Retriggerable = true; // 设置为允许重触发 // m_aiTask.AIChannels.All.DataTransferMechanism = AIDataTransferMechanism.Dma; // 路由AI Sample Clcok到PFI2, AI Convert Clock到PFI3 //if (m_config.Debugging) //{ // Logger.Info(string.Format("route ai sample clock to FFI2, ai convert clock to PFI3.")); // m_aiTask.ExportSignals.SampleClockOutputTerminal = string.Concat("/" + NI_CARD_NAME_DEFAULT + "/PFI2"); ; // m_aiTask.ExportSignals.AIConvertClockOutputTerminal = string.Concat("/" + NI_CARD_NAME_DEFAULT + "/PFI3"); ; //} m_aiTask.EveryNSamplesReadEventInterval = m_params.ScanPixelsPerAcquisition; m_aiTask.EveryNSamplesRead += new EveryNSamplesReadEventHandler(AiEveryNSamplesRead); m_aiUnscaledReader = new AnalogUnscaledReader(m_aiTask.Stream); m_aiUnscaledReader.SynchronizeCallbacks = false; } catch (Exception e) { Logger.Error(string.Format("config ai task exception: [{0}].", e)); code = API_RETURN_CODE.API_FAILED_NI_CONFIG_AI_TASK_EXCEPTION; } return(code); }
private API_RETURN_CODE ConfigCiTask(string ciChannel, string ciSrc, string ciClock, ref Task ciTask, ref CounterSingleChannelReader ciMultiChannelReader) { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; try { ciTask = new Task(); ciTask.CIChannels.CreateCountEdgesChannel(ciChannel, "", CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up); ciTask.Control(TaskAction.Verify); ciTask.Timing.SampleClockRate = m_params.CtrSampleRate; ciTask.Timing.ConfigureSampleClock(ciClock, ciTask.Timing.SampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, m_params.ValidScanPixelsPerFrame); ciTask.Stream.ConfigureInputBuffer(m_params.ValidScanPixelsPerFrame); // CIDataTransferMechanism x = ciTask.CIChannels.All.DataTransferMechanism; // 指定CI Channel使用的物理输入终端[APD的脉冲接收端] ciTask.CIChannels[0].CountEdgesTerminal = ciSrc; // 设置Ci Pause Trigger源为PFIx,PFIx与Acq Trigger[一般是Do]物理直连,接收Do的输出信号,作为触发 // 低电平使能Pause Trigger,高电平禁能 // ciTask.Triggers.PauseTrigger.ConfigureDigitalLevelTrigger(ciGate, DigitalLevelPauseTriggerCondition.Low); // 设置Arm Start Trigger,使CI与AO、DO同时启动工作 string source = m_sysConfig.GetStartSyncSignal(); ciTask.Triggers.ArmStartTrigger.ConfigureDigitalEdgeTrigger(source, DigitalEdgeArmStartTriggerEdge.Rising); ciTask.EveryNSamplesReadEventInterval = m_params.ScanPixelsPerAcquisition; ciTask.EveryNSamplesRead += new EveryNSamplesReadEventHandler(CiEveryNSamplesRead); ciMultiChannelReader = new CounterSingleChannelReader(ciTask.Stream); ciMultiChannelReader.SynchronizeCallbacks = false; } catch (Exception e) { Logger.Error(string.Format("config ci task[{0}] exception: [{1}].", ciChannel, e)); code = API_RETURN_CODE.API_FAILED_NI_CONFIG_CI_TASK_EXCEPTION; } return(code); }
public API_RETURN_CODE ReleaseScanTask(ScanTask scanTask) { API_RETURN_CODE code = StopScanTask(scanTask); if (code != API_RETURN_CODE.API_SUCCESS) { return(code); } m_scanTasks.Remove(scanTask); if (ScanTaskReleased != null) { ScanTaskReleased.Invoke(scanTask, null); } return(API_RETURN_CODE.API_SUCCESS); }
/// <summary> /// 配置Do输出任务 /// </summary> /// <returns></returns> private API_RETURN_CODE ConfigDoTask() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; try { m_doTask = new Task(); m_doTask.DOChannels.CreateChannel(GetDoPhysicalChannelName(), "", ChannelLineGrouping.OneChannelForEachLine); m_doTask.Control(TaskAction.Verify); m_doTask.Timing.SampleClockRate = m_params.DoSampleRate; m_doTask.Timing.ConfigureSampleClock("", m_doTask.Timing.SampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, m_params.AoSampleCountPerFrame); // 设置Do Start Trigger源为Ao Start Trigger[默认],实现启动同步 string source = m_sysConfig.GetStartSyncSignal(); m_doTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(source, DigitalEdgeStartTriggerEdge.Rising); // 路由Do Sample Clcok到PFI1 //if (m_config.Debugging) //{ // Logger.Info(string.Format("route do sample clock to PFI1.")); // m_doTask.ExportSignals.SampleClockOutputTerminal = string.Concat("/" + NI_CARD_NAME_DEFAULT + "/PFI1"); //} m_doTask.Stream.WriteRegenerationMode = WriteRegenerationMode.AllowRegeneration; DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(m_doTask.Stream); DigitalWaveform wave = DigitalWaveform.FromPort(m_params.DigitalTriggerSamplesPerLine, 0x01); writer.WriteWaveform(false, wave); } catch (Exception e) { Logger.Error(string.Format("config do task exception: [{0}].", e)); code = API_RETURN_CODE.API_FAILED_NI_CONFIG_DO_TASK_EXCEPTION; } return(code); }
/// <summary> /// 启动任务 /// </summary> /// <returns></returns> public API_RETURN_CODE Start() { API_RETURN_CODE code = API_RETURN_CODE.API_SUCCESS; code = ConfigAoTask(); if (code != API_RETURN_CODE.API_SUCCESS) { Stop(); return(code); } code = ConfigDoTask(); if (code != API_RETURN_CODE.API_SUCCESS) { Stop(); return(code); } if (m_sysConfig.GetAcqDevice() == ACQ_DEVICE.PMT) { code = ConfigAiTask(); } else { code = ConfigCiTasks(); } if (code != API_RETURN_CODE.API_SUCCESS) { Stop(); return(code); } code = StartAllTasks(); if (code != API_RETURN_CODE.API_SUCCESS) { Stop(); return(code); } return(code); }
private void cbxScanPixels_SelectedIndexChanged(object sender, EventArgs e) { int scanPixels = ((KeyValuePair <int, string>)cbxScanPixels.SelectedItem).Key; if (m_config.GetScanXPoints() == scanPixels && m_config.GetScanYPoints() == scanPixels) { return; } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; // if task is not running, just update config if (m_scheduler.TaskScanning() == false) { m_config.SetScanXPoints(scanPixels); m_config.SetScanYPoints(scanPixels); m_scheduler.ConfigScanTask(m_scheduler.GetScanningTask()); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; return; } // if task is already running, stop first m_scheduler.StopScanTask(m_scheduler.GetScanningTask()); // update config m_config.SetScanXPoints(scanPixels); m_config.SetScanYPoints(scanPixels); // create & start task m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } }
private void btnScan_Click(object sender, EventArgs e) { //if (!LaserDevice.IsConnected()) //{ // MessageBox.Show("激光器未连接,请先连接激光器."); // return; //} if (m_scheduler.TaskScanning() == false) { if (m_config.GetActivatedChannelNum() == 0) { MessageBox.Show("激光未打开,请至少打开一路激光通道."); return; } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } } else { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; ScanTask scanTask = m_scheduler.GetScanningTask(); API_RETURN_CODE code = m_scheduler.StopScanTask(scanTask); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("停止扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } } }
public API_RETURN_CODE StartScanTask(ScanTask scanTask) { if (scanTask == null) { return(API_RETURN_CODE.API_FAILED_SCAN_TASK_INVALID); } if (FindScanTask(scanTask.TaskId) == null) { return(API_RETURN_CODE.API_FAILED_SCAN_TASK_NOT_FOUND); } m_params.Calculate(); // 计算参数 m_params.GenerateColorMapping(); // m_params.GenerateAiChannelIndex(); // 计算使用PMT的情况下各个AI通道采集数据对应的Index m_waver.Generate(); // 计算AO输出波形和触发信号 scanTask.Config(); // 配置扫描任务 API_RETURN_CODE code = m_card.Start(); // 启动板卡 if (code != API_RETURN_CODE.API_SUCCESS) { Logger.Info(string.Format("start scan task[{0}|{1}] failed: [{2}].", scanTask.TaskId, scanTask.TaskName, code)); StopScanTask(scanTask); return(code); } scanTask.Start(); // 启动扫描任务 m_scanningTask = scanTask; if (ScanTaskStarted != null) { ScanTaskStarted.Invoke(scanTask, null); } Logger.Info(string.Format("start scan task[{0}|{1}] success.", scanTask.TaskId, scanTask.TaskName)); return(code); }
private void cbxDwellTime_SelectedIndexChanged(object sender, EventArgs e) { double dwellTime = double.Parse(cbxDwellTime.SelectedItem.ToString()); if (m_config.GetScanDwellTime() == dwellTime) { return; } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; // if task is not running, just update config if (m_scheduler.TaskScanning() == false) { m_config.SetScanDwellTime(dwellTime); m_scheduler.ConfigScanTask(m_scheduler.GetScanningTask()); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; return; } // if task is already running, stop first m_scheduler.StopScanTask(m_scheduler.GetScanningTask()); // update config m_config.SetScanDwellTime(dwellTime); // create & start task m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } }
private void rbtnTwo_CheckedChanged(object sender, EventArgs e) { SCAN_MIRROR_NUM mirrorNum = rbtnTwo.Checked ? SCAN_MIRROR_NUM.TWO : SCAN_MIRROR_NUM.THREEE; if (m_config.GetScanMirrorNum() == mirrorNum) { return; } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; // if task is not running, just update config if (m_scheduler.TaskScanning() == false) { m_config.SetScanMirrorNum(mirrorNum); m_scheduler.ConfigScanTask(m_scheduler.GetScanningTask()); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; return; } // if task is already running, stop first m_scheduler.StopScanTask(m_scheduler.GetScanningTask()); // update config m_config.SetScanMirrorNum(mirrorNum); // create & start task m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); // UpdateControlers(); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } }
private void UpdateLaserSwitch(CheckBox chbx, CHAN_ID id) { LASER_CHAN_SWITCH status = chbx.Checked ? LASER_CHAN_SWITCH.ON : LASER_CHAN_SWITCH.OFF; this.Cursor = System.Windows.Forms.Cursors.WaitCursor; // if task is not running, just update config if (m_scheduler.TaskScanning() == false) { chbx.Checked = !chbx.Checked; status = chbx.Checked ? LASER_CHAN_SWITCH.ON : LASER_CHAN_SWITCH.OFF; m_config.SetLaserSwitch(id, status); if (LaserDevice.IsConnected()) { if (status == LASER_CHAN_SWITCH.ON) { LaserDevice.OpenChannel(id); LaserDevice.SetChannelPower(id, m_config.GetLaserPower(id)); } else { LaserDevice.CloseChannel(id); } } this.Cursor = System.Windows.Forms.Cursors.Default; return; } // task is already running if (status == LASER_CHAN_SWITCH.OFF) // 激光当前是OFF状态 { m_scheduler.StopScanTask(m_scheduler.GetScanningTask()); // 先停止扫描 chbx.Checked = true; // 再更新配置,并打开激光,设置激光功率 m_config.SetLaserSwitch(id, LASER_CHAN_SWITCH.ON); if (LaserDevice.IsConnected()) { LaserDevice.OpenChannel(id); LaserDevice.SetChannelPower(id, m_config.GetLaserPower(id)); } m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); // 创建Task,并启动 API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } } else { // 激光当前是ON状态 if (m_config.GetActivatedChannelNum() == 1) // 该路激光是扫描状态下唯一开启的激光 { this.Cursor = System.Windows.Forms.Cursors.Default; return; // 作为扫描状态下唯一开启的激光,不允许关闭,直接返回 } else { m_scheduler.StopScanTask(m_scheduler.GetScanningTask()); // 先停止扫描 chbx.Checked = false; // 再更新配置,并关闭激光 m_config.SetLaserSwitch(id, LASER_CHAN_SWITCH.OFF); if (LaserDevice.IsConnected()) { LaserDevice.CloseChannel(id); } m_scheduler.CreateScanTask(0, "实时扫描", out ScanTask scanTask); // 创建Task,并启动 API_RETURN_CODE code = m_scheduler.StartScanTask(scanTask); this.Cursor = System.Windows.Forms.Cursors.Default; if (code != API_RETURN_CODE.API_SUCCESS) { MessageBox.Show(string.Format("启动扫描任务失败,失败码: [0x{0}][{1}].", ((int)code).ToString("X"), code)); } } } }