| | |
| | | using Microsoft.VisualBasic; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using NPOI.SS.Formula.Functions; |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.Util; |
| | | using NPOI.XSSF.UserModel; |
| | |
| | | public ResponseMessage ProductDataUpload(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | ResponseMessage msg = new ResponseMessage(); |
| | | string inputSequence = Plc1.Read(1536, 1, out _)[0].ToString(); |
| | | int numplca = Plc1.Read(1536, 1, out _)[0]; |
| | | string inputSequence = numplca.ToString(); |
| | | |
| | | var productList = new List<int>() { 1 }.Select(u => |
| | | { |
| | |
| | | return FindProductBySequence(sequence, true); |
| | | }).ToList(); |
| | | |
| | | if (PlcNumForAll == -1) |
| | | { |
| | | PlcNumForAll = numplca; |
| | | } |
| | | |
| | | int waitInterval = 300; |
| | | int repeatTime = M141Config.DetectTimeout / waitInterval; |
| | |
| | | |
| | | Plc1.WriteSingleAddress(1516, 1, out _); |
| | | |
| | | if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1)) |
| | | { |
| | | if (M141Config.numpro >= 50) |
| | | { |
| | | M141Config.numpro = 0; |
| | | } |
| | | |
| | | if (productList[0].Result == "OK") |
| | | { |
| | | M141Config.numpro++; |
| | | } |
| | | |
| | | //mqtt.demes(productList[0], M141Config.zwoid); |
| | | string Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(productList[0], M141Config.zwoid, M141Config.numpro)).Result; |
| | | if (Msgreceice == null) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常 返回数据为null"); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice); |
| | | |
| | | if (obj.zstatus == "200") |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{productList[0].PID}数据上传MES成功 {Msgreceice}"); |
| | | } |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES失败 {Msgreceice}"); |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常 {Msgreceice}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | lock (plcnumlock) |
| | | { |
| | | int differ = numplca - PlcNumForAll; |
| | | if (differ > 1) |
| | | { |
| | | for (int i = PlcNumForAll + 1; i < numplca; i++) |
| | | { |
| | | try |
| | | { |
| | | var plist = mysqlhelper.GetProductList(i + "_1"); |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = plist[0].SEQUENCE; |
| | | newp.PID = plist[0].PID; |
| | | newp.BasketCode = plist[0].BasketCode; |
| | | newp.Result = "NG"; |
| | | newp.SN = plist[0].SN; |
| | | var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result; |
| | | |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | else if (differ != -29998) |
| | | { |
| | | for (int i = PlcNumForAll + 1; i <= 29999; i++) |
| | | { |
| | | try |
| | | { |
| | | var plist = mysqlhelper.GetProductList(i + "_1"); |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = plist[0].SEQUENCE; |
| | | newp.PID = plist[0].PID; |
| | | newp.BasketCode = plist[0].BasketCode; |
| | | newp.Result = "NG"; |
| | | newp.SN = plist[0].SN; |
| | | var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result; |
| | | |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | for (int i = 1; i < numplca; i++) |
| | | { |
| | | try |
| | | { |
| | | var plist = mysqlhelper.GetProductList(i + "_1"); |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = plist[0].SEQUENCE; |
| | | newp.PID = plist[0].PID; |
| | | newp.BasketCode = plist[0].BasketCode; |
| | | newp.Result = "NG"; |
| | | newp.SN = plist[0].SN; |
| | | var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result; |
| | | |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | PlcNumForAll = numplca; |
| | | } |
| | | |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | object plcnumlock = new object(); |
| | | int PlcNumForAll = -1; |
| | | |
| | | private bool _isDemoStarted = false; |
| | | [ProcessMethod("OfflineDemo", "OfflineDemo", "离线测试", InvokeType.CalibInvoke)] |
| | |
| | | continue; |
| | | } |
| | | |
| | | var sn = nameDatas[0]+"_1"; |
| | | var sn = nameDatas[0] + "_1"; |
| | | var imageSeq = nameDatas[2][^1].ToString(); |
| | | var measureBind = M141Config.MeasureBindCollection.FirstOrDefault(u => u.ImageSaveSeq == imageSeq); |
| | | |