示例#1
0
 /// <summary>
 /// 取消测试的表
 /// </summary>
 /// <param name="tempmeter"></param>
 /// <param name="session"></param>
 /// <param name="info"></param>
 private void Cancel_meter(MeterInfo tempmeter, MySession session, MyRequestInfo info)
 {
     try
     {
         //下发8f 8e回复出厂设置
         string send8F          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8F(tempmeter.MeterRand_num), info, true, false);
         string send8E          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8E(tempmeter.MeterRand_num), info, false, false);
         ArraySegment <byte> f  = new ArraySegment <byte>(DataHelper.Str2Byte(send8F));
         ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send8E));
         session.Send(f);
         session.Send(f2);
         LogHelper.Info("发送命令" + send8F);
         LogHelper.Info("发送命令" + send8E);
         tempmeter.MeterTest = "准备";
         Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
     }
     catch (Exception e)
     {
         LogHelper.Info(tempmeter.MeterId + e);
     }
 }
示例#2
0
        /// <summary>
        /// 从成功和失败的表中查询表
        /// 判断表的总结果是否为成功,表的测试状态为准备下发81命令
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo)
        {
            lock (obj3)
            {
                Myadapter_r = new DT_ResultTableAdapter();
                DataTable dt        = new DataTable();
                MeterInfo tempmeter = new MeterInfo();
                bool      f         = true;
                Thread.Sleep(1000);
                var info = requestInfo;
                dt = Myadapter_r.GetDataBy_r(info.EquipmentID, "合格", "初始", "失败");
                if (dt != null && dt.Rows.Count > 0)
                {
                    tempmeter = DataHelper.Dt2Ob(dt);
                }
                else
                {
                    f = false;
                }

                if (tempmeter != null && f)
                {
                    DateTime dtime = DateTime.Now;
                    tempmeter.MeterTime = dtime;
                    //成功的下发81修改网络参数,失败的不处理
                    if ((tempmeter.MeterState.Equals("合格") || tempmeter.MeterCancel.Equals("合格")) && tempmeter.MeterTest.Equals("准备"))
                    {
                        string ip              = CommonFunction.dicBooks["strJituanHostIP"];
                        string port            = CommonFunction.dicBooks["strJituanHostPort"];
                        string domain          = CommonFunction.dicBooks["strJituanHostDomain"];
                        string send81          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore81(ip, port, true, domain, tempmeter.MeterRand_num), info, false, true);
                        ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send81));
                        session.Send(f2);
                        tempmeter.MeterTest = "就绪";
                        //更新测试状态和修改时间
                        Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                    }
                    else
                    {
                        LogHelper.Info("燃气表错误发送恢复出厂设置");
                    }
                }
                else
                {
                    LogHelper.Info("表不在检测列表中");
                }
            }
        }
示例#3
0
        /// <summary>
        /// 检测平台连接表后回复命令
        /// (id ,IP,port)+结果(AA/55/66)
        /// 表没有正确修改,检测平台要回复没有修改成功
        /// 修改成功(表在meterinfo中),表test=正测,检测平台 = 正忙
        /// 修改失败(表在meterinfo中(表移入到meterfail中,State=失败),表在meterfail中(不用管))检测平台=空闲
        /// 解析失败(表在meterinfo中,后把表的测试状态改为空闲,延迟15s检测平台的状态改为空闲)
        ///
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo)
        {
            lock (obj_33)
            {
                Myadapter   = new Dt_MeterInfoTableAdapter();
                Myadapter_r = new DT_ResultTableAdapter();
                Myadapter_p = new Dt_PlateInfoTableAdapter();
                var    info   = requestInfo;
                string result = info.Data.Substring(26, 2);
                try
                {
                    dt        = Myadapter.GetDataBy1(info.EquipmentID);
                    tempmeter = DataHelper.Dt2Ob(dt);
                    if (tempmeter == null)
                    {
                        dt        = Myadapter_r.GetDataBy_r(info.EquipmentID, "合格", "初始", "初始");
                        tempmeter = DataHelper.Dt2Ob(dt);
                    }
                }
                catch (Exception)
                {
                    LogHelper.Error("数据库连接异常");
                }
                switch (result)
                {
                case "AA":
                    if (tempmeter != null)
                    {
                        DateTime dtime2 = DateTime.Now;
                        tempmeter.MeterTime = dtime2;
                        tempmeter.MeterTest = "正测";
                        if (tempmeter.MeterCancel.Equals("合格"))
                        {
                            Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                        }
                        else
                        {
                            Myadapter.UpdateMeterTest2(tempmeter.MeterTime, tempmeter.MeterTest, tempmeter.MeterId);
                        }
                        //修改检测平台=正忙
                        Thread.Sleep(100);
                        Xiugai(tempmeter, "正忙");
                    }
                    else
                    {
                        LogHelper.Info("错误的33命令1");
                    }
                    break;

                case "55":
                    if (tempmeter != null)
                    {
                        if (tempmeter.MeterCancel.Equals("否"))
                        {
                            tempmeter.MeterState      = "失败";
                            tempmeter.MeterComState   = tempmeter.MeterComState.Equals("待测") ? "失败" : tempmeter.MeterComState;
                            tempmeter.MeterIcState    = tempmeter.MeterIcState.Equals("待测") ? "失败" : tempmeter.MeterIcState;
                            tempmeter.MeterChuState   = tempmeter.MeterChuState.Equals("待测") ? "失败" : tempmeter.MeterChuState;
                            tempmeter.MeterZhongState = tempmeter.MeterComState.Equals("待测") ? "失败" : tempmeter.MeterZhongState;
                            Myadapter_r.InsertMeter(tempmeter.MeterId,
                                                    tempmeter.MeterType,
                                                    tempmeter.MeterComState,
                                                    tempmeter.MeterIcState,
                                                    tempmeter.MeterChuState,
                                                    tempmeter.MeterZhongState,
                                                    tempmeter.MeterState,
                                                    tempmeter.MeterTest,
                                                    tempmeter.MeterRand_num,
                                                    tempmeter.Meteriport,
                                                    tempmeter.MeterTime,
                                                    tempmeter.MeterCancel,
                                                    tempmeter.MeterEvery,
                                                    tempmeter.MeterPrivilege,
                                                    tempmeter.CheckTime,
                                                    tempmeter.ManufactureName_id,
                                                    tempmeter.Subtime);
                            Myadapter.DeleteMeter(tempmeter.MeterId);
                        }
                        CommonFunction.platm.ChangeBHG();
                        Xiugai(tempmeter, "空闲");
                    }
                    else
                    {
                        dt        = Myadapter_r.GetDataBy_r(info.EquipmentID, "失败", "失败", "失败");
                        tempmeter = DataHelper.Dt2Ob(dt);
                        if (tempmeter != null)
                        {
                            Thread.Sleep(3 * 1000);
                            Xiugai(tempmeter, "空闲");
                        }
                        else
                        {
                            LogHelper.Info("此表具不再任何检测表中");
                        }
                    }
                    break;

                case "66":
                    if (tempmeter.MeterCancel.Equals("否"))
                    {
                        DateTime dtime = DateTime.Now;
                        tempmeter.MeterTime = dtime;
                        tempmeter.MeterTest = "空闲";
                        Myadapter.UpdateMeterTest2(tempmeter.MeterTime, tempmeter.MeterTest, tempmeter.MeterId);
                        Thread.Sleep(15 * 1000);
                        string s = "空闲";
                        Xiugai(tempmeter, s);
                    }
                    break;

                default:
                    LogHelper.Info("错误的33命令");
                    break;
                }
                //更新界面
                CommonFunction.platm.ChangeMeter();
                CommonFunction.platm.ChangePlat();
            }
        }
示例#4
0
        /// <summary>
        /// tempi为表具在meterinfos的索引号
        /// tempmeter为收到请求的表具
        /// 调用logical中的函数来安排
        /// 将成功或失败的表移到成功和失败的表中,8E的时候从这两个表中查询
        /// 判断表具恢复出厂设置功能是否成功(8E)()
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo)
        {
            lock (obj)
            {
                Myadapter_r   = new DT_ResultTableAdapter();
                Myadapter_csb = new Dt_Chu_csbTableAdapter();
                Myadapter_xzy = new Dt_Chu_xzyTableAdapter();
                Myadapter_msb = new Dt_Chu_msbTableAdapter();
                Myadapter_Ic  = new Dt_IcTableAdapter();
                Myadapter_Mp  = new Dt_MPTableAdapter();
                Myadapter_p   = new Dt_PlateInfoTableAdapter();
                Myadapter     = new Dt_MeterInfoTableAdapter();
                bool     ishavepri = false;
                Boolean  flag_sen  = true;
                Boolean  flag_xiu  = true;
                Boolean  flag_xinx = true;
                var      info      = requestInfo;
                DateTime dtime2    = DateTime.Now;
                //LogHelper.Error(dtime2 + "  " + info.EquipmentID + "  " + info.Key + "获取锁");
                try
                {
                    dt = Myadapter.GetDataBy1(info.EquipmentID);
                    if (Myadapter.SQ_Privilege("1") != 0)
                    {
                        ishavepri = true;
                    }
                }
                catch (Exception e)
                {
                    LogHelper.Info("数据库连接异常90" + e);
                }
                tempmeter = DataHelper.Dt2Ob(dt);
                if (tempmeter != null)
                {
                    //随机数与datetime
                    tempmeter.MeterRand_num = info.Data.Substring(52, 8);
                    DateTime dtime = DateTime.Now;
                    tempmeter.MeterTime = dtime;
                    switch (tempmeter.MeterState)
                    {
                    case "完成":
                        //如果表上传,说明恢复出厂设置不成功
                        XiugaiSF(tempmeter, session, info);
                        break;

                    case "失败":
                        //不可能一旦失败表就会移入到meterfail表中
                        break;

                    case "不合格":
                        //不可能一旦失败表就会移入到meterfail表中
                        break;

                    case "合格":
                        //免检产品
                        Xiugaisuc(tempmeter, session, info);
                        break;

                    case "初始":
                        //查询测量标志位
                        if (tempmeter.MeterTest.Equals("正测") || tempmeter.MeterTest.Equals("准备") || tempmeter.MeterTest.Equals("就绪"))
                        {
                            //更新随机数
                            //下发1F
                            string send0F          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore0F("1F", 2, 1), info, true, true);
                            ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                            session.Send(f0);
                            LogHelper.Info("发送命令4" + send0F);
                            Myadapter.UpdateRand_num(tempmeter.MeterRand_num, tempmeter.MeterId);
                        }
                        else if (tempmeter.MeterTest.Equals("空闲"))
                        {
                            //安排分
                            string[] re = Logical.Meter_AnPai(tempmeter, ishavepri);
                            //LogHelper.Error(tempmeter.MeterId + re[1]);
                            //返回2222代表此表合格,其需要回复出厂设置并修改到正式服务器
                            if (re[1].Equals("成功"))
                            {
                                Xiugaisuc(tempmeter, session, info);
                            }
                            //返回3333代表此表的所有测试都失败
                            else if (re[1].Equals("失败"))
                            {
                                //Xiugaifai(tempmeter, session, info);
                            }
                            //返回安排的结果
                            else if (!re[1].Equals("空"))
                            {
                                //获取对应的IP与port
                                //下发8f与81命令
                                //并向检测平台下发33命令
                                //修改表的测试状态为准备2
                                //修改检测平台的测试状态为就绪
                                //保存表对应检测平台的IP与port
                                try
                                {
                                    IPAddress ip     = IPAddress.Parse(re[1]);
                                    int       port   = Convert.ToInt32(re[2]);
                                    Socket    socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                                    socket.Connect(ip, port);
                                    string send34 = null;
                                    try
                                    {
                                        switch (re[3])
                                        {
                                        case "PlatComs":
                                            string typee = "";
                                            if (tempmeter.MeterType.Equals("膜式表"))
                                            {
                                                dt_temp = Myadapter_msb.GetData(tempmeter.MeterId);
                                                typee   = "msb";
                                            }
                                            else if (tempmeter.MeterType.Equals("修正仪"))
                                            {
                                                dt_temp = Myadapter_xzy.GetData(tempmeter.MeterId);
                                                typee   = "xzy";
                                            }
                                            else if (tempmeter.MeterType.Equals("超声波"))
                                            {
                                                dt_temp = Myadapter_csb.GetData(tempmeter.MeterId);
                                                typee   = "csb";
                                            }
                                            send34 = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Com(dt_temp, typee), info, false, false);
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, re[0], "-1", "-1", "-1");
                                            }
                                            else
                                            {
                                                Myadapter_Mp.Update_MP_Com(re[0], tempmeter.MeterId);
                                            }
                                            Myadapter_p.UpdatePlatCom("就绪", int.Parse(re[0]));
                                            break;

                                        case "PlatIcs":
                                            dt_temp = Myadapter_Ic.GetData(tempmeter.MeterId);
                                            send34  = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Ic(dt_temp), info, false, false);
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, "-1", re[0], "-1", "-1");
                                            }
                                            else
                                            {
                                                Myadapter_Mp.Update_MP_IC(re[0], tempmeter.MeterId);
                                            }
                                            Myadapter_p.UpdatePlatIc("就绪", int.Parse(re[0]));
                                            break;

                                        case "PlatChus_msb":
                                            dt_temp = Myadapter_msb.GetData(tempmeter.MeterId);
                                            send34  = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Chu_msb(dt_temp), info, false, false);
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, "-1", "-1", re[0], "-1");
                                            }
                                            else
                                            {
                                                Myadapter_Mp.Update_MP_Chu(re[0], tempmeter.MeterId);
                                            }
                                            Myadapter_p.UpdatePlatChu_msb("就绪", int.Parse(re[0]));
                                            break;

                                        case "PlatChus_xzy":
                                            dt_temp = Myadapter_xzy.GetData(tempmeter.MeterId);
                                            send34  = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Chu_xzy(dt_temp), info, false, false);
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, "-1", "-1", re[0], "-1");
                                            }
                                            else
                                            {
                                                Myadapter_Mp.Update_MP_Chu(re[0], tempmeter.MeterId);
                                            }
                                            Myadapter_p.UpdatePlatChu_xzy("就绪", int.Parse(re[0]));
                                            break;

                                        case "PlatChus_csb":
                                            dt_temp = Myadapter_csb.GetData(tempmeter.MeterId);
                                            send34  = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Chu_csb(dt_temp), info, false, false);
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, "-1", "-1", re[0], "-1");
                                            }
                                            else
                                            {
                                                Myadapter_p.UpdatePlatChu_csb("就绪", int.Parse(re[0]));
                                            }
                                            break;

                                        case "PlatZhos":
                                            //dt_temp =
                                            //send34 = DownCommond.GenerateSendFrame(DownCommond.GenerateCore33(tempmeter.MeterId) + DownCommond.GenerateCore34_Zho(dt_temp), info, false, false);
                                            //socket.Send(DataHelper.Str2Byte(send34));
                                            socket.Close();
                                            Myadapter_p.UpdatePlatZho("就绪", int.Parse(re[0]));
                                            //有问题
                                            if (Convert.ToInt64(Myadapter_Mp.SQ_MP(tempmeter.MeterId)) == 0)
                                            {
                                                Myadapter_Mp.Insert_MP(tempmeter.MeterId, "-1", "-1", "-1", re[0]);
                                            }
                                            else
                                            {
                                                Myadapter_Mp.Update_MP_Zho(re[0], tempmeter.MeterId);
                                            }
                                            break;
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        flag_xinx = false;
                                        flag_sen  = false;
                                        flag_xiu  = false;
                                        LogHelper.Error("检测平台修改数据库或读取燃气表测试信息异常" + e);
                                    }
                                    if (flag_xinx)
                                    {
                                        socket.Send(DataHelper.Str2Byte(send34));
                                        socket.Close();
                                        LogHelper.Info("发送命令33" + send34);
                                    }
                                }
                                catch (Exception e)
                                {
                                    flag_sen = false;
                                    flag_xiu = false;
                                    LogHelper.Error("检测平台异常或数据异常" + e);
                                }
                                if (flag_sen)
                                {
                                    try
                                    {
                                        string send8F3          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8F(tempmeter.MeterRand_num), info, true, false);
                                        string send813          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore81(re[1], re[2], false, "", tempmeter.MeterRand_num), info, false, true);
                                        ArraySegment <byte> f3  = new ArraySegment <byte>(DataHelper.Str2Byte(send8F3));
                                        ArraySegment <byte> f23 = new ArraySegment <byte>(DataHelper.Str2Byte(send813));
                                        session.Send(f3);
                                        Thread.Sleep(1000);
                                        session.Send(f23);
                                        LogHelper.Info("发送命令8F" + send8F3);
                                        LogHelper.Info("发送命令81" + send813);
                                    }
                                    catch (Exception e)
                                    {
                                        flag_xiu = false;
                                        LogHelper.Error("修改网络参数下发失败" + e);
                                    }
                                }
                                else
                                {
                                    //更新随机数
                                    //下发1F
                                    string send0F          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore0F("1F", 2, 1), info, true, true);
                                    ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                                    session.Send(f0);
                                    LogHelper.Info("发送命令3" + send0F);
                                    Myadapter.UpdateRand_num(tempmeter.MeterRand_num, tempmeter.MeterId);
                                }
                                if (flag_xiu)
                                {
                                    tempmeter.MeterTest  = "准备";
                                    tempmeter.Meteriport = re[0] + "@" + re[1] + "@" + re[2] + "@" + re[3];
                                    Myadapter.UpdateMeterTest(tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, tempmeter.MeterTest, tempmeter.MeterId);
                                }
                            }
                            else if (re[1].Equals("空"))
                            {
                                LogHelper.Info("无空闲检测平台");
                                Random rd              = new Random();
                                int    uplod_time      = rd.Next(10, 20);
                                string send0F          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore0F("1F", uplod_time, 5), info, true, true);
                                ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                                session.Send(f0);
                                LogHelper.Info("发送命令2" + send0F);
                                Myadapter.UpdateRand_num(tempmeter.MeterRand_num, tempmeter.MeterId);
                            }
                            else
                            {
                                LogHelper.Info("安排出错,大于检测平台数");
                            }
                        }
                        else
                        {
                            LogHelper.Info("非规定测量标志位");
                        }
                        break;

                    default:
                        LogHelper.Info("未知状态");
                        break;
                    }
                    CommonFunction.platm.ChangeMeter();
                    CommonFunction.platm.ChangePlat();
                }
                else
                {
                    try
                    {
                        dt = Myadapter_r.GetDataBy_r(info.EquipmentID, "合格", "初始", "失败");
                    }
                    catch (Exception e)
                    {
                        LogHelper.Info("数据库连接异常90" + e);
                    }
                    tempmeter = DataHelper.Dt2Ob(dt);
                    if (tempmeter != null)
                    {
                        //随机数与datetime
                        //在11之前修改为合格,表在metersuccess中,metertest=空闲,metercancel=合格
                        //如果测试状态为正测
                        tempmeter.MeterRand_num = info.Data.Substring(52, 8);
                        DateTime dtime = DateTime.Now;
                        tempmeter.MeterTime = dtime;
                        if ((tempmeter.MeterCancel.Equals("合格") && tempmeter.MeterTest.Equals("空闲")) || (tempmeter.MeterCancel.Equals("是") && tempmeter.MeterState.Equals("失败")))
                        {
                            Cancel_meter(tempmeter, session, info);
                        }
                        else if (tempmeter.MeterCancel.Equals("合格") && tempmeter.MeterTest.Equals("正测"))
                        {
                            //更新随机数
                            //下发1F
                            string send0F          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore0F("1F", 2, 1), info, true, true);
                            ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                            session.Send(f0);
                            LogHelper.Info("发送命令1" + send0F);
                            Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                        }
                    }
                }
            }
        }
示例#5
0
 /// <summary>
 /// 上行81命令
 /// 测试完成,修改正式域名(此时表state为成功,Test为就绪)从metersuccess中查找
 /// 准备去检测平台测试(此时表的state为初始,test状态为准备)从meterinfo中查找
 /// 判断表的修改网络参数是否成功?(这里要考虑数据库更新的IP port是否在+81之前
 /// 不在这里判断修改网络参数若检测平台没有回复,就不能排除是表的问题了)
 /// 让这个线程休眠500ms来等待数据库操作
 /// </summary>
 /// <param name="session"></param>
 /// <param name="requestInfo"></param>
 public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo)
 {
     lock (obj2)
     {
         Myadapter   = new Dt_MeterInfoTableAdapter();
         Myadapter_r = new DT_ResultTableAdapter();
         DataTable dt        = new DataTable();
         MeterInfo tempmeter = new MeterInfo();
         bool      issuccess = false;
         Thread.Sleep(1000);
         var info = requestInfo;
         try
         {
             dt = Myadapter.GetDataBy1(info.EquipmentID);
             if (dt != null && dt.Rows.Count > 0)
             {
                 tempmeter = DataHelper.Dt2Ob(dt);
             }
             else
             {
                 dt        = Myadapter_r.GetDataBy_r(info.EquipmentID, "合格", "初始", "初始");
                 tempmeter = DataHelper.Dt2Ob(dt);
                 issuccess = true;
             }
         }
         catch (Exception e)
         {
             LogHelper.Error("数据库连接异常" + e);
         }
         if (tempmeter != null)
         {
             DateTime dtime = DateTime.Now;
             tempmeter.MeterTime = dtime;
             string IP     = DataHelper.Str2IP(info.Data.Substring(4, 8));
             string port   = Convert.ToInt32(info.Data.Substring(12, 4), 16).ToString();
             string domain = Encoding.ASCII.GetString(DataHelper.SplitArray(DataHelper.Str2Byte(info.Data), 8, 32));
             //修改到正式服务器的表,不需检测网络修改功能
             if (issuccess)
             {
                 if ((tempmeter.MeterState.Equals("合格") || (tempmeter.MeterCancel.Equals("合格") && tempmeter.MeterState.Equals("初始"))) && tempmeter.MeterTest.Equals("就绪"))
                 {
                     string send0F = S0f(info.EquipmentType, info);
                     if (send0F.Equals("0"))
                     {
                         LogHelper.Info("设备类型不是标准值");
                     }
                     else
                     {
                         //of不需要发送
                         ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                         session.Send(f0);
                         LogHelper.Info("发送命令" + send0F);
                         tempmeter.MeterState = "完成";
                         tempmeter.MeterTest  = "空闲";
                         Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                     }
                 }
                 else if (tempmeter.MeterCancel.Equals("合格") && tempmeter.MeterState.Equals("初始") && tempmeter.MeterTest.Equals("准备"))
                 {
                     tempmeter.MeterTest = "特殊";
                     string ip    = CommonFunction.dicBooks["strMainHostIP"];
                     string port2 = CommonFunction.dicBooks["strMainHostPort"];
                     //下发81,修改回来,修改状态为就绪,下次上传81时再修改正式域
                     string send813          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore81(ip, port2, false, "", tempmeter.MeterRand_num), info, false, true);
                     ArraySegment <byte> f23 = new ArraySegment <byte>(DataHelper.Str2Byte(send813));
                     session.Send(f23);
                     LogHelper.Info("发送命令81" + send813);
                     Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                 }
                 else if (tempmeter.MeterState.Equals("初始") && tempmeter.MeterTest.Equals("特殊"))
                 {
                     tempmeter.MeterTest = "准备";
                     string send8E          = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8E(tempmeter.MeterRand_num), info, false, false);
                     ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send8E));
                     session.Send(f2);
                     LogHelper.Info("发送命令" + send8E);
                     Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId);
                 }
             }
             else if (tempmeter.MeterState.Equals("初始") && tempmeter.MeterTest.Equals("准备") && !issuccess)
             {
                 string   re  = tempmeter.Meteriport;
                 string[] tip = re.Split('@');
                 //修改网络参数成功
                 if (tip[1].Equals(IP) && tip[2].Equals(port))
                 {
                     string send0F = S0f(info.EquipmentType, info);
                     if (send0F.Equals("0"))
                     {
                         LogHelper.Info("设备类型不是标准值");
                     }
                     else
                     {
                         ArraySegment <byte> f0 = new ArraySegment <byte>(DataHelper.Str2Byte(send0F));
                         session.Send(f0);
                         LogHelper.Info("发送命令" + send0F);
                         tempmeter.MeterTest = "就绪";
                         Myadapter.UpdateMeterTest2(tempmeter.MeterTime, tempmeter.MeterTest, tempmeter.MeterId);
                     }
                 }
                 else
                 {
                     //修改网络参数失败
                     //下发8e休眠,并将其移到测试失败的表中
                     //检测平台将收不到表,会回复33没有连上的命令,需要在33哪里修改检测平台的状态为空闲
                     tempmeter.MeterState = "失败";
                     tempmeter.MeterTest  = "空闲";
                     LogHelper.Info("网络参数未正确修改到检测平台");
                     Myadapter_r.InsertMeter(tempmeter.MeterId,
                                             tempmeter.MeterType,
                                             tempmeter.MeterComState,
                                             tempmeter.MeterIcState,
                                             tempmeter.MeterChuState,
                                             tempmeter.MeterZhongState,
                                             tempmeter.MeterState,
                                             tempmeter.MeterTest,
                                             tempmeter.MeterRand_num,
                                             tempmeter.Meteriport,
                                             tempmeter.MeterTime,
                                             tempmeter.MeterCancel,
                                             tempmeter.MeterEvery,
                                             tempmeter.MeterPrivilege,
                                             tempmeter.CheckTime,
                                             tempmeter.ManufactureName_id,
                                             tempmeter.Subtime);
                     Myadapter.DeleteMeter(tempmeter.MeterId);
                     CommonFunction.platm.ChangeSB();
                 }
             }
             else
             {
                 LogHelper.Info("分配逻辑出错");
             }
             //更新界面
             CommonFunction.platm.ChangeMeter();
             CommonFunction.platm.ChangePlat();
             CommonFunction.platm.ChangeHG();
         }
         else
         {
             LogHelper.Info("表不再检测列表中");
         }
     }
 }