Ejemplo n.º 1
0
 /// <summary>
 /// 开启串口封装的方法
 /// </summary>
 private void OpenPort()
 {
     //从配置文件获得当前串口配置
     if (_commPort.Opened)
     {
         _commPort.Close();
     }
     _commPort.GetCommPortSet("commportSet");
     //打开串口
     try
     {
         _commPort.Open();
         if (_commPort.Opened)
         {
             Tools.FormBottomPortStatus = true;
         }
         else
         {
             Tools.FormBottomPortStatus = false;
         }
     }
     catch
     {
         _tools.PrompMessage(1);
     }
 }
Ejemplo n.º 2
0
        private void FrmTestHardware_Load(object sender, EventArgs e)
        {
            #region 中英文转换

            if (_isEnglish)
            {
                Text                      = "Hardware Checking"; //硬件检测
                LblLHP.Text               = "LHP";               //左手心
                LblLHB.Text               = "LHB";               //左手背
                LblRHP.Text               = "RHP";               //右手心
                LblRHB.Text               = "RHB";               //右手背
                LblLF.Text                = "LF";                //左脚
                LblRF.Text                = "RF";                //右脚
                LblHighVoltage.Text       = "High Voltage";      //探头高压
                Lblαcountrate.Text        = "αcount rate";       //α计数率
                LblαTotalcnt.Text         = "αTotal cnt";        //α总计数
                Lblβcountrate.Text        = "βcount rate";       //β计数率
                LblβTotalcnt.Text         = "βTotal cnt";        //β总计数
                LblStatus.Text            = "Status";            //工作状态
                LblV.Text                 = "V";
                LblAlphacps.Text          = "cps";
                LblAlphacnt.Text          = "cnt";
                LblBetacps.Text           = "cps";
                LblBetacnt.Text           = "cnt";
                GrpFrisker.Text           = "Frisker";             //衣物探头
                LblFriskercount.Text      = "Count rate";          //计数
                GrpSensorstate.Text       = "Sensor state";        //红外状态
                LblFriskerState.Text      = "Frisker";             //衣物
                LblRHandState.Text        = "RHand";               //右手
                LblLHandState.Text        = "LHand";               //左手
                GrpDetectorSelfTest.Text  = "Detector Self-Test";  //探头自检
                BtnAlphaCheck.Text        = "α";                   //α自检
                BtnBetaCheck.Text         = "β";                   //β自检
                GrpSelfTestParameter.Text = "Self-Test Parameter"; //自检参数
                BtnSelfCheck.Text         = "Run";                 //自检
                CmbControl.Text           = "L";
                CmbPulse.Text             = "L";
                LblControl.Text           = "Control";    //控制
                LblPWidth.Text            = "P Width";    //脉宽
                LblPulse.Text             = "Pulse";      //脉冲
                LblSelfcount.Text         = "Count rate"; //计数
            }

            #endregion 中英文转换

            //初始化运行状态为默认状态
            _platformState = HardwarePlatformState.Default;
            //初始化测量时间为系统参数时间
            _measuringTime = _sqltime + 1;

            #region 开启端口

            //从配置文件获得当前串口配置
            if (_commPort.Opened == true)
            {
                _commPort.Close();
            }

            _commPort.GetCommPortSet("commportSet");
            //打开串口
            try
            {
                _commPort.Open();
                if (_commPort.Opened)
                {
                    Tools.FormBottomPortStatus = true;
                }
                else
                {
                    Tools.FormBottomPortStatus = false;
                }
            }
            catch
            {
                if (_isEnglish == true)
                {
                    MessageBox.Show("Port open error! Please check whether the communication is normal.");
                    //return;
                }
                else
                {
                    MessageBox.Show("端口打开错误!请检查通讯是否正常。");
                    //return;
                }
            }

            #endregion 开启端口

            //获得通道信息
            Channel channel = new Channel();
            channelS = channel.GetChannel();
            if (bkWorkerReceiveData.IsBusy == false)
            {
                //开启异步线程
                bkWorkerReceiveData.RunWorkerAsync();
            }
        }