public void UartRecv_AutoFocus(byte[] text, int PackageLen) { bool result = false; int LastSendCmd = myApi.CurrentSendCmd; try { if (DEVICE_CMD_ID.MOVE_TD == LastSendCmd) { result = myApi.RecvDeviceReady(text); if (result) { timerUartRecv.Enabled = false; myApi.SendMovMotorTS(myApi.AutoFocus[1]); timerUartRecv.Interval = 1000 * 30; timerUartRecv.Enabled = true; } } else if (DEVICE_CMD_ID.MOVE_TS == LastSendCmd) { result = myApi.RecvDeviceReady(text); if (result) { timerUartRecv.Enabled = false; myApi.SendAngleA(myApi.AutoFocus[2]); timerUartRecv.Interval = 1000 * 30; timerUartRecv.Enabled = true; } } else if (DEVICE_CMD_ID.SET_A_ANGLE == LastSendCmd) { result = myApi.RecvDeviceReady(text); if (result) { timerUartRecv.Enabled = false; myApi.SendAngleZ(myApi.AutoFocus[3]); timerUartRecv.Interval = 1000 * 30; timerUartRecv.Enabled = true; } } else if (DEVICE_CMD_ID.SET_Z_ANGLE == LastSendCmd) { result = myApi.RecvDeviceReady(text); if (result) { timerUartRecv.Enabled = false; myApi.SendGetAngleABXYZ(); timerUartRecv.Interval = 1000 * 5; timerUartRecv.Enabled = true; } } else if (DEVICE_CMD_ID.GET_ABXYZ_ANGLE == LastSendCmd) { result = myApi.RecvGetAngleABXYZ(text, ref showAngle); if (result) { timerUartRecv.Enabled = false; } } else if (DEVICE_CMD_ID.SET_DEV_PAUSE == LastSendCmd) { result = myApi.RecvDeviceReady(text); if (result) { timerUartRecv.Enabled = false; } } else { } if (result) { if (DEVICE_CMD_ID.GET_ABXYZ_ANGLE == LastSendCmd) { if (load_flag) { load_flag = false; textBoxAxisZ.Text = showAngle[4].ToString(); buttonOK.Enabled = true; buttonCancel.Enabled = true; } else { MessageBox.Show("自动对焦成功"); this.DialogResult = DialogResult.OK; this.Close(); } } else if (DEVICE_CMD_ID.SET_DEV_PAUSE == LastSendCmd) { MessageBox.Show("已停止对焦"); this.DialogResult = DialogResult.Cancel; this.Close(); } else { } } else { } } catch (Exception ex) { myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]"); } }