示例#1
0
        /// <summary>
        /// 分配车位、ETV
        /// </summary>
        private void AllocateLctAndEtv(out CSMG etv, out CLocation lct, IList <CSMG> workList, Dictionary <CSMG, CScope> dicWorkScope, bool isMax)
        {
            etv = null;
            lct = null;
            IList <CSMG> freeEtvList = FreeDeviceListOfWorkScope(workList);
            int          count       = freeEtvList.Count;

            switch (count)
            {
            case 0:
                FindNearestEtvAndLct(out etv, out lct, workList, dicWorkScope, isMax);
                break;

            case 1:
                etv = freeEtvList[0];
                lct = AllocateLocation(dicWorkScope[etv], isMax);
                break;

            case 2:
                FindNearestEtvAndLct(out etv, out lct, freeEtvList, dicWorkScope, isMax);
                break;

            default:
                break;
            }
        }
示例#2
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);
        }
示例#3
0
 /// <summary>
 /// 获取指定ETV当前地址
 /// </summary>
 /// <param name="eid"></param>
 /// <returns></returns>
 public string GetEtvCurrAddress(int eid)
 {
     if (EqpStates != null)
     {
         CStatCode[] codes = this.SelectStatusCodes(eid);
         if (codes[1].CurrentValue == 0 || codes[1].CurrentValue < 1 || codes[1].CurrentValue > 20)
         {
             CSMG etv = this.SelectSMG(eid);
             return(etv.CurrAddress);   //已经实时保存了ETV的当前地址的
         }
         string line  = codes[0].CurrentValue.ToString();
         string layer = codes[2].CurrentValue.ToString();
         string list  = "";
         if (codes[1].CurrentValue < 10)
         {
             list = "0" + codes[1].CurrentValue.ToString();
         }
         else
         {
             list = codes[1].CurrentValue.ToString();
         }
         string address = line + list + layer;
         return(address);
     }
     return(null);
 }
示例#4
0
        /// <summary>
        /// 设置车厅出车类型
        /// </summary>
        /// <param name="hnmb"></param>
        /// <param name="htype"></param>
        /// <returns></returns>
        public int SetHallType(int hnmb, CSMG.EnmHallType htype)
        {
            try
            {
                CSMG smg = this.SelectSMG(hnmb);
                if (smg != null && smg.SMGType == CSMG.EnmSMGType.Hall)
                {
                    if (smg.HallType != htype)
                    {
                        CWTask wtsk = new CWTask();

                        if (htype == CSMG.EnmHallType.EnterorExit)
                        {
                            smg.HallType = htype;
                            CWData.myDB.UpdateHallType(smg.ID, htype);
                            return(0);
                        }
                        else if (htype == CSMG.EnmHallType.Entance)
                        {
                            if (wtsk.GetMasterTaskNumOfHid(hnmb, CMasterTask.EnmMasterTaskType.GetCar) == 0)
                            {
                                smg.HallType = htype;
                                CWData.myDB.UpdateHallType(smg.ID, htype);
                                return(0);
                            }
                            else
                            {
                                return(11);
                            }
                        }
                        else if (htype == CSMG.EnmHallType.Exit)
                        {
                            if (wtsk.GetMasterTaskNumOfHid(hnmb, CMasterTask.EnmMasterTaskType.SaveCar) == 0)
                            {
                                smg.HallType = htype;
                                CWData.myDB.UpdateHallType(smg.ID, htype);
                                return(0);
                            }
                            else
                            {
                                return(12);
                            }
                        }
                    }
                }
                return(0);
            }
            catch (Exception ex)
            {
                HttpRuntime.Cache.Remove("SMGs");
                throw ex;
            }
        }
示例#5
0
 /// <summary>
 /// 更新设备的子作业及主作业号
 /// </summary>
 /// <param name="smg"></param>
 public void UpdateSMGTaskStat(CSMG smg)
 {
     try
     {
         CSMG eqp = this.SelectSMG(smg.ID); //更新内存实际引用对象
         eqp.nIsWorking = smg.nIsWorking;
         eqp.NextTaskId = smg.NextTaskId;
         eqp.MTskID     = smg.MTskID;
         CWData.myDB.UpdateSMGTaskStat(eqp);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
        /// <summary>
        /// 更新设备的available
        /// </summary>
        public void UpdateSMGStatus(int EtvID, bool isAvail, CSMG.EnmModel model)
        {
            CSMG etv = SelectSMG(EtvID);

            if (etv == null)
            {
                throw new Exception("SMG ID无效!");
            }
            else
            {
                etv.Available = isAvail;
                etv.Model     = model;
                //更新数据库
                CWData.myDB.UpdateSMGStat(etv.ID, etv.Available, etv.Model);
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="smg"></param>
        /// <returns></returns>
        public static string SMGModelFormatting(CSMG smg)
        {
            string s = "";

            switch (smg.Model)
            {
            case EnmModel.AutoStarting:
                s = "自动启动中";
                break;

            case EnmModel.AutoStarted:
                s = "单机全自动";
                break;

            case EnmModel.AutoAligning:
                s = "自动分配";
                break;

            case EnmModel.AutoPending:
                s = "自动挂起";
                break;

            case EnmModel.AutoStopped:
                s = "自动停止";
                break;

            case EnmModel.AutoStopping:
                s = "自动停止中";
                break;

            default:
                s = "";
                break;
            }

            return(s);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
0
        private void DealLed4Message()
        {
            #region
            while (isStart)
            {
                try
                {
                    int total;
                    int space;
                    int occupy;
                    int fixLct;
                    int spaceBigLct;
                    Program.mng.SelectLctofInfo(out total, out space, out occupy, out fixLct, out spaceBigLct);

                    CMasterTask[] mtsks   = Program.mng.GetAllMasterTaskOfHid(14);
                    string        dataStr = "";
                    CSMG          hall    = Program.mng.SelectSMG(14);
                    if (hall.Available)
                    {
                        #region 作业
                        if (hall.nIsWorking != 0)
                        {
                            CMasterTask gmtsk = null;
                            if (mtsks != null)
                            {
                                foreach (CMasterTask mtsk in mtsks)
                                {
                                    foreach (CTask tsk in mtsk.Tasks)
                                    {
                                        if (hall.nIsWorking == tsk.ID)
                                        {
                                            gmtsk = mtsk;
                                        }
                                    }
                                }
                            }
                            if (gmtsk != null)
                            {
                                if (gmtsk.ICCardCode != "")
                                {
                                    if (gmtsk.Type == EnmMasterTaskType.GetCar)
                                    {
                                        dataStr = "当前取车卡号:" + gmtsk.ICCardCode;
                                    }
                                    else if (gmtsk.Type == EnmMasterTaskType.SaveCar)
                                    {
                                        dataStr = "当前存车卡号:" + gmtsk.ICCardCode;
                                    }
                                    else
                                    {
                                        dataStr = "当前作业卡号:" + gmtsk.ICCardCode;
                                    }
                                }
                            }
                        }
                        else
                        {
                            dataStr = "剩余空闲车位:" + space.ToString() + "  其中大车位:" + spaceBigLct.ToString();
                        }
                        #endregion
                    }
                    else
                    {
                        dataStr = " 正在维护,请稍后存取车";
                    }

                    if (dataStr != "")
                    {
                        if (string.Compare(dataStr, dataStr4) != 0)
                        {
                            myDelegate.DisplayLed4Title(dataStr);
                            dataStr4 = dataStr;
                        }
                    }

                    if (isStart)
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception ex)
                {
                    CWSException.WriteError(ex.ToString());
                    Thread.Sleep(10000);
                }
            }
            #endregion
        }
示例#11
0
 public EtvMaxScope(CSMG pEtv, IList <CSMG> pEtvList, CScope physicScope)
 {
     cETV             = pEtv;
     etvList          = pEtvList;
     mPhysicWorkScope = physicScope;
 }
示例#12
0
 public CWTaskTran(int hallID) : this()
 {
     moHall = (new CWSMG()).SelectSMG(hallID);
 }
示例#13
0
 public EtvWorkScope(CSMG mETV, IList <CSMG> mEtvList)
 {
     cETV    = mETV;
     etvList = mEtvList;
 }
示例#14
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);
        }
示例#15
0
        /// <summary>
        /// 缴费出车:依作业范围内找出可达车位的ETV集合1,找出空闲的ETV集合2,
        /// 依集合2找出最近的ETV,如果找不到,查找集合2,
        /// 后依ETV可达的作业范围找出距离车位最近的出车厅,如果找不到,则依ETV的物理范围找出
        /// 距离最近的车厅
        /// </summary>
        public void AllocateEtvAndHall(IList <CSMG> Etvs, IList <CSMG> Halls, CLocation lct, out CSMG Etv, out CSMG Hall)
        {
            Etv     = null;
            Hall    = null;
            ETVList = Etvs;
            Dictionary <CSMG, CScope> dicWork    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> dicMaxWork = mScopeService.DicMaxScope;

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

            IList <CSMG> EtvWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, dicWork);
            if (EtvWorkList.Count > 0)
            {
                IList <CSMG> freeWorkList = FreeDeviceListOfWorkScope(EtvWorkList);
                if (freeWorkList.Count == 0)
                {
                    Etv = NearestEtvToAddress(lct.Address, EtvWorkList, lct.Region);
                }
                else if (freeWorkList.Count == 1)
                {
                    Etv = freeWorkList[0];
                }
                else //从空闲ETV集合中查找
                {
                    Etv = NearestEtvToAddress(lct.Address, freeWorkList, lct.Region);
                }
            }
            else   //从最大作业范围内找出
            {
                IList <CSMG> maxWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, dicMaxWork);
                foreach (CSMG allocateEtv in maxWorkList)
                {
                    if (new CWSMG().CheckEtvMode(allocateEtv.ID))
                    {
                        Etv = allocateEtv;
                        break;
                    }
                }
            }
            //找好ETV后,找出合适的车厅
            if (Etv != null)
            {
                CScope scope = dicWork[Etv];
                //先分配在此区域内的车厅,如果两个车厅都不可达,才能考虑跨区分配
                IList <CSMG> availHalls = NearHallLists(scope, Halls, lct.Address, lct.Region);
                if (availHalls.Count > 0)
                {
                    IList <CSMG> freeHalls = new List <CSMG>();
                    foreach (CSMG hall in availHalls)
                    {
                        if (hall.nIsWorking == 0)
                        {
                            freeHalls.Add(hall);
                        }
                    }
                    if (freeHalls.Count > 0)
                    {
                        Hall = freeHalls[0];
                    }
                    else
                    {
                        Hall = availHalls[0];
                    }
                }
                //ETV工作范围内不包含可用的出车厅,则从物理范围内查找
                if (Hall == null)
                {
                    CScope       mScope   = dicMaxWork[Etv];
                    IList <CSMG> maxHalls = NearHallLists(mScope, Halls, lct.Address, lct.Region);
                    if (maxHalls.Count > 0)
                    {
                        Hall = maxHalls[0];
                    }
                }
            }
        }