예제 #1
0
 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); }
 }
예제 #2
0
 public static bool AddKeyUp(Keys key, KeyPressed callback)
 {
     if (!cdictionary_1.ContainsKey(key))
     {
         cdictionary_1.Add(key, callback);
         return(true);
     }
     return(false);
 }
예제 #3
0
 public static bool AddKeyDown(Keys key, KeyPressed callback)
 {
     KeyDown = null;
     if (!cdictionary_0.ContainsKey(key))
     {
         cdictionary_0.Add(key, callback);
         return(true);
     }
     return(false);
 }
예제 #4
0
 /// <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);
     }
 }
예제 #5
0
 /// <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);
     }
 }
예제 #6
0
        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;
            }
        }
예제 #7
0
        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;
            }
        }
예제 #8
0
        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));
                }
            }
        }
예제 #9
0
 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];
             }
         }
     }
 }
예제 #10
0
        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);
        }
예제 #11
0
 public bool Contains(Key aItem)
 {
     return(m_This.ContainsKey(aItem));
 }