| | |
| | | { |
| | | try |
| | | { |
| | | var obj = JsonConvert.DeserializeObject<AutoLineMacQueueBak>(zwordstr); |
| | | ConfigAOI1.zwoid = obj.zwoid; |
| | | var obj = JsonConvert.DeserializeObject<AutoLineMacQueueBak>(zwordstr); |
| | | if (!string.IsNullOrEmpty(obj.zwoid) && obj.zstatus == "200") |
| | | { |
| | | ConfigAOI1.zwoid = obj.zwoid; |
| | | Plc1.WriteSingleAddress(1524, 1, out _); |
| | | Plc1.WriteSingleAddress(1514, 1, out _); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid获取成功 {obj.zstatus} {obj.zwoid} "); |
| | |
| | | return msg; |
| | | } |
| | | |
| | | [ProcessMethod("", "MESupdata", "MES正常上传单个OK产品获取条码", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | ////[ProcessMethod("", "MESupdata", "MES正常上传单个OK产品获取条码", InvokeType.TestInvoke)] |
| | | ////public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | ////{ |
| | | //// ResponseMessage msg = new ResponseMessage(); |
| | | |
| | | //// Plc3 = invokeDevice as PLCBase; |
| | | //// //上传反馈结果 |
| | | //// bool Issuccess = false; |
| | | //// bool Issuccess1 = false; |
| | | |
| | | //// string tary_label = string.Empty; |
| | | |
| | | //// string tary_label1 = string.Empty; |
| | | |
| | | //// var plcnum = Plc3.Read(2100, 1, out _); |
| | | //// var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | //// if (plcnum[0] == 0) |
| | | //// { |
| | | //// Issuccess = true; |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label); |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | //// { |
| | | //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// } |
| | | //// if (plcnum1[0] == 0) |
| | | //// { |
| | | //// Issuccess1 = true; |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// Issuccess1 = UpMES(plcnum1[0] + "_1", "N", out tary_label1); |
| | | |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | //// { |
| | | //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// } |
| | | //// if (Issuccess && Issuccess1) |
| | | //// { |
| | | //// Plc3.WriteSingleAddress(2120, 1, out _); |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// Plc3.WriteSingleAddress(2120, 2, out _); |
| | | //// } |
| | | //// return msg; |
| | | ////} |
| | | |
| | | ////[ProcessMethod("", "MESupFinallydata", "MES上传单个尾盘OK产品获取条码", InvokeType.TestInvoke)] |
| | | ////public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | ////{ |
| | | //// ResponseMessage msg = new ResponseMessage(); |
| | | |
| | | //// Plc3 = invokeDevice as PLCBase; |
| | | //// //上传反馈结果 |
| | | //// bool Issuccess = false; |
| | | //// bool Issuccess1 = false; |
| | | |
| | | //// string tary_label = string.Empty; |
| | | |
| | | //// string tary_label1 = string.Empty; |
| | | |
| | | //// var plcnum = Plc3.Read(2100, 1, out _); |
| | | //// var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | //// if (plcnum[0] != 0|| plcnum1[0] != 0) |
| | | //// { |
| | | //// if (plcnum[0] == 0) |
| | | //// { |
| | | //// Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1); |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | //// { |
| | | //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// } |
| | | //// else if(plcnum1[0] == 0) |
| | | //// { |
| | | //// Issuccess = UpMES(plcnum[0] + "_1", "Y", out tary_label); |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | //// { |
| | | //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// } |
| | | //// else if (plcnum[0] != 0 && plcnum1[0] != 0) |
| | | //// { |
| | | //// Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label); |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | //// { |
| | | //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1); |
| | | //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | //// { |
| | | //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | |
| | | //// if (Issuccess && Issuccess1) |
| | | //// { |
| | | //// Plc3.WriteSingleAddress(2120, 1, out _); |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// Plc3.WriteSingleAddress(2120, 2, out _); |
| | | //// } |
| | | //// return msg; |
| | | ////} |
| | | |
| | | //private bool UpMES(string PLCNum ,string endtray , out string result ) |
| | | //{ |
| | | // var plist = mysqlhelper.GetProductList(PLCNum); |
| | | // ProductModel newp = new ProductModel(); |
| | | // newp.SEQUENCE = plist[0].SEQUENCE; |
| | | // newp.PID = plist[0].PID; |
| | | // newp.BasketCode = plist[0].BasketCode; |
| | | // newp.Zword = plist[0].Zword; |
| | | // newp.Result = "OK"; |
| | | // newp.SN = plist[0].SN; |
| | | // bool isok = UptoMES(newp, endtray, out result); |
| | | // return isok; |
| | | |
| | | //} |
| | | |
| | | [ProcessMethod("", "PLCreadTosave", "PLC数据读取保存", InvokeType.TestInvoke)] |
| | | public ResponseMessage PLCreadTosave(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | ResponseMessage msg = new ResponseMessage(); |
| | | |
| | | Plc3 = invokeDevice as PLCBase; |
| | | //上传反馈结果 |
| | | bool Issuccess = false; |
| | | bool Issuccess1 = false; |
| | | var plcnum11 = Plc1.Read(1542, 1, out _); |
| | | var plcnum12 = Plc1.Read(1544, 1, out _); |
| | | |
| | | string tary_label = string.Empty; |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PLC信息记录保存触发 获取PLC序号{plcnum11[0]}和{plcnum12[0]}"); |
| | | |
| | | string tary_label1 = string.Empty; |
| | | |
| | | var plcnum = Plc3.Read(2100, 1, out _); |
| | | var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | if (plcnum[0] == 0) |
| | | { |
| | | Issuccess = true; |
| | | } |
| | | else |
| | | { |
| | | Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | { |
| | | StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | } |
| | | if (plcnum1[0] == 0) |
| | | { |
| | | Issuccess1 = true; |
| | | } |
| | | else |
| | | { |
| | | Issuccess1 = UpMES(plcnum1[0] + "_1", "N", out tary_label1); |
| | | |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | { |
| | | StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | } |
| | | if (Issuccess && Issuccess1) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 1, out _); |
| | | } |
| | | else |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | [ProcessMethod("", "MESupFinallydata", "MES上传单个尾盘OK产品获取条码", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | ResponseMessage msg = new ResponseMessage(); |
| | | |
| | | Plc3 = invokeDevice as PLCBase; |
| | | //上传反馈结果 |
| | | bool Issuccess = false; |
| | | bool Issuccess1 = false; |
| | | |
| | | string tary_label = string.Empty; |
| | | |
| | | string tary_label1 = string.Empty; |
| | | |
| | | var plcnum = Plc3.Read(2100, 1, out _); |
| | | var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | if (plcnum[0] != 0|| plcnum1[0] != 0) |
| | | { |
| | | if (plcnum[0] == 0) |
| | | { |
| | | Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | { |
| | | StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | } |
| | | else if(plcnum1[0] == 0) |
| | | { |
| | | Issuccess = UpMES(plcnum[0] + "_1", "Y", out tary_label); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | { |
| | | StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | } |
| | | else if (plcnum[0] != 0 && plcnum1[0] != 0) |
| | | { |
| | | Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1)) |
| | | { |
| | | StartPrint(tary_label1, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label)) |
| | | { |
| | | StartPrint(tary_label, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (Issuccess && Issuccess1) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 1, out _); |
| | | } |
| | | else |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | private bool UpMES(string PLCNum ,string endtray , out string result ) |
| | | { |
| | | var plist = mysqlhelper.GetProductList(PLCNum); |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = plist[0].SEQUENCE; |
| | | newp.PID = plist[0].PID; |
| | | newp.BasketCode = plist[0].BasketCode; |
| | | newp.Zword = plist[0].Zword; |
| | | newp.Result = "OK"; |
| | | newp.SN = plist[0].SN; |
| | | bool isok = UptoMES(newp, endtray, out result); |
| | | return isok; |
| | | |
| | | } |
| | | |
| | | private bool UptoMES( ProductModel pro, string endtray, out string result) |
| | |
| | | result = string.Empty; |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | bool Issuccess1 = false; |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息记录保存触发"); |
| | | //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息记录保存触发"); |
| | | |
| | | var plcnum = Plc3.Read(2100, 1, out _); |
| | | |
| | | Issuccess = GetProImformation(plcnum[0]); |
| | | |
| | | var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | Issuccess1 = GetProImformation(plcnum1[0]); |
| | | |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息记录保存触发 获取PLC序号{plcnum[0]}和{plcnum1[0]}"); |
| | | |
| | | if (Issuccess && Issuccess1) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 1, out _); |
| | |
| | | bool Issuccess = false; |
| | | bool Issuccess1 = false; |
| | | |
| | | // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传mes触发"); |
| | | var plcnum = Plc3.Read(2100, 1, out _); |
| | | Issuccess = GetProImformation(plcnum[0]); |
| | | |
| | | var plcnum1 = Plc3.Read(2102, 1, out _); |
| | | Issuccess1 = GetProImformation(plcnum1[0]); |
| | | |
| | | if (!Issuccess && !Issuccess1) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | return msg; |
| | | } |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传mes触发,获取PLC序号{plcnum[0]}和{plcnum1[0]}"); |
| | | |
| | | string saveTary_ID=string.Empty; |
| | | |
| | | //if (!Issuccess && !Issuccess1) |
| | | //{ |
| | | // Plc3.WriteSingleAddress(2120, 2, out _); |
| | | // return msg; |
| | | //} |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传MES触发"); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传MES触发,产品信息数量为:{M141Config.Productioncode.Count}"); |
| | | |
| | | if (M141Config.Productioncode.Count == 50) |
| | | { |
| | | { |
| | | //产品正常上传 |
| | | while(M141Config.Productioncode.Count>0) |
| | | while (M141Config.Productioncode.Count>0) |
| | | { |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = M141Config.Productioncode[0].SEQUENCE; |
| | |
| | | if (!isok) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | return msg; |
| | | } |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID)) |
| | | { |
| | | StartPrint(tary_ID, "Honeywell PX240S(300 dpi)"); |
| | | saveTary_ID = tary_ID; |
| | | StartPrint(tary_ID, "Honeywell PX240S (300 dpi)"); |
| | | M141Config.MES_codes.Add(new MES_code |
| | | { |
| | | Printers_code = tary_ID |
| | |
| | | } |
| | | M141Config.Productioncode.RemoveAt(0); |
| | | } |
| | | M141Config.Productioncode.Clear(); |
| | | } |
| | | else if (M141Config.Productioncode.Count > 50) |
| | | { |
| | |
| | | for (int i = 0; i < 50; i++) |
| | | { |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = M141Config.Productioncode[-1].SEQUENCE; |
| | | newp.PID = M141Config.Productioncode[-1].PID; |
| | | newp.BasketCode = M141Config.Productioncode[-1].BasketCode; |
| | | newp.Zword = M141Config.Productioncode[-1].Zword; |
| | | int count = M141Config.Productioncode.Count; |
| | | newp.SEQUENCE = M141Config.Productioncode[count - 1].SEQUENCE; |
| | | newp.PID = M141Config.Productioncode[count - 1].PID; |
| | | newp.BasketCode = M141Config.Productioncode[count - 1].BasketCode; |
| | | newp.Zword = M141Config.Productioncode[count - 1].Zword; |
| | | newp.Result = "OK"; |
| | | newp.SN = M141Config.Productioncode[-1].SN; |
| | | newp.SN = M141Config.Productioncode[count - 1].SN; |
| | | string tary_ID = string.Empty; |
| | | bool isok = UptoMES(newp, "N", out tary_ID); |
| | | if (!isok) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | return msg; |
| | | |
| | | } |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID)) |
| | | { |
| | | StartPrint(tary_ID, "Honeywell PX240S(300 dpi)"); |
| | | saveTary_ID = tary_ID; |
| | | StartPrint(tary_ID, "Honeywell PX240S (300 dpi)"); |
| | | M141Config.MES_codes.Add(new MES_code |
| | | { |
| | | Printers_code = tary_ID |
| | | }); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"条码:{tary_ID}已触发S6打印并且保存"); |
| | | } |
| | | M141Config.Productioncode.RemoveAt(-1); |
| | | M141Config.Productioncode.RemoveAt(count - 1); |
| | | } |
| | | M141Config.Productioncode.Clear(); |
| | | } |
| | | else if (M141Config.Productioncode.Count < 50) |
| | | else if (M141Config.Productioncode.Count > 0 && M141Config.Productioncode.Count < 50) |
| | | { |
| | | //产品缺少需要额外的条码补救 |
| | | while (M141Config.Productioncode.Count > 0) |
| | |
| | | if (!isok) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | return msg; |
| | | } |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID)) |
| | | { |
| | | StartPrint(tary_ID, "Honeywell PX240S(300 dpi)"); |
| | | saveTary_ID = tary_ID; |
| | | StartPrint(tary_ID, "Honeywell PX240S (300 dpi)"); |
| | | M141Config.MES_codes.Add(new MES_code |
| | | { |
| | | Printers_code = tary_ID |
| | |
| | | } |
| | | M141Config.Productioncode.RemoveAt(0); |
| | | } |
| | | M141Config.Productioncode.Clear(); |
| | | } |
| | | if (Issuccess && Issuccess1) |
| | | else if (M141Config.Productioncode.Count == 0) |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 1, out _); |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(saveTary_ID)) |
| | | { |
| | | StartPrint(saveTary_ID, "Honeywell PX240S (300 dpi)"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Plc3.WriteSingleAddress(2120, 2, out _); |
| | | } |
| | | return msg; |
| | | //if (Issuccess && Issuccess1) |
| | | //{ |
| | | Plc3.WriteSingleAddress(2120, 1, out _); |
| | | return msg; |
| | | //} |
| | | //else |
| | | //{ |
| | | // Plc3.WriteSingleAddress(2120, 2, out _); |
| | | // return msg; |
| | | //} |
| | | |
| | | } |
| | | |
| | | [ProcessMethod("", "MESup1", "MES上传进料口空篮", InvokeType.TestInvoke)] |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("", "MESup2", "MES上传进料口满载", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESup2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | } |
| | | } |