예제 #1
0
 /// <summary>
 /// 添加对象
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static void addTh10w(string key, CommonSession cs)
 {
     ThJob.updateTh10w(key, cs);
 }
예제 #2
0
        public void Execute(IJobExecutionContext context)
        {
            List <string> delList = new List <string>();

            //定时清理指定时间之前的SESSION连接
            foreach (KeyValuePair <string, CommonSession> th in th10w)
            {
                if (th.Value != null)
                {
                    //定时下发查询指令
                    TH10WProtocolSession session = ((TH10WProtocolSession)(th.Value).session);
                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeTh10w(key);
                }
            }

            delList = new List <string>();

            //th11s定时下发查询指令
            foreach (KeyValuePair <string, CommonSession> th in th11s)
            {
                if (th.Value != null)
                {
                    //定时下发查询指令
                    TH11SProtocolSession session = ((TH11SProtocolSession)(th.Value).session);

                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }

                    session.Send("010300000002C40B");
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeTh11s(key);
                }
            }

            delList = new List <string>();

            //ane定时下发查询指令
            foreach (KeyValuePair <string, CommonSession> th in anemoclinoGrap)
            {
                if (th.Value != null)
                {
                    //定时下发查询指令
                    ANEMOCLINOGRAPProtocolSession session = ((ANEMOCLINOGRAPProtocolSession)(th.Value).session);

                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }

                    session.Send("0101C1E0");
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeAnemoclinoGrap(key);
                }
            }

            delList = new List <string>();

            //ACTW-CAR小型清洁刷式温盐传感器
            foreach (KeyValuePair <string, CommonSession> th in tw)
            {
                if (th.Value != null)
                {
                    CommonSession cs = th.Value;
                    //定时下发查询指令
                    ACTWCARProtocolSession session = ((ACTWCARProtocolSession)(cs).session);

                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }

                    if (!ThJob.twIsWorking(th.Key))
                    {
                        session.Send("1111776970652C302C0D");
                        //设置设备工作状态
                        ThJob.setTwIsWorking(th.Key, true);
                    }
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeTw(key);
                }
            }

            delList = new List <string>();

            //ACLW-CAR传感器通讯协议与电气参数
            foreach (KeyValuePair <string, CommonSession> th in lw)
            {
                if (th.Value != null)
                {
                    CommonSession cs = th.Value;
                    //定时下发查询指令
                    ACLWCARProtocolSession session = ((ACLWCARProtocolSession)(cs).session);

                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }

                    if (!ThJob.lwIsWorking(th.Key))
                    {
                        session.Send("1111776970652C302C0D");
                        ThJob.setLwIsWorking(th.Key, true);
                    }
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeLw(key);
                }
            }

            delList = new List <string>();

            //百叶箱光照传感器
            foreach (KeyValuePair <string, CommonSession> th in lls)
            {
                if (th.Value != null)
                {
                    CommonSession cs = th.Value;
                    //定时下发查询指令
                    LouverlightSensorProtocolSession session = ((LouverlightSensorProtocolSession)(cs).session);

                    //清理5分钟前的连接
                    if ((DateTime.Now - session.LastActiveTime).TotalMilliseconds > ThJob.clearTime)
                    {
                        //记录要删除的KEY
                        delList.Add(session.SessionID);
                        continue;
                    }

                    session.Send("010300000006C5C8");
                }
            }

            //删除记录的KEY
            if (delList != null && delList.Count > 0)
            {
                foreach (string key in delList)
                {
                    ThJob.removeLouverlightSensor(key);
                }
            }
        }
예제 #3
0
 /// <summary>
 /// 添加对象
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static void addLouverlightSensor(string key, CommonSession cs)
 {
     ThJob.updateLouverlightSensor(key, cs);
 }
예제 #4
0
        /// <summary>
        /// 设置工作状态
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static void setLwIsWorking(string key, bool status)
        {
            CommonSession cs = ThJob.getLw(key);

            cs.isWorking = status;
        }
예제 #5
0
        /// <summary>
        /// 获取工作状态
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool lwIsWorking(string key)
        {
            CommonSession cs = ThJob.getLw(key);

            return(cs == null ? false : cs.isWorking);
        }
예제 #6
0
 /// <summary>
 /// 删除对象
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static void addAnemoclinoGrap(string key, CommonSession cs)
 {
     ThJob.updateAnemoclinoGrap(key, cs);
 }