Beispiel #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() + "]");
            }
        }
Beispiel #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                sendVoltage = Convert.ToDouble(textBoxHighVoltage.Text);
                sendCurrent = Convert.ToDouble(textBoxCurrent.Text);

                myUart.Pack_Debug_out(null, "[HighVoltage] voltage open,v=" + sendVoltage.ToString() + "c=" + sendCurrent.ToString());

                bool checkResult = FormChildMeasure.checkHighVoltageRange(myApi.TargetType, sendVoltage, sendCurrent);
                if (checkResult)
                {
                    myApi.SendHighVoltageUp(sendVoltage, sendCurrent);
                    timerUartRecv.Interval = 1000 * 40;
                    timerUartRecv.Enabled  = true;
                }

                //string pattern = @"^[0-9]*$";
                //Match m1 = Regex.Match(textBoxHighVoltage.Text, pattern);   // 匹配正则表达式
                //Match m2 = Regex.Match(textBoxCurrent.Text, pattern);
                //if ((!m1.Success) || (!m2.Success))
                //{
                //    FormDeviceInit.showErrorMessageBox("只能输入整数");

                //    return;
                //}

                //int voltageMin = 10;
                //int voltageMax = 25;
                //int currentMin = 5;
                //int currentMax = 40;

                //if (myParent.myConfig.TargetType == 0)
                //{
                //    voltageMin = 10;
                //    voltageMax = 25;
                //    currentMin = 5;
                //    currentMax = 40;
                //}
                //else if (myParent.myConfig.TargetType == 1)
                //{
                //    voltageMin = 10;
                //    voltageMax = 40;
                //    currentMin = 5;
                //    currentMax = 40;
                //}
                //else
                //{

                //}

                //int voltage = Convert.ToInt32(textBoxHighVoltage.Text);
                //int current = Convert.ToInt32(textBoxCurrent.Text);
                //if ((voltage >= voltageMin) && (voltage <= voltageMax)
                //    && (current >= currentMin) && (current <= currentMax))
                //{
                //    myParent.ShortcutHighVoltage_SetValue[0] = voltage;
                //    myParent.ShortcutHighVoltage_SetValue[1] = current;

                //    this.DialogResult = DialogResult.OK;
                //    this.Close();
                //}
                //else
                //{
                //    string str = "输入范围错误!电压:";
                //    str += voltageMin.ToString();
                //    str += "~";
                //    str += voltageMax.ToString();
                //    str += "  电流:";
                //    str += currentMin.ToString();
                //    str += "~";
                //    str += currentMax.ToString();

                //    FormDeviceInit.showErrorMessageBox(str);
                //}
            }
            catch (Exception ex)
            {
                myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
            }
        }