Exemple #1
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() + "]");
            }
        }
Exemple #2
0
        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() + "]");
            }
        }