//////////////graycode////////////// public void UartInitial() { tl.LogMessage("Connected Set", "Connecting to port " + comPort); MySCP.ComPort = comPort; MySCP.UartInitial(); if (MySCP.Connected) { if (MySCP.CheckDevice()) { connectedState = true; MySCP.PC2Focuser = PC2Focuser;//将存储模式参数传给SCP if (PC2Focuser) { MySCP.Position = ReadPosition(); //将PC存储的位置赋值给SCP m_Position = MySCP.Position; //将PC存储的位置作为当前位置 MySCP.GetInitState(); //查询初始化状态,MySCP里面会自动初始化 } } else { UartUninitial(); MessageBox.Show("No device detected, please check connection!"); } } else//这里不用UartUninitial();初始化未成功会自动关闭 { MessageBox.Show("No device detected, please check connection!"); } }
public void UartInitial() { try { MySCP.ComPort = (string)comboBoxcomPort.SelectedItem; //MessageBox.Show(MySCP.ComPort); MySCP.UartInitial(); if (MySCP.Connected) { //查询版本信息 if (MySCP.CheckDevice()) { ShowLabel(true); } else { ShowLabel(false); } } else//这里不用UartUninitial();初始化未成功会自动关闭 { ShowLabel(false); } } //catch (IOException ex) catch (Exception ex) { ErrorInfo = ex.ToString(); ShowLabel(false); } }