| | |
| | | public static class PLCService |
| | | { |
| | | private static readonly object OLock = new object(); |
| | | private static readonly object RuKuLock = new object(); |
| | | private static readonly object OutLock = new object(); |
| | | |
| | | private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); |
| | | private static decimal weight94 = 0; |
| | |
| | | { |
| | | #region 跨跺机任务处理 ########### |
| | | // 判断目标位置是否是跨跺机出库工位 |
| | | if (modTask.EndLocate == "266" && modTask.StartRoadway != "R05") |
| | | if (modTask.EndLocate == "266")// && modTask.StartRoadway != "R05" |
| | | { |
| | | // 判断入库工位是否存在未完成的入库任务 |
| | | var modInTask = _db.Queryable<WcsTask>().OrderBy(m => m.Levels, OrderByType.Asc).OrderBy(m => m.CreateTime, OrderByType.Asc) |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | string aaa = PLCCommon.RoadwayToOutStationNum(modTask.StartRoadway, "1"); // 获取1楼中专工位号 |
| | | taskInfo.Ip = PLCCommon.GetPlcIp(aaa).PlcIP; |
| | | taskInfo.EndPai = "2"; |
| | | taskInfo.EndLie = "60"; |
| | | taskInfo.EndCeng = "1"; |
| | | taskInfo.EndStation = aaa; |
| | | if (modTask.StartRoadway != "R05") |
| | | { |
| | | string aaa = PLCCommon.RoadwayToOutStationNum(modTask.StartRoadway, "1"); // 获取1楼中专工位号 |
| | | taskInfo.Ip = PLCCommon.GetPlcIp(aaa).PlcIP; |
| | | taskInfo.EndPai = "2"; |
| | | taskInfo.EndLie = "60"; |
| | | taskInfo.EndCeng = "1"; |
| | | taskInfo.EndStation = aaa; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (modTask.EndLocate == "265" && modTask.StartRoadway != "R05" && modTask.StartRoadway != "R06") |
| | | if (modTask.EndLocate == "265") // && modTask.StartRoadway != "R05" && modTask.StartRoadway != "R06" |
| | | { |
| | | // 判断入库工位是否存在未完成的入库任务 |
| | | var modInTask = _db.Queryable<WcsTask>().OrderBy(m => m.Levels, OrderByType.Asc).OrderBy(m => m.CreateTime, OrderByType.Asc) |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | string aaa = PLCCommon.RoadwayToOutStationNum(modTask.StartRoadway, "1"); // 获取1楼中专工位号 |
| | | taskInfo.Ip = PLCCommon.GetPlcIp(aaa).PlcIP; |
| | | taskInfo.EndPai = "2"; |
| | | taskInfo.EndLie = "60"; |
| | | taskInfo.EndCeng = "1"; |
| | | taskInfo.EndStation = aaa; |
| | | if (modTask.StartRoadway != "R05" && modTask.StartRoadway != "R06") |
| | | { |
| | | string aaa = PLCCommon.RoadwayToOutStationNum(modTask.StartRoadway, "1"); // 获取1楼中专工位号 |
| | | taskInfo.Ip = PLCCommon.GetPlcIp(aaa).PlcIP; |
| | | taskInfo.EndPai = "2"; |
| | | taskInfo.EndLie = "60"; |
| | | taskInfo.EndCeng = "1"; |
| | | taskInfo.EndStation = aaa; |
| | | } |
| | | } |
| | | |
| | | // 写入放货工位固定地址 |
| | |
| | | |
| | | #region#实时显示重量到LED屏幕 |
| | | var modPosPalletWeightIng = modDevice.listStation.FirstOrDefault(m => m.Text == "实际重量"); |
| | | var (resPalletWeightIng, palletWeightValIng) = plcConn.GetPlcDBValue(modPosPalletWeightIng.PosType, modDevice.DbNumber, modPosPalletWeightIng.PlcPos); |
| | | switch (modDevice.StationNum) |
| | | if (modPosPalletWeightIng != null) |
| | | { |
| | | case "094": |
| | | { |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight94) |
| | | var (resPalletWeightIng, palletWeightValIng) = plcConn.GetPlcDBValue(modPosPalletWeightIng.PosType, modDevice.DbNumber, modPosPalletWeightIng.PlcPos); |
| | | switch (modDevice.StationNum) |
| | | { |
| | | case "094": |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight94 = Convert.ToDecimal(palletWeightValIng); |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight94) |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight94 = Convert.ToDecimal(palletWeightValIng); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case "160": |
| | | { |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight160) |
| | | break; |
| | | case "160": |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight160 = Convert.ToDecimal(palletWeightValIng); |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight160) |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight160 = Convert.ToDecimal(palletWeightValIng); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case "155": |
| | | { |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight155) |
| | | break; |
| | | case "155": |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight155 = Convert.ToDecimal(palletWeightValIng); |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight155) |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight155 = Convert.ToDecimal(palletWeightValIng); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case "152": |
| | | { |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight152) |
| | | break; |
| | | case "152": |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight152 = Convert.ToDecimal(palletWeightValIng); |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight152) |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight152 = Convert.ToDecimal(palletWeightValIng); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case "153": |
| | | { |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight153) |
| | | break; |
| | | case "153": |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight153 = Convert.ToDecimal(palletWeightValIng); |
| | | if (Convert.ToDecimal(palletWeightValIng) != weight153) |
| | | { |
| | | LedDisplay(modDevice.LedIP, $"当前重量(KG):{Convert.ToDecimal(palletWeightValIng)}"); |
| | | weight153 = Convert.ToDecimal(palletWeightValIng); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | |
| | | var http = new HttpService(); |
| | | string TaskNo = "", EndLocate = ""; |
| | | |
| | | //根据工位判断是否为叠托机工位申请空托盘跺入库,是:向WMS申请空托盘跺组托 |
| | | string groupMsg = ""; |
| | | if (modDevice.StationNum == "72") |
| | | { |
| | | groupMsg = http.BindNullPalletWcs(10, palletVal); |
| | | |
| | | if (groupMsg.Contains("-1")) |
| | | { |
| | | // 写入输送线退回指令 |
| | | var ret = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modPosEndLocat.PlcPos, modDevice.StationNum); |
| | | if (ret.IsSucceed) |
| | | { |
| | | plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "350"); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //向WMS申请巷道 |
| | | strMsg = http.RequestRoadWay(palletVal, modDevice.StationNum, taskModel, louCeng, ref EndLocate, ref TaskNo, (int)palletHeightVal); |
| | | |
| | | if (!strMsg.Contains("-1")) |
| | |
| | | #endregion |
| | | |
| | | var http = new HttpService(); |
| | | string TaskNo = ""; |
| | | // 向WMS申请储位信息 |
| | | strMsg = http.RequestLocate(palletVal, modDevice.StationNum, taskModel, roadway, ref TaskNo, (int)taskInfo2.PalletQty); |
| | | string TaskNo = ""; |
| | | lock (RuKuLock) |
| | | { |
| | | // 向WMS申请储位信息 |
| | | strMsg = http.RequestLocate(palletVal, modDevice.StationNum, taskModel, roadway, ref TaskNo, (int)taskInfo2.PalletQty); |
| | | } |
| | | |
| | | // 根据任务号获取起始工位地址,根据起始工位地址获取LEDIP 推送到LED屏幕。 |
| | | var taskInfo = _db.Queryable<WcsTask>().First(w => w.TaskNo == TaskNo); |
| | |
| | | TaskType = ((int)TaskTypeEnum.Out).ToString(), |
| | | TaskStatus = ((int)TaskStatusEnum.Complete).ToString() |
| | | }; |
| | | HttpService httpService = new HttpService(); |
| | | var modResponseTask = httpService.RequestTask(requestMode).Result; |
| | | if (modResponseTask.StatusCode == 0) |
| | | { |
| | | modInsertTaskMonitor.InteractiveMsg += ",返回给WMS任务完成"; |
| | | } |
| | | else |
| | | { |
| | | Log.Error(string.Format("任务反馈失败:StatusCode:{0};Msg:{1}", modResponseTask.StatusCode, modResponseTask.Msg)); |
| | | lock(OutLock) |
| | | { |
| | | HttpService httpService = new HttpService(); |
| | | var modResponseTask = httpService.RequestTask(requestMode).Result; |
| | | if (modResponseTask.StatusCode == 0) |
| | | { |
| | | modInsertTaskMonitor.InteractiveMsg += ",返回给WMS任务完成"; |
| | | } |
| | | else |
| | | { |
| | | Log.Error(string.Format("任务反馈失败:StatusCode:{0};Msg:{1}", modResponseTask.StatusCode, modResponseTask.Msg)); |
| | | } |
| | | } |
| | | } |
| | | |