Esempio n. 1
0
        private void loadMainLineVD(DevcieManager devMgr)
        {
            foreach (DeviceBaseWrapper dev in devMgr.getDataDeviceEnum())
            {
                try
                {
                    if (dev is VDDeviceWrapper)
                    {
                        VDDeviceWrapper vddev = dev as VDDeviceWrapper;
                        if (dev.location == "F" || dev.location == "H" || dev.location == "T")
                        {
                            //  dictVD.Add(dev.deviceName,  vddev);
                            if (!CanTriggerCSLSEvent(vddev))
                                continue;
                            vddev.OnCSLSControlEvent += new CSLSControlEventHandler(vddev_OnCSLSControlEvent);

                        }
                    }
                }
                catch (Exception ex)
                {
                    ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
                }

            }
            ConsoleServer.WriteLine("速限管理啟動完成!");
        }
Esempio n. 2
0
        private void loadMainLineVD(DevcieManager devMgr)
        {
            foreach (DeviceBaseWrapper dev in devMgr.getDataDeviceEnum())
               {
               if (dev is VDDeviceWrapper)
               {
                   if (!lines.Contains(dev.lineid + "-" + dev.direction))
                   {
                       lines.Add(dev.lineid + "-" + dev.direction, ArrayList.Synchronized(new System.Collections.ArrayList()));
                       lineJamRanges.Add(dev.lineid + "-" + dev.direction, ArrayList.Synchronized(new System.Collections.ArrayList()));
                       lineDegree2and1JamRanges.Add(dev.lineid + "-" + dev.direction, ArrayList.Synchronized(new System.Collections.ArrayList()));
                   }

                   if (dev.location == "F" || dev.location == "H" || dev.location == "T")
                   {
                       htVDDevices.Add(dev.deviceName, dev);
                        ((ArrayList)lines[dev.lineid + "-" + dev.direction]).Add(dev);
                   }

               }
               }

               IDictionaryEnumerator ie = lines.GetEnumerator();  //取得所有的路線
               while (ie.MoveNext())
               {
               ((ArrayList)ie.Value).Sort();   //排序所有的車輛偵測器

               ArrayList vdlist = (ArrayList)ie.Value;
               if (vdlist.Count == 1)
                   (vdlist[0] as DeviceBaseWrapper).AryInx = 0;

               // 填上前後車輛偵測器鏈結
               if (vdlist.Count > 1)
                   for (int i = 0; i < vdlist.Count; i++)
                   {
                       ((DeviceBaseWrapper)vdlist[i]).AryInx = i;

                       if (i == 0)
                           ((DeviceBaseWrapper)vdlist[i]).NextDevice = vdlist[i + 1] as DeviceBaseWrapper;
                       else if (i == vdlist.Count - 1)
                           ((DeviceBaseWrapper)vdlist[i]).PreDevice = vdlist[i - 1] as DeviceBaseWrapper;
                       else
                       {
                           ((DeviceBaseWrapper)vdlist[i]).PreDevice = vdlist[i - 1] as DeviceBaseWrapper;
                           ((DeviceBaseWrapper)vdlist[i]).NextDevice = vdlist[i + 1] as DeviceBaseWrapper;
                       }

                   }

               }

               // oneMinTmr.Elapsed += new System.Timers.ElapsedEventHandler(oneMinTmr_Elapsed);
               // oneMinTmr.Start();
               oneMinTmr = new System.Threading.Timer(new System.Threading.TimerCallback(oneMinTmr_Elapsed));
               oneMinTmr.Change(0, 60 * 1000);

               ConsoleServer.WriteLine("壅塞管理啟動完成!");
        }