/// <summary> /// 设备执行任务之前,检查是否路径被锁定,防止上下架冲突 /// </summary> /// <param name="curNode"></param> /// <param name="curTask"></param> /// <param name="reStr">若可用,返回0,1:路径被锁定,不可用,2:其它错误,-1:系统异常</param> /// <returns></returns> public int TaskLockCheck(FlowCtlBaseModel.CtlNodeBaseModel curNode, CtlDBAccess.Model.ControlTaskModel curTask, ref string reStr) { try { lock (pathCheckLock) { if (curTask == null) { reStr = "任务为空"; return(2); } CtlDBAccess.Model.MainControlTaskModel mainTask = mainCtlTaskBll.GetModel(curTask.MainTaskID); if (!wcsPathMap.Keys.Contains(mainTask.FlowPathKey)) { reStr = "不存在的路径:" + mainTask.FlowPathKey; return(2); } FlowCtlBaseModel.WCSFlowPathModel wcsPath = wcsPathMap[mainTask.FlowPathKey]; if (wcsPath.PathCata == "上架") { // List<CtlDBAccess.Model.MainControlTaskModel> lockedMaintaskList = GetLockedTaskList(curNode, "下架"); if (!NodeLockedBytask(curNode, "下架")) { return(0); } else { return(1); } } else if (wcsPath.PathCata == "下架") { //List<CtlDBAccess.Model.MainControlTaskModel> lockedMaintaskList = GetLockedTaskList(curNode, "上架"); if (!NodeLockedBytask(curNode, "上架")) { return(0); } else { return(1); } } else { return(0); } } } catch (Exception ex) { reStr = ex.ToString(); return(-1); } }
private void OnDelMaintask() { if (this.parentPNP.RoleID > 2) { MessageBox.Show("没有管理员权限"); return; } int re = PoupAskmes("是否确定要删除?"); if (re != 1) { return; } CtlDBAccess.BLL.MainControlTaskBll mainTaskBll = new CtlDBAccess.BLL.MainControlTaskBll(); foreach (DataGridViewRow rw in this.dataGridView1.SelectedRows) { string mainTaskID = rw.Cells["管理任务ID"].Value.ToString(); CtlDBAccess.Model.MainControlTaskModel mainTask = mainTaskBll.GetModel(mainTaskID); if (mainTask == null) { continue; } if (mainTask.TaskStatus == "执行中") { if (parentPNP.RoleID == 1) { mainTaskBll.Delete(mainTaskID); } } else { mainTaskBll.Delete(mainTaskID); } } OnRefreshWMSDt(); }
private bool ExeSndTaskBusiness(ref string reStr) { try { switch (this.currentTaskPhase) { case 1: { this.currentTaskDescribe = "等待有板信号"; this.rfidUID = ""; this.db1ValsToSnd[5] = 0; this.db1ValsToSnd[6] = 1; this.db1ValsToSnd[7] = 0; this.db1ValsToSnd[8] = 0; this.db1ValsToSnd[9] = 0; if (this.db2Vals[0] != 2) { break; } if (SysCfg.SysCfgModel.SimMode) { this.rfidUID = this.SimRfidUID; logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); } else { if (this.barcodeRW != null && barcodeCheck) { this.rfidUID = this.barcodeRW.ReadBarcode().Trim(); //this.barcodeRW.Trim(); if (string.IsNullOrWhiteSpace(this.rfidUID)) { break; } logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); } } this.currentTaskPhase++; break; } case 2: { this.currentTask = null; currentTaskDescribe = "等待检索待执行任务"; List <CtlDBAccess.Model.ControlTaskModel> taskList = ctlTaskBll.GetTaskToRunList((int)SysCfg.EnumAsrsTaskType.输送机送出, "待执行", this.nodeID); // CtlDBAccess.Model.ControlTaskModel taskToRun = null; foreach (CtlDBAccess.Model.ControlTaskModel task in taskList) { if (0 != dlgtPathLockcheck(this, task, ref reStr)) { continue; } if (barcodeCheck) { if (task.PalletCode == this.rfidUID) { this.currentTask = task; break; } } else { this.currentTask = task; break; } } if (this.currentTask == null) { this.currentTaskDescribe = string.Format("没有匹配托盘{0}的任务", this.rfidUID); if (this.barcodeRW != null && barcodeCheck) { if (SysCfg.SysCfgModel.SimMode) { this.rfidUID = this.SimRfidUID; } else { this.rfidUID = this.barcodeRW.ReadBarcode().Trim(); //this.barcodeRW.Trim(); } if (string.IsNullOrWhiteSpace(this.rfidUID)) { break; } } break; } if (this.currentTask.TaskIndex == 1) { CtlDBAccess.BLL.MainControlTaskBll mainTaskBll = new CtlDBAccess.BLL.MainControlTaskBll(); CtlDBAccess.Model.MainControlTaskModel mainTask = mainTaskBll.GetModel(this.currentTask.MainTaskID); if (dlgtHeightChecked != null) { if (!dlgtHeightChecked(mainTask, db2Vals[2], ref reStr)) { string strHeightExceed = string.Format("货物{0}超高,与{1}目标货位{2}冲突", this.rfidUID, mainTask.EndDevice, mainTask.EndDeviceParam); if (this.db1ValsToSnd[0] != 3) { logRecorder.AddDebugLog(nodeName, strHeightExceed); } this.currentTaskDescribe = strHeightExceed; this.db1ValsToSnd[0] = 3; break; } } if (mainTask != null) { mainTask.TaskStatus = "执行中"; mainTaskBll.Update(mainTask); } } //发送任务参数 this.db1ValsToSnd[6] = 1; this.db1ValsToSnd[7] = 21; this.db1ValsToSnd[8] = (short)this.currentTask.ControlID; this.db1ValsToSnd[9] = short.Parse(this.currentTask.EndDevice); if (!string.IsNullOrWhiteSpace(this.rfidUID)) { logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); } logRecorder.AddDebugLog(nodeName, string.Format("控制ID{0}执行到第2步,发送参数,等待PLC读数据完成", this.currentTask.ControlID)); this.currentTaskPhase++; break; } case 3: { this.db1ValsToSnd[5] = 1; //写入数据 this.currentTask.TaskStatus = "执行中"; ctlTaskBll.Update(currentTask); //等待PLC 读数据完成 this.currentTaskDescribe = "等待输送机读数据完成"; if (this.db2Vals[5] != 2) { break; } this.db1ValsToSnd[5] = 2; this.db1ValsToSnd[7] = 0; this.db1ValsToSnd[8] = 0; this.db1ValsToSnd[9] = 0; logRecorder.AddDebugLog(nodeName, string.Format("控制ID{0}任务执行到第3步,参数复位", this.currentTask.ControlID)); this.currentTaskPhase++; ctlTaskBll.Update(currentTask); break; } case 4: { this.currentTaskDescribe = "输送任务发送完毕"; currentTask = null; break; } default: { break; } } return(true); } catch (Exception ex) { reStr = ex.ToString(); return(false); } }