/// <summary> /// 获取监测站信息 /// </summary> /// <param name="devId"></param> /// <returns></returns> public static StatInfo GetStatInfo(int devId) { StatInfo model = null; if (_devRelatedStatDic.ContainsKey(devId)) { model = _devRelatedStatDic[devId]; } else { var stat = new ESMonitor.BLL.Devs().GetDevStat(devId); if (stat != null) { var statInfo = new StatInfo { StatId = stat.Id, Country = stat.Country, StatCodeUp = 1 }; _devRelatedStatDic.Add(devId, statInfo); } } return(model); }
public static void UpdateDevStats(int devId) { var stat = new ESMonitor.BLL.Devs().GetDevStat(devId); if (stat != null) { var statInfo = new StatInfo { StatId = stat.Id, Country = stat.Country, StatCodeUp = 1 }; _devRelatedStatDic[devId] = statInfo; } }
public static void Init() { _devStatusDic = new Dictionary <int, DevStatus>(); //初始化这两个结构 _devAddrDic = new Dictionary <uint, int>(); //编号和Id的关系 _devRelatedStatDic = new Dictionary <int, StatInfo>(); var bll = new ESMonitor.BLL.Devs();//生成一个业务层的设备类 var dt = bll.GetDevAddrList().Tables[0]; foreach (DataRow dr in dt.Rows) { var model = new DevStatus { Id = Convert.ToInt32(dr["DevId"]), IsRegistered = false, RecvTime = new DateTime(), Status = (int)CommStatus.DisConnect, HeartBeatTime = new DateTime(), SendTime = new DateTime() }; _devStatusDic.Add(model.Id, model); var addr = (byte[])(dr["NodeId"]); var nodeId = Utility.BytesToUint32(addr, 0, false); _devAddrDic.Add(nodeId, model.Id); } dt = bll.GetDevRelatedStat("").Tables[0]; foreach (DataRow dr in dt.Rows) { var statInfo = new StatInfo(); var devId = Convert.ToInt32(dr["DevId"]); statInfo.StatId = Convert.ToInt32(dr["StatId"]); statInfo.Country = dr["Country"].ToString(); statInfo.StatCodeUp = int.Parse(dr["StatCodeUp"].ToString()); _devRelatedStatDic.Add(devId, statInfo); } }
public static void Init() { devStatusDic = new Dictionary <int, DevStatus>(); //初始化这两个结构 devAddrDic = new Dictionary <UInt32, int>(); //编号和Id的关系 devRelatedStatDic = new Dictionary <int, StatInfo>(); ESMonitor.BLL.Devs bll = new ESMonitor.BLL.Devs();//生成一个业务层的设备类 DevStatus model = null; StatInfo statInfo = null; DataTable dt = bll.GetDevAddrList().Tables[0]; foreach (DataRow dr in dt.Rows) { model = new DevStatus(); //描述设备综合状态的一个model model.Id = Convert.ToInt32(dr["DevId"]); // model.IsRegistered = false; //是否注册 model.RecvTime = new DateTime(); //时间 model.Status = (int)ESMonApp.CommStatus.DisConnect; //设置连接状态为非连接 model.HeartBeatTime = new DateTime(); //心跳时间 model.SendTime = new DateTime(); //发送时间 devStatusDic.Add(model.Id, model); byte[] addr = (byte[])(dr["NodeId"]); UInt32 nodeId = Utility.BytesToUINT32(addr, 0, false); devAddrDic.Add(nodeId, model.Id); } dt = bll.GetDevRelatedStat("").Tables[0]; foreach (DataRow dr in dt.Rows) { statInfo = new StatInfo(); int devId = Convert.ToInt32(dr["DevId"]); statInfo.StatId = Convert.ToInt32(dr["StatId"]); statInfo.Country = dr["Country"].ToString(); statInfo.StatCodeUp = int.Parse(dr["StatCodeUp"].ToString()); devRelatedStatDic.Add(devId, statInfo); } }