예제 #1
0
        public void initEquipment()
        {
            bool   Init_flag    = true;
            string init_message = "";

            try
            {
                if (configdata.Fqyifpz == true)
                {
                    switch (configdata.Fqyxh.ToLower())           //通过仪器型号选择初始化项目
                    {
                    case "nha_503":
                        try
                        {
                            UseFqy              = "fla_502";
                            fla_502             = new Exhaust.Fla502(configdata.Fqyxh);
                            fla_502.isNhSelfUse = configdata.isFqyNhSelfUse;
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "fla_502":
                        try
                        {
                            UseFqy  = "fla_502";
                            fla_502 = new Exhaust.Fla502(configdata.Fqyxh);
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "cdf5000":
                        try
                        {
                            UseFqy  = "cdf5000";
                            fla_502 = new Exhaust.Fla502(configdata.Fqyxh);
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "mqw_50a":
                    case "mqw_50b":
                        try
                        {
                            UseFqy  = "mqw_50a";
                            fla_502 = new Exhaust.Fla502(configdata.Fqyxh);
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "mqw_511":
                        try
                        {
                            UseFqy  = "mqw_511";
                            fla_502 = new Exhaust.Fla502(configdata.Fqyxh);
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "fasm_5000":
                        try
                        {
                            UseFqy  = "fasm_5000";
                            fla_502 = new Exhaust.Fla502(configdata.Fqyxh);
                            if (fla_502.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                        break;

                    case "fla_501":
                        try
                        {
                            UseFqy  = "fla_501";
                            fla_501 = new Exhaust.Fla501();
                            if (fla_501.Init_Comm(configdata.Fqyck, configdata.Fqyckpzz) == false)
                            {
                                fla_501      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_501   = null;
                            Init_flag = false;
                        }
                        break;
                    }
                }
            }
            catch (Exception)
            {
            }

            //这里只初始化了废气分析仪其他设备要继续初始化
            try
            {
                if (configdata.Cgjifpz)
                {
                    try
                    {
                        igbt = new Dynamometer.IGBT("BNTD", configdata.isIgbtContainGdyk);
                        if (igbt.Init_Comm(configdata.Cgjck, configdata.cgjckpzz) == false)
                        {
                            igbt          = null;
                            Init_flag     = false;
                            init_message += "测功机串口打开失败.";
                        }
                    }
                    catch (Exception er)
                    {
                        igbt      = null;
                        Init_flag = false;
                        MessageBox.Show(er.ToString(), "出错啦");
                    }
                }
            }
            catch (Exception)
            {
            }
            try
            {
                if (configdata.Ydjifpz == true && configdata.Ydjxh != "CDF5000")
                {
                    try
                    {
                        flb_100             = new Exhaust.FLB_100(configdata.Ydjxh);
                        flb_100.isNhSelfUse = configdata.isYdjNhSelfUse;
                        if (flb_100.Init_Comm(configdata.Ydjck, configdata.Ydjckpzz) == false)
                        {
                            flb_100       = null;
                            Init_flag     = false;
                            init_message += "烟度计串口打开失败.";
                        }
                    }
                    catch (Exception er)
                    {
                        flb_100   = null;
                        Init_flag = false;
                        MessageBox.Show(er.ToString(), "出错啦");
                    }
                }
            }
            catch (Exception)
            {
            }
            try
            {
                if (configdata.Lljifpz == true)
                {
                    try
                    {
                        flv_1000             = new Exhaust.Flv_1000();
                        flv_1000.isNhSelfUse = configdata.isLljNhSelfUse;
                        if (flv_1000.Init_Comm(configdata.Lljck, configdata.Lljckpzz) == false)
                        {
                            flv_1000      = null;
                            Init_flag     = false;
                            init_message += "流量计串口打开失败.";
                        }
                    }
                    catch (Exception er)
                    {
                        flv_1000  = null;
                        Init_flag = false;
                        MessageBox.Show(er.ToString(), "出错啦");
                    }
                }
            }
            catch (Exception)
            {
                flv_1000  = null;
                Init_flag = false;
            }
            try
            {
                if (configdata.BpqMethod == "串口")
                {
                    try
                    {
                        bpq = new bpxcontrol(configdata.BpqXh);
                        if (bpq.Init_Comm(configdata.BpqCom, configdata.BpqComPz) == false)
                        {
                            bpq           = null;
                            Init_flag     = false;
                            init_message += "变频器串口打开失败.";
                        }
                    }
                    catch (Exception er)
                    {
                        bpq       = null;
                        Init_flag = false;
                        MessageBox.Show(er.ToString(), "出错啦");
                    }
                }
            }
            catch (Exception)
            {
                bpq       = null;
                Init_flag = false;
            }
        }
예제 #2
0
        public void initEquipment()
        {
            bool   Init_flag    = true;
            string init_message = "";

            //这里只初始化了废气分析仪其他设备要继续初始化

            try
            {
                if (equipconfig.Ydjifpz == true)
                {
                    if (equipconfig.Ydjxh != "CDF5000")
                    {
                        try
                        {
                            flb_100             = new Exhaust.FLB_100(equipconfig.Ydjxh);
                            flb_100.isNhSelfUse = equipconfig.isYdjNhSelfUse;
                            if (flb_100.Init_Comm(equipconfig.Ydjck, "9600,N,8,1") == false)
                            {
                                flb_100       = null;
                                Init_flag     = false;
                                init_message += "烟度计串口打开失败.";
                                Msg(label_msg, panel_msg, init_message, false);
                            }
                            else if (equipconfig.Ydjxh != "nht_1")
                            {
                                string ydjzt = flb_100.Get_Mode();
                                if (ydjzt.Contains("故障"))
                                {
                                    ydjzt = flb_100.Get_Mode();
                                    if (ydjzt.Contains("故障"))
                                    {
                                        init_message += "烟度计通讯异常";
                                        Msg(label_msg, panel_msg, init_message, false);
                                        return;
                                    }
                                    else if (ydjzt.Contains("预热"))
                                    {
                                        init_message += "烟度计正在预热";
                                        Msg(label_msg, panel_msg, init_message, false);
                                        return;
                                    }
                                }
                                else if (ydjzt.Contains("预热"))
                                {
                                    init_message += "烟度计正在预热";
                                    Msg(label_msg, panel_msg, init_message, false);
                                    return;
                                }
                                flb_100.Set_Measure();
                                Thread.Sleep(1000);
                                timer1.Start();
                            }
                            else
                            {
                                flb_100.Set_Measure();
                                Thread.Sleep(1000);
                                timer1.Start();
                            }
                        }
                        catch (Exception er)
                        {
                            flb_100   = null;
                            Init_flag = false;

                            MessageBox.Show(er.ToString(), "出错啦");
                        }
                    }
                    else if (fla_502 == null)
                    {
                        try
                        {
                            fla_502             = new Exhaust.Fla502("cdf5000");
                            fla_502.isNhSelfUse = equipconfig.isFqyNhSelfUse;
                            if (fla_502.Init_Comm(equipconfig.Fqyck, equipconfig.Fqyckpzz) == false)
                            {
                                fla_502      = null;
                                Init_flag    = false;
                                init_message = "废气仪串口打开失败.";
                                return;
                            }
                            fla_502.Set_Measure();
                            Thread.Sleep(1000);
                            timer1.Start();
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString(), "出错啦");
                            fla_502   = null;
                            Init_flag = false;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }