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()); } }
/// <summary> /// 任务申请 /// </summary> private bool FillTaskRequire(ref string reStr) { EnumAsrsTaskType taskType = EnumAsrsTaskType.扫码工位; //if (taskType != EnumAsrsTaskType.空) //{ // if (ExistUnCompletedTask((int)taskType)) // { // return true; // } //} string getBarcode = string.Empty; if (SysCfg.SysCfgModel.SimMode) { getBarcode = StartBarcode; } else { if (((this.db1ValsToSnd[0] == 1 || this.db1ValsToSnd[0] == 0) && this.currentTask == null) || ((this.db1ValsToSnd[1] == 1 || this.db1ValsToSnd[1] == 0) && this.currentTaskPhase == 3) || ((this.currentTaskPhase == 0) && (this.currentTask != null))) { //getBarcode = barcodeRW.ReadBarcode();// getBarcode = StartBarcode; if (string.IsNullOrWhiteSpace(getBarcode)) { if (this.currentTask == null) { this.db1ValsToSnd[0] = 1; } return(true); } // 如果读取到的的Barcode 不是开始 if (getBarcode.ToLower() != StartBarcode) { return(false); } else { if (this.db2Vals[0] == 2 || this.db2Vals[1] == 2) { this.logRecorder.AddDebugLog(nodeName, "扫描到Start条形码,DB2的状态错误!"); return(false); } } if (((this.db1ValsToSnd[0] == 1) && (this.currentTask == null)) || ((this.currentTaskPhase == 0) && (this.currentTask != null))) { this.logRecorder.AddDebugLog(nodeName, "已扫描Start条形码!"); this.db1ValsToSnd[0] = 2; if (((this.currentTaskPhase == 0) && (this.currentTask != null))) { this.currentTaskPhase = 1; } } } } if (this.currentTask == null) { //生成新任务 this.currentTaskPhase = 1; ControlTaskModel task = new ControlTaskModel(); task.DeviceID = this.nodeID; task.CreateMode = "自动"; task.CreateTime = System.DateTime.Now; task.TaskParam = this.nodeID; task.TaskID = System.Guid.NewGuid().ToString("N"); task.TaskType = (int)taskType; task.TaskPhase = this.currentTaskPhase; task.TaskStatus = SysCfg.EnumTaskStatus.执行中.ToString(); task.Remark = nodeName.ToString(); this.ctlTaskBll.Add(task); this.currentTask = task; currentTaskDescribe = "扫码任务生成"; } return(true); }
//EnumAsrsTaskType GetTaskTypeByNodeName(string nodeName) //{ // if (nodeName == "卸载读卡A") // { // return EnumAsrsTaskType.卸载读卡A; // } // else if (nodeName == "卸载读卡B") // { // return EnumAsrsTaskType.卸载读卡B; // } // else // { // return EnumAsrsTaskType.空; // } //} /// <summary> /// 装载任务申请 /// </summary> private bool FillTaskRequire(ref string reStr) { if (db2Vals[0] == 2 && db1ValsToSnd[0] != 2) { //EnumAsrsTaskType taskType = GetTaskTypeByNodeName(this.nodeName); EnumAsrsTaskType taskType = EnumAsrsTaskType.卸载读卡; if (ExistUnCompletedTask((int)taskType)) { return(true); } //先读RFID卡 currentTaskDescribe = "开始读RFID"; this.rfidUID = ""; if (SysCfg.SysCfgModel.SimMode) { this.rfidUID = this.SimRfidUID; } else { this.rfidUID = rfidRW.ReadStrData();// } this.rfidUID = this.rfidUID.TrimEnd('\0'); this.rfidUID = this.rfidUID.Trim(); if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != 3) { this.logRecorder.AddDebugLog(nodeName, "读RFID失败"); } this.db1ValsToSnd[0] = 3; return(true); } //验证RFID的格式START if (!VerifyRFID(this.rfidUID)) { if (this.db1ValsToSnd[0] != 3) { this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "RFID验证失败"); } this.db1ValsToSnd[0] = 3; return(true); } this.logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID.Trim()); //验证RFID的格式END // //生成新任务 this.currentTaskPhase = 1; ControlTaskModel task = new ControlTaskModel(); task.DeviceID = this.nodeID; task.CreateMode = "自动"; task.CreateTime = System.DateTime.Now; task.TaskID = System.Guid.NewGuid().ToString("N"); task.TaskType = (int)taskType; task.TaskParam = this.rfidUID; task.TaskPhase = this.currentTaskPhase; task.TaskStatus = SysCfg.EnumTaskStatus.执行中.ToString(); task.Remark = nodeName; task.tag1 = stockName; this.ctlTaskBll.Add(task); this.currentTask = task; currentTaskDescribe = "卸载任务生成"; return(true); } if (db2Vals[0] == 1 && this.currentTask == null) { this.db1ValsToSnd[0] = 1; this.db1ValsToSnd[1] = 1; } return(true); }