Example #1
0
        public void DoTask(uint devid, DevCarrierTaskE carriertask, bool isoversize = false)
        {
            if (Monitor.TryEnter(_obj, TimeSpan.FromSeconds(2)))
            {
                try
                {
                    CarrierTask task = DevList.Find(c => c.ID == devid);
                    if (task != null)
                    {
                        if (task.OperateMode == DevOperateModeE.自动)
                        {
                            if (task.Status == DevCarrierStatusE.停止 && task.Task == carriertask && task.FinishTask == carriertask)
                            {
                                carriertask = DevCarrierTaskE.终止;
                            }
                        }
                        else
                        {
                            carriertask = DevCarrierTaskE.终止;
                        }

                        task.DoTask(carriertask, isoversize ? DevCarrierSizeE.超限 : DevCarrierSizeE.非超限);
                    }
                }
                finally { Monitor.Exit(_obj); }
            }
        }
Example #2
0
 internal bool HaveCarrierTaskInTrack(uint trackid, DevCarrierTaskE carriertype)
 {
     return(DevList.Exists(c => c.TrackId == trackid &&
                           c.ConnStatus == SocketConnectStatusE.通信正常 &&
                           c.OperateMode == DevOperateModeE.自动 &&
                           c.Task == carriertype &&
                           c.Task != c.FinishTask));
 }
Example #3
0
 internal bool IsCarrierInTask(uint carrier_id, DevCarrierTaskE task)
 {
     return(DevList.Exists(c => c.ID == carrier_id &&
                           c.ConnStatus == SocketConnectStatusE.通信正常 &&
                           c.OperateMode == DevOperateModeE.自动 &&
                           c.Task == task &&
                           c.Task != c.FinishTask));
 }
Example #4
0
        public bool HaveFerryOnTileTrack(ushort ferry_code, DevCarrierTaskE type, out string result)
        {
            if (!Monitor.TryEnter(_obj, TimeSpan.FromSeconds(2)))
            {
                result = "稍后再试!";
                return(false);
            }
            try
            {
                Track track = PubMaster.Track.GetTrackByCode(ferry_code);
                if (track != null)
                {
                    if (track.Type == TrackTypeE.摆渡车_入 || track.Type == TrackTypeE.摆渡车_出)
                    {
                        result = "小车已经在摆渡车上了!";
                        return(true);
                    }
                    FerryTask task = null;
                    if (type == DevCarrierTaskE.前进至摆渡车)
                    {
                        task = DevList.Find(c => c.IsOnSite(track.ferry_down_code));
                    }

                    if (type == DevCarrierTaskE.后退至摆渡车)
                    {
                        task = DevList.Find(c => c.IsOnSite(track.ferry_up_code));
                    }

                    if (task == null)
                    {
                        result = "找不到对应轨道(" + track.name + ")的摆渡车设备信息";
                        mlog.Status(true, result);
                        return(false);
                    }

                    if (!CheckFerryStatus(task, out result))
                    {
                        mlog.Status(true, task.Device.name + "摆渡车HaveFerryOnTileTrack()" + result);
                        return(false);
                    }

                    if (task.Status == DevFerryStatusE.停止)
                    {
                        return(true);
                    }
                    mlog.Status(true, task.Device.name + "摆渡车HaveFerryOnTileTrack()" + result);
                }
            }
            finally
            {
                Monitor.Exit(_obj);
            }
            result = "没有符合条件的摆渡车!";
            return(false);
        }
Example #5
0
        /// <summary>
        /// 判断小车是否处于任务
        /// </summary>
        /// <param name="carrier_id"></param>
        /// <param name="carriertask"></param>
        /// <returns></returns>
        internal bool IsTaskAndDoTask(uint carrier_id, DevCarrierTaskE carriertask)
        {
            CarrierTask task = DevList.Find(c => c.ID == carrier_id);

            if (task != null)
            {
                if (task.Task == carriertask && task.FinishTask == DevCarrierTaskE.终止)
                {
                    return(true);
                }
                task.DoTask(carriertask, DevCarrierSizeE.非超限);
            }
            return(false);
        }
Example #6
0
        public bool DoManualTask(uint devid, DevCarrierTaskE carriertask, out string result, bool isoversize = false)
        {
            bool   isferryupsite = false;
            ushort trackcode     = PubTask.Carrier.GetCarrierSite(devid);

            if (trackcode == 0)
            {
                result = "小车当前站点为0";
                return(false);
            }
            switch (carriertask)
            {
            case DevCarrierTaskE.后退取砖:
                if (IsLoad(devid))
                {
                    result = "运输车有货不能后退取砖!";
                    return(false);
                }
                break;

            case DevCarrierTaskE.前进放砖:
                if (IsNotLoad(devid))
                {
                    result = "运输车没有货不能前进放货!";
                    return(false);
                }
                isferryupsite = true;
                break;

            case DevCarrierTaskE.后退至摆渡车:
            case DevCarrierTaskE.前进至摆渡车:
                #region [判断是否有摆渡车]
                if (carriertask == DevCarrierTaskE.后退至摆渡车 &&
                    !((trackcode >= 200 && trackcode < 300) || (trackcode >= 600 && trackcode < 700)))
                {
                    result = "小车需要在入库轨道头或者上砖轨道";
                    return(false);
                }
                if (carriertask == DevCarrierTaskE.前进至摆渡车 &&
                    !((trackcode >= 500 && trackcode < 600) || (trackcode >= 100 && trackcode < 200)))
                {
                    result = "小车需要在出库轨道头或者下砖轨道";
                    return(false);
                }
                if (!PubTask.Ferry.HaveFerryOnTrack(trackcode, carriertask, out result))
                {
                    return(false);
                }
                #endregion
                break;

            case DevCarrierTaskE.后退至轨道倒库:
                if (!((trackcode >= 500 && trackcode < 600) || trackcode >= 740))
                {
                    result = "小车需要在出库轨道或者上砖摆渡车";
                    return(false);
                }
                break;

            case DevCarrierTaskE.前进至点:
                if (!((trackcode >= 100 && trackcode < 400) || (trackcode >= 700 && trackcode < 740)))
                {
                    result = "小车需要在入库轨道或者下砖摆渡车";
                    return(false);
                }
                isferryupsite = true;
                break;

            case DevCarrierTaskE.后退至点:
                if (!((trackcode >= 300 && trackcode < 600) || trackcode >= 740))
                {
                    result = "小车需要在出库轨道或者上砖摆渡车";
                    return(false);
                }
                break;

            case DevCarrierTaskE.顶升取货:
                break;

            case DevCarrierTaskE.降放货:
                break;

            case DevCarrierTaskE.终止:
                break;
            }

            //小车在摆渡车上-离开摆渡车时,需要判断摆渡车是否停止、并且对准轨道
            if (carriertask != DevCarrierTaskE.终止 &&
                carriertask != DevCarrierTaskE.降放货 &&
                carriertask != DevCarrierTaskE.顶升取货 &&
                carriertask != DevCarrierTaskE.前进至摆渡车 &&
                carriertask != DevCarrierTaskE.后退至摆渡车)
            {
                Track track = GetCarrierTrack(devid);
                if (track != null &&
                    (track.Type == TrackTypeE.摆渡车_入 || track.Type == TrackTypeE.摆渡车_出))
                {
                    if (!PubTask.Ferry.IsStopAndSiteOnTrack(track.id, isferryupsite, out result))
                    {
                        return(false);
                    }
                }
            }

            DoTask(devid, carriertask, isoversize);
            result = "";
            return(true);
        }