| | |
| | | using System.Globalization; |
| | | using static Hanhe.iWCS.JingmenGEMTwoProtocol.PLCControl; |
| | | using Hanhe.iWCS.DeviceDriver; |
| | | using System.Data.OleDb; |
| | | |
| | | namespace Hanhe.iWCS.JingmenGEMTwoProtocol |
| | | { |
| | |
| | | if (trayCode.errCode == 0 && trayCode.result.Length == 80) |
| | | { |
| | | //获取托盘码等信息 读取通道 10、11、12的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineData(pmInfo, trayCode.result); |
| | | string location = ""; |
| | | GetMachineData(pmInfo,ref location, trayCode.result); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | if (tray != null && tray.addState == 0) |
| | | { |
| | |
| | | if (trayCode.errCode == 0 && trayCode.result.Length == 95) |
| | | { |
| | | //获取托盘码等信息 读取通道 11、12、13的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineData(pmInfo, trayCode.result, false, "1"); |
| | | string flLoc = ""; |
| | | string location = ""; |
| | | GetMachineData(pmInfo,ref location, trayCode.result, false, "1"); |
| | | if (pmInfo.location.Contains("FLZT")) |
| | | { |
| | | flLoc = pmInfo.location; |
| | | pmInfo.location = location; |
| | | } |
| | | |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | if (tray != null) |
| | | { |
| | |
| | | { |
| | | CMMLog.Info($"物料编码:{tray.materialCode},批次号:{tray.lotNo}"); |
| | | string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location; |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料", 0, tray.trayCode, timeStamp); |
| | | ProcessHelper.deleteInfo(pmInfo.location + "-包装下线"); |
| | | //包装取料卸货完成,设备生产数量加一 |
| | |
| | | if (trayCode.errCode == 0 && trayCode.result.Length == 80) |
| | | { |
| | | //获取托盘码等信息 读取通道 10、11、12的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineData(pmInfo, trayCode.result); |
| | | string location = ""; |
| | | GetMachineData(pmInfo,ref location, trayCode.result); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | if (tray != null && tray.addState == 0) |
| | | { |
| | |
| | | if (trayCode.errCode == 0 && trayCode.result.Length == 95) |
| | | { |
| | | //获取托盘码等信息 读取通道 11、12、13的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineData(pmInfo, trayCode.result, false, "2"); |
| | | string flLoc = ""; |
| | | string location = ""; |
| | | GetMachineData(pmInfo,ref location, trayCode.result, false, "2"); |
| | | if (pmInfo.location.Contains("FLZT")) |
| | | { |
| | | flLoc = pmInfo.location; |
| | | pmInfo.location = location; |
| | | } |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | if (tray != null) |
| | | { |
| | |
| | | { |
| | | CMMLog.Info($"物料编码:{tray.materialCode},批次号:{tray.lotNo}"); |
| | | string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location; |
| | | HHAmsExecuteResult req; |
| | | if (pmInfo.deviceType == "22") |
| | | { |
| | |
| | | /// 小车到达包装机安全门口请求进入 |
| | | /// </summary> |
| | | /// <param name="ips"></param> |
| | | internal static void PickUpFullDoorUnload(string ip, string taskNo) |
| | | internal static void PickUpFullDoorUnload(string ip, string taskNo, string type) |
| | | { |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip).FirstOrDefault(); |
| | | //ASM写入通道0小车动作,1-取料 |
| | | int[] num = new int[2] { 1, 1 }; |
| | | if(type == "PDA打包下线") |
| | | { |
| | | num[0] = 4; |
| | | } |
| | | var writeRes0 = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | host = ip, |
| | |
| | | var plc = Settings.GetPlcInfo().Where(a => a.ip == ip).FirstOrDefault(); |
| | | if (plc != null) |
| | | { |
| | | //写入包装机--安全门关门指令 |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | if (plc.location.Contains("FLZT")) |
| | | { |
| | | host = ip, |
| | | addr = plc.writeAddr + 1, |
| | | data = 3, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为4."); |
| | | //Console.WriteLine($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为4."); |
| | | //写入返料站台--取货完成 |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = ip, |
| | | addr = plc.writeAddr, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为1."); |
| | | } |
| | | else |
| | | { |
| | | //写入包装机--安全门关门指令 |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = ip, |
| | | addr = plc.writeAddr + 1, |
| | | data = 3, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为3."); |
| | | } |
| | | |
| | | } |
| | | else CMMLog.Debug($"包装下线,4,ip=null!"); |
| | | } |
| | |
| | | |
| | | if (req) |
| | | { |
| | | ProcessHelper.deleteInfo(plc.location + "-复称入缓存架"); |
| | | ProcessHelper.deleteInfo(plc.location + "-复称下线"); |
| | | var queryList = MongoDBSingleton.Instance.Find<packageInfoModel>(Query.And(Query.EQ("machineNo", model.machince), Query.EQ("trayCode", model.ext2), Query.EQ("weight2", "")), "packageInfoModel"); |
| | | if (queryList.Count > 0) |
| | | { |
| | |
| | | MongoDBSingleton.Instance.Update<ProductList>(Query.And(Query.EQ("Date", DateTime.Now.ToString("yyyy-MM-dd")), Query.EQ("machine", model.machince)), Update.Set("percentOfPass", proInfo.percentOfPass).Set("qualifiedQuantity", proInfo.qualifiedQuantity), UpdateFlags.None); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ProcessHelper.recordInfo(plc.location + "-复称下线", "当前半成品库区未获取到可用货位,检查是否已满"); |
| | | } |
| | | |
| | | } |
| | | if (result.result[2] == 2) |
| | |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | if (req) |
| | | { |
| | | ProcessHelper.deleteInfo(plc.location + "-复称入缓存架"); |
| | | ProcessHelper.deleteInfo(plc.location + "-复称下线"); |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 3, |
| | |
| | | else CMMLog.Debug($"packageInfoModel未找到数据,machineNo:{model.machince},trayCode:{model.ext2}"); |
| | | } |
| | | } |
| | | else CMMLog.Debug($"复称入缓存架NG流程:WMS生成任务失败!"); |
| | | else |
| | | { |
| | | ProcessHelper.recordInfo("复称下线", "当前NG库区未获取到可用货位,检查是否已满"); |
| | | CMMLog.Debug($"复称入缓存架NG流程:WMS生成任务失败!"); |
| | | } |
| | | } |
| | | string PlcBit02 = Settings.GetPlcInfo().Where(a => a.deviceType == "2").FirstOrDefault().location; |
| | | UpdateBuilder update = Update.Set("ng", result.result[2]); |
| | |
| | | string ChangeBit = WMSHelper.WmsUpdateWay(taskInfo.CN_S_SOURCE_NO, plc.Extend); |
| | | if (!string.IsNullOrEmpty(ChangeBit)) |
| | | { |
| | | ProcessHelper.deleteInfo("叠包NG"); |
| | | CMMLog.Info($"起点:{taskInfo.CN_S_END_BIT}"); |
| | | CMMLog.Info($"终点:{ChangeBit}"); |
| | | int[] parms = { StockInstance.Instance.GetAGVCodeForBitCode(taskInfo.CN_S_END_BIT), StockInstance.Instance.GetAGVCodeForBitCode(ChangeBit) }; |
| | |
| | | TSHelper.GoToAGV(taskNo, 10, 8); |
| | | |
| | | MongoDBSingleton.Instance.Update<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), Update.Set("CN_S_END_BIT", ChangeBit).Set("CN_S_START_BIT", taskInfo.CN_S_END_BIT), "TN_I_TASK_MST", UpdateFlags.None); |
| | | |
| | | |
| | | MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single); |
| | | |
| | | } |
| | | else CMMLog.Debug($"调用WMS改道接口,未获取到可用点位。"); |
| | | //Console.WriteLine($"读码信息比对结果:条码与传送的数据不一致"); |
| | | else |
| | | { |
| | | CMMLog.Debug($"调用WMS改道接口,未获取到可用点位。"); |
| | | ProcessHelper.recordInfo("叠包NG","NG库区未获取到可用货位,检查NG库区是否已满"); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | string wmstaskno = ""; |
| | | string traycode = ""; |
| | | bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode); |
| | | if (req) CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | else CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务失败!"); |
| | | if (req) |
| | | { |
| | | CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | ProcessHelper.deleteInfo("叠盘下线"); |
| | | } |
| | | else |
| | | { |
| | | ProcessHelper.recordInfo("叠盘下线", "叠盘机下线库区未查询到可用货位,检查叠盘机下线库区是否已满"); |
| | | CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务失败!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | //可生成任务 |
| | | var CBInfo = Settings.GetConnectingbitsList().Where(a => a.enable == 1).ToList(); |
| | | if (CBInfo != null && timecuo != null) |
| | | //if (CBInfo != null) |
| | | { |
| | | string timeStamp = timecuo.data.First().timeStamp.ToString(); |
| | | foreach (var a in CBInfo) |
| | |
| | | /// <param name="info"></param> |
| | | /// <param name="result"></param> |
| | | /// <param name="noPack">true : MES交互方式 false : 无MES交互方式</param> |
| | | private static void GetMachineData(Settings.PlcInfo pmInfo,int[] result ,bool noPack = true,string isOne = "") |
| | | private static void GetMachineData(Settings.PlcInfo pmInfo, ref string loc, int[] result ,bool noPack = true,string isOne = "") |
| | | { |
| | | //Console.WriteLine($"进入数据处理流程!"); |
| | | CMMLog.Info($"进入数据处理流程!"); |
| | |
| | | string empCode = RemoveNull(GetTrayCode(result.Take(5).ToArray()));//员工编码 |
| | | string trayCode = RemoveNull(GetTrayCode(result.Skip(5).Take(3).ToArray()));//托盘码 |
| | | string location = RemoveNull(GetTrayCode(result.Skip(8).Take(1).ToArray()));//设备货位编码 |
| | | loc = location; |
| | | #region 2024-12-30 变更 加入mes生产订单编号 分录ID 变更注释 |
| | | string orderCode = ""; //生产订单编号 |
| | | int fEntryID = 0; //分录ID |
| | |
| | | if (locInfo.state == "1") |
| | | { |
| | | //变更注释 |
| | | //if (string.IsNullOrEmpty(locInfo.END_LOC)) |
| | | //{ |
| | | if (string.IsNullOrEmpty(locInfo.END_LOC)) |
| | | { |
| | | CMMLog.Info("InWarehouse:" + JsonConvert.SerializeObject(locInfo)); |
| | | string wmstaskno = ""; |
| | | string trayCode = locInfo.timeCuo; |
| | |
| | | } |
| | | } |
| | | else CMMLog.Info($"接驳位入立库流程:WMS生成任务失败!"); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //防止辅材回库的终点货位数据没删,导致入库任务计算成了辅材任务,这里需要二次判断 |
| | | // if(locInfo.trayCode.Substring(0,3) == "SWT") |
| | | // { |
| | | // HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), locCode, locInfo.END_LOC, "辅材转运", 0, locInfo.trayCode); |
| | | // } |
| | | // else |
| | | // { |
| | | // MongoDBSingleton.Instance.Update<ConnectingBits>(Query.EQ("_id", locInfo._id), Update.Set("END_LOC", ""), UpdateFlags.None); |
| | | // } |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | //防止辅材出库的终点货位数据没删,导致入库任务计算成了辅材任务,这里需要二次判断 |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), locCode, locInfo.END_LOC, "辅材出库(二段)", 0, locInfo.trayCode); |
| | | if (req.success) |
| | | { |
| | | MongoDBSingleton.Instance.Update<ConnectingBits>(Query.EQ("Bit", locCode), Update.Set("state", "2"), "ConnectingBits", UpdateFlags.None); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info("InWarehouse" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 电钴接驳位入立库任务 |
| | | /// </summary> |
| | | /// <param name="locCode"></param> |
| | | internal static void DGInWarehouse(string locCode) |
| | | { |
| | | try |
| | | { |
| | | var locInfo = MongoDBSingleton.Instance.FindOne<DGConnectingBits>(Query.EQ("Bit", locCode), "DGConnectingBits"); |
| | | if (locInfo != null) |
| | | { |
| | | if (locInfo.state == "1") |
| | | { |
| | | CMMLog.Info("DGInWarehouse:" + JsonConvert.SerializeObject(locInfo)); |
| | | if (!string.IsNullOrEmpty(locInfo.END_LOC)) |
| | | { |
| | | var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), locInfo.Bit, locInfo.END_LOC, "电钴生产退库(二段)", 0, locInfo.trayCode); |
| | | if(amsResult.success) |
| | | { |
| | | CMMLog.Info($"电钴生产退库(二段)流程:WMS生成任务成功!"); |
| | | MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", locCode), Update.Set("state", "2"), "DGConnectingBits", UpdateFlags.None); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | string wmstaskno = ""; |
| | | string trayCode = locInfo.trayCode; |
| | | bool req = WMSHelper.WMSIn(locCode, "电钴打包下线", ref wmstaskno, ref trayCode, "", "DGCK"); |
| | | if (req) |
| | | { |
| | | CMMLog.Info($"电钴接驳位入立库流程:WMS生成任务成功!"); |
| | | MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", locCode), Update.Set("state", "2"), "DGConnectingBits", UpdateFlags.None); |
| | | } |
| | | else CMMLog.Info($"电钴接驳位入立库流程:WMS生成任务失败!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info("DGInWarehouse" + ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | else CMMLog.Info("立库通道未配置"); |
| | | } |
| | | |
| | | internal static void fcrk(Settings.PlcInfo plc) |
| | | internal static void fcrk(Settings.PlcInfo plc,bool action, string taskNo = "") |
| | | { |
| | | int[] num = new int[1] { 2 }; |
| | | var wirte1 = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | if (action) |
| | | { |
| | | addr = plc.writeAddr + 2, |
| | | host = plc.ip, |
| | | port = plc.port, |
| | | data = num |
| | | }); |
| | | CMMLog.Info($"在通道{plc.writeAddr + 2}中写入{JsonConvert.SerializeObject(num)},ip:{plc.ip},端口:{plc.port}"); |
| | | 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 result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 2, |
| | | addr = plc.readAddr, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"查询设备{plc.location}通道{plc.readAddr}里面数据为{result.result[0]}、{result.result[1]}."); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1 && result.result[1] == 2) |
| | | { |
| | | //推送小车进入 |
| | | TSHelper.GoToAGV(taskNo, 10, 1); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int[] num = new int[1] { 2 }; |
| | | var wirte1 = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | addr = plc.writeAddr + 2, |
| | | host = plc.ip, |
| | | port = plc.port, |
| | | data = num |
| | | }); |
| | | CMMLog.Info($"在通道{plc.writeAddr + 2}中写入{JsonConvert.SerializeObject(num)},ip:{plc.ip},端口:{plc.port}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 电钴A(洗板烘干机组)设备上空下满 |
| | | /// </summary> |
| | | /// <param name="plc"></param> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | internal static void AMachine(Settings.PlcInfo plc) |
| | | { |
| | | if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location)) |
| | | { |
| | | try |
| | | { |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //送空 |
| | | bool req = WMSHelper.WMSOut(plc.location, "", ""); |
| | | if (req) CMMLog.Debug($"电钴A设备 调用WMS获取空托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型) |
| | | else CMMLog.Debug($"电钴A设备 调用WMS获取空托出库生成任务失败!"); |
| | | } |
| | | if (result.result[0] == 2) |
| | | { |
| | | //取满 |
| | | string wmstaskno = ""; |
| | | string traycode = ""; |
| | | bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode); |
| | | if (req) CMMLog.Debug($"电钴A设备 调用WMS获取满托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型) |
| | | else CMMLog.Debug($"电钴A设备 调用WMS获取满托入库生成任务失败!"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info($"电钴A设备 err:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 电钴C(钴板剪切机组)设备上满下空 |
| | | /// </summary> |
| | | /// <param name="a"></param> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | internal static void CMachine(Settings.PlcInfo plc) |
| | | { |
| | | if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location)) |
| | | { |
| | | try |
| | | { |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //送满 |
| | | bool req = WMSHelper.WMSOut(plc.location, "", ""); |
| | | if (req) CMMLog.Debug($"电钴C设备 调用WMS获取满托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型) |
| | | else CMMLog.Debug($"电钴C设备 调用WMS获取满托出库生成任务失败!"); |
| | | } |
| | | if (result.result[0] == 2) |
| | | { |
| | | //取空 |
| | | string wmstaskno = ""; |
| | | string traycode = ""; |
| | | bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode); |
| | | if (req) CMMLog.Debug($"电钴C设备 调用WMS获取空托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型) |
| | | else CMMLog.Debug($"电钴C设备 调用WMS获取空托入库生成任务失败!"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info($"电钴C设备 err:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | internal static void DGMachine(Settings.PlcInfo plc, string taskNo, bool action) |
| | | { |
| | | if (action) |
| | | { |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 2, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 2}里面数据为1."); |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 2, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"查询设备{plc.location}通道{plc.readAddr + 2}里面数据为{JsonConvert.SerializeObject(result)}."); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //推送小车进入 |
| | | TSHelper.GoToAGV(taskNo, 10, 1); |
| | | writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 2, |
| | | data = 0, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 2}里面数据为0."); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 3, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 3}里面数据为1."); |
| | | } |
| | | } |
| | | |
| | | internal static void DGMachineTwo(Settings.PlcInfo plc, string taskNo, bool action) |
| | | { |
| | | if (action) |
| | | { |
| | | 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 result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"查询设备{plc.location}通道{plc.readAddr + 1}里面数据为{JsonConvert.SerializeObject(result)}."); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //推送小车进入 |
| | | TSHelper.GoToAGV(taskNo, 10, 3); |
| | | writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr, |
| | | data = 0, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为0."); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 1, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为1."); |
| | | } |
| | | } |
| | | |
| | | internal static void DMachine(Settings.PlcInfo plc) |
| | | { |
| | | if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location)) |
| | | { |
| | | try |
| | | { |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"包装机满托下线:读取通道号为:{plc.readAddr},ip:{plc.ip},端口:{plc.port}"); |
| | | CMMLog.Debug($"包装机满托下线值为:{result.result[0]}"); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //成品下线任务生成到接驳平台 |
| | | string traycode = ""; |
| | | var DGinfoList = MongoDBSingleton.Instance.FindAll<DGPackingLineFullModel>("DGPackingLineFullModel"); |
| | | if (DGinfoList.Count > 0) |
| | | { |
| | | var DGinfo = DGinfoList.Where(a => a.isUse == "0").OrderBy(a => a.createTime).First(); |
| | | //将数据插入中间表 |
| | | traycode = DGinfo.trayCode; |
| | | } |
| | | //可生成任务 |
| | | CMMLog.Debug($"包装机满托下线:获取托盘号:{traycode}"); |
| | | if (!string.IsNullOrEmpty(traycode)) |
| | | { |
| | | var CBInfo = Settings.GetDGConnectingbitsList().Where(a => a.enable == 1).ToList(); |
| | | if (CBInfo != null) |
| | | { |
| | | foreach (var a in CBInfo) |
| | | { |
| | | if (!string.IsNullOrEmpty(a.locCode)) |
| | | { |
| | | //在中间表中查找点位 |
| | | var CBTable = MongoDBSingleton.Instance.FindOne<DGConnectingBits>(Query.EQ("Bit", a.locCode), "DGConnectingBits"); |
| | | if (CBTable != null) |
| | | { |
| | | if (string.IsNullOrEmpty(CBTable.trayCode)) |
| | | { |
| | | //生成任务,并且将点位写入中间表 |
| | | var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), plc.location, a.locCode, "包装机满托下线", 0, traycode); |
| | | if (amsResult.success) |
| | | { |
| | | CMMLog.Debug($"包装机满托下线:AMS调用API成功!"); |
| | | MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", a.locCode), Update.Set("trayCode", traycode), UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<DGPackingLineFullModel>(Query.EQ("trayCode", traycode), Update.Set("isUse", "1"), UpdateFlags.None); |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //生成任务,并且将点位写入中间表 |
| | | var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), plc.location, a.locCode, "包装机满托下线", 0, traycode); |
| | | if (amsResult.success) |
| | | { |
| | | CMMLog.Debug($"包装机满托下线:AMS调用API成功!"); |
| | | //打包下线任务生成成功,向中间表插入数据 |
| | | |
| | | MongoDBSingleton.Instance.Insert<DGConnectingBits>(new DGConnectingBits { Bit = a.locCode, trayCode = traycode, state = "0" }); |
| | | MongoDBSingleton.Instance.Update<DGPackingLineFullModel>(Query.EQ("trayCode", traycode), Update.Set("isUse", "1"), UpdateFlags.None); |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位点位未配置"); |
| | | } |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位未配置"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info($"电钴C设备 err:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | |
| | | public string Msg { get; set; } |
| | | public LKData Data { get; set; } |
| | | public int AffectedRows { get; set; } |
| | | |
| | | public bool Success { get; set; } |
| | | } |
| | | |
| | | public class LKData |
| | | { |
| | | /// <summary> |
| | | /// 批次号 |
| | | /// </summary> |
| | | public string CN_S_LOT_NO { get; set; } |
| | | public int CN_S_EXT8 { get; set; } |
| | | /// <summary> |
| | | /// 物料编码 |
| | | /// </summary> |
| | | public string CN_S_ITEM_CODE { get; set; } |
| | | /// <summary> |
| | | /// 桶重量 |
| | | /// </summary> |
| | | public float CN_F_QUANTITY { get; set; } |
| | | /// <summary> |
| | | /// 桶数量 |
| | | /// </summary> |
| | | public int CN_N_CONUT { get; set; } |
| | | /// <summary> |
| | | /// 生产日期 |
| | | /// </summary> |
| | | public string CN_T_PRODUCTION_S { get; set; } |
| | | |
| | | public string CN_S_EXT8 { get; set; } |
| | | } |
| | | |
| | | #endregion |