| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 3楼打包机下线,判断打包机是否由生成打包下线的任务(四钴车间) |
| | | /// </summary> |
| | | /// <param name="plc"></param> |
| | | internal static void CheckPackingLineFullTwo(Settings.PlcInfo plc) |
| | | { |
| | | //读plc信号,看有没有下线请求,判断是否已经有任务 |
| | | //没有任务,继续plc,包装下线的物料信号 |
| | | //检查打包机通道1是否有出料任务信号,如果有生成取料任务。 |
| | | if (CheckStartFree(plc.location)) |
| | | { |
| | | try |
| | | { |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //获取MODBUS通道里面存放的时间戳 |
| | | var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | addr = plc.readAddr + 10, |
| | | host = plc.ip, |
| | | port = plc.port, |
| | | dataNum = 170 |
| | | }); |
| | | if (resultTime.errCode == 0) |
| | | { |
| | | string wmstaskno = ""; |
| | | TimeCuoInfoComTwo timecuo = TimeCuoTwo(resultTime.result); |
| | | if (timecuo != null) |
| | | { |
| | | string timeStamp = timecuo.TimeCuo; |
| | | //string employeeId = timecuo.employeeId1; |
| | | //// ERP变更-调用ERP接口传输相关数据 |
| | | //WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeStamp, timeStamp, employeeId,true); |
| | | } |
| | | else CMMLog.Info($"时间戳接口返回值为空!"); |
| | | } |
| | | else CMMLog.Info($"MODBUS时间戳数据返回值错误:返回值解析:{JsonConvert.SerializeObject(result)}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 打包机出口MODBUS交互(开始取料,取料完成) |
| | |
| | | /// 设备允许出料 1 PLC写,AMS读 1-设备请求出料;2-允许进入;3-确认货物取走,送出物料; |
| | | |
| | | ///打包线下线——小车开始取货 |
| | | internal static void PackingLineUnload1012(string ip, string taskNo) |
| | | internal static void PackingLineUnload1012(string ip, string taskNo, int port) |
| | | { |
| | | var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); |
| | | if (plc != null) |
| | | { |
| | | try |
| | |
| | | /// </summary> |
| | | /// <param name="ip"></param> |
| | | /// <param name="taskNo"></param> |
| | | internal static void PackingLineComplete4(string ip, string taskNo) |
| | | internal static void PackingLineComplete4(string ip, string taskNo, int port) |
| | | { |
| | | //取货完成后需要读取设备时间戳里面的数据,并将其暂存至中间表等到入库任务完成传输给WMS |
| | | |
| | | var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); |
| | | if (plc != null) |
| | | { |
| | | try |
| | |
| | | |
| | | internal static void CheckPackingLineFullThree(Settings.PlcInfo plc) |
| | | { |
| | | string trayCode = ""; |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 25, |
| | |
| | | if (result.result[0] == 1) |
| | | { |
| | | //获取物料信息 根据托盘码区分 |
| | | string trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); |
| | |
| | | }); |
| | | |
| | | string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); |
| | | UpdateBuilder update = Update.Set("materialCode", materialCode); |
| | | UpdateBuilder update = Update.Set("materialCode", materialCode).Set("createTime",DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), update, UpdateFlags.None); |
| | | |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为1."); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var xxPlc = Settings.GetPlcInfo().Where(a => a.deviceType == "27" && a.enable == 1).FirstOrDefault(); |
| | | if(xxPlc != null) |
| | | { |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if(result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 2, |
| | | addr = plc.readAddr + 8, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (resultTime.errCode == 0) |
| | | { |
| | | string timeCuoData = (resultTime.result[0] * 65536 + resultTime.result[1]).ToString(); |
| | | TimeCuoInfoComTwo time = null; |
| | | var timeTwo = MongoDBSingleton.Instance.Find<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), "TimeCuoInfoComTwo"); |
| | | if(timeTwo.Count > 0) |
| | | { |
| | | time = timeTwo.OrderBy(a => a.createTime).FirstOrDefault(); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("_id", time._id),Update.Set("TimeCuo", timeCuoData)); |
| | | } |
| | | string wmstaskno = ""; |
| | | WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeCuoData, timeCuoData, time.employeeId, true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Info("下线口设备未配置"); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |