Exemple #1
0
        /// <summary>
        /// 血压计
        /// </summary>
        public void ThreadExectueBP()
        {
            string str = "";

Label_0000:

            this.m_communicationBP = null;
            str = GetClsCommunicationBP(ConfigurationManager.AppSettings["CHITBP"], 9600, ConfigurationManager.AppSettings["TFDeviceName"]);

            if (str == "")
            {
                this.m_DeviceBP = null;
                Thread.Sleep(200);
                goto Label_0000;
            }

            try
            {
                //this.m_communicationBM = new ClsCommunicationCom(this.GetOs(), com, baudRate);

                if (this.m_communicationBP != null)
                {
                    this.m_communicationBP.DataExchange += new TransMessageHandle(this.m_communication_DataExchange);
                }

                this.m_DeviceBP = ClsDeviceFactory.CreateDevice(this.m_communicationBP, str, sex, age, height, m_BFHour, m_BFMinu);

                if (this.m_DeviceBP != null)
                {
                    if (ReadMode)
                    {
                        ClsResult.ResultFlag = false;
                        Thread.Sleep(1000);
                        this.SendMsg("CONNECT" + str);

                        this.m_communicationBP.StartDeviceListen();

                        if (this.m_DeviceBP.ExecQuery())
                        {
                            if (ClsResult.ResultFlag == true)
                            {
                                this.m_DeviceBP.ExecClose();

                                this.m_communicationBP.WriteDataLog();
                                this.SendMsg("TRANSEND");
                                Thread.Sleep(500);
                            }
                        }
                        else
                        {
                            this.m_communicationBP.WriteDataLog();
                            this.SendMsg("ERROR");
                        }
                    }
                    else
                    {
                        this.m_DeviceBP.ExecClose();
                    }
                }
                else
                {
                    this.SendMsg("UNKNOWN" + str);
                }

                if (this.m_DeviceBP != null)
                {
                    if (ClsResult.ResultFlag == true)
                    {
                        Thread.Sleep(this.m_DeviceBP.m_delay);
                    }
                }
                else
                {
                    Thread.Sleep(3000);
                }

                this.m_communicationBP.Disconnect();
                this.m_communicationBP.StopHardListen();

                if (ClsResult.ResultFlag == true)
                {
                    Thread.Sleep(1000);
                }

                goto Label_0000;
            }
            catch (Exception ex)
            {
                goto Label_0000;
            }
        }
        /// <summary>
        /// 电子称-新
        /// </summary>
        public void ThreadExectueBM_N()
        {
            string str = "";

Label_0000:

            this.m_communicationBM_N = null;

            str = GetClsCommunicationBM_N(ConfigurationManager.AppSettings["CHITBM"], 115200, "CHITBM_N");
            bool getResult = false;

            if (str == "")
            {
                WritelogInfo("1.str=''");
                this.m_DeviceBM_N = null;

                System.Windows.Forms.Application.DoEvents();
                Thread.Sleep(200);
                goto Label_0000;
            }

            try
            {
                if (this.m_communicationBM_N != null)
                {
                    this.m_communicationBM_N.DataExchange += new TransMessageHandle(this.m_communication_DataExchange);
                }

                if (this.m_DeviceBM_N == null)
                {
                    this.m_DeviceBM_N = ClsDeviceFactory.CreateDevice(this.m_communicationBM_N, str, sex, age, height, m_BFHour, m_BFMinu);
                }

                if (this.m_DeviceBM_N != null)
                {
                    if (ReadMode)
                    {
                        ClsResult.ResultFlag = false;
                        //this.SendMsg("CONNECT" + str);

                        this.m_communicationBM_N.StartDeviceListen();

                        if (this.m_DeviceBM_N.ExecQuery())
                        {
                            if (ClsResult.ResultFlag == true)
                            {
                                WritelogInfo("2.ResultFlag == true");
                                getResult = true;

                                this.m_communicationBM_N.WriteDataLog();
                                this.SendMsg("TRANSEND");
                                WritelogInfo("TRANSEND:" + ClsResult.DeviceValue.QCTBM.TiZhong);
                                //Thread.Sleep(500);
                                System.Windows.Forms.Application.DoEvents();
                            }
                        }
                        else
                        {
                            WritelogInfo("3.m_DeviceBM_N.ExecQuery()=false");
                            this.m_communicationBM_N.WriteDataLog();
                            this.SendMsg("ERROR");

                            //Thread.Sleep(500);
                            System.Windows.Forms.Application.DoEvents();

                            this.m_DeviceBM_N.ExecClose();
                        }
                    }

                    if (ClsResult.ResultFlag == true)
                    {
                        WritelogInfo("4.this.m_DeviceBM_N.m_delay");
                        Thread.Sleep(this.m_DeviceBM_N.m_delay);
                    }
                }
                else
                {
                    Thread.Sleep(200);

                    WritelogInfo("5.this.m_DeviceBM_N =null");
                }

                this.m_communicationBM_N.Disconnect();
                this.m_communicationBM_N.StopHardListen();
                System.Windows.Forms.Application.DoEvents();

                goto Label_0000;
            }
            catch (Exception ex)
            {
                WritelogInfo("99." + ex.Message + ex.StackTrace);
                goto Label_0000;
            }
        }
Exemple #3
0
        /// <summary>
        /// 欧姆龙血压计
        /// </summary>
        public void ThreadExectueHEM()
        {
            string str;

Label_0000:
            str = this.m_communicationHEM.GetDeviceName();

            if (str == "")
            {
                this.m_DeviceHEM = null;
                Thread.Sleep(200);
                goto Label_0000;
            }

            try
            {
                this.m_DeviceHEM = ClsDeviceFactory.CreateDevice(this.m_communicationHEM, str, sex, age, height, m_BFHour, m_BFMinu);

                if (this.m_DeviceHEM != null)
                {
                    if (ReadMode)
                    {
                        ClsResult.ResultFlag = false;
                        Thread.Sleep(0x3e8);
                        this.SendMsg("CONNECT" + str);
                        if (this.m_DeviceHEM.ExecQuery())
                        {
                            if (!str.StartsWith("BF") || (ClsResult.DeviceMsg != "参数设置已经完成,请进行测量."))
                            {
                                this.m_DeviceHEM.ExecClose();
                            }
                            this.m_communicationHEM.WriteDataLog();
                            this.SendMsg("TRANSEND");
                            Thread.Sleep(500);
                        }
                        else
                        {
                            this.m_communicationHEM.WriteDataLog();
                            this.SendMsg("ERROR");
                        }
                    }
                    else
                    {
                        this.m_DeviceHEM.ExecClose();
                    }
                }
                else
                {
                    this.SendMsg("UNKNOWN" + str);
                }
                if (this.m_DeviceHEM != null)
                {
                    Thread.Sleep(this.m_DeviceHEM.m_delay);
                }
                else
                {
                    Thread.Sleep(0xbb8);
                }
                this.m_communicationHEM.Disconnect();
                Thread.Sleep(0x3e8);
                goto Label_0000;
            }
            catch (Exception)
            {
                goto Label_0000;
            }
        }
        /// <summary>
        /// 电子称
        /// </summary>
        public void ThreadExectueBM()
        {
            string str = "";

Label_0000:

            this.m_communicationBM = null;
            str = GetClsCommunicationBM(ConfigurationManager.AppSettings["CHITBM"], 4800, ConfigurationManager.AppSettings["TFDeviceName"]);
            bool getResult = false;

            if (str == "")
            {
                this.m_DeviceBM = null;
                Thread.Sleep(200);
                goto Label_0000;
            }

            try
            {
                //this.m_communicationBM = new ClsCommunicationCom(this.GetOs(), com, baudRate);

                if (this.m_communicationBM != null)
                {
                    this.m_communicationBM.DataExchange += new TransMessageHandle(this.m_communication_DataExchange);
                }

                this.m_DeviceBM = ClsDeviceFactory.CreateDevice(this.m_communicationBM, str, sex, age, height, m_BFHour, m_BFMinu);

                if (this.m_DeviceBM != null)
                {
                    if (ReadMode)
                    {
                        ClsResult.ResultFlag = false;
                        Thread.Sleep(1000);
                        this.SendMsg("CONNECT" + str);

                        this.m_communicationBM.StartDeviceListen();

                        if (this.m_DeviceBM.ExecQuery())
                        {
                            //if (!str.StartsWith("QCTBF") || (ClsResult.DeviceMsg != "参数设置已经完成,请进行测量."))
                            //{
                            if (ClsResult.ResultFlag == true)
                            {
                                getResult = true;
                                //this.m_DeviceBM.ExecClose();

                                this.m_communicationBM.WriteDataLog();
                                this.SendMsg("TRANSEND");
                                Thread.Sleep(500);
                            }
                            //}
                        }
                        else
                        {
                            this.m_communicationBM.WriteDataLog();
                            this.SendMsg("ERROR");
                        }
                    }
                    else
                    {
                        this.m_DeviceBM.ExecClose();
                    }

                    if (ClsResult.ResultFlag == true)
                    {
                        Thread.Sleep(this.m_DeviceBM.m_delay);
                    }
                }
                else
                {
                    this.SendMsg("UNKNOWN" + str);
                    Thread.Sleep(1000);
                }

                this.m_communicationBM.Disconnect();
                this.m_communicationBM.StopHardListen();

                if (ClsResult.ResultFlag == true)
                {
                    Thread.Sleep(500);
                }

                goto Label_0000;
            }
            catch (Exception ex)
            {
                goto Label_0000;
            }
        }