| | |
| | | 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 == 95) |
| | | { |
| | | //获取托盘码等信息 读取通道 11、12、13的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | |
| | | string flLoc = ""; |
| | | string location = ""; |
| | | GetMachineData(pmInfo,ref location, trayCode.result, false, "1"); |
| | |
| | | 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}里面数据为4."); |
| | | } |
| | | |
| | | } |
| | | else CMMLog.Debug($"包装下线,4,ip=null!"); |
| | | } |
| | |
| | | //可生成任务 |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <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)); |
| | | string wmstaskno = ""; |
| | | string trayCode = ""; |
| | | bool req = WMSHelper.WMSIn(locCode, "电钴打包下线", ref wmstaskno, ref trayCode, "", "CKHJ"); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | internal static void outWare(string taskNo,bool flage) |
| | | { |
| | | var plc = Settings.GetPlcInfo().Where(a => a.Extend == "2" && a.enable == 1).FirstOrDefault(); |
| | |
| | | } |
| | | } |
| | | |
| | | 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, 3); |
| | | 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 |
| | | }); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //成品下线任务生成到接驳平台 |
| | | string traycode = DateTime.Now.ToString("yyyy-MM-dd").Replace("-", ""); |
| | | //可生成任务 |
| | | var CBInfo = Settings.GetDGConnectingbitsList().Where(a => a.enable == 1).ToList(); |
| | | if (CBInfo != null) |
| | | { |
| | | //string timeStamp = timecuo.data.First().timeStamp.ToString(); |
| | | string timeStamp = ""; |
| | | 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).Set("timeCuo", timeStamp), 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", timeCuo = timeStamp }); |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位点位未配置"); |
| | | } |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位未配置"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | CMMLog.Info($"四钴C设备 err:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | public class WMS_STOCK_VIEW |