Exemple #1
0
        }/// <summary>

        /// 向下移动一行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDown_Click(object sender, EventArgs e)
        {
            try
            {
                if (gvCmdSet.IsLastRow)
                {
                    return;
                }
                RouteFragmentConfigInfo currAct = bsFragment.Current as RouteFragmentConfigInfo;
                if (currAct == null)
                {
                    return;
                }
                IList <RouteFragmentConfigInfo> acts = bsFragment.List as IList <RouteFragmentConfigInfo>;
                if (acts == null)
                {
                    return;
                }
                if (acts.Count <= 0)
                {
                    return;
                }
                int selectIndex = acts.IndexOf(currAct);
                RouteFragmentConfigInfo NextAct = DataToObject.CreateDeepCopy <RouteFragmentConfigInfo>(acts[selectIndex + 1]);
                NextAct.CmdIndex      = NextAct.CmdIndex - 1;
                acts[selectIndex]     = NextAct;
                currAct.CmdIndex      = currAct.CmdIndex + 1;
                acts[selectIndex + 1] = currAct;
                bsFragment.DataSource = acts;
                bsFragment.ResetBindings(false);
                gvCmdSet.MoveNext();
            }
            catch (Exception ex)
            { MsgBox.ShowError(ex.Message); }
        }
Exemple #2
0
 /// <summary>
 /// 根据呼叫器ID加载呼叫器配置明细
 /// </summary>
 /// <param name="CallBoxID"></param>
 /// <returns></returns>
 public static IList <CallBoxDetail> LoadCallBoxDetails(int CallBoxID)
 {
     try
     {
         IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
         Hashtable   dic        = new Hashtable();
         dic["CallBoxID"] = CallBoxID;
         DataTable dt = dbOperator.LoadDatas("LoadCallBoxDetails", dic);
         return(DataToObject.TableToEntity <CallBoxDetail>(dt));
     }
     catch (Exception ex)
     { throw ex; }
 }
 private void gvDetail_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
 {
     try
     {
         gvPass.BeforeLeaveRow -= gvPass_BeforeLeaveRow;
         labelControl1.Focus();
         gvDetail.CloseEditor();
         labelControl1.Focus();
         e.Allow = Valid();
         if (!e.Allow)
         {
             return;
         }
         if (gvDetail.FocusedRowHandle >= 0)
         {
             TaskConfigDetail CurrDetail = bsDetail[gvDetail.FocusedRowHandle] as TaskConfigDetail;
             if (CurrDetail != null)
             {
                 if (gvPass.FocusedRowHandle >= 0)
                 {
                     TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass;
                     if (CurrConfigPass != null)
                     {
                         if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode))
                         {
                             baPass.RemoveCurrent();
                         }
                     }
                     IList <IOActionInfo> Actions = bsIOActions.List as IList <IOActionInfo>;
                     CurrConfigPass.MustPassIOAction = Actions;
                 }
                 IList <TaskConfigMustPass> ConfigMustPasss = baPass.List as List <TaskConfigMustPass>;
                 if (ConfigMustPasss != null)
                 {
                     CurrDetail.TaskConfigMustPass = DataToObject.CreateDeepCopy <IList <TaskConfigMustPass> >(ConfigMustPasss);
                 }
             }
         }
     }
     catch (Exception ex)
     { MsgBox.ShowError(ex.Message); }
     finally
     { gvPass.BeforeLeaveRow += gvPass_BeforeLeaveRow; }
 }
        private bool HandleCallBoxMonitor(CallBoxInfo CallBox, CallBoxDetail CurrBoxDetail, int staragestate, string codes = "")
        {
            try
            {
                lock (lockstorage)
                {
                    #region 处理监控功能
                    //处理监控功能
                    //监控功能则为更新储位的状态
                    DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore");
                    CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage);
                    StorageInfo CallStore = CoreData.StorageList.FirstOrDefault(q => q.ID == CurrBoxDetail.LocationID);
                    if (CallStore == null)
                    {
                        LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "对应的监控储位");
                        return(false);
                    }
                    int StoreState = staragestate;
                    if (CallStore.StorageState != StoreState)
                    {
                        //更新数据库中的对应监控的储位状态信息
                        AGVServerDAccess.UpdateStorageState(StoreState, -1, CallStore.ID);
                        if (!string.IsNullOrEmpty(codes))
                        {
                            //更新备注
                            AGVServerDAccess.UpdteStorageRemark(CallStore.ID, codes);
                        }
                        //更新储位的名称 逗号分隔
                        CallStore.StorageState = StoreState;
                        CallStore.Remark       = codes;
                    }
                    return(true);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                DelegateState.InvokeDispatchStateEvent(ex.Message);
                return(false);
            }
        }
Exemple #5
0
 /// <summary>
 /// 根据呼叫器ID加载呼叫器信息
 /// </summary>
 /// <param name="BoxID"></param>
 /// <returns></returns>
 public static CallBoxInfo LoadAllCallBoxByID(int BoxID)
 {
     try
     {
         IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
         Hashtable   dic        = new Hashtable();
         dic["CallBoxID"] = BoxID;
         DataTable           dt           = dbOperator.LoadDatas("LoadCallBoxByID", dic);
         IList <CallBoxInfo> CallBoxInfos = DataToObject.TableToEntity <CallBoxInfo>(dt);
         if (CallBoxInfos == null || (CallBoxInfos != null && CallBoxInfos.Count <= 0))
         {
             return(null);
         }
         else
         {
             return(CallBoxInfos.FirstOrDefault());
         }
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #6
0
 public static DispatchTaskInfo CheckTaskIsFinish(string dispathNo)
 {
     try
     {
         IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
         Hashtable   hs         = new Hashtable();
         hs["dispatchNo"] = dispathNo;
         DataTable dt = dbOperator.LoadDatas("CheckTaskIsFinish", hs);
         IList <DispatchTaskInfo> DispatchTaskInfos = DataToObject.TableToEntity <DispatchTaskInfo>(dt);
         if (DispatchTaskInfos == null || (DispatchTaskInfos != null && DispatchTaskInfos.Count <= 0))
         {
             return(null);
         }
         else
         {
             return(DispatchTaskInfos.FirstOrDefault());
         }
     }
     catch (Exception ex)
     { LogHelper.WriteErrorLog(ex); return(null); }
 }
Exemple #7
0
        /// <summary>
        /// 向上移动一行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUp_Click(object sender, EventArgs e)
        {
            try
            {
                if (gvCmdSet.IsFirstRow)
                {
                    return;
                }


                RouteFragmentConfigInfo frag = bsFragment.Current as RouteFragmentConfigInfo;
                if (frag == null)
                {
                    return;
                }
                IList <RouteFragmentConfigInfo> listfrag = bsFragment.List as IList <RouteFragmentConfigInfo>;
                if (listfrag == null)
                {
                    return;
                }
                if (listfrag.Count <= 0)
                {
                    return;
                }
                int selectIndex             = listfrag.IndexOf(frag);
                RouteFragmentConfigInfo pre = DataToObject.CreateDeepCopy <RouteFragmentConfigInfo>(listfrag[selectIndex - 1]);
                frag.CmdIndex             = frag.CmdIndex - 1;
                listfrag[selectIndex - 1] = frag;
                pre.CmdIndex          = pre.CmdIndex + 1;
                listfrag[selectIndex] = pre;

                bsFragment.DataSource = listfrag;
                bsFragment.ResetBindings(false);
                gvCmdSet.MovePrev();
            }
            catch (Exception ex)
            {
                MsgBox.ShowError(ex.Message);
            }
        }/// <summary>
Exemple #8
0
 /// <summary>
 /// 根据条件加载任务信息
 /// </summary>
 public static IList <DispatchTaskInfo> LoadDispatchTask(string Condition)
 {
     try
     {
         IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
         Hashtable   dic        = new Hashtable();
         dic["TaskState"] = Condition;
         dic["CurrDate"]  = DateTime.Now.ToString("yyyyMMdd");
         dic["PreDate"]   = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
         DataTable dtTaskInfo           = dbOperator.LoadDatas("LoadTaskInfo", dic);
         IList <DispatchTaskInfo> Tasks = DataToObject.TableToEntity <DispatchTaskInfo>(dtTaskInfo);
         foreach (DispatchTaskInfo item in Tasks)
         {
             dic["dispatchNo"] = item.dispatchNo;
             DataTable dtTaskDetail = dbOperator.LoadDatas("LoadTaskDetail", dic);
             IList <DispatchTaskDetail> TaskDetail = DataToObject.TableToEntity <DispatchTaskDetail>(dtTaskDetail);
             item.TaskDetail = TaskDetail;
         }
         return(Tasks);
     }
     catch (Exception ex)
     { throw ex; }
 }
 private void gvPass_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
 {
     try
     {
         if (gvPass.FocusedRowHandle < 0)
         {
             return;
         }
         TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass;
         if (CurrConfigPass != null)
         {
             IList <TaskConfigMustPass> AllPassLands = baPass.List as IList <TaskConfigMustPass>;
             if (AllPassLands != null && AllPassLands.Count(p => p.MustPassLandCode == CurrConfigPass.MustPassLandCode) > 1)
             {
                 gvPass.FocusedColumn = colMustPassLandCode;
                 gvPass.ShowEditor();
                 e.Allow = false;
                 return;
             }
             if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode))
             {
                 gvPass.FocusedColumn = colMustPassLandCode;
                 gvPass.ShowEditor();
                 e.Allow = false;
                 return;
             }
             IList <IOActionInfo> IOActions = bsIOActions.List as List <IOActionInfo>;
             if (IOActions != null)
             {
                 CurrConfigPass.MustPassIOAction = DataToObject.CreateDeepCopy <IList <IOActionInfo> >(IOActions);
             }
         }
     }
     catch (Exception ex)
     { MsgBox.ShowError(ex.Message); }
 }
        private bool InitAndStartServer()
        {
            try
            {
                DelegateState.InvokeDispatchStateEvent("正在读取数据库连接...");
                ConnectConfigTool.setDBase();
                if (ConnectConfigTool.DBase == null)
                {
                    DelegateState.InvokeDispatchStateEvent("数据库连接文件不存在!");
                    return(false);
                }
                IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
                if (dbOperator == null)
                {
                    DelegateState.InvokeDispatchStateEvent("数据库连接文件不存在!");
                    return(false);
                }
                bool IsConnectDB = false;

                try
                {
                    IsConnectDB = dbOperator.ServerIsThrough();
                }
                catch (Exception ex)
                {
                    DelegateState.InvokeDispatchStateEvent("数据库连接失败【" + ex.Message + "】");
                }
                if (!IsConnectDB)
                {
                    return(false);
                }
                CoreData.dbOperator = dbOperator;
                #region 读取系统参数
                DelegateState.InvokeDispatchStateEvent("正在读取系统参数...");
                DataTable dtSysparameter = CoreData.dbOperator.LoadDatas("QuerySyspara");
                foreach (DataRow row in dtSysparameter.Rows)
                {
                    CoreData.SysParameter[row["ParameterCode"].ToString()] = row["ParameterValue"].ToString();
                }
                DelegateState.InvokeDispatchStateEvent("读取系统参数成功...");
                #endregion
                DataTable dtAllCallBox = CoreData.dbOperator.LoadDatas("QueryAllCallBox");
                CoreData.AllCallBoxes = DataToObject.TableToEntity <CallBoxInfo>(dtAllCallBox);
                DataTable dtAllCallBoxDetail = CoreData.dbOperator.LoadDatas("QueryAllCallBoxDetails");
                CoreData.AllCallBoxDetail = DataToObject.TableToEntity <CallBoxDetail>(dtAllCallBoxDetail);
                //读取储位
                DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore");
                CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage);

                //读取区域
                DataTable dtarea = CoreData.dbOperator.LoadDatas("LoadAllArea");
                CoreData.AllAreaList = DataToObject.TableToEntity <AreaInfo>(dtarea);

                //初始化呼叫器通信
                Seccions.Clear();
                foreach (CallBoxInfo callbox in CoreData.AllCallBoxes)
                {
                    //if (callbox.CallBoxID != 5)
                    //{
                    //    continue;
                    //}
                    SiemensConnectInfo ConnConfig = new SiemensConnectInfo()
                    {
                        ServerIP = callbox.CallBoxIP, Port = callbox.CallBoxPort
                    };

                    CommunicationSiemensPlc Commer = new CommunicationSiemensPlc(callbox.CallBoxID, ConnConfig);
                    if (!Commer.InitSiemens())
                    {
                        DelegateState.InvokeDispatchStateEvent("初始化呼叫器:" + callbox.CallBoxID.ToString() + "IP:" + "callbox.CallBoxIP" + "失败!");
                        continue;
                    }
                    Commer.Start();
                    Seccions.Add(Commer);
                }
                DelegateState.InvokeDispatchStateEvent("初始化成功...");
                return(true);
            }
            catch (Exception ex)
            {
                DelegateState.InvokeDispatchStateEvent(ex.Message);
                return(false);
            }
        }
 private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         gvPass.BeforeLeaveRow -= gvPass_BeforeLeaveRow;
         gvDetail.CloseEditor();
         labelControl1.Focus();
         if (!Valid())
         {
             return;
         }
         if (gvPass.FocusedRowHandle >= 0)
         {
             TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass;
             if (CurrConfigPass != null)
             {
                 if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode))
                 {
                     baPass.RemoveCurrent();
                 }
                 IList <IOActionInfo> IOActions = bsIOActions.List as List <IOActionInfo>;
                 if (IOActions != null)
                 {
                     CurrConfigPass.MustPassIOAction = DataToObject.CreateDeepCopy <IList <IOActionInfo> >(IOActions);
                 }
             }
         }
         if (gvDetail.FocusedRowHandle >= 0)
         {
             TaskConfigDetail CurrDetail = bsDetail[gvDetail.FocusedRowHandle] as TaskConfigDetail;
             if (CurrDetail != null)
             {
                 IList <TaskConfigMustPass> ConfigMustPasss = baPass.List as List <TaskConfigMustPass>;
                 if (ConfigMustPasss != null)
                 {
                     CurrDetail.TaskConfigMustPass = DataToObject.CreateDeepCopy <IList <TaskConfigMustPass> >(ConfigMustPasss);
                 }
             }
         }
         TaskConfigInfo           CurrTaskConfig      = bsConfig.Current as TaskConfigInfo;
         IList <TaskConfigDetail> AllTaskConfigDetail = bsDetail.List as IList <TaskConfigDetail>;
         if (CurrTaskConfig != null && AllTaskConfigDetail != null && AllTaskConfigDetail.Count > 0)
         {
             if (CurrTaskConfig.IsNew && AllTaskConfigs.Where(p => p.TaskConditonCode == CurrTaskConfig.TaskConditonCode).Count() > 0)
             {
                 MsgBox.ShowWarn("任务条件配置编号已存在!");
                 return;
             }
             CurrTaskConfig.TaskConfigDetail = DataToObject.CreateDeepCopy <IList <TaskConfigDetail> >(AllTaskConfigDetail);
             OperateReturnInfo opr = AGVDAccess.AGVClientDAccess.SaveTaskConfig(CurrTaskConfig);
             MsgBox.Show(opr);
             if (opr.ReturnCode == OperateCodeEnum.Success)
             {
                 this.DialogResult = DialogResult.OK;
             }
         }
     }
     catch (Exception ex)
     { MsgBox.ShowError(ex.Message); }
     finally
     { gvPass.BeforeLeaveRow += gvPass_BeforeLeaveRow; }
 }
Exemple #12
0
        /// <summary>
        /// 分派任务
        /// </summary>
        private async void assignTask()
        {
            try
            {
                lock (HandleTaskobje)
                {
                    timerFreshTask.Enabled = false;
                    foreach (CarMonitor car in MoniCars.Where(p => (!string.IsNullOrEmpty(p.ExcuteTaksNo)) && p.TaskDetailID >= 0))
                    {
                        //将当前的任务明细更新完成
                        if (!string.IsNullOrEmpty(car.ExcuteTaksNo) && car.TaskDetailID != -1)
                        {
                            //HandTaskDetail(car.CurrSite.ToString(), car.ExcuteTaksNo, car.TaskDetailID);
                            if (car.Sate == 0 && car.CurrSite.ToString() == car.ArmLand)
                            {
                                #region 更新储位状态
                                UnLockStorage(car, Stores);
                                #endregion
                                AGVSimulationDAccess.HandTaskDetail(car.AgvID, car.CurrSite.ToString(), car.ExcuteTaksNo, car.TaskDetailID);
                                AGVSimulationDAccess.HandTaskzb(car.ExcuteTaksNo);
                                DispatchTaskInfo CarTaskInfo = AGVSimulationDAccess.CheckTaskIsFinish(car.ExcuteTaksNo);
                                if (CarTaskInfo == null)
                                {
                                    car.ExcuteTaksNo = "";
                                }
                            }
                        }
                    }


                    Hashtable hs = new Hashtable();
                    //查找当前有效任务
                    IList <DispatchTaskInfo> tasks = AGVSimulationDAccess.LoadDispatchTask("0,1");
                    if (tasks != null && tasks.Count > 0)
                    {
                        foreach (DispatchTaskInfo task in tasks)
                        {
                            if (task.TaskDetail.Count <= 0)
                            {
                                continue;
                            }
                            //查找合适的AGV来领取任务
                            CarMonitor NoTaskCar = null;
                            //如果任务为待处理的,就找空闲的车来执行
                            //如果任务是正在执行中的,则找对应的空闲agv来继续执行
                            //查找任务到具体任务明细
                            DispatchTaskDetail TaskDetail = (from a in task.TaskDetail
                                                             where (a.State == 0 || a.State == 1)
                                                             orderby a.DetailID ascending
                                                             select a).FirstOrDefault();
                            if (task.TaskState == 0)
                            {
                                if (TaskDetail != null)
                                {
                                    if (task.ExeAgvID != 0)
                                    {
                                        NoTaskCar = (from a in MoniCars
                                                     where task.ExeAgvID == a.AgvID && !string.IsNullOrEmpty(a.CurrSite.ToString()) && (a.Sate == 0 || a.IsBack) && a.ExcuteTaksNo == "" && /*a.TaskDetailID == -1*/
                                                     getDistant(a.CurrSite.ToString(), TaskDetail.LandCode) >= 0
                                                     orderby getDistant(a.CurrSite.ToString(), TaskDetail.LandCode) ascending
                                                     select a).FirstOrDefault();
                                    }
                                    else
                                    {
                                        NoTaskCar = (from a in MoniCars
                                                     where !string.IsNullOrEmpty(a.CurrSite.ToString()) && (a.Sate == 0 || a.IsBack) && a.ExcuteTaksNo == "" && /*a.TaskDetailID == -1*/
                                                     getDistant(a.CurrSite.ToString(), TaskDetail.LandCode) >= 0
                                                     orderby getDistant(a.CurrSite.ToString(), TaskDetail.LandCode) ascending
                                                     select a).FirstOrDefault();
                                    }
                                }
                            }
                            else if (task.TaskState == 1)
                            {
                                NoTaskCar = MoniCars.FirstOrDefault(p => p.AgvID == task.ExeAgvID && ((p.Sate == 0 || p.Sate == 2 || p.IsBack)));
                            }
                            //找到对应的agv
                            if (NoTaskCar != null && NoTaskCar.CurrSite > 0)
                            {
                                if (NoTaskCar.IsBack)
                                {
                                    NoTaskCar.IsBack = !NoTaskCar.IsBack;
                                }
                            }
                            else
                            {
                                continue;
                            }
                            //如果任务明细全部完成,那么需要将主任务状态更新并且让对应的agv回待命点
                            LandmarkInfo BeginLand, EndLand = null;
                            if (TaskDetail == null)
                            {
                            }
                            else
                            {
                                //判断一下当前小时是否就在任务地标上
                                if (NoTaskCar.CurrSite.ToString() == TaskDetail.LandCode && (TaskDetail.State == 0 || TaskDetail.State == 1))
                                {
                                    NoTaskCar.OperType     = TaskDetail.OperType;
                                    NoTaskCar.PutType      = TaskDetail.PutType;
                                    NoTaskCar.ArmLand      = TaskDetail.LandCode;
                                    NoTaskCar.ExcuteTaksNo = TaskDetail.dispatchNo;
                                    NoTaskCar.TaskDetailID = TaskDetail.DetailID;
                                    AGVSimulationDAccess.HandTaskDetail(NoTaskCar.AgvID, TaskDetail.LandCode, TaskDetail.dispatchNo, TaskDetail.DetailID);
                                    UnLockStorage(NoTaskCar, Stores);
                                    //NoTaskCar.TaskDetailID = -1;
                                    continue;
                                }

                                //判断小车当前的任务明细是否允许需要等待放行命令
                                DispatchTaskDetail PreTaskDetail = (from a in task.TaskDetail
                                                                    where a.LandCode == NoTaskCar.CurrSite.ToString()
                                                                    orderby a.DetailID ascending
                                                                    select a).FirstOrDefault();
                                //如果不允许执行则跳过
                                if (PreTaskDetail != null && PreTaskDetail.IsAllowExcute == 0)
                                {
                                    continue;
                                }
                                //记录当前小车的任务信息
                                //更新任务为执行状态
                                AGVSimulationDAccess.TaskHandle(task.dispatchNo, NoTaskCar.AgvID, 1, TaskDetail.LandCode, TaskDetail.DetailID);
                                NoTaskCar.ExcuteTaksNo = task.dispatchNo;
                                NoTaskCar.TaskDetailID = TaskDetail.DetailID;
                                NoTaskCar.ArmLand      = TaskDetail.LandCode;
                                NoTaskCar.PutType      = TaskDetail.PutType;
                                NoTaskCar.OperType     = TaskDetail.OperType;
                                BeginLand = AllLands.FirstOrDefault(p => p.LandmarkCode == NoTaskCar.CurrSite.ToString());
                                EndLand   = AllLands.FirstOrDefault(p => p.LandmarkCode == TaskDetail.LandCode);
                                if (BeginLand != null && EndLand != null)
                                {
                                    NoTaskCar.CurrRoute = DataToObject.CreateDeepCopy <List <LandmarkInfo> >(CountRoute.GetRoute(BeginLand, EndLand));
                                    string CountRouteResult = string.Join(",", NoTaskCar.CurrRoute.Select(p => p.LandmarkCode));
                                    LogHelper.WriteLog(CountRouteResult);
                                    if (NoTaskCar.CurrRoute.Count <= 0)
                                    {
                                        continue;
                                    }
                                    if (!Traffic.BeforStartTrafficForStop(NoTaskCar))
                                    {
                                        Traffic.GetTrafficResour(NoTaskCar);
                                        //if (Route_Ini != null)
                                        //{ Route_Ini(NoTaskCar.CurrRoute); }
                                        NoTaskCar.StepChange += DoCar_StepChange;
                                        NoTaskCar.Start();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        List <CarMonitor> NoReleaseCars = MoniCars.Where(p => p.Sate != 1 && p.Sate != 2 && !string.IsNullOrEmpty(p.ExcuteTaksNo)).ToList();
                        foreach (CarMonitor item in NoReleaseCars)
                        {
                            item.ExcuteTaksNo = "";
                        }
                    }
                    List <CarMonitor> NoBackCars = MoniCars.Where(p => p.Sate != 1 && p.Sate != 2 && string.IsNullOrEmpty(p.ExcuteTaksNo) && p.CurrSite.ToString() != p.StandbyLandMark).ToList();
                    foreach (CarMonitor car in NoBackCars)
                    {
                        if (string.IsNullOrEmpty(car.StandbyLandMark))
                        {
                            continue;
                        }
                        LandmarkInfo BeginLand = AllLands.FirstOrDefault(p => p.LandmarkCode == car.CurrSite.ToString());
                        LandmarkInfo EndLand   = AllLands.FirstOrDefault(p => p.LandmarkCode == car.StandbyLandMark);
                        //以车的当前地标为开始地标,待命点为结束地标规划回待命点路线
                        if (BeginLand == null || EndLand == null)
                        {
                            continue;
                        }
                        else
                        {
                            //规划路线
                            car.CurrRoute = DataToObject.CreateDeepCopy <List <LandmarkInfo> >(CountRoute.GetRoute(BeginLand, EndLand));
                            if (car.CurrRoute.Count <= 0)
                            {
                                continue;
                            }
                            if (!Traffic.BeforStartTrafficForStop(car))
                            {
                                Traffic.GetTrafficResour(car);
                                //if (Route_Ini != null)
                                //{ Route_Ini(car.CurrRoute); }
                                car.StepChange += DoCar_StepChange;
                                car.Start();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { timerFreshTask.Enabled = true; }
        }
        /// <summary>
        /// 处理呼叫器呼叫任务
        /// </summary>
        /// <param name="CallBox"></param>
        /// <param name="CurrBoxDetail"></param>
        /// <param name="BtnID"></param>
        /// <returns></returns>
        private bool HandleCallBoxCall(CallBoxInfo CallBox, CallBoxDetail CurrBoxDetail, int BtnID)
        {
            try
            {
                lock (lockstorage)
                {
                    #region 处理呼叫逻辑
                    //加载是否启用储位状态
                    string IsUserStoreState = CoreData.SysParameter["IsUserStoreState"].ToString();
                    if (string.IsNullOrEmpty(IsUserStoreState))
                    {
                        IsUserStoreState = "否";
                    }
                    int CallBoxID = CallBox.CallBoxID;
                    IList <TaskConfigDetail> TaskConfigDetails = AGVClientDAccess.load_TaskDetail(CurrBoxDetail.TaskConditonCode);
                    if (TaskConfigDetails == null && (TaskConfigDetails != null && TaskConfigDetails.Count <= 0))
                    {
                        LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "任务信息");
                        return(false);
                    }
                    DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore");
                    CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage);
                    //开始根据任务配置信息创建任务
                    StorageInfo CallStore = CoreData.StorageList.FirstOrDefault(q => q.ID == CurrBoxDetail.LocationID);
                    if (CallStore == null)
                    {
                        LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "对应的监控储位");
                        return(false);
                    }
                    //验证当前按钮盒下是否存在未完成的任务
                    if (AGVSimulationDAccess.ChekAllowCreatTask(CallBoxID, CallStore.LankMarkCode, CurrBoxDetail.ButtonID) > 0)
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫存在未完成任务,请稍后再试!");
                        return(false);
                    }
                    //验证当前按钮盒下是否存在未完成的任务
                    if (AGVSimulationDAccess.ChekAllowCreatTask2(CallBoxID, CallStore.LankMarkCode, CurrBoxDetail.ButtonID) > 0)
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫存在未完成任务 未回写的任务,请稍后再试!");
                        return(false);
                    }
                    AreaInfo callarea = CoreData.AllAreaList.FirstOrDefault(p => p.OwnArea == CallStore.OwnArea);
                    if (callarea != null && callarea.MaxTaskCount > 0)
                    {
                        if (AGVSimulationDAccess.ChekAllowCreatTask3(callarea.OwnArea) >= callarea.MaxTaskCount)
                        {
                            LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxIP.ToString() + " 地址" + CurrBoxDetail.DBAddress + " 对应的区域任务数量达到最大,不产生任务");
                            return(false);
                        }
                    }
                    if (!string.IsNullOrEmpty(CallStore.StorageName))
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxIP.ToString() + " 地址" + CurrBoxDetail.DBAddress + "对应储位未启用");
                        return(false);
                    }

                    //组装任务信息
                    string           dispatchNo = Guid.NewGuid().ToString();
                    DispatchTaskInfo TaskInfo   = new DispatchTaskInfo();
                    TaskInfo.dispatchNo = dispatchNo;
                    TaskInfo.TaskState  = 0;
                    TaskInfo.CallLand   = CallStore.LankMarkCode;
                    TaskInfo.stationNo  = CallBoxID;
                    TaskInfo.CallID     = BtnID;
                    TaskInfo.taskType   = 0;
                    TaskInfo.OwerArea   = CallStore.OwnArea;
                    //创建任务明细
                    int DetailID   = 1;
                    int PrePutType = -1;
                    foreach (TaskConfigDetail item in TaskConfigDetails)
                    {
                        //通过任务任务配置明细寻找目标地标
                        StorageInfo ArmStore = null;
                        LogHelper.WriteCallBoxLog("呼叫储位为:" + item.ArmOwnArea.ToString());
                        if (item.ArmOwnArea == -1)
                        {
                            ArmStore = CallStore;
                            LogHelper.WriteCallBoxLog("呼叫储位地标为:" + CallStore.LankMarkCode);
                        }
                        else
                        {
                            if (IsUserStoreState == "否")
                            {
                                ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType);
                            }
                            else
                            {
                                ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType && p.LockState == 0);
                            }
                        }
                        if (ArmStore == null)
                        {
                            LogHelper.WriteCallBoxLog(string.Format("按钮盒{0}   地址:{1}   BtnID{2}   对应呼叫,目的储位不存在[原因:不存在或被占用]", CallBox.CallBoxID, CurrBoxDetail.DBAddress, CurrBoxDetail.ButtonID));
                            return(false);
                        }

                        #region  用
                        //再通过配置任务号来处理必经地标
                        IList <TaskConfigMustPass> ConfigMustPasses = AGVServerDAccess.LoadTaskMustPass(item.TaskConditonCode, item.DetailID);
                        if (ConfigMustPasses != null && ConfigMustPasses.Count > 0)
                        {
                            ////如果配置的必经地标则需要产生任务经过必经地标
                            foreach (TaskConfigMustPass MustPassItem in ConfigMustPasses)
                            {
                                foreach (IOActionInfo Action in MustPassItem.MustPassIOAction)
                                {
                                    IOActionInfo CurrIOActionInfo = AGVServerDAccess.LoadAllIOAction(Action.ActionID);
                                    if (CurrIOActionInfo == null)
                                    {
                                        LogHelper.WriteCallBoxLog("按钮器" + CallBox.CallBoxID.ToString() + "对应呼叫,必经地标中的IO动作" + Action.ActionID.ToString() + "档案信息不存在");
                                        continue;
                                    }
                                    DispatchTaskDetail newTaskDetail = new DispatchTaskDetail();
                                    newTaskDetail.dispatchNo         = dispatchNo;
                                    newTaskDetail.DetailID           = DetailID;
                                    newTaskDetail.LandCode           = MustPassItem.MustPassLandCode;
                                    newTaskDetail.IsAllowExcute      = Action.IsPass;
                                    newTaskDetail.IsSensorStop       = 0;
                                    newTaskDetail.OperType           = -1;
                                    newTaskDetail.IsWait             = Action.IsWait;
                                    newTaskDetail.WaitTime           = Action.WaitTime;
                                    newTaskDetail.TaskConditonCode   = MustPassItem.TaskConditonCode;
                                    newTaskDetail.TaskConfigDetailID = item.DetailID;
                                    TaskInfo.TaskDetail.Add(newTaskDetail);
                                }
                            }
                        }
                        #endregion


                        //如果没有必经地标或者添加完必经地标后需要继续添加后续的任务配置明细
                        DispatchTaskDetail dispathDetail_TaskConfig = new DispatchTaskDetail();
                        dispathDetail_TaskConfig.dispatchNo = dispatchNo;
                        dispathDetail_TaskConfig.DetailID   = DetailID;
                        dispathDetail_TaskConfig.LandCode   = ArmStore.LankMarkCode;
                        dispathDetail_TaskConfig.StorageID  = ArmStore.ID;
                        if (!string.IsNullOrEmpty(ArmStore.Remark))
                        {
                            TaskInfo.GoodsInfo = ArmStore.Remark;
                        }
                        dispathDetail_TaskConfig.OperType       = item.Action;
                        dispathDetail_TaskConfig.IsAllowExcute  = item.IsWaitPass;
                        dispathDetail_TaskConfig.PassType       = item.PassType;
                        dispathDetail_TaskConfig.IsNeedCallBack = item.IsNeedCallBack;
                        dispathDetail_TaskConfig.IsCallGoods    = item.IsCallGoods;

                        if (PrePutType == -1)
                        {
                            dispathDetail_TaskConfig.PutType = ArmStore.StorageState;
                        }
                        else
                        {
                            dispathDetail_TaskConfig.PutType = PrePutType;
                        }
                        dispathDetail_TaskConfig.IsSensorStop = item.IsSensorStop;
                        TaskInfo.TaskDetail.Add(dispathDetail_TaskConfig);
                        PrePutType = ArmStore.StorageState;
                        DetailID  += 1;
                    }//结束循环处理任务配置

                    //循环组装完任务信息后保存到数据库
                    if (TaskInfo != null && TaskInfo.TaskDetail.Count > 0)
                    {
                        AGVServerDAccess.CreatTaskInfo(TaskInfo, IsUserStoreState == "是" ? true : false);
                    }
                    return(true);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                DelegateState.InvokeDispatchStateEvent(ex.Message);
                return(false);
            }
        }