Ejemplo n.º 1
0
        public FetchDeviceData[] Fetch(string[] deviceTypes, string lineId, string direction,int mileage, int segCnt, int sysSegCnt, bool IsBranch)
        {
            Hashtable hsDevName = new Hashtable();
               System.Collections.ArrayList retlist = new ArrayList();
               if(!lines.Contains( lineId+"-"+direction))
               throw new Exception(lineId+"-"+direction+",not Found");

               if(sysSegCnt>0)
               {
             int seg_cnt=0, sys_seg_cnt=0;
               I_Positionable p = FindFirst_Position(lineId, direction, mileage);
               do
               {
                   if (p.getDevType() == "C")
                   {
                       sys_seg_cnt++;
                       seg_cnt++;
                   }
                   if (p.getDevType() == "I")
                       seg_cnt++;

                   p = p.getPrevDev();
               } while (p != null && sys_seg_cnt < sysSegCnt);

               if (seg_cnt > segCnt)
                   segCnt = seg_cnt;

               }

               foreach(string type in  deviceTypes)
               {
               ArrayList tmplist;
              tmplist= Search(type,FindFirst_Position(lineId,direction,mileage),segCnt,0,IsBranch);
              foreach (FetchDeviceData data in tmplist)
              {
                  if (!hsDevName.Contains(data.DevName))
                  {
                      hsDevName.Add(data.DevName, data);
                      retlist.Add(data);
                  }
              }
               }

               FetchDeviceData[] ret = new FetchDeviceData[retlist.Count];
             //  retlist.Sort();
               for (int i = 0; i < retlist.Count; i++)
               ret[i] = retlist[i] as FetchDeviceData;

               return ret;
        }
Ejemplo n.º 2
0
        public FetchDeviceData[] Fetch(string[] deviceTypes, string lineId, int startMileage, int endMileage)
        {
            if (startMileage == endMileage)
               throw new Exception("起訖範圍不能相等!");
            System.Collections.ArrayList []lineDevices=new ArrayList[2];
            if (System.Convert.ToInt32(lineId.Substring(lineId.Length - 1, 1)) % 2 == 0)
            {
                lineDevices[0] = lines[lineId + "-" + "E"] as System.Collections.ArrayList;
                lineDevices[1] = lines[lineId + "-" + "W"] as System.Collections.ArrayList;

            }
            else
            {
                lineDevices[0] = lines[lineId + "-" + "N"] as System.Collections.ArrayList;
                lineDevices[1] = lines[lineId + "-" + "S"] as System.Collections.ArrayList;

            }
            int temp;

            if (startMileage > endMileage)
            {
                temp = startMileage;
                startMileage = endMileage;
                endMileage = temp;
            }

               System.Collections.ArrayList retAry=new ArrayList();
               foreach (string devType in deviceTypes)
               {
               for (int i = 0; i < lineDevices.Length; i++)
               {
                   foreach (object obj in lineDevices[i])
                   {
                       if (obj is DeviceBaseWrapper)
                       {
                           DeviceBaseWrapper dev = obj as DeviceBaseWrapper;
                           if (dev.mile_m >= startMileage && dev.mile_m < endMileage && dev.deviceType == devType)
                               retAry.Add(dev);

                       }
                   }

               }
               }

            FetchDeviceData[] ret = new FetchDeviceData[retAry.Count];

            for (int i = 0; i < retAry.Count; i++)
            {
                DeviceBaseWrapper wraper=retAry[i] as DeviceBaseWrapper;

                ret[i] = new FetchDeviceData(wraper.deviceName, 0,wraper.lineid,wraper.direction,wraper.mile_m,
                    Program.matrix.line_mgr[lineId].getSectionByMile(wraper.direction,wraper.mile_m).maxSpeed,
                    Program.matrix.line_mgr[lineId].getSectionByMile(wraper.direction,wraper.mile_m).minSpeed);
            }

            return ret;
        }