public void CtrlArgsMeasure(string session, Wlst.mobile.MsgWithMobile infos)
        {
            var info = infos.WstSluSvrAnsReadCtrlArgs;//wstsvr_ans_slu_ctrl_measure;

            if (info == null)
            {
                return;
            }

            foreach (var g in Records)
            {
                if (g.RtuId == info.SluId && g.Addr == info.CtrlId)
                {
                    if (g.Finish)
                    {
                        break;
                    }
                    g.AnsTime = DateTime.Now.ToString("HH:mm:ss");
                    // DateTime ts = Convert.ToDateTime(DateTime.Now);
                    TimeSpan tss = DateTime.Now.Subtract(g.OpTime);
                    g.TimeDifference = tss.TotalSeconds.ToString("f2") + " 秒";  //时差
                    g.Finish         = true;
                }
            }
            recalctrlinfo();
        }
        //private void InitEvent()
        //{
        //    //ProtocolServer.RegistProtocol(Wlst.Sr.ProtocolPhone.LxSys.wlst_sys_svr_to_cnt_info,//.ClientPart.wlst_Infrastructure_server_to_clinet_msginfo,
        //    //                              MsgAction, typeof(UserOperateMsgViewModel), this);



        //    //Wlst.Cr.CoreMims.ShowMsgInfo.ShowNewMsg.ActionAddShowInfo += AddNewRecordItem;


        //    //EventPublisher.AddEventSubScriptionTokener(
        //    //   Assembly.GetExecutingAssembly().GetName().ToString(), FundEventHandlers, FundOrderFilters);
        //}


        private void ExExecuteOpenLight(string session, Wlst.mobile.MsgWithMobile args)
        {
            var    datax = args.WstRtuSvrAnsCntOrderOpenCloseLight;
            var    lst   = args.Args.Addr;
            OpType OpTemp;

            if (lst == null)
            {
                return;
            }
            if (datax.IsOpen)
            {
                OpTemp = OpType.RtuOpen;
            }
            else
            {
                OpTemp = OpType.RtuClose;
            }

            //var tu = new Tuple<int, int, int,int>(datax.RtuId, (int)OpTemp, datax.LoopId,-1);

            //if(userOpDic.ContainsKey(tu))
            //{
            UpdateRecordItem(datax.RtuId, OpTemp, datax.LoopId);
            //    userOpDic[tu] = 1;

            //}
        }
        public void SluCtrlMeasure(string session, Wlst.mobile.MsgWithMobile infos)
        {
            if (ctrlinfo.Count == 0)
            {
                return;
            }
            var info = infos.WstSluSvrAnsSluMeasure;

            if (info == null)
            {
                return;
            }
            var sluids = (from t in ctrlinfo select t.Key.Item1).ToList();

            if (sluids.Contains(info.SluId) == false)
            {
                return;
            }

            var typs = (from t in ctrlinfo select t.Key.Item2).ToList();

            if (typs.Contains(info.Type) == false)
            {
                return;
            }



            foreach (var g in Records)
            {
                if (g.RtuId == info.SluId && g.AddrType == info.Type)
                {
                    if (info.Type == 0)
                    {
                        if (g.Finish)
                        {
                            break;
                        }
                        g.AnsTime = DateTime.Now.ToString("HH:mm:ss");
                        // DateTime ts = Convert.ToDateTime(DateTime.Now);
                        TimeSpan tss = DateTime.Now.Subtract(g.OpTime);
                        g.TimeDifference = tss.TotalSeconds.ToString("f2") + " 秒"; //时差
                        g.Finish         = true;
                        recalctrlinfo();
                    }
                    else if (info.Type == 5)
                    {
                        foreach (var f in info.InfoBaseic5)
                        {
                            if (f.Info.CtrlId == g.Addr)
                            {
                                if (g.Finish)
                                {
                                    break;
                                }
                                g.AnsTime = DateTime.Now.ToString("HH:mm:ss");
                                // DateTime ts = Convert.ToDateTime(DateTime.Now);
                                TimeSpan tss = DateTime.Now.Subtract(g.OpTime);
                                g.TimeDifference = tss.TotalSeconds.ToString("f2") + " 秒"; //时差
                                g.Finish         = true;
                                recalctrlinfo();
                            }
                        }
                    }
                }
            }
        }
        public void SluMeasureBack(string session, Wlst.mobile.MsgWithMobile infos)
        {
            var info = infos.WstSluSvrAnsRightOperator;

            if (info == null)
            {
                return;
            }
            if (info.Op == 1)
            {
                OpType OpTemp = new OpType();

                if (infos.Args.Addr.Count > 2)
                {
                    int sluid = infos.Args.Addr[0];
                    int addr  = infos.Args.Addr[1];
                    int grid  = infos.Args.Addr[2];
                    foreach (var g in Records)
                    {
                        if (g.Gid == infos.Head.Gid)
                        {
                            g.Nindex = info.Nindex;
                        }
                    }
                }
            }
            else
            {
                //var ts = new Tuple<int, int>(info.SluId, info.Nindex);
                //if (!_second.ContainsKey(ts)) return;
                //var ngt = _second[ts];

                //var tu = new Tuple<int, long>(info.SluId, ngt);

                foreach (var g in Records)
                {
                    if (g.RtuId == info.SluId)
                    {
                        if (g.Nindex == info.Nindex)
                        {
                            if (g.Finish)
                            {
                                break;
                            }
                            bool Succ = false;
                            if (info.Status == 0x3a) //成功
                            {
                                Succ = true;
                            }
                            else if (info.Status == 0x61) //成功
                            {
                                Succ = true;
                            }
                            else if (info.Status == 0x62) //成功
                            {
                                Succ = true;
                            }
                            //else if (info.Status == 0x63) //成功
                            //{
                            //    g.IsSuccessful = "失败";
                            //    g.AttachInfo = "硬件队列已满.";
                            //}
                            //else if (info.Status == 0x5a) //成功
                            //{
                            //    g.IsSuccessful = "失败";
                            //    g.AttachInfo = "数据错误.";
                            //}
                            //else
                            //{
                            //    g.IsSuccessful = "失败";
                            //    g.AttachInfo = "原因未知.";
                            //}

                            //if (dtime == null) dtime = DateTime.Now.ToString("HH:mm:ss");
                            if (Succ)
                            {
                                g.AnsTime = DateTime.Now.ToString("HH:mm:ss");
                                //  DateTime ts = Convert.ToDateTime(DateTime.Now );
                                TimeSpan tss = DateTime.Now.Subtract(g.OpTime);
                                g.TimeDifference = tss.TotalSeconds.ToString("f2") + " s";  //时差
                                g.Finish         = true;
                            }
                            //g.AnsTime = dtime;//应答时间   DateTime.Now.ToString("HH:mm:ss") ;
                            //DateTime ts = Convert.ToDateTime(dtime);
                            //TimeSpan tss = ts.Subtract(g.OpTime);
                            //g.TimeDifference = tss.TotalSeconds + " s";  //时差
                        }
                    }
                }
            }
        }
        ////    private ConcurrentDictionary<int, int> ExWeekSetCount =
        ////new ConcurrentDictionary<int, int>();

        private void ResponseSndWeekSetK1K3(string session, Wlst.mobile.MsgWithMobile infos)
        {
            if (equinfo.Count == 0 || infos.WstRtuOrders == null || infos.WstRtuOrders.RtuIds.Count == 0)
            {
                return;
            }
            if (equinfo.ContainsKey(infos.WstRtuOrders.RtuIds[0]) == false)
            {
                return;
            }



            //if (_isViewShow == false) return;
            var datax = infos.WstRtuOrders;

            OpType OpTemp = new OpType();
            int    loooop = -1;

            if (datax.Op == 31)   //选测
            {
                OpTemp = OpType.RtuMeasure;
                foreach (var item in datax.Items)
                {
                    //var tu = new Tuple<int, int, int,int>(item.RtuId, (int)OpTemp, loooop,-1);
                    //if (userOpDic.ContainsKey(tu))
                    //{
                    UpdateRecordItem(item.RtuId, OpTemp, loooop);
                    //userOpDic[tu] = 1;
                    //}
                }
            }
            if (datax.Op == 21) //对时
            {
                OpTemp = OpType.AsynTime;
                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop);
                }

                //foreach (var item in datax.Items)
                //{
                //    //var tu = new Tuple<int, int, int,int>(item.RtuId, (int)OpTemp, loooop,-1);
                //    //if (userOpDic.ContainsKey(tu))
                //    //{
                //        UpdateRecordItem(item.RtuId, OpTemp, loooop);
                //    //    userOpDic[tu] = 1;
                //    //}
                //}
            }
            if (datax.Op == 22)//召测时间
            {
                OpTemp = OpType.ZcTime;

                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop, datax.Date);
                }
                //foreach (var item in datax.Items)
                //{
                //    //var tu = new Tuple<int, int, int,int>(item.RtuId, (int)OpTemp, loooop,-1);
                //    //if (userOpDic.ContainsKey(tu))
                //    //{
                //        UpdateRecordItem(item.RtuId, OpTemp, loooop, datax.Date);
                //    //    userOpDic[tu] = 1;
                //    //}
                //}
            }
            if (datax.Op == 11)//周设置13
            {
                OpTemp = OpType.Snd13Week;

                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop);
                }
            }
            if (datax.Op == 12)//周设置46
            {
                OpTemp = OpType.Snd46Week;

                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop);
                }
            }
            if (datax.Op == 13)//周设置78
            {
                OpTemp = OpType.Snd78Week;

                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop);
                }
            }
            if (datax.Op == 14)//周设置全年
            {
                OpTemp = OpType.SndAllYearWeek;

                foreach (var g in datax.RtuIds)
                {
                    UpdateRecordItem(g, OpTemp, loooop);
                }
            }
        }