private void ReadForData_EventHandler_1(object sender, DownEventArgs e) { try { CDownConf info = e.Value; //$60031G12000828 string rawData = e.RawData; if (info == null) { return; } string stationid = rawData.Substring(1, 4); string type = rawData.Substring(5, 4); string data = rawData.Substring(9, 6); if (type == "1G12") { if (info.StorageWater.HasValue) { if (readDataDic.ContainsKey(stationid)) { readDataDic[stationid] = data; } readDataDic.Add(stationid, data); } } } catch (Exception exp) { Debug.WriteLine(exp.Message); } }
public static bool AddKeyUp(Keys key, KeyPressed callback) { if (!cdictionary_1.ContainsKey(key)) { cdictionary_1.Add(key, callback); return(true); } return(false); }
public static bool AddKeyDown(Keys key, KeyPressed callback) { KeyDown = null; if (!cdictionary_0.ContainsKey(key)) { cdictionary_0.Add(key, callback); return(true); } return(false); }
/// <summary> /// 添加一个键弹起的钩子处理 /// </summary> /// <param name="key">弹起的键</param> /// <param name="callback">按键的处理事件函数</param> public static bool AddKeyUp(Keys key, KeyPressed callback) { if (!handledKeysUp.ContainsKey(key)) { handledKeysUp.Add(key, callback); return(true); } else { return(false); } }
/// <summary> /// 添加一个按下键的钩子处理 /// </summary> /// <param name="key">按下的键</param> /// <param name="callback">按键的处理事件函数</param> public static bool AddKeyDown(Keys key, KeyPressed callback) { KeyDown = null; if (!handledKeysDown.ContainsKey(key)) { handledKeysDown.Add(key, callback); return(true); } else { return(false); } }
public void GetDtuList(int uID, string sID, string cmds, string gprsNum, bool isset) { try { DownRequest request = new DownRequest { StationId = sID, Cmds = cmds, GprsNum = gprsNum, IsSet = isset }; DownConf info = grpcClient.GetDownConf(request); downConfList = new CDictionary <int, DownConf>(); if (info != null) { if (downConfList.ContainsKey(uID)) { downConfList[uID] = info; } else { downConfList.Add(uID, info); } } } catch (Exception exp) { Debug.WriteLine("RPC failed" + exp); throw; } }
public void GetOLStatus(int uID, string subcenterId) { try { Subcenter sub = new Subcenter { SubcenterdId = subcenterId }; DtuList list = grpcClient.GetDtuList(sub); dtuList = new CDictionary <int, DtuList>(); if (list != null) { if (dtuList.ContainsKey(uID)) { dtuList[uID] = list; } else { dtuList.Add(uID, list); } } } catch (Exception exp) { Debug.WriteLine("RPC failed" + exp); throw; } }
private void ReadSDXml() { m_mapStationData = new CDictionary <string, CEntityStation>(); m_mapStationbeidouID = new CDictionary <string, string>(); m_mapStationgprsID = new CDictionary <string, string>(); // 读取XML,初始化站点数据表 List <CEntityStation> listSD = Deserialize(); if (null == listSD) { return; } for (int i = 0; i < listSD.Count; ++i) { try { if (!m_mapStationData.ContainsKey(listSD[i].StationID)) { // 通知界面 m_mapStationData.Add(listSD[i].StationID, listSD[i]); m_mapStationbeidouID.Add(listSD[i].StationID, listSD[i].BDSatellite); m_mapStationgprsID.Add(listSD[i].StationID, listSD[i].GPRS); } else { // 位置站点,读取站点数据文件不匹配 System.Diagnostics.Debug.WriteLine(string.Format("站点数据中站点\"{0}\"已存在", listSD[i].StationID)); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(string.Format("站点数据异常" + e)); } } }
public void InitMap() { String[] rows = File.ReadAllLines("Config/map.txt"); foreach (String row in rows) { String[] pieces = row.Split(','); if (pieces.Length == 2) { if (!HdProtocolMap.ContainsKey(pieces[0])) { HdProtocolMap.Add(pieces[0], pieces[1]); } else { HdProtocolMap[pieces[0]] = pieces[1]; } } } }
public ReadDatas GetReadDatas(ReadRequest request) { readDataDic = new CDictionary <string, string>(); ReadDatas readDatas = new ReadDatas(); m_timer_1.Start(); if (request.RType == ReadRequest.Types.readType.ReadStoredWater) { CProtocolEventManager.DownForData += ReadForData_EventHandler_1; foreach (var id in request.SList.Ids) { CEntityStation station = CDBDataMgr.Instance.GetStationById(id); CPortDataMgr.Instance.GroupStorageWaterFirst(station); } } else if (request.RType == ReadRequest.Types.readType.ReadRealWater) { CProtocolEventManager.DownForData += ReadForData_EventHandler_2; foreach (var id in request.SList.Ids) { CEntityStation station = CDBDataMgr.Instance.GetStationById(id); CPortDataMgr.Instance.GroupRealityWater(station); } } else if (request.RType == ReadRequest.Types.readType.ReadRain) { CProtocolEventManager.DownForData += ReadForData_EventHandler_3; foreach (var id in request.SList.Ids) { CEntityStation station = CDBDataMgr.Instance.GetStationById(id); CPortDataMgr.Instance.GroupRainWater(station); } } //else if (request.RType == ReadRequest.Types.readType.ReadSoil) //{ // foreach (var id in request.SList.Ids) // { // CEntityStation station = CDBDataMgr.Instance.GetStationById(id); // CPortDataMgr.Instance.GroupSoilWater(station); // } //} //等待读取完成 while (true) { // 等待 if (timeDown_1) { foreach (var id in request.SList.Ids) { if (readDataDic.ContainsKey(id)) { readDatas.RData.Add(new ReadData() { StationId = id, Data = readDataDic[id] }); } else { readDatas.RData.Add(new ReadData() { StationId = id, Data = "" }); } } break; } } m_timer_1.Stop(); CProtocolEventManager.DownForData -= ReadForData_EventHandler_1; CProtocolEventManager.DownForData -= ReadForData_EventHandler_2; CProtocolEventManager.DownForData -= ReadForData_EventHandler_3; return(readDatas); }
public bool Contains(Key aItem) { return(m_This.ContainsKey(aItem)); }