Ejemplo n.º 1
0
        private void AutoControlButton_Click(object sender, EventArgs e)
        {
            var history  = History.LatestHistory();
            var template = AppController.Shared.CurrentTemplate;

            if (template != null)
            {
                history = template.History;
            }
            if (history == null)
            {
                AutoClosingMessageBox.Show("尚未记录任何焊接数据,请记录几次焊接流程后再尝试自动控制。\r\n\r\n本对话框将在5秒内自动关闭", "提示", 5000);
                return;
            }
            else if (history.Signals.Count == 0)
            {
                AutoClosingMessageBox.Show("无效的焊接记录:不包含任何信号数据。请你选择一个模板,或采集一次焊接数据后再进行自动焊接。\r\n\r\n本对话框将在5秒内自动关闭", "提示", 5000);
                return;
            }
            else
            {
                var serialPort = currentSerialPort;
                if (serialPort == null)
                {
                    MessageBox.Show("请选择一个端口并打开。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                // 在显示对话框前删除事件监听器
                serialPort.DataReceived -= dataReceivedEventHandler;
                var form = new WeldingControlForm(serialPort, history);
                form.AutoControl = !manualControl; // Start auto control if event comes from signal!
                manualControl    = true;           // revert it back to manual control.
                form.ShowDialog(this);
                // 对话框完成后继续事件监听
                serialPort.DataReceived += dataReceivedEventHandler;
                //SimulateSignal(0);
            }
        }
Ejemplo n.º 2
0
 private void AutoControlButton_Click(object sender, EventArgs e)
 {
     var history = History.LatestHistory();
     var template = AppController.Shared.CurrentTemplate;
     if (template != null)
     {
         history = template.History;
     }
     if (history == null)
     {
         AutoClosingMessageBox.Show("尚未记录任何焊接数据,请记录几次焊接流程后再尝试自动控制。\r\n\r\n本对话框将在5秒内自动关闭", "提示", 5000);
         return;
     }
     else if (history.Signals.Count == 0)
     {
         AutoClosingMessageBox.Show("无效的焊接记录:不包含任何信号数据。请你选择一个模板,或采集一次焊接数据后再进行自动焊接。\r\n\r\n本对话框将在5秒内自动关闭", "提示", 5000);
         return;
     }
     else
     {
         var serialPort = currentSerialPort;
         if (serialPort == null)
         {
             MessageBox.Show("请选择一个端口并打开。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         // 在显示对话框前删除事件监听器
         serialPort.DataReceived -= dataReceivedEventHandler;
         var form = new WeldingControlForm(serialPort, history);
         form.AutoControl = !manualControl; // Start auto control if event comes from signal!
         manualControl = true; // revert it back to manual control.
         form.ShowDialog(this);
         // 对话框完成后继续事件监听
         serialPort.DataReceived += dataReceivedEventHandler;
         //SimulateSignal(0);
     }
 }