| | |
| | | public PLCBase Plc1; |
| | | bool devicestate = false; |
| | | PLCBase Plc2; |
| | | public PLCBase Plc3; |
| | | public Thread ThHeartPlc; |
| | | |
| | | public RabbitMQHelper mqtt; |
| | |
| | | mqtt = new RabbitMQHelper(M141Config.zIP, M141Config.zport, M141Config.zuser, M141Config.zpassword); |
| | | mqtt.Connect(M141Config.MESchannel); |
| | | } |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"已关闭上传mes"); |
| | | } |
| | | |
| | | InitialContinuousNGAlarm(); |
| | | InitialContinuousNGAlarm(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | AlarmTypeList.Add(item2.alarmtype); |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"报警类别{item2.alarmtype}加入队列,队列个数为{AlarmTypeList.Count}"); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | |
| | | StateDIC[StateDICKey] = new List<int>(); |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"报警类别{StateDICKey}加入字典:StateDIC"); |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | CSVdata = csvdata, |
| | | }; |
| | | AlarmType.Add(item.alarmtype, alarmData); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"报警{item.alarmname}类别{key}作为key加入AlarmType字典"); |
| | | |
| | | } |
| | | |
| | | alarmData.CSVhead += $",{item.alarmname}"; |
| | |
| | | |
| | | if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0) |
| | | { |
| | | var defecttem1 = detectResults.SelectMany(u => u.AllNetResults).SelectMany(m => m.DetectDetails).Select(detail => detail.ClassName).ToList(); |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN} S3S5检测 缺陷名称集合为{string.Join(",", defecttem1)}"); |
| | | |
| | | var defecttem = detectResults.SelectMany(u => u.AllNetResults.SelectMany(m => m.DetectDetails)).Where(u => u.ClassName == M141Config.defectname).ToList(); |
| | | |
| | | List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | public async Task RunImageCheckAsync(List<ProductModel> products, string triggerText, string triggerSource, MeasureBind measureBind) |
| | | { |
| | | await Task.Run(() => |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | private void RunCustomizedMethod(List<ProductModel> products, string triggerText, string triggerSource, IImageSet imgSet, string methodId, List<DetectResult> resultList) |
| | | { |
| | | try |
| | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"自定义检测过程异常,{ex.GetExceptionMessage()}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #region plc |
| | | public ResponseMessage RunImageCheck_plc(IOperationConfig config) |
| | |
| | | |
| | | CheckPositionDoneAsync_plc(measureBinds[0].WorkPosition, inputSequence, config, cameraIds); |
| | | |
| | | |
| | | return msg; |
| | | |
| | | } |
| | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"相机{camera.Name}检测前清理缓存完成"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | inputSequence = triggerDatas[triggerDatas.Length - 1]; |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | string index = config.TriggerStr.Split(',')[1]; |
| | | var positionSet = M141Config.WorkPositionCollection.FirstOrDefault(u => u.PositionName == positionName); |
| | | |
| | |
| | | |
| | | if (pList[0].Result == "OK") |
| | | { |
| | | M141Config.numpro++; |
| | | Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result; |
| | | //M141Config.numpro++; |
| | | //Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result; |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{pList[0].PID}汇总OK暂时不上传"); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label)) |
| | | { |
| | | StartPrint(obj.tary_label); |
| | | StartPrint(obj.tary_label, "Honeywell PX240S(300 dpi)"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES异常 {Msgreceice}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc给出的产品序号为{numplca}"); |
| | |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{newp.PID}关闭NG上传"); |
| | | } |
| | | //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result; |
| | | //M141Config.mesnum2++; |
| | | //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll,前站NG排料且plc触发清零产品{newp.PID}数据上传,结果为{newp.Result}"); |
| | | |
| | | } |
| | | catch |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"已关闭mes连接或者数据上传接口"); |
| | | } |
| | | } |
| | | |
| | | //ReplyPlcData(positionName, config.TriggerValue); |
| | |
| | | data += "NA,"; |
| | | } |
| | | } |
| | | CSVRecordAsync($"AllDeviceProductRecord.csv", data, Head); |
| | | CSVRecordAsync($"AllDeviceProductRecord_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, Head); |
| | | |
| | | } |
| | | catch (Exception exx) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #region 打印机相关 |
| | | PrintDocument printDocument1 = new PrintDocument(); |
| | | string Printmessage = ""; |
| | | |
| | | public void StartPrint(string str) |
| | | public void StartPrint(string str, string PrinterName) |
| | | { |
| | | try |
| | | { |
| | | int ttwith = 320; |
| | | int ttheigh = 160; |
| | | int ttwith = 240; |
| | | int ttheigh = 80; |
| | | Printmessage = str; |
| | | |
| | | this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)"; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //C229M2508250500002 |
| | | private void printDocument_Print(object sender, PrintPageEventArgs e) |
| | | { |
| | |
| | | { |
| | | DisableECI = true,//设置内容编码 |
| | | CharacterSet = "UTF-8", //设置二维码的宽度和高度 |
| | | Width = 123, |
| | | Height = 123, |
| | | Width = 60, |
| | | Height = 60, |
| | | Margin = 1//设置二维码的边距,单位不是固定像素 |
| | | }; |
| | | |
| | | writer.Options = options; |
| | | Bitmap map = writer.Write(Printmessage); |
| | | e.Graphics.DrawImage(map, new System.Drawing.Point(90, 10)); |
| | | e.Graphics.DrawImage(map, new System.Drawing.Point(90, 4)); |
| | | |
| | | // 在二维码下方画内容文字 |
| | | using (Font font = new Font("Arial", 10)) |
| | |
| | | // 让文字居中到二维码下方 |
| | | SizeF textSize = e.Graphics.MeasureString(Printmessage, font); |
| | | float textX = 90 + (map.Width - textSize.Width) / 2; |
| | | float textY = 10 + map.Height; |
| | | float textY = 1 + map.Height; |
| | | |
| | | e.Graphics.DrawString(Printmessage, font, brush3, textX, textY); |
| | | } |
| | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |