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

            try
            {
                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 (result)
                {
                    if (LastSendCmd == DEVICE_CMD_ID.GET_HIGH_VOLTAGE)
                    {
                        showVoltage = myApi.recvVoltage;
                        showCurrent = myApi.recvCurrent;

                        textBoxHighVoltage.Text = showVoltage.ToString();
                        textBoxCurrent.Text     = showCurrent.ToString();
                        buttonCancel.Enabled    = true;
                        buttonOK.Enabled        = true;
                        myParentForm.statusBar_HighVoltageUpdate(myApi.sendVoltage, myApi.sendCurrent);
                    }
                    else if (LastSendCmd == DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP)
                    {
                        if ((sendVoltage > 0) || (sendCurrent > 0))
                        {
                            myConfig.SaveWarmUpTime();
                        }

                        MessageBox.Show("开启高压成功");
                        myParentForm.statusBar_HighVoltageUpdate(myApi.sendVoltage, myApi.sendCurrent);

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (LastSendCmd == DEVICE_CMD_ID.SET_HIGH_VOLTAGE_DOWN)
                    {
                        if ((sendVoltage > 0) || (sendCurrent > 0))
                        {
                            myConfig.SaveWarmUpTime();
                        }

                        myParentForm.statusBar_HighVoltageUpdate(myApi.sendVoltage, myApi.sendCurrent);

                        MessageBox.Show("关闭高压成功");

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
            }
        }
Esempio n. 2
0
        public void UartRecv_Texture(byte[] text, int PackageLen)
        {
            bool result      = false;
            int  LastSendCmd = myApi.CurrentSendCmd;

            try
            {
                if (DEVICE_CMD_ID.SET_DEV_PAUSE == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;
                        if (!MeasureStopFlag)
                        {
                            myApi.SendStartMeaurePostion(PeakDegree[GroupIndex_Psi]);
                            timerUartRecv.Interval = 1000 * 30;
                            timerUartRecv.Enabled  = true;
                        }
                        else
                        {
                            myApi.SendCloseShutter();
                        }
                    }
                }
                else if (DEVICE_CMD_ID.SET_START_MEA_POS == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;

                        myApi.SendHighVoltageUp(TubeVoltage[GroupIndex_Psi], TubeCurrent[GroupIndex_Psi]);
                        timerUartRecv.Interval = 1000 * 40;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;

                        Thread.Sleep(5000);
                        myApi.SendGetHighVoltage();
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.GET_HIGH_VOLTAGE == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        result = myApi.RecvGetHighVoltage(text);
                        timerUartRecv.Enabled = false;

                        if (result)
                        {
                            myApi.SendMeasureTime(MeasureTime[GroupIndex_Psi]);
                            timerUartRecv.Interval = 1000 * 5;
                            timerUartRecv.Enabled  = true;
                        }
                    }
                }
                else if (DEVICE_CMD_ID.SET_MES_TIME == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;
                        myApi.SendSpeedB(PhiSpeed[GroupIndex_Psi]);
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.SET_B_SPEED == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;
                        if (0 == GroupIndex_Psi)
                        {
                            myApi.SendOpenShutter();
                            timerUartRecv.Interval = 1000 * 5;
                            timerUartRecv.Enabled  = true;
                        }
                        else
                        {
                            myApi.SendAngleA(myApi.AnglePsi[MeasureIndex_Psi]);
                            timerUartRecv.Interval = 1000 * 30;
                            timerUartRecv.Enabled  = true;
                        }
                    }
                }
                else if (DEVICE_CMD_ID.OPEN_LIGHT_SHUTTER == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;

                        myApi.SendAngleA(myApi.AnglePsi[MeasureIndex_Psi]);
                        timerUartRecv.Interval = 1000 * 30;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.SET_A_ANGLE == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;

                        myApi.SendAngleB(0);
                        timerUartRecv.Interval = 1000 * 30;
                        timerUartRecv.Enabled  = true;
                    }
                }
                else if (DEVICE_CMD_ID.SET_B_ANGLE == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;

                        myApi.SendStartCycleScan(360);
                        timerUartRecv.Interval = 1000 * 5;
                        timerUartRecv.Enabled  = true;

                        myApi.RecvDataCount = 0;
                        myApi.RecvDataTable.Rows.Clear();
                        ChartRealTimeShowIndex = 0;
                        myApi.TotalDataCount   = (int)(360 / (PhiSpeed[GroupIndex_Psi] * MeasureTime[GroupIndex_Psi]));
                        myUart.Pack_Debug_out(null, "[Texture] totalcount=" + myApi.TotalDataCount.ToString());
                        myApi.SSC_RecvDataReadIndex  = 0;
                        myApi.SSC_RecvDataWriteIndex = 0;
                        myApi.SSC_AnalyzeDataCount   = 0;

                        //myApi.RecvDataTableSaveFileStart(myApi.AnglePsi[MeasureIndex_Psi], MeasureIndex_Psi);
                        //myApi.Texture_SaveFileStart(FaceExp[GroupIndex_Psi], GroupIndex_Psi, BM[GroupIndex_Psi]);

                        ChartRealTimeInit();
                    }
                }
                else if (DEVICE_CMD_ID.START_SCAN == LastSendCmd)
                {
                    // save data
                    timerUartRecv.Enabled = false;
                    myApi.CSB_RecvDataAnalyze(text);
                    myApi.RecvDataTableUpdate(myApi.SSC_AnalyzeDataArray, myApi.SSC_AnalyzeDataCount);

                    //myApi.RecvDataTableSaveFileProc(myApi.SSC_AnalyzeDataArray, myApi.SSC_AnalyzeDataCount);

                    myApi.RecvDataCount += (myApi.SSC_AnalyzeDataCount / 21);
                    myUart.Pack_Debug_out(null, "[Texture] analyzecount=" + (myApi.SSC_AnalyzeDataCount / 21).ToString() + "totalrecvcount=" + myApi.RecvDataCount.ToString());

                    myApi.SSC_AnalyzeDataCount = 0;
                    Array.Clear(myApi.SSC_AnalyzeDataArray, 0, myApi.SSC_AnalyzeDataArray.Length);

                    if (myApi.RecvDataCount >= myApi.TotalDataCount)
                    {
                        Array.Clear(myApi.SSC_RecvDataArray, 0, myApi.SSC_RecvDataArray.Length);
                        myApi.SSC_RecvDataReadIndex  = 0;
                        myApi.SSC_RecvDataWriteIndex = 0;

                        //myApi.RecvDataTableSaveFileEnd();
                        //myApi.Texture_SaveFileEnd();
                        RecvDataFinishFlag = true;
                    }
                }
                else if (DEVICE_CMD_ID.CLOSE_LIGHT_SHUTTER == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;
                        myApi.SendHighVoltageDown(myApi.DefaultVotage, myApi.DefaultCurrent);
                        timerUartRecv.Interval = 1000 * 10;
                        timerUartRecv.Enabled  = true;

                        timerHighVoltage_10min.Enabled = true;
                    }
                }
                else if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_DOWN == LastSendCmd)
                {
                    if (myApi.RecvDeviceReady(text))
                    {
                        timerUartRecv.Enabled = false;
                        // measure end
                        MeasureStopFlag = true;
                    }
                }
                else
                {
                }



                if (DEVICE_CMD_ID.GET_HIGH_VOLTAGE == LastSendCmd)
                {
                    myParentForm.statusBar_HighVoltageUpdate(myApi.recvVoltage, myApi.recvCurrent);

                    ChartRealTimeShowIndex = 0;
                    //chartRealTime.Series["射线强度"].Points.Clear();

                    double xMin = 0;
                    double xMax = 360;

                    chartRealTime.ChartAreas["ChartArea1"].AxisX.Maximum = xMax;
                    chartRealTime.ChartAreas["ChartArea1"].AxisX.Minimum = xMin;

                    if (MeasureIndex_Psi == 0)
                    {
                        dataGridViewClear();
                    }
                }
                else if ((DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP == LastSendCmd) ||
                         (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_DOWN == LastSendCmd))
                {
                    if ((myApi.TubeVoltage > 0) || (myApi.TubeCurrent > 0))
                    {
                        myConfig.SaveWarmUpTime();
                    }
                    else
                    {
                    }
                    if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_UP == LastSendCmd)
                    {
                        timerHighVoltage_10min.Enabled = false;
                    }
                    else if (DEVICE_CMD_ID.SET_HIGH_VOLTAGE_DOWN == LastSendCmd)
                    {
                        if (MeasureStopFlag)
                        {
                            MeasureStopFlag          = false;
                            buttonStart.Enabled      = true;
                            buttonStop.Enabled       = false;
                            groupBoxSettings.Enabled = true;
                            myParentForm.tableLayoutPanel1.Enabled = true;
                            myParentForm.tableLayoutPanel2.Enabled = true;

                            //MessageBox.Show("测量结束");
                            myParentForm.toolStripStatusLabelMeasureStatus.Text = "测量结束";
                        }
                    }

                    myParentForm.statusBar_HighVoltageUpdate(myApi.sendVoltage, myApi.sendCurrent);
                }
                else if ((DEVICE_CMD_ID.START_SCAN == LastSendCmd) && (myApi.RecvDataCount > 0) && (0 == myApi.DetectorType))
                {
                    ChartRealTimeUpdate();
                }
                else
                {
                }
                // 接收数据完成
                if (RecvDataFinishFlag)
                {
                    RecvDataFinishFlag = false;

                    PhiMeasureFinish();
                }
            }
            catch (Exception ex)
            {
                myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
            }
        }
Esempio n. 3
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() + "]");
            }
        }