| | |
| | | |
| | | internal static void recordInfo(string taskName,string errMsg) |
| | | { |
| | | //var errInfo = MongoDBSingleton.Instance.FindOne<errInfoTable>(Query.EQ("taskName", taskName), "errInfoTable"); |
| | | //if(errInfo != null) |
| | | //{ |
| | | // MongoDBSingleton.Instance.Update<errInfoTable>(Query.EQ("_id", errInfo._id), Update.Set("errMsg", errMsg).Set("dateTime", DateTime.Now), UpdateFlags.None); |
| | | //} |
| | | //else |
| | | //{ |
| | | // MongoDBSingleton.Instance.Insert<errInfoTable>(new errInfoTable |
| | | // { |
| | | // taskName = taskName, |
| | | // errMsg = errMsg, |
| | | // dateTime = DateTime.Now |
| | | // }); |
| | | //} |
| | | var errInfo = MongoDBSingleton.Instance.FindOne<errInfoTable>(Query.EQ("taskName", taskName), "errInfoTable"); |
| | | if(errInfo != null) |
| | | { |
| | | MongoDBSingleton.Instance.Update<errInfoTable>(Query.EQ("_id", errInfo._id), Update.Set("errMsg", errMsg).Set("dateTime", DateTime.Now), UpdateFlags.None); |
| | | } |
| | | else |
| | | { |
| | | MongoDBSingleton.Instance.Insert<errInfoTable>(new errInfoTable |
| | | { |
| | | taskName = taskName, |
| | | errMsg = errMsg, |
| | | dateTime = DateTime.Now |
| | | }); |
| | | } |
| | | } |
| | | |
| | | internal static void deleteInfo(string taskName) |
| | | { |
| | | //MongoDBSingleton.Instance.Remove<errInfoTable>(Query.EQ("taskName", taskName), RemoveFlags.None); |
| | | MongoDBSingleton.Instance.Remove<errInfoTable>(Query.EQ("taskName", taskName), RemoveFlags.None); |
| | | } |
| | | |
| | | |
| | |
| | | if (plc.Count > 0) |
| | | { |
| | | #region 判断输送线模式 变更注释 |
| | | bool action = true; |
| | | foreach(var a in plc) |
| | | { |
| | | var modeResult = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | { |
| | | dataNum = 1, |
| | | addr = a.readAddr + 3, |
| | | host = a.ip, |
| | | port = a.port |
| | | }); |
| | | if (modeResult != null && modeResult.errCode == 0) |
| | | { |
| | | CMMLog.Debug($"OutWareTask:读取滚筒机{a.ip}通道号为:{a.readAddr + 3}的值为:{modeResult.result[0]}"); |
| | | if (modeResult.result[0] == 2) |
| | | { |
| | | action = false; |
| | | CMMLog.Debug($"OutWareTask:输送线为 入库模式,输送线点位:{a.location}"); |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | //读取中间表模式 |
| | | var modelInfo = MongoDBSingleton.Instance.FindOne<ModeList>("ModeList"); |
| | | if (modelInfo != null) |
| | | { |
| | | if (modelInfo.Mode == "入库模式") |
| | | { |
| | | action = false; |
| | | CMMLog.Debug($"OutWareTask:中间表 ModeList为 入库模式"); |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | action = false; |
| | | CMMLog.Debug("OutWareTask:中间表 ModeList 为空"); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | if (!action) |
| | | { |
| | | return false; |
| | | } |
| | | //bool action = true; |
| | | //foreach(var a in plc) |
| | | //{ |
| | | // var modeResult = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel |
| | | // { |
| | | // dataNum = 1, |
| | | // addr = a.readAddr + 3, |
| | | // host = a.ip, |
| | | // port = a.port |
| | | // }); |
| | | // if (modeResult != null && modeResult.errCode == 0) |
| | | // { |
| | | // CMMLog.Debug($"OutWareTask:读取滚筒机{a.ip}通道号为:{a.readAddr + 3}的值为:{modeResult.result[0]}"); |
| | | // if (modeResult.result[0] == 2) |
| | | // { |
| | | // action = false; |
| | | // CMMLog.Debug($"OutWareTask:输送线为 入库模式,输送线点位:{a.location}"); |
| | | // break; |
| | | // } |
| | | // else |
| | | // { |
| | | // //读取中间表模式 |
| | | // var modelInfo = MongoDBSingleton.Instance.FindOne<ModeList>("ModeList"); |
| | | // if (modelInfo != null) |
| | | // { |
| | | // if (modelInfo.Mode == "入库模式") |
| | | // { |
| | | // action = false; |
| | | // CMMLog.Debug($"OutWareTask:中间表 ModeList为 入库模式"); |
| | | // break; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // action = false; |
| | | // CMMLog.Debug("OutWareTask:中间表 ModeList 为空"); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | //}; |
| | | //if (!action) |
| | | //{ |
| | | // return false; |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | CMMLog.Info($"OutWareTask 11111"); |
| | | string ssx01 = plc[0].location; |
| | | string ssx02 = plc[1].location; |
| | | //CMMLog.Info($"查询输送线当前点位:{a.location}"); |
| | | var slptInfo1 = MongoDBSingleton.Instance.FindOne<SLPTLoc>(Query.EQ("locCode", ssx01), "SLPTLoc"); |
| | | if (slptInfo1 == null) |
| | | { |
| | | CMMLog.Info($"OutWareTask 222222"); |
| | | endMachLoc = ssx01; |
| | | slptInfo1 = new SLPTLoc |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Info($"OutWareTask 3333333"); |
| | | var slptInfo2 = MongoDBSingleton.Instance.FindOne<SLPTLoc>(Query.EQ("locCode", ssx02), "SLPTLoc"); |
| | | if (slptInfo2 == null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | CMMLog.Info($"OutWareTask 44444444444"); |
| | | var loc = slptInfo1.taskNum <= slptInfo2.taskNum ? slptInfo1 : slptInfo2; |
| | | CMMLog.Info("OutWareTask :" + JsonConvert.SerializeObject(loc)); |
| | | if (loc.taskNum < 2) |
| | |
| | | new SqlHelper<object>().ExecuteSql($"update dbo.tn_am_task_mst set CN_S_END_BIT='{endMachLoc}',CN_S_END_AGVBIT = '{StockInstance.Instance.GetAGVCodeForBitCode(endMachLoc)}' where CN_S_TASK_NO = '{mst.CN_S_TASK_NO}'"); |
| | | |
| | | var plcTwo = Settings.GetPlcInfo().Where(a => a.location == endMachLoc && a.enable == 1).First(); |
| | | int[] num = new int[1] { 1 }; |
| | | var wirte = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | { |
| | | addr = plcTwo.writeAddr + 1, |
| | | host = plcTwo.ip, |
| | | data = num, |
| | | port = plcTwo.port |
| | | }); |
| | | //int[] num = new int[1] { 1 }; |
| | | //var wirte = OITcpHelper.RegisterWriteOutPutMulti(new OITcpHelper.RegisterWriteOutPutModelMulti |
| | | //{ |
| | | // addr = plcTwo.writeAddr + 1, |
| | | // host = plcTwo.ip, |
| | | // data = num, |
| | | // port = plcTwo.port |
| | | //}); |
| | | |
| | | result = true; |
| | | } |