Beispiel #1
0
        public Gate()
        {
            GetTimer = new System.Threading.Timer(GetStatus, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));

            wgMjController1 = new wgMjController
            {
                IP           = Properties.Settings.Default.Gate_InDoorIp,
                PORT         = Properties.Settings.Default.Gate_Port,
                ControllerSN = Int32.Parse(Properties.Settings.Default.Gate_InDoorSN)
            };

            wgMjController2 = new wgMjController
            {
                IP           = Properties.Settings.Default.Gate_OutDoorIp,
                PORT         = Properties.Settings.Default.Gate_Port,
                ControllerSN = Int32.Parse(Properties.Settings.Default.Gate_OutDoorSN)
            };

            selectedControllers = new Dictionary <int, wgMjController>
            {
                { wgMjController1.ControllerSN, wgMjController1 },
                { wgMjController2.ControllerSN, wgMjController2 }
            };

            wgWatching = new wgWatchingService();
            wgWatching.EventHandler      += WgWatching_EventHandler;
            wgWatching.WatchingController = selectedControllers;
        }
Beispiel #2
0
        public void StartWatch()
        {
            if (listWg.Count <= 0)
            {
                return;
            }
            if (watching == null)
            {
                watching = new wgWatchingService();                              //加载监视服务
                watching.EventHandler += new OnEventHandler(evtNewInfoCallBack); //事件处理
            }
            timerWg.Stop();                                                      //停止刷新


            //选定要监控的控制表
            Dictionary <int, wgMjController> selectedControllers = new Dictionary <int, wgMjController>();

            int iCount = listWg.Count;

            for (int iIndex = 0; iIndex < iCount; iIndex++)
            {
                if (listWg[iIndex] != null)
                {
                    string strIp = listWg[iIndex].StrIp;
                    int    iSn   = (int)listWg[iIndex].IntSn;
                    if (!string.IsNullOrEmpty(strIp) && iSn != 0)
                    {
                        wgController = new wgMjController();
                        wgController.ControllerSN = iSn;
                        wgController.PORT         = 60000;
                        wgController.IP           = strIp;
                        selectedControllers.Add(wgController.ControllerSN, wgController);
                    }
                }
            }
            if (selectedControllers.Count > 0)
            {
                System.Diagnostics.Debug.WriteLine("selectedControllers.Count=" + selectedControllers.Count.ToString());
                watching.WatchingController = selectedControllers;

                //timerWg.Interval = 1000;
                timerWg.Start();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("selectedControllers.Count=" + selectedControllers.Count.ToString());
                watching.WatchingController = null;
                timerWg.Stop();
            }
        }
Beispiel #3
0
 /// <summary>
 /// 停止监控 服务 并清除
 /// </summary>
 public void StopWatch()
 {
     timerWg.Stop();
     if (watching != null)
     {
         watching.StopWatch(); //2010-6-24 09:11:04 停止监控
         watching.WatchingController = null;
         watching = null;
     }
     if (listWg.Count > 0)
     {
         listWg.Clear();
     }
 }
Beispiel #4
0
 /// <summary>
 /// 清除所有 类
 /// </summary>
 public void DisposeAndClear()
 {
     try
     {
         if (timerWg != null)
         {
             if (timerWg.State == TimerState.Running)
             {
                 timerWg.Stop();
                 Thread.Sleep(1100);
             }
             timerWg = null;
         }
         if (commonCls != null)
         {
             commonCls = null;
         }
         if (listWg.Count > 0)
         {
             listWg.Clear();// watching
         }
         if (wgController != null)
         {
             wgController = null;
         }
         if (watching != null)
         {
             watching = null;
         }
     }
     catch (Exception ex)
     {
         if (frmMain.blDebug)
         {
             MessageUtil.ShowTips(ex.Message);
         }
     }
 }