Beispiel #1
0
        /// <summary>
        /// 找出离车厅最近的可用ETV
        /// </summary>
        private bool FindNearestEtvAndLct(out CSMG etv, out CLocation lct, IList <CSMG> EtvList, Dictionary <CSMG, CScope> dicScope, bool isMax)
        {
            etv = null;
            lct = null;
            CWSMG        cwsmg        = new CWSMG();
            IList <CSMG> fNeareasEtvs = SortedByAddress(pHall.Address, EtvList, pHall.Region); //排序

            if (fNeareasEtvs.Count == 0)
            {
                return(false);
            }
            foreach (CSMG smg in fNeareasEtvs)
            {
                if (cwsmg.CheckEtvMode(smg.ID))
                {
                    lct = AllocateLocation(dicScope[smg], isMax);
                    if (lct != null)
                    {
                        etv = smg;
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #2
0
 /// <summary>
 /// 依所有可达该地址的ETV集合,找出空闲的ETV集合
 /// </summary>
 /// <param name="pWorkList"></param>
 /// <returns></returns>
 protected IList <CSMG> FreeDeviceListOfWorkScope(IList <CSMG> pWorkList)
 {
     try
     {
         CWSMG        cwsmg   = new CWSMG();
         IList <CSMG> devices = new List <CSMG>();
         foreach (CSMG smg in pWorkList)
         {
             if (cwsmg.CheckEtvMode(smg.ID) && smg.nIsWorking == 0)
             {
                 devices.Add(smg);
             }
         }
         return(devices);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 从ETV集合中,找出作业范围包含车位地址的ETV
 /// </summary>
 /// <param name="EtvLists">ETV集合</param>
 /// <param name="dicScope">ETV的作业范围集合</param>
 /// <param name="address">要包含的地址</param>
 /// <returns></returns>
 protected int FindEtvScopeInLocation(IList <CSMG> EtvLists, Dictionary <CSMG, CScope> dicScope, string address)
 {
     try
     {
         CWSMG cwsmg = new CWSMG();
         int   col   = clcCommom.GetColOfAddress(address);
         foreach (CSMG smg in EtvLists)
         {
             if (cwsmg.CheckEtvMode(smg.ID))
             {
                 CScope scope = dicScope[smg];
                 if (col >= scope.LeftCol && col <= scope.RightCol)
                 {
                     return(smg.ID);
                 }
             }
         }
         return(0);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 临时卡/定期卡 分配原则:先从ETV的作业范围找出可达车厅的ETV集合,从集合中找出与车厅区域一致的ETV
        /// 依ETV作业范围,找出适合车型的最近的车位。
        /// </summary>
        /// <param name="smgID">移动设备ID</param>
        /// <param name="CarSize">车辆外形</param>
        /// <param name="hall">当前存车车厅</param>
        /// <param name="lcts">所有车位集合</param>
        /// <param name="SMGs">所有移动设备集合</param>
        /// <returns></returns>
        public CLocation Allocate(out int smgID, string CarSize, CSMG hall, IList <CLocation> lcts, IList <CSMG> SMGs)
        {
            pHall     = hall;
            carsize   = CarSize;
            locations = lcts;
            ETVList   = SMGs; //建立ETV工作区域

            CLocation lct = null;
            CSMG      smg = null;

            smgID = 0;
            Dictionary <CSMG, CScope> workScope    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;

            #region 记录日志
            try
            {
                StringBuilder sb = new StringBuilder();
                foreach (CSMG esmg in SMGs)
                {
                    CScope workspe = workScope[esmg];
                    CScope maxspe  = maxWorkScope[esmg];
                    sb.AppendLine(string.Format("Etv" + esmg.ID + "  工作范围:" + workspe.LeftCol + "-" + workspe.RightCol + "  物理范围:" + maxspe.LeftCol + "-" + maxspe.RightCol));
                }
                new CWSException(sb.ToString(), 2);
            }
            catch
            { }
            #endregion
            //获取工作范围内能到达车厅列的ETV的集合
            IList <CSMG> workEtvList = AddressInEtvWorkScope(pHall.Region, pHall.Address, workScope);
            if (workEtvList.Count > 0)
            {
                AllocateLctAndEtv(out smg, out lct, workEtvList, workScope, false); //先找ETV,再找车位的
            }
            if (lct == null || smg == null)                                         //工作范围内没有可达的ETV,则从最大工作范围内查找
            {
                IList <CSMG> maxWorkList = AddressInEtvWorkScope(pHall.Region, pHall.Address, maxWorkScope);
                if (maxWorkList.Count > 0)
                {
                    AllocateLctAndEtv(out smg, out lct, maxWorkList, maxWorkScope, true);
                }
            }
            //如果再找不到的话,则判断当前ETV集合,找出模式为全自动的,强制分配,车位也依全库分配
            CWSMG cwsmg = new CWSMG();
            if (lct == null || smg == null)
            {
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in SMGs
                                       where cwsmg.CheckEtvMode(ee.ID) == true &&
                                       ee.Available == true
                                       orderby Math.Abs(ee.Region - hall.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                foreach (CSMG se in lastList)
                {
                    CScope scope = maxWorkScope[se];
                    lct = this.AllocateLocation(scope, true);
                    if (lct != null)
                    {
                        smg = se;
                        break;
                    }
                }
            }
            if (smg != null)
            {
                smgID = smg.ID;
            }
            return(lct);
        }
Beispiel #5
0
        /// <summary>
        /// 固定卡存车:可达进车厅的Etv集合,找出空闲的,可达车位的ETV
        /// </summary>
        /// <param name="hall"></param>
        /// <param name="etvs"></param>
        /// <returns></returns>
        public int AllocateEtv(CSMG hall, CLocation toLct, IList <CSMG> etvs)
        {
            int etvID  = 0;
            int lctCol = clcCommom.GetColOfAddress(toLct.Address);

            ETVList = etvs;
            Dictionary <CSMG, CScope> workScope = mScopeService.DicWorkScope;

            IList <CSMG> workETVList = AddressInEtvWorkScope(hall.Region, hall.Address, workScope);

            if (workETVList.Count > 0)
            {
                IList <CSMG> freeEtvList = FreeDeviceListOfWorkScope(workETVList);
                if (freeEtvList.Count == 0)
                {
                    //无空闲ETV,则从工作范围内找出离车厅最近且可达车位的ETV
                    etvID = FindEtvScopeInLocation(workETVList, workScope, toLct.Address);
                }
                else if (freeEtvList.Count == 1)
                {
                    CSMG   etv   = freeEtvList[0];
                    CScope scope = mScopeService.DicWorkScope[etv];
                    if (scope.LeftCol <= lctCol && scope.RightCol >= lctCol)
                    {
                        etvID = etv.ID;
                    }
                    else
                    {
                        etvID = FindEtvScopeInLocation(workETVList, workScope, toLct.Address);
                    }
                }
                else
                {
                    foreach (CSMG smg in freeEtvList)
                    {
                        CScope scope = mScopeService.DicWorkScope[smg];
                        if (scope.LeftCol <= lctCol && scope.RightCol >= lctCol)
                        {
                            etvID = smg.ID;
                            break;
                        }
                    }
                }
            }

            //如果工作范围内找不出可达车位的ETV,则从物理范围内找出可达的
            if (etvID == 0)
            {
                Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;
                IList <CSMG> maxWorkEtvList            = AddressInEtvWorkScope(hall.Region, hall.Address, maxWorkScope); //找出能到达车厅的
                if (maxWorkEtvList.Count > 0)
                {
                    etvID = FindEtvScopeInLocation(maxWorkEtvList, maxWorkScope, toLct.Address); //找出能到达车位的
                }
            }

            //找出模式为全自动的,强制分配
            if (etvID == 0)
            {
                CWSMG       cwsmg    = new CWSMG();
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in etvs
                                       where cwsmg.CheckEtvMode(ee.ID) == true
                                       orderby Math.Abs(ee.Region - hall.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                if (etvsList.Count > 1)
                {
                    etvID = etvsList[0].ID;
                }
            }
            return(etvID);
        }
Beispiel #6
0
        /// <summary>
        /// 厅外刷卡取车:先从ETV工作范围内找出可达车位的ETV集合(依工作区域大小排序),再找出空闲的ETV集合
        /// 先从空闲ETV集合中找出可达出车厅的ETV,如果找不到,再从工作范围内找出车位的ETV集合找出可达出车厅的ETV
        /// 再找不到的,则从最大作业范围内找出可达车位的ETV集合,再从中找出可达车厅的且是可用的ETV
        /// </summary>
        public int AllocateEtv(CLocation lct, string hall_Address, IList <CSMG> Etvs)
        {
            int eID     = 0;
            int hallCol = clcCommom.GetColOfAddress(hall_Address);

            ETVList = Etvs;
            Dictionary <CSMG, CScope> workScope    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;

            #region 记录日志
            try
            {
                StringBuilder sb = new StringBuilder();
                foreach (CSMG esmg in Etvs)
                {
                    CScope workspe = workScope[esmg];
                    CScope maxspe  = maxWorkScope[esmg];
                    sb.AppendLine(string.Format("Etv" + esmg.ID + "  工作范围:" + workspe.LeftCol + "-" + workspe.RightCol + "  物理范围:" + maxspe.LeftCol + "-" + maxspe.RightCol));
                }
                new CWSException(sb.ToString(), 2);
            }
            catch
            { }
            #endregion

            //找出工作范围内可达车位的ETV集合
            IList <CSMG> EtvWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, workScope);
            if (EtvWorkList.Count > 0)
            {
                IList <CSMG> FreeEtvList = FreeDeviceListOfWorkScope(EtvWorkList);
                if (FreeEtvList.Count == 0)
                {
                    //无空闲的ETV,从工作范围可达车位的ETV集合中找出可达出车厅的ETV
                    eID = FindEtvScopeInLocation(EtvWorkList, workScope, hall_Address);
                }
                else if (FreeEtvList.Count == 1)
                {
                    CSMG   etv   = FreeEtvList[0];
                    CScope scope = workScope[etv];
                    if (hallCol >= scope.LeftCol && hallCol <= scope.RightCol)
                    {
                        eID = etv.ID;
                    }
                    else
                    {
                        eID = FindEtvScopeInLocation(EtvWorkList, workScope, hall_Address);
                    }
                }
                else
                {
                    foreach (CSMG smg in FreeEtvList)
                    {
                        CScope scope = workScope[smg];
                        if (hallCol >= scope.LeftCol && hallCol <= scope.RightCol)
                        {
                            eID = smg.ID;
                            break;
                        }
                    }
                }
            }

            //如果从工作范围内找不到可达出车厅的ETV,则从物理作业范围内找出可用的ETV
            if (eID == 0)
            {
                IList <CSMG> maxWorkEtvList = AddressInEtvWorkScope(lct.Region, lct.Address, maxWorkScope); //到达车位
                if (maxWorkEtvList.Count > 0)
                {
                    eID = FindEtvScopeInLocation(maxWorkEtvList, maxWorkScope, hall_Address); //到达车厅
                }
            }

            //找出模式为全自动的,强制分配
            if (eID == 0)
            {
                CWSMG       cwsmg    = new CWSMG();
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in Etvs
                                       where cwsmg.CheckEtvMode(ee.ID) == true
                                       orderby Math.Abs(ee.Region - lct.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                if (etvsList.Count > 1)
                {
                    eID = etvsList[0].ID;
                }
            }
            return(eID);
        }