Exemplo n.º 1
0
 /// <summary>
 /// 高速堆垛机的下发给PLC的调用函数
 /// 由于只有一个叉,动作类型暂时保留固定写单叉动作。
 /// </summary>
 /// <param name="stocker">堆垛机编码</param>
 /// <param name="plc">对应写入PLC的OPC连接</param>
 /// <param name="taskMode">任务模型</param>
 /// <param name="forkTaskFlag">取货任务的任务类型</param>
 /// <param name="forkRow">取货的行(2,1,3,4)</param>
 /// <param name="forkColumn">取货的列</param>
 /// <param name="forkLayer">取货的层</param>
 /// <param name="forkStation">取货的站台</param>
 /// <param name="forkTaskFlag2">放货的任务类型</param>
 /// <param name="forkRow2">放货的行(2,1,3,4)</param>
 /// <param name="forkColumn2">放货的列</param>
 /// <param name="forkLayer2">放货的层</param>
 /// <param name="forkStation2">放货的站台</param>
 /// <param name="taskNo">任务号</param>
 /// <param name="taskAccount">任务过账 </param>
 /// <returns></returns>
 public BllResult SendTaskToStocker(Equipment stocker, IPLC plc, SuperSRMTaskMode taskMode,
                                    SRMForkTaskFlag forkTaskFlag, string forkRow, string forkColumn, string forkLayer, string forkStation,
                                    SRMForkTaskFlag forkTaskFlag2, string forkRow2, string forkColumn2, string forkLayer2, string forkStation2,
                                    string taskNo, TaskAccount taskAccount)
 {
     try
     {
         List <EquipmentProp> propsToWriter = new List <EquipmentProp>();
         var props  = stocker.EquipmentProps;
         var action = props.Find(t => t.EquipmentTypeTemplateCode == "WCSForkTaskMode");
         action.Value = taskMode.GetIndexString();
         var taskFlag = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1TaskFlag");
         taskFlag.Value = forkTaskFlag.GetIndexString();
         var row = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Row");
         row.Value = forkRow;
         var column = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Column");
         column.Value = forkColumn;
         var layer = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Layer");
         layer.Value = forkLayer;
         var station = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Station");
         station.Value = forkStation;
         var taskFlag2 = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1TaskFlag2");
         taskFlag2.Value = forkTaskFlag2.GetIndexString();
         var row2 = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Row2");
         row2.Value = forkRow2;
         var column2 = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Column2");
         column2.Value = forkColumn2;
         var layer2 = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Layer2");
         layer2.Value = forkLayer2;
         var station2 = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Station2");
         station2.Value = forkStation2;
         var task = props.Find(t => t.EquipmentTypeTemplateCode == "WCSFork1Task");
         task.Value = taskNo;
         var account = props.Find(t => t.EquipmentTypeTemplateCode == "WCSTaskAccount");
         account.Value = taskAccount.GetIndexString();
         propsToWriter.AddRange(new List <EquipmentProp>()
         {
             action, taskFlag, row, column, layer, station, taskFlag2, row2, column2, layer2, station2, task, account
         });
         return(plc.Writes(propsToWriter));
     }
     catch (Exception ex)
     {
         Logger.Log($"PLC写入信息错误:" + ex.Message, LogLevel.Exception);
         return(BllResultFactory.Error($"下发任务出现异常:{ex.Message}"));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 下发数据到WCS交换区
 /// </summary>
 /// <param name="stocker"></param>
 /// <param name="plc"></param>
 /// <param name="forkAction"></param>
 /// <param name="forkTaskFlag"></param>
 /// <param name="forkRow"></param>
 /// <param name="forkColumn"></param>
 /// <param name="forkLayer"></param>
 /// <param name="forkStation"></param>
 /// <param name="taskNo"></param>
 /// <returns></returns>
 public BllResult SendTaskToStocker(Equipment stocker, IPLC plc, SRMForkAction forkAction, SRMForkTaskFlag forkTaskFlag, string forkRow, string forkColumn, string forkLayer, string forkStation, string taskNo)
 {
     try
     {
         List <EquipmentProp> propsToWriter = new List <EquipmentProp>();
         var props  = stocker.EquipmentProps;
         var action = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSForkAction.ToString());
         action.Value = forkAction.GetIndexString();
         var taskFlag = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1TaskFlag.ToString());
         taskFlag.Value = forkTaskFlag.GetIndexString();
         var row = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Row.ToString());
         row.Value = forkRow;
         var column = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Column.ToString());
         column.Value = forkColumn;
         var layer = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Layer.ToString());
         layer.Value = forkLayer;
         var station = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Station.ToString());
         station.Value = forkStation;
         var task = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Task.ToString());
         task.Value = taskNo;
         propsToWriter.AddRange(new List <EquipmentProp>()
         {
             action, taskFlag, row, column, layer, station, task
         });
         return(plc.Writes(propsToWriter));
     }
     catch (Exception ex)
     {
         return(BllResultFactory.Error($"下发任务出现异常:{ex.Message}"));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 重新下发堆垛机任务
        /// </summary>
        /// <param name="stocker"></param>
        /// <param name="plc"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="layer"></param>
        /// <param name="forkStation"></param>
        /// <param name="taskForResend"></param>
        /// <param name="forkTaskFlag"></param>
        /// <returns></returns>
        protected BllResult ReSendTask(Equipment stocker, IPLC plc, string row, string column, string layer, string forkStation, TaskEntity taskForResend, SRMForkTaskFlag forkTaskFlag)
        {
            BllResult sendResult = SendTaskToStocker(stocker, plc, SRMForkAction.货叉1号, forkTaskFlag, row, column, layer, forkStation, taskForResend.Id.ToString());

            if (sendResult.Success)
            {
                taskForResend.SendAgain = 2;
                AppSession.Dal.UpdateCommonModel <TaskEntity>(taskForResend);
                Logger.Log($"重新下发堆垛机{stocker.Name},任务:{taskForResend.Id},任务类型:{taskForResend.TaskType},货叉类型:{forkTaskFlag}成功,出库口:{taskForResend.ToPort}", LogLevel.Info);
                return(BllResultFactory.Sucess());
            }
            else
            {
                Logger.Log($"重新下发堆垛机{stocker.Name},任务:{taskForResend.Id},任务类型:{taskForResend.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};", LogLevel.Error);
                return(BllResultFactory.Error());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 下发堆垛机库外取放货任务  相对于站台来说的
        /// </summary>
        /// <param name="stocker"></param>
        /// <param name="plc"></param>
        /// <param name="task"></param>
        /// <param name="taskEntityStatus"></param>
        /// <param name="forkTaskFlag"></param>
        /// <param name="station"></param>
        /// <returns></returns>
        protected BllResult SendTaskToStation(Equipment stocker, IPLC plc, TaskEntity task, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, Equipment station, int tempStatus)
        {
            task.TaskStatus = taskEntityStatus.GetIndexInt();
            //task.ArrivaEquipmentCode = stocker.Code;
            var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task);

            if (tempResult.Success)
            {
                BllResult sendResult = SendTaskToStocker(stocker, plc, SRMForkAction.货叉1号, forkTaskFlag, "0", "0", "0", station.StationIndex.ToString(), task.Id.ToString());

                if (sendResult.Success)
                {
                    Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,接货站台为:{station.Name}", LogLevel.Success);
                    return(BllResultFactory.Sucess());
                }
                else
                {
                    Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error);
                    //回滚任务状态,记录日志
                    task.TaskStatus = tempStatus;
                    //task.ArriveEquipmentCode = tempGateway;
                    AppSession.Dal.UpdateCommonModel <TaskEntity>(task);
                    return(BllResultFactory.Error());
                }
            }
            else
            {
                Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error);
                return(BllResultFactory.Error($"下发堆垛机{stocker.Name}库外放货时,更新任务{task.Id}状态失败:{tempResult.Msg}"));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 单叉整任务下发
        /// </summary>
        /// <param name="srm"></param>
        /// <param name="plc"></param>
        /// <param name="newTaskFlag"></param>
        /// <param name="getForkTaskFlag"></param>
        /// <param name="getForkRow"></param>
        /// <param name="getForkColumn"></param>
        /// <param name="getForkLayer"></param>
        /// <param name="getForkStation"></param>
        /// <param name="putForkTaskFlag"></param>
        /// <param name="putForkRow"></param>
        /// <param name="putForkColumn"></param>
        /// <param name="putForkLayer"></param>
        /// <param name="putForkStation"></param>
        /// <param name="taskNo"></param>
        /// <param name="forkTaskFlag"></param>
        /// <returns></returns>
        public BllResult SendTaskToSRM(Equipment srm, IPLC plc, SSRMNewTaskFlag newTaskFlag,
                                       SRMForkTaskFlag getForkTaskFlag, string getForkRow, string getForkColumn, string getForkLayer, string getForkStation,
                                       SRMForkTaskFlag putForkTaskFlag, string putForkRow, string putForkColumn, string putForkLayer, string putForkStation,
                                       string taskNo, SSRMTaskCompleteFlag completeFlag)
        {
            try
            {
                List <EquipmentProp> propsToWriter = new List <EquipmentProp>();
                var props = srm.EquipmentProps;

                var action = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSNewTask.ToString());
                action.Value = newTaskFlag.GetIndexString();

                //--

                var getTaskFlag = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSGetFork1TaskFlag.ToString());
                getTaskFlag.Value = getForkTaskFlag.GetIndexString();

                var getRow = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSGetRow.ToString());
                getRow.Value = getForkRow;

                var getStation = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSGetPort.ToString());
                getStation.Value = getForkStation;

                var getColumn = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSGetColumn.ToString());
                getColumn.Value = getForkColumn;

                var getLayer = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSGetLayer.ToString());
                getLayer.Value = getForkLayer;

                //--

                var putTaskFlag = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSPutFork1TaskFlag.ToString());
                putTaskFlag.Value = putForkTaskFlag.GetIndexString();

                var putRow = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSPutRow.ToString());
                putRow.Value = putForkRow;

                var putStation = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSPutPort.ToString());
                putStation.Value = putForkStation;

                var putColumn = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSPutColumn.ToString());
                putColumn.Value = putForkColumn;

                var putLayer = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSPutLayer.ToString());
                putLayer.Value = putForkLayer;

                // -
                var taskNoProp = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSTaskNo.ToString());
                taskNoProp.Value = taskNo;

                // -
                var taskFlagProp = props.Find(t => t.EquipmentTypeTemplateCode == SSRMProps.WCSTaskCompleteFlag.ToString());
                taskFlagProp.Value = completeFlag.GetIndexString();


                propsToWriter.AddRange(new List <EquipmentProp>()
                {
                    action, getTaskFlag, getRow, getColumn, getLayer, getStation, putTaskFlag, putRow, putStation, putColumn, putLayer, taskNoProp, taskFlagProp
                });
                return(plc.Writes(propsToWriter));
            }
            catch (Exception ex)
            {
                Logger.Log($"PLC写入信息错误:" + ex.Message, LogLevel.Exception);
                return(BllResultFactory.Error($"下发任务出现异常:{ex.Message}"));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 下发库内取货与放货任务 相对于库位来说
        /// </summary>
        /// <param name="srm"></param>
        /// <param name="plc"></param>
        /// <param name="task"></param>
        /// <param name="tempFirstStatus"></param>
        /// <param name="tempStatus"></param>
        /// <param name="tempGateway"></param>
        /// <param name="tempLocation"></param>
        /// <returns></returns>
        protected BllResult SendTaskToLocation(Equipment srm, IPLC plc, TaskEntity task, Location tempLocation, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, int tempStatus)
        {
            task.TaskStatus = taskEntityStatus.GetIndexInt();
            var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task);

            if (tempResult.Success)
            {
                // short rowIndex = srm.Code == tempLocation.SrmCode ? tempLocation.RowIndex1.Value : tempLocation.RowIndex2.Value;
                short     rowIndex   = 0;
                BllResult sendResult = SendTaskToSRM(srm, plc, SRMForkAction.货叉1号, forkTaskFlag, rowIndex.ToString(), tempLocation.Line.ToString(), tempLocation.Layer.ToString(), "0", task.Id.ToString());
                if (sendResult.Success)
                {
                    Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,目标库位:{tempLocation.Code}", LogLevel.Success);
                    return(BllResultFactory.Sucess());
                }
                else
                {
                    Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error);
                    //回滚任务状态,记录日志
                    task.TaskStatus = tempStatus;
                    AppSession.Dal.UpdateCommonModel <TaskEntity>(task);
                    return(BllResultFactory.Error());
                }
            }
            else
            {
                Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error);
                return(BllResultFactory.Error($"下发堆垛机{srm.Name}{forkTaskFlag},更新任务{task.Id}状态失败:{tempResult.Msg}"));
            }
        }