Esempio n. 1
0
        public void UartRecv_DeviceInit(byte[] text, int PackageLen)
        {
            bool result      = false;
            int  LastSendCmd = myApi.CurrentSendCmd;

            try
            {
                string strRecvData = System.Text.Encoding.Default.GetString(text);
                if ((strRecvData.IndexOf("**") >= 0) ||
                    (myApi.SDD_ErrorState))
                {
                    UartRecv_DeviceError(text, PackageLen);

                    return;
                }
                else
                {
                }



                if (DEVICE_CMD_ID.SET_DEV_PAUSE == LastSendCmd)
                {
                    result = myApi.RecvDeviceReady(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                        myApi.CheckHostAttachStatus();
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.CHECK_HOST_ATTACH_STATUS == LastSendCmd)
                {
                    result = myApi.RecvHostAttachStatus(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                        myApi.SendGetHighVoltage();
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.GET_HIGH_VOLTAGE == LastSendCmd)
                {
                    result = myApi.RecvGetHighVoltage(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                    }
                }
                else if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP == LastSendCmd)
                {
                    result = myApi.RecvDeviceReady(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                    }
                }
                else if (DEVICE_CMD_ID.GET_DEV_ZERO_POINT == LastSendCmd)
                {
                    result = myApi.RecvGetDeviceZeroPoint(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                        myApi.FiveAxis_GetZeroPoint();
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.GET_5_AXIS_ZERO_POINT == LastSendCmd)
                {
                    result = myApi.RecvFiveAxis_GetZeroPoint(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                    }
                }
                else if (DEVICE_CMD_ID.SET_SDP == LastSendCmd)
                {
                    result = myApi.RecvDeviceReady(text);
                    if (result)
                    {
                        timerUartRecv.Enabled = false;
                    }
                }
                else
                {
                    timerUartRecv.Enabled = false;
                }

                if (result)
                {
                    if (DEVICE_CMD_ID.GET_HIGH_VOLTAGE == LastSendCmd)
                    {
                        buttonDone.Enabled = true;
                    }
                    else if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP == LastSendCmd)
                    {
                        WarmUpWait();
                    }
                    else if (DEVICE_CMD_ID.GET_5_AXIS_ZERO_POINT == LastSendCmd)
                    {
                        myApi.SendSetSdp(myApi.DetectorType + 1);
                        timerUartRecv.Interval = 1000 * 10;
                        timerUartRecv.Enabled  = true;

                        //if (ZeroPointCheck())
                        //{
                        //    if (ZeroPointModifyConfirm())
                        //    {
                        //        ZeroPointModifyProc();
                        //    }
                        //    else
                        //    {

                        //    }
                        //}
                        //else
                        //{

                        //}
                    }
                    else if (DEVICE_CMD_ID.SET_SDP == LastSendCmd)
                    {
                        if (0 == myApi.DetectorType)
                        {
                            // 如果SDD,通信间隔超过60min,等待3min
                            DetectorInitFinish();
                        }
                        else if (1 == myApi.DetectorType)
                        {
                            TCPRecv_DeviceInit();
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                    }
                }
                else
                {
                    //string strRecvData = System.Text.Encoding.Default.GetString(text);
                    //showErrorMessageBox(strRecvData);
                }
            }
            catch (Exception ex)
            {
                myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
            }
        }