public void UartRecv_FiveAxis(byte[] text, int PackageLen) { bool result = false; int LastSendCmd = myApi.CurrentSendCmd; try { string strRecvData = System.Text.Encoding.Default.GetString(text); if (strRecvData.IndexOf("**") >= 0) { bool isEnable = false; if (myApi.SDDApi.FiveAxis_RecvLaser(text, out isEnable)) { if (isEnable) { buttonMoveStart.Enabled = true; buttonMoveStop.Enabled = true; myApi.SendGetAngleABXYZ(); timerUartRecv.Interval = 1000 * 5; timerUartRecv.Enabled = true; } else { buttonMoveStart.Enabled = false; buttonMoveStop.Enabled = false; timerUartRecv.Enabled = false; } return; } } 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_ABXYZ_ANGLE == LastSendCmd) { result = myApi.RecvDeviceReady(text); 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) { textBoxAxisA.Text = showAngle[0].ToString(); textBoxAxisB.Text = showAngle[1].ToString(); textBoxAxisX.Text = showAngle[2].ToString(); textBoxAxisY.Text = showAngle[3].ToString(); textBoxAxisZ.Text = showAngle[4].ToString(); buttonMoveStart.Enabled = true; buttonMoveStop.Enabled = true; } else if (DEVICE_CMD_ID.SET_ABXYZ_ANGLE == LastSendCmd) { 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() + "]"); } }
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() + "]"); } }