| | |
| | | data = num,//原先是1,单个写入 |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为1."); |
| | | Console.WriteLine($"写入设备{plc.location}通道{plc.writeAddr}里面数据为1."); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为{JsonConvert.SerializeObject(num)}."); |
| | | Console.WriteLine($"写入设备{plc.location}通道{plc.writeAddr}里面数据为{JsonConvert.SerializeObject(num)}."); |
| | | ///小车和复称位对接 |
| | | //小车请求进料,并且查询设备是否允许AGV进入 |
| | | var readRes = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | |
| | | CMMLog.Debug($"改AGV参数:10,4"); |
| | | //判断任务起点,找到起点包装机设备号,在中间表MachineInfo中查找上一台设备(包装机)的数据,通过modbus通道传入(数据需要转换,ASCII转16short,可能还需要数据拆分) |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | if (plc.deviceType == "21") |
| | | if (plc.deviceType == "22") |
| | | { |
| | | //四钴车间 |
| | | var machine = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), "MachineInfo"); |
| | | var machine = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), "MachineInfoTetracobalt"); |
| | | if (machine != null) |
| | | { |
| | | CMMLog.Debug("进入machine判断"); |
| | |
| | | // num[b] = Convert.ToInt32(Convert.ToString(int.Parse(taskInfo.Ext2), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); |
| | | //} |
| | | |
| | | CMMLog.Debug($"{num}"); |
| | | Console.WriteLine(num); |
| | | CMMLog.Debug($"{JsonConvert.SerializeObject(num)}"); |
| | | var wirteall = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | addr = plc.writeAddr + 5, |
| | |
| | | }); |
| | | if (result.result.Length > 0) |
| | | { |
| | | MongoDBSingleton.Instance.Update<MachineInfo>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]), UpdateFlags.None); |
| | | if(plc.deviceType == "22") |
| | | { |
| | | var newWeight = result.result[19] + "," + result.result[20]; |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]), UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]).Set("oneTrayWeightFC",newWeight), UpdateFlags.None); |
| | | } |
| | | else |
| | | { |
| | | MongoDBSingleton.Instance.Update<MachineInfo>(Query.EQ("trayCode", model.ext2), Update.Set("secondNg", result.result[2]), UpdateFlags.None); |
| | | } |
| | | |
| | | //获取从复称平台读出的 时间戳,并转换处理为 string 字符串 |
| | | //string timeStamp = Convert.ToInt32(Completion(result.result[26]) + Completion(result.result[27]), 2).ToString(); |
| | | string timeStamp = Convert.ToInt32(Completion(result.result[25]) + Completion(result.result[26]), 2).ToString(); |
| | |
| | | } |
| | | |
| | | if (result.result[0] == 3 && result.result[2] == 1) |
| | | //if (result.result[2] == 1) |
| | | { |
| | | CMMLog.Info($"SecondWeightActionOne:准备生成复称入缓存架任务,开始确定托盘号:{model.ext2}"); |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | if(plc.deviceType == "22") |
| | | { |
| | | req = WMSHelper.WMSInTwo(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | else |
| | | { |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | |
| | | ERPService.updatePackageInfo(model.machince, model.ext2, result.result); |
| | | //if (req) TSHelper.GoToAGV(cN_S_TASK_NO, 10, 6); |
| | | //else CMMLog.Debug($"WMS返回{req}"); |
| | |
| | | { |
| | | //复称平台复称货物NG——进入NG复称流程 调用WMS接口分配货架库位 |
| | | //TSHelper.GoToAGV(cN_S_TASK_NO, 10, 6); |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | if(plc.deviceType == "22") |
| | | { |
| | | req = WMSHelper.WMSInTwo(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | else |
| | | { |
| | | req = WMSHelper.WMSIn(plc.location, model.ext2, ref wmstaskno, ref traycode, timeStamp); |
| | | } |
| | | |
| | | if (req) CMMLog.Info($"SecondWeightActionOne:复称入缓存架NG流程:WMS生成任务成功!"); |
| | | else CMMLog.Info($"SecondWeightActionOne:复称入缓存架NG流程:WMS生成任务失败!"); |
| | | var plcInfo = Settings.GetPlcInfo().Where(a => a.location == model.ext3).FirstOrDefault(); |
| | |
| | | CMMLog.Debug($"三楼双层缓存架卸货交互:trayCode:{trayCodeTask.CN_S_BATCH_NO}"); |
| | | if (plc.deviceType =="22") |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfo", RemoveFlags.Single); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfoTetracobalt", RemoveFlags.Single); |
| | | if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("trayCode", trayCodeTask.CN_S_BATCH_NO), "MachineInfoTetracobalt", RemoveFlags.Single); |
| | | } |
| | | else |
| | |
| | | var writeRes1 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 3,// + 4 |
| | | addr = plc.writeAddr, |
| | | data = 0, |
| | | port = plc.port |
| | | }); |
| | | |
| | | writeRes1 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 3, |
| | | data = 1, |
| | | port = plc.port |
| | | }); |
| | | //var writeRes1 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | //{ |
| | | // host = plc.ip, |
| | | // addr = plc.writeAddr + 3, |
| | | // data = 1, |
| | | // port = plc.port |
| | | //}); |
| | | } |
| | | } |
| | | |
| | |
| | | else if (readres.result[0] == 2) |
| | | { |
| | | TSHelper.GoToAGV(taskNo, 10, 3); |
| | | //var task = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | //var machine = MongoDBSingleton.Instance.FindOne<WMSInfo>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "WMSInfo"); |
| | | //if (machine != null) |
| | | //{ |
| | | // if (Settings.cacheStackWrite == "0") |
| | | // { |
| | | // int[] num = DiePan(machine); |
| | | // |
| | | // var wirteall01 = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | // { |
| | | // addr = plc.writeAddr + 10, |
| | | // host = plc.ip, |
| | | // port = plc.port, |
| | | // data = num |
| | | // }); |
| | | // } |
| | | // else WriteCacheStackingData(plc, task, machine); |
| | | // |
| | | // var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | // { |
| | | // addr = plc.writeAddr + 1, |
| | | // host = plc.ip, |
| | | // port = plc.port, |
| | | // data = 2 |
| | | // }); |
| | | //} |
| | | } |
| | | } |
| | | else CMMLog.Debug($"缓存入叠盘机,1013,plc=null!"); |
| | |
| | | if (plc.deviceType == "23") |
| | | { |
| | | //四钴车间 |
| | | var machineTwo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwo"); |
| | | var machineTwo = MongoDBSingleton.Instance.FindOne<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwoTetracobalt"); |
| | | CMMLog.Info($"3楼缓存架入叠托:收到信号4,查询MachineInfoTwoTetracobalt表信息:{JsonConvert.SerializeObject(machineTwo)}。"); |
| | | if (machineTwo != null) |
| | | { |
| | |
| | | CMMLog.Info($"3楼缓存架入叠托:写入数据:{JsonConvert.SerializeObject(num)},IPort:{plc.ip},{plc.port}"); |
| | | var wirteall01 = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | addr = plc.writeAddr + 10, |
| | | addr = plc.writeAddr + 5, |
| | | host = plc.ip, |
| | | port = plc.port, |
| | | data = num |
| | |
| | | CMMLog.Info($"3楼缓存架入叠托:返回数据:{JsonConvert.SerializeObject(wirteall01)},IPort:{plc.ip},{plc.port}"); |
| | | if (wirteall01.errCode == 0) |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwo", RemoveFlags.Single); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", task.CN_S_BATCH_NO), "MachineInfoTwoTetracobalt", RemoveFlags.Single); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | |
| | | var ErpItemInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", machineInfoTwo.materialCode), "ERPItemTable"); |
| | | CMMLog.Info($"3楼缓存架入叠托:收到信号5,查询MachineInfoTwoTetracobalt表信息:{JsonConvert.SerializeObject(ErpItemInfo)}。"); |
| | | CMMLog.Info($"3楼缓存架入叠托:收到信号4,查询ERPItemTable表信息:{JsonConvert.SerializeObject(ErpItemInfo)}。"); |
| | | |
| | | //偏移量 +11 通道范围: 40311 ~ 40390 |
| | | CMMLog.Info($"叠盘机数据处理."); |
| | | //10~19通道 |
| | | int[] num = new int[105];//总长度:80 |
| | | int[] num = new int[105];//总长度:105 |
| | | |
| | | #region 0~23 => 6~29 |
| | | int a = 0;//员工编号处理 |
| | |
| | | a = 0;//托盘码处理 |
| | | for (int b = 5; b <= 7; b++) |
| | | { |
| | | num[b] = int.Parse(AsciiToTen(machine.trayCode.Substring(a, 2))); |
| | | a = a + 2; |
| | | //num[b] = int.Parse(AsciiToTen(machine.trayCode.Substring(a, 2))); |
| | | //a = a + 2; |
| | | |
| | | num[b] = 0; |
| | | } |
| | | num[8] = int.Parse(AsciiToTen(machine.location));//包装机号 |
| | | for (int b = 9; b <= 10; b++) |
| | |
| | | int k = b % 2 == 0 ? 0 : 16; |
| | | num[b] = Convert.ToInt32(Convert.ToString(int.Parse(machine.oneTrayWeight), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); |
| | | } |
| | | for (int b = 15; b <= 16; b++) num[b] = 0;// 叠包后实际重量 && 复称结果 默认:0 |
| | | for (int b = 15; b <= 16; b++) |
| | | { |
| | | var arrTwo = machineInfoTwo.oneTrayWeightFC.Split(',').ToList(); |
| | | num[b] = int.Parse(arrTwo[b - 15]);//复称重量 |
| | | } |
| | | //for (int b = 15; b <= 16; b++) num[b] = 0;// 叠包后实际重量 && 复称结果 默认:0 |
| | | num[17] = int.Parse(machineInfoTwo.trayType); |
| | | |
| | | num[18] = machine.addState;//是否需要叠包 |
| | |
| | | var plc = Settings.GetPlcInfo().Where(a => a.deviceType == ip).FirstOrDefault(); |
| | | if(plc != null) |
| | | { |
| | | OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | if(plc.deviceType == "23") |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | | host = plc.ip, |
| | | data = 2,//4 |
| | | port = plc.port |
| | | }); |
| | | Thread.Sleep(100); |
| | | var readres = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 2, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (readres != null) |
| | | { |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | if (readres.result[0] == 3 && readres.result[1] == 1) |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值3。"); |
| | | //读码信息比对结果:OK 读到通道2参数为1时,小车将托盘放置在叠盘机上(改参数10为7) |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | addr = plc.writeAddr + 1, |
| | | host = plc.ip, |
| | | data = 3, |
| | | port = plc.port |
| | | }); |
| | | if (wirte.errCode == 0) |
| | | { |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single); |
| | | |
| | | wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | | host = plc.ip, |
| | | data = 3,//4 |
| | | data = 0, |
| | | port = plc.port |
| | | }); |
| | | if (wirte.errCode == 0) |
| | | TSHelper.GoToAGV(taskNo, 10, 7); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | | host = plc.ip, |
| | | data = 2, |
| | | port = plc.port |
| | | }); |
| | | var readres = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 2, |
| | | addr = plc.readAddr + 1, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if (readres != null) |
| | | { |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | if (readres.result[0] == 3 && readres.result[1] == 1) |
| | | { |
| | | //并删除WMSInfo中间表中对应托盘号的数据(也可在小车离开叠盘机之后删除,暂定通道2参数1) |
| | | CMMLog.Debug($"读码信息比对结果:OK ,并删除WMSInfo中间表中对应托盘号的数据"); |
| | | MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single); |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值4。"); |
| | | if (CacheStackingMouth8(plc)) |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值3。"); |
| | | //读码信息比对结果:OK 读到通道2参数为1时,小车将托盘放置在叠盘机上(改参数10为7) |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值成功,更改AGV参数10为7,让小车离开。"); |
| | | TSHelper.GoToAGV(taskNo, 10, 7); |
| | | addr = plc.writeAddr + 1, |
| | | host = plc.ip, |
| | | data = 3, |
| | | port = plc.port |
| | | }); |
| | | if (wirte.errCode == 0) |
| | | { |
| | | //并删除WMSInfo中间表中对应托盘号的数据(也可在小车离开叠盘机之后删除,暂定通道2参数1) |
| | | CMMLog.Debug($"读码信息比对结果:OK ,并删除WMSInfo中间表中对应托盘号的数据"); |
| | | MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single); |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值4。"); |
| | | if (CacheStackingMouth8(plc)) |
| | | { |
| | | CMMLog.Debug($"3楼缓存架入叠托OK:TaskNo:{taskInfo.CN_S_TASK_NO},叠包OK写入值成功,更改AGV参数10为7,让小车离开。"); |
| | | TSHelper.GoToAGV(taskNo, 10, 7); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (readres.result[0] == 3 && readres.result[1] == 2) |
| | | { |
| | | CMMLog.Debug($"读码信息比对结果:条码与传送的数据不一致"); |
| | | //二期--调用 WMS 改道接口 获取 目标点位,并 更改 AGV 站点 |
| | | string ChangeBit = WMSHelper.WmsUpdateWay(taskInfo.CN_S_SOURCE_NO, plc.Extend); |
| | | if (!string.IsNullOrEmpty(ChangeBit)) |
| | | else if (readres.result[0] == 3 && readres.result[1] == 2) |
| | | { |
| | | int[] parms = { StockInstance.Instance.GetAGVCodeForBitCode(taskInfo.CN_S_END_BIT), StockInstance.Instance.GetAGVCodeForBitCode(ChangeBit) }; |
| | | TSHelper.ChangeParam(taskNo, 1, parms); |
| | | TSHelper.GoToAGV(taskNo, 3, 1);// 泰州格林美更改起点层数为1-荆门也需要更改 |
| | | CMMLog.Debug($"读码信息比对结果:条码与传送的数据不一致"); |
| | | //二期--调用 WMS 改道接口 获取 目标点位,并 更改 AGV 站点 |
| | | string ChangeBit = WMSHelper.WmsUpdateWay(taskInfo.CN_S_SOURCE_NO, plc.Extend); |
| | | if (!string.IsNullOrEmpty(ChangeBit)) |
| | | { |
| | | int[] parms = { StockInstance.Instance.GetAGVCodeForBitCode(taskInfo.CN_S_END_BIT), StockInstance.Instance.GetAGVCodeForBitCode(ChangeBit) }; |
| | | TSHelper.ChangeParam(taskNo, 1, parms); |
| | | TSHelper.GoToAGV(taskNo, 3, 1);// 泰州格林美更改起点层数为1-荆门也需要更改 |
| | | |
| | | //TSHelper.ChangeParam(taskNo, 1, StockInstance.Instance.GetAGVCodeForBitCode(taskInfo.CN_S_END_BIT)); |
| | | //TSHelper.ChangeParam(taskNo, 2, 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); |
| | | //TSHelper.ChangeParam(taskNo, 1, StockInstance.Instance.GetAGVCodeForBitCode(taskInfo.CN_S_END_BIT)); |
| | | //TSHelper.ChangeParam(taskNo, 2, 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); |
| | | } |
| | | else CMMLog.Debug($"调用WMS改道接口,未获取到可用点位。"); |
| | | Console.WriteLine($"读码信息比对结果:条码与传送的数据不一致"); |
| | | } |
| | | else CMMLog.Debug($"调用WMS改道接口,未获取到可用点位。"); |
| | | Console.WriteLine($"读码信息比对结果:条码与传送的数据不一致"); |
| | | //PLCControl.CacheStackingMouth6(plc); |
| | | } |
| | | //PLCControl.CacheStackingMouth6(plc); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="ip"></param> |
| | | /// <param name="taskNo"></param> |
| | | internal static void CacheStackingMouth6(Settings.PlcInfo plc) |
| | | internal static void CacheStackingMouth6(Settings.PlcInfo plc, string taskNo) |
| | | { |
| | | //var readres = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | //{ |
| | | // dataNum = 2, |
| | | // addr = plc.readAddr + 1, |
| | | // host = plc.ip, |
| | | // port = plc.port |
| | | //}); |
| | | //if (readres != null) |
| | | //{ |
| | | |
| | | //} |
| | | var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); |
| | | MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single); |
| | | var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | | data = 3, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | Thread.Sleep(2000); |
| | | wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = plc.writeAddr + 1, |
| | | data = 0, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Info($"叠盘下线读取通道{plc.ip},port:{plc.port},地址:{plc.readAddr + 1}的值为{JsonConvert.SerializeObject(result)}"); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | //1.满托下线 |
| | |
| | | { |
| | | string wmstaskno = ""; |
| | | string traycode = ""; |
| | | string trayType = result.result[1] == 1 ? "川字托" : "田字托"; |
| | | string trayType = ""; |
| | | if (plc.deviceType == "25") |
| | | { |
| | | trayType = result.result[1] == 1 ? "川字托" : result.result[1] == 2 ? "田字托" : ""; |
| | | if (string.IsNullOrEmpty(trayType)) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode,"","",false, trayType); |
| | | if (req) CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | if (req) |
| | | { |
| | | CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务成功!"); |
| | | if (plc.deviceType == "25") |
| | | { |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", plc.location), "trayTypeTable"); |
| | | if (trayTypeInfo == null) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | { |
| | | locCode = plc.location, |
| | | trayType = result.result[1].ToString() |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | else CMMLog.Debug($"调用WMS获取三楼叠盘机生成任务失败!"); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <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 |
| | |
| | | /// <param name="info"></param> |
| | | /// <param name="result"></param> |
| | | /// <param name="noPack">true : MES交互方式 false : 无MES交互方式</param> |
| | | private static void GetMachineDataTetracobalt(int[] result ,bool noPack = true) |
| | | private static void GetMachineDataTetracobalt(int[] result, ref string timeStamp, bool noPack = true) |
| | | { |
| | | CMMLog.Info($"数据处理流程:进入数据处理流程!"); |
| | | |
| | | string empCode = GetTrayCode(result.Take(5).ToArray());//员工编码 |
| | | string empCode = RemoveNull(GetTrayCode(result.Take(5).ToArray()));//员工编码 |
| | | string trayCode = GetTrayCode(result.Skip(5).Take(3).ToArray());//托盘码 |
| | | trayCode = "0"; |
| | | string location = GetTrayCode(result.Skip(8).Take(1).ToArray());//设备货位编码 |
| | | if(trayCode != null && location != null) |
| | | { |
| | |
| | | } |
| | | else CMMLog.Info($"数据处理流程:包装机无MES情况下,模拟MES数据,中间表<MachineInfoTetracobalt>中已有当前包装机号{location}为首的数据"); |
| | | } |
| | | var info = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", location), "MachineInfo"); |
| | | var info = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", location), "MachineInfoTetracobalt"); |
| | | |
| | | if (info != null) |
| | | { |
| | |
| | | info.addState = Convert.ToInt32(Completion(result[18]), 2); |
| | | if (info.addState == 0) CMMLog.Error($"数据处理流程:获取MODBUS信息异常:是否叠包值为0."); |
| | | info.packageCode = Convert.ToInt32(Completion(result[19]), 2).ToString(); |
| | | info.productTime = Convert.ToInt32(Completion(result[21]) + Completion(result[22]), 2).ToString(); |
| | | info.productTime = Convert.ToInt32(Completion(result[20]) + Completion(result[21]), 2).ToString(); |
| | | |
| | | //info.addWeight = Convert.ToInt32(Completion(result[10]) + Completion(result[11]), 2).ToString(); |
| | | //info.packNg = 1;//不需要此参数 result[12] |
| | |
| | | } |
| | | else CMMLog.Info($"数据处理流程:请查询<MachineInfoTetracobalt>表中machineNo字段是否为当前包装机号,并且trayCode是否为0"); |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")), "MachineInfo"); |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")), "MachineInfoTetracobalt"); |
| | | |
| | | if (infoPack != null) |
| | | { |
| | |
| | | //注意:这里赋值中间表参数请对照信息交互表具体通道值对应 |
| | | UpdateBuilder update = Update.Set("palletLayers", info.secondNg.ToString()).Set("overlappingLayers", info.addState.ToString()).Set("bagNo", info.packageCode). |
| | | Set("lotNo", info.lotNo).Set("productType", info.productType).Set("materialCode", info.materialCode).Set("materialName", info.materialName).Set("measurementUnit", info.measurementUnit); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("machineNo", location), update, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), update, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("machineNo", location), update, "MachineInfoTetracobalt", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), update, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | } |
| | | //在中间表中找到刚刚插入的MES数据(目前还没有读取并写入设备数据) |
| | | |
| | | timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | trayCode = "VW" + timeStamp; |
| | | |
| | | var query1 = Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")); |
| | | UpdateBuilder updateBuider = Update.Set("empCode", info.empCode).Set("location", info.location). |
| | | Set("trayCode", info.trayCode).Set("productWeight", info.productWeight). |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight). |
| | | Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("productTime", info.productTime). |
| | | Set("trayCode", trayCode).Set("productWeight", info.productWeight). |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight).Set("trayType", info.trayType).Set("addState", info.addState). |
| | | Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("productTime", info.productTime).Set("packageCode", info.packageCode). |
| | | Set("jsonData", json).Set("modify", DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<MachineInfo>(query1, updateBuider, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query1, updateBuider, "MachineInfoTetracobalt", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(query1, updateBuider, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | CMMLog.Info($"数据处理流程:更新MachineInfoTetracobalt中间表刚刚插入的MES数据!设备号为:{location},托盘号为:{trayCode}"); |
| | | } |
| | | else |
| | |
| | | Set("trayCodeWeight", info.trayCodeWeight).Set("oneTrayWeight", info.oneTrayWeight). |
| | | Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("productTime", info.productTime). |
| | | Set("jsonData", json).Set("modify", DateTime.Now); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query2, updateBuider, "MachineInfo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwo", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(query2, updateBuider, "MachineInfoTetracobalt", UpdateFlags.None); |
| | | MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("trayCode", trayCode), updateBuider, "MachineInfoTwoTetracobalt", UpdateFlags.None); |
| | | CMMLog.Info($"数据处理流程:更新MachineInfoTetracobalt中间表其他设备的数据!设备号为:{location},托盘号为:{trayCode}"); |
| | | } |
| | | else CMMLog.Info($"数据处理流程:无法在MachineInfoTetracobalt中间表中找到当前设备编号的数据!当前设备编号为:{location},托盘码为:{trayCode}"); |
| | |
| | | internal static void CheckPackingMachineTetracobalt(Settings.PlcInfo pmInfo) |
| | | { |
| | | //var count = MongoDBSingleton.Instance.FindOne<>//occupy |
| | | var count = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("occupy", "1"), "MachineInfo"); |
| | | var count = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("occupy", "1"), "MachineInfoTetracobalt"); |
| | | |
| | | //检查包装机通道0是否有下料信号,如果有生成下料任务。线程循环读取,无需设置循环。——通道0参数为1 |
| | | if (count == null) |
| | |
| | | if (trayCode.errCode == 0 && trayCode.result.Length == 105) |
| | | { |
| | | //获取托盘码等信息 读取通道 11、12、13的数据作为托盘码 读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表 |
| | | GetMachineDataTetracobalt(trayCode.result, false); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo"); |
| | | string timeStamp = ""; |
| | | GetMachineDataTetracobalt(trayCode.result, ref timeStamp, false); |
| | | var tray = MongoDBSingleton.Instance.FindOne<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTetracobalt"); |
| | | if (tray != null) |
| | | { |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:MachineInfoTetracobalt数据插入成功!"); |
| | | bool IsContLaterCode = true; |
| | | if (ERPService.ERPSwitch01 == "1") |
| | | { |
| | | string employeeId = "G" + tray.trayCodeWeight.PadLeft(7, '0'); |
| | | string employeeId = "G" + tray.empCode.PadLeft(7, '0'); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码:{employeeId}"); |
| | | // 判断当前【员工编号】通道信息读出来的员工编号是否已经存在于我们的员工信息表-ERPEmployeeTable(查询字段-employee_id) |
| | | var erpEmployeeInfo = MongoDBSingleton.Instance.FindOne<ERPEmployeeTable>(Query.EQ("employee_id", employeeId), "ERPEmployeeTable"); |
| | | if (erpEmployeeInfo == null) IsContLaterCode = false; |
| | | var erpItemInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", tray.materialCode), "ERPItemTable"); |
| | | if (string.IsNullOrEmpty(tray.empCode) || string.IsNullOrEmpty(tray.materialCode) || erpEmployeeInfo == null || erpEmployeeInfo == null) |
| | | { |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:人员表或者物料表未找到该数据,员工编号:{employeeId},物料编码:{tray.materialCode}!"); |
| | | IsContLaterCode = false; |
| | | } |
| | | else CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码查询成功"); |
| | | } |
| | | |
| | | if (IsContLaterCode) |
| | | { |
| | | //检索员工信息成功 |
| | | var wirteall01 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | addr = pmInfo.writeAddr, |
| | | host = pmInfo.ip, |
| | | port = pmInfo.port, |
| | | data = 4 |
| | | }); |
| | | |
| | | //string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | //tray.trayCode = "VW" + timeStamp; |
| | | //MongoDBSingleton.Instance.Update<MachineInfoTetracobalt>(Query.EQ("_id", tray._id), Update.Set("trayCode", tray.trayCode), UpdateFlags.None); |
| | | //MongoDBSingleton.Instance.Update<MachineInfoTwoTetracobalt>(Query.EQ("_id", tray._id), Update.Set("trayCode", tray.trayCode), UpdateFlags.None); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:托盘码:{tray.trayCode}"); |
| | | if (tray.addState == 0) |
| | | { |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfo", RemoveFlags.None); |
| | | MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTetracobalt", RemoveFlags.None); |
| | | if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTetracobalt>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:叠托层数为0,不允许生成任务"); |
| | | } |
| | | else if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) |
| | | { |
| | | string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); |
| | | HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料(四钴)", 0, tray.trayCode, timeStamp); |
| | | if (req.success) |
| | | { |
| | | string weight = (double.Parse(tray.oneTrayWeight) / 100).ToString(); |
| | | //int weight = int.Parse(tray.oneTrayWeight) / 100; |
| | | ERPService.packageInfo(tray.machineNo, tray.trayCode, tray.lotNo, weight); |
| | | |
| | | //记录托盘类型 |
| | | var trayTypeInfo = MongoDBSingleton.Instance.FindOne<trayTypeTable>(Query.EQ("locCode", pmInfo.location), "trayTypeTable"); |
| | | if(trayTypeInfo == null) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<trayTypeTable>(new trayTypeTable |
| | | { |
| | | locCode = pmInfo.location, |
| | | trayType = tray.trayType |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Debug($"(四钴车间)包装下线流程-{pmInfo.location}:员工编码查询失败"); |
| | | //检索员工信息失败写入对方通道值1 读取地址+3 |
| | | var wirteall01 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | |
| | | // } |
| | | // else CMMLog.Info($"当前包装机出现故障,无法生成任务。包装机号:{pmInfo.location}"); |
| | | } |
| | | else CMMLog.Debug($"当前machineInfo中间表已存在数据:{JsonConvert.SerializeObject(count)}"); |
| | | else CMMLog.Debug($"当前MachineInfoTetracobalt中间表已存在数据:{JsonConvert.SerializeObject(count)}"); |
| | | } |
| | | |
| | | |
| | |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | //3:人工叫空托盘(川字) 4:人工叫空托盘(田字) |
| | | if (result.result[0] == 3 || result.result[0] == 4) |
| | | if ((pmInfo.deviceType == "1" && result.result[0] == 3)|| (pmInfo.deviceType == "21" &&(result.result[0] == 3 || result.result[0] == 4))) |
| | | { |
| | | //包装线补空流程 |
| | | //判断空托缓存点(5 对 2)是否有空托,有空托判断是否有任务,有任务则判断另一个点位 |
| | |
| | | { |
| | | CMMLog.Info($"周转托盘位:{a}"); |
| | | var ddInfo = Settings.GetDDSiteList().Where(b => b.ddLoc == a && b.Enable == 1).FirstOrDefault(); |
| | | if(ddInfo != null) |
| | | if (ddInfo != null) |
| | | { |
| | | if(ddInfo.trayType == result.result[0] - 2) |
| | | if (ddInfo.trayType == result.result[0] - 2) |
| | | { |
| | | if (ProcessHelper.PickUpEndFree(pmInfo.location) && ProcessHelper.PickUpStartFree(a)) |
| | | { |
| | |
| | | CMMLog.Info("配置文件未配置包装机空托缓存点"); |
| | | } |
| | | } |
| | | //流程未对接好,是否这样使用 待定 |
| | | //if (result.result[0] == 4) |
| | | //{ |
| | | // //调用wms出库接口 |
| | | // var tasks = MongoDBSingleton.Instance.Find<TN_I_TASK_MST>(Query.EQ("CN_S_END_BIT", pmInfo.location), "TN_I_TASK_MST"); |
| | | // //判断一下当前叠托点是否有任务占用 |
| | | // if (ProcessHelper.CheckEndFree(pmInfo.location) && tasks.Count == 0) |
| | | // { |
| | | // //可以生成任务,调WMS接口获取任务信息 |
| | | // bool req = WMSHelper.WMSOut(pmInfo.location, ""); |
| | | // if (req) CMMLog.Debug($"调用WMS获取辅材出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型) |
| | | // else CMMLog.Debug($"调用WMS获取辅材出库生成任务失败!"); |
| | | // } |
| | | // else CMMLog.Debug($"检查当前叠托点是否有任务占用,或者MST主表中有缓存架入叠盘机的任务!"); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (action) |
| | | { |
| | | int[] num = new int[3] {1,1,1}; |
| | | int[] num = new int[3] {1,0,1}; |
| | | var writeRes = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | host = plc.ip, |
| | |
| | | { |
| | | //推送小车进入 |
| | | TSHelper.GoToAGV(taskNo, 10, 3); |
| | | writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | |
| | | int[] num1 = new int[2] { 1, 2}; |
| | | writeRes = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 2, |
| | | data = 2, |
| | | addr = plc.writeAddr + 1, |
| | | data = num1, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 2}里面数据为2."); |
| | | |
| | | //writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | //{ |
| | | // host = plc.ip, |
| | | // addr = plc.writeAddr + 2, |
| | | // data = 2, |
| | | // port = plc.port |
| | | //}); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为{JsonConvert.SerializeObject(num1)}."); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (action) |
| | | { |
| | | int[] num = new int[4] { 2, 0, 1, 1 }; |
| | | var writeRes = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = plc.readAddr + 3, |
| | | host = plc.ip, |
| | | addr = plc.writeAddr, |
| | | data = num, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为{JsonConvert.SerializeObject(num)}."); |
| | | CMMLog.Debug($"查询设备{plc.location}通道{plc.readAddr + 3}里面数据为{result.result[0]}."); |
| | | if (result.result[0] == 1) |
| | | { |
| | | int[] num = new int[4] { 2, 0, 0, 1 }; |
| | | var writeRes = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr, |
| | | data = num, |
| | | port = plc.port |
| | | }); |
| | | CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr}里面数据为{JsonConvert.SerializeObject(num)}."); |
| | | } |
| | | |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 4, |
| | | addr = plc.readAddr, |
| | |
| | | CMMLog.Debug($"查询设备{plc.location}通道{plc.readAddr}里面数据为{result.result[0]}、{result.result[1]}、{result.result[3]}."); |
| | | if (result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 2 && result.result[1] == 2 && result.result[2] == 2) |
| | | if (result.result[0] == 2 && result.result[1] == 2 && result.result[3] == 2) |
| | | { |
| | | //推送小车进入 |
| | | TSHelper.GoToAGV(taskNo, 10, 3); |
| | | writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | TSHelper.GoToAGV(taskNo, 10, 1); |
| | | var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | { |
| | | host = plc.ip, |
| | | addr = plc.writeAddr + 3, |
| | |
| | | } |
| | | Thread.Sleep(100000); |
| | | } |
| | | |
| | | internal static void CheckPackingLineFullThree(Settings.PlcInfo plc) |
| | | { |
| | | string trayCode = ""; |
| | | var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 25, |
| | | addr = plc.readAddr, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | if(result != null && result.errCode == 0) |
| | | { |
| | | if (result.result[0] == 1) |
| | | { |
| | | //获取物料信息 根据托盘码区分 |
| | | trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码 |
| | | |
| | | |
| | | var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); |
| | | if (infoPack != null) |
| | | { |
| | | string empCode = RemoveNull(GetTrayCode(result.result.Skip(1).Take(5).ToArray()));//员工编码 |
| | | string machineCode = RemoveNull(GetTrayCode(result.result.Skip(9).Take(1).ToArray()));//包装机号 |
| | | int needWeight = Convert.ToInt32(Completion(result.result[10]) + Completion(result.result[11]), 2);//产品需求重量 |
| | | int oneWeight = Convert.ToInt32(Completion(result.result[12]) + Completion(result.result[13]), 2);//单托毛重 |
| | | int readWeight = Convert.ToInt32(Completion(result.result[14]) + Completion(result.result[15]), 2);//单托净重 |
| | | int fcWeight = Convert.ToInt32(Completion(result.result[16]) + Completion(result.result[17]), 2);//单托复称重量 |
| | | int trayType = Convert.ToInt32(Completion(result.result[18]), 2);//托盘类型 |
| | | int addState = Convert.ToInt32(Completion(result.result[19]), 2);//叠包层数 |
| | | int bagNumber = Convert.ToInt32(Completion(result.result[20]), 2);//袋号 |
| | | int productTime = Convert.ToInt32(Completion(result.result[21]) + Completion(result.result[22]), 2);//生产日期 |
| | | string timeCuoTwo = Convert.ToInt32(Completion(result.result[23]) + Completion(result.result[24]), 2).ToString(); //时间戳 |
| | | |
| | | UpdateBuilder updateBuilder = Update.Set("employeeId", empCode).Set("trayCode", trayCode).Set("packingMachineNumber", machineCode).Set("needWeight", needWeight) |
| | | .Set("oneWeight", oneWeight).Set("realWeight", readWeight).Set("FCWeight", fcWeight).Set("trayType", trayType) |
| | | .Set("isFold", addState).Set("bagNumber", bagNumber).Set("productData", productTime); |
| | | //产品批次号 产品型号 物料名称 计量单位均可在erp表中根据物料编码获取 |
| | | |
| | | result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 15, |
| | | addr = plc.readAddr + 131, |
| | | host = plc.ip, |
| | | port = plc.port |
| | | }); |
| | | |
| | | string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); |
| | | 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 |
| | | } |
| | | } |