Example #1
0
        private void OnGenerateTask()
        {
            try
            {
                AsrsTaskModel task  = new AsrsTaskModel();
                string        reStr = "";
                task.TaskPhase  = 0;
                task.TaskStatus = "待执行";
                EnumAsrsTaskType taskType = (EnumAsrsTaskType)Enum.Parse(typeof(EnumAsrsTaskType), this.comboBoxTasks.Text);
                task.TaskType = (int)taskType;
                if (taskType == EnumAsrsTaskType.产品入库)
                {
                    task.InputPort = int.Parse(this.textBoxPortID.Text);
                }
                else
                {
                    task.OutputPort = int.Parse(this.textBoxPortID.Text);
                }
                task.CellA = new CellCoordModel(int.Parse(textBoxRow.Text), int.Parse(textBoxCol.Text), int.Parse(textBoxLayer.Text));

                if (presenter.Stacker.FillTask(task, ref reStr))
                {
                    Console.WriteLine("分配{0}任务成功", taskType.ToString());
                    this.label11.Text = string.Format("当前任务:{0} ,站台号:{1},货位地址:{2}-{3}-{4}", taskType.ToString(), this.textBoxPortID.Text, task.CellA.Row, task.CellA.Col, task.CellA.Layer);
                }
                else
                {
                    Console.WriteLine("分配{0}任务失败,{1}", taskType.ToString(), reStr);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Example #2
0
 public bool FillTask(AsrsTaskModel task, ref string reStr)
 {
     if (this.currentTask != null)
     {
         reStr = "当前任务未执行完,不能接受新的任务";
         return(false);
     }
     this.currentTask = task;
     return(true);
 }
Example #3
0
        private void TaskReback()
        {
            if (this.currentTask != null && this.currentTaskPhase > 0)
            {
                this.currentTask      = null;
                this.currentTaskPhase = 0;
            }
            if (db1ValsToSnd[1] != 3)
            {
                ///DevCmdReset();
                Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count());
                db1ValsToSnd[1] = 3;//
            }

            currentTaskDescribe = "任务撤销,等待'撤销信号'复位";
        }
Example #4
0
 public bool DevReset()
 {
     try
     {
         Array.Clear(db1ValsToSnd, 0, db1ValsToSnd.Count());
         db1ValsToSnd[0] = 1;
         db1ValsToSnd[1] = 1;
         string reStr = "";
         if (!NodeCmdCommit(false, ref reStr))
         {
             Console.WriteLine("提交命令数据错误:" + reStr);
             return(false);
         }
         this.currentTask    = null;
         currentTaskDescribe = "等待新的任务";
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         return(false);
     }
 }
Example #5
0
        public bool ExeBusiness(ref string reStr)
        {
            if (!devStatusRestore)
            {
                devStatusRestore = DevStatusRestore();
            }
            if (!devStatusRestore)
            {
                return(false);
            }
            //任务撤销
            if (db2Vals[2] == 3 && db1ValsToSnd[1] != 3)
            {
                TaskReback();
                return(true);
            }
            if (db1ValsToSnd[1] == 3 && db2Vals[2] == 1)
            {
                //任务撤销命令复位,应答也复位
                db1ValsToSnd[1] = 1;
            }
            //if (currentTask != null)
            //{
            //    this.currentStat.Status = EnumNodeStatus.设备使用中;

            //}
            //else
            //{
            //    this.currentStat.Status = EnumNodeStatus.设备空闲;
            //}
            if (this.db2Vals[0] != 0)
            {
                this.db1ValsToSnd[11] = 1;
                currentTaskDescribe   = "设备故障";
                return(true);
            }
            switch (currentTaskPhase)
            {
            case 0:
            {
                currentTaskDescribe = "等待新的任务";
                if (currentTask == null)
                {
                    break;
                }
                currentTaskDescribe = "等待设备空闲状态";
                if (this.db2Vals[1] == 1)         //设备处于空闲状态,可以 接受新的任务
                {
                    //写入参数
                    string logInfo = string.Format("开始执行任务:{0},{1}-{2}-{3}", ((EnumAsrsTaskType)currentTask.TaskType).ToString(), this.currentTask.CellA.Row, this.currentTask.CellA.Col, this.currentTask.CellA.Layer);
                    if (WriteTaskParam())
                    {
                        this.currentTaskPhase++;
                        this.currentTask.TaskStatus = EnumTaskStatus.执行中.ToString();
                        this.currentTask.TaskPhase  = currentTaskPhase;
                    }
                }

                break;
            }

            case 1:
            {
                //参数写入完成
                currentTaskDescribe  = "开始发送参数";
                this.db1ValsToSnd[0] = 2;
                if (!NodeCmdCommit(true, ref reStr))
                {
                    Console.WriteLine("发送参数失败");
                    break;
                }
                currentTask.TaskPhase = currentTaskPhase;
                Console.WriteLine("{0}参数发送完成");
                this.currentTaskPhase++;
                this.currentTask.TaskPhase = currentTaskPhase;

                break;
            }

            case 2:
            {
                //等待任务完成
                currentTaskDescribe = "等待设备进入工作状态";
                if (db2Vals[1] != 2)
                {
                    //必须进入工作状态
                    break;
                }


                db1ValsToSnd[0]     = 1;
                currentTaskDescribe = "等待任务完成";
                if (db2Vals[2] == 2)
                {
                    for (int i = 3; i < db1ValsToSnd.Count(); i++)
                    {
                        db1ValsToSnd[i] = 0;
                    }
                    //处理任务

                    //if (!TaskCompletedProcess(this.taskParamModel, this.currentTask))
                    //{
                    //    logRecorder.AddDebugLog(nodeName, "任务完成后处理失败!");
                    //    break;
                    //}
                    db1ValsToSnd[1] = 2;
                    if (!NodeCmdCommit(true, ref reStr))
                    {
                        Console.WriteLine("发送任务处理完成状态失败");
                        break;
                    }
                    // string debugLog = string.Format("任务ID:{0},{1}完成!", currentTask.TaskID, currentTask.Remark);
                    string debugLog = string.Format("任务:{0},{1}-{2}-{3}完成", ((EnumAsrsTaskType)currentTask.TaskType).ToString(), this.currentTask.CellA.Row, this.currentTask.CellA.Col, this.currentTask.CellA.Layer);
                    Console.WriteLine(debugLog);
                    currentTaskDescribe = "任务完成";
                    this.currentTaskPhase++;
                }

                currentTask.TaskPhase = currentTaskPhase;

                break;
            }

            case 3:
            {
                currentTaskDescribe = "等待任务完成信号复位";
                if (db2Vals[2] != 1)
                {
                    break;
                }

                DevReset();
                currentTask         = null;
                currentTaskPhase    = 0;
                currentTaskDescribe = "等待执行下一个任务";
                break;
            }

            default:
                break;
            }
            return(true);
        }