| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.UI.Model.Winform; |
| | | using Sunny.UI; |
| | |
| | | { |
| | | this.Invoke(() => |
| | | { |
| | | var specList = p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()).ToList(); |
| | | var specList = p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()).ToList(); |
| | | specList.AddRange(p.Details.SelectMany(u => u.ResultList.SelectMany(s => s.Specs.Select(m => (Spec)m)))); |
| | | specList.Sort((a, b) => string.Compare(a.Code, b.Code)); |
| | | |
| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Newtonsoft.Json; |
| | | using System.ComponentModel; |
| | |
| | | data.result = isOK ? MES_OK : MES_NG; |
| | | |
| | | var specList = p.Details.SelectMany(u => u.ResultList.SelectMany(u => u.Specs)).ToList(); |
| | | specList.AddRange(p.Details.SelectMany(u => u.SpecList ?? new List<Spec>())); |
| | | specList.AddRange(p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>())); |
| | | |
| | | specList.ForEach(s => |
| | | { |
| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.M135.DBManager; |
| | | using Newtonsoft.Json; |
| | |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(d.FAIData)) |
| | | { |
| | | d.SpecList = JsonConvert.DeserializeObject<List<Spec>>(d.FAIData); |
| | | d.SpecList = JsonConvert.DeserializeObject<List<ISpec>>(d.FAIData); |
| | | } |
| | | else |
| | | { |
| | | d.SpecList = new List<Spec>(); |
| | | d.SpecList = new List<ISpec>(); |
| | | } |
| | | |
| | | if (!string.IsNullOrWhiteSpace(d.DefectDesc)) |
| | |
| | | using Bro.Common.Model; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.DataBase.Model; |
| | | using System.ComponentModel.DataAnnotations.Schema; |
| | | |
| | |
| | | public string FAIData { get; set; } = ""; |
| | | public bool IsDone { get; set; } = false; |
| | | |
| | | [NotMapped] |
| | | //[NotMapped] |
| | | public List<DetectResult> ResultList { get; set; } = new List<DetectResult>(); |
| | | [NotMapped] |
| | | public List<Spec> SpecList { get; set; } = new List<Spec>(); |
| | | [NotMapped] |
| | | //[NotMapped] |
| | | public List<ISpec> SpecList { get; set; } = new List<ISpec>(); |
| | | //[NotMapped] |
| | | public List<string> DefectList { get; set; } = new List<string>(); |
| | | } |
| | | } |
| | |
| | | </ItemGroup>--> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" /> |
| | | <PackageReference Include="NPOI" Version="2.7.1" /> |
| | | <PackageReference Include="ScottPlot.WinForms" Version="4.1.58" /> |
| | | <PackageReference Include="System.ServiceModel.Duplex" Version="4.8.1" /> |
| | |
| | | } |
| | | |
| | | public PLCBase Plc1; |
| | | PLCBase Plc2; |
| | | Thread ThHeartPlc; |
| | | public override void Open() |
| | | { |
| | | base.Open(); |
| | | |
| | | ML = DeviceCollection.FirstOrDefault(u => u is MachineLearningBase) as MachineLearningBase; |
| | | if (ML == null) |
| | | { |
| | |
| | | Thread.Sleep(3000); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 网络预热 |
| | |
| | | else |
| | | { |
| | | p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE); |
| | | if ("NoRead".Equals(p.BasketCode)) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"{p.PID}_{p.SEQUENCE}获取框具码失败 赋值Noread"); |
| | | } |
| | | } |
| | | |
| | | mysqlhelper.NewProduct(p); |
| | |
| | | var errorSpec = _errorSpec.Copy(); |
| | | errorSpec.Code = "检测TBD"; |
| | | errorSpec.ActualValue = -999; |
| | | DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key }; |
| | | DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key ,Id=Guid.NewGuid().ToString()}; |
| | | ngResults.Add(ngResult); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | detectResults.AddRange(ngResults); |
| | | resultList.AddRange(detectResults); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); |
| | | RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | CSVRecordAsync($"{positionName}_Record_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, head); |
| | | |
| | | //UpdatePositionResultToDB(detail); |
| | | var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | //var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | |
| | | mysqlhelper.UpdateProduct(p); |
| | | if (positionSet.IsLastPosition) |
| | |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.M135.Common; |
| | | using Bro.M135.DBManager; |
| | | using HalconDotNet; |
| | | using Microsoft.VisualBasic; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using NPOI.Util; |
| | | using Sunny.UI; |
| | | using System.Data; |
| | | using System.Data.SqlTypes; |
| | |
| | | Dictionary<string, List<double>> dicdate = new Dictionary<string, List<double>>(); |
| | | ManualResetEvent set1 = new ManualResetEvent(false); |
| | | ManualResetEvent set2 = new ManualResetEvent(false); |
| | | |
| | | |
| | | public event Action<string> StartPrinter; |
| | | |
| | | [ProcessMethod("ImageCheck", "ImageCheckOperation", "通用图片检测操作", InvokeType.TestInvoke)] |
| | | public ResponseMessage ImageCheckOperation(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("printer", "printer", "打印机打印", InvokeType.TestInvoke)] |
| | | public ResponseMessage Printer(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | ResponseMessage msg = new ResponseMessage(); |
| | | |
| | | Plc2 = invokeDevice as PLCBase; |
| | | string message = ""; |
| | | StartPrinter.Invoke(message); |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | public void PlcwritePrinter(int add,int value) |
| | | { |
| | | Plc2.WriteSingleAddress(add,value,out _); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | protected List<ISpec> GetSpecListFromConfigSelection(List<SpecSelector> specSelectors) |
| | | { |
| | |
| | | var spec = M141Config.SpecCollection.FirstOrDefault(s => s.Code == u.SpecCode); |
| | | if (spec != null) |
| | | { |
| | | var temp = spec.Copy<Spec>(); |
| | | var temp = spec.Copy(); |
| | | temp.ActualValue = null; |
| | | temp.MeasureResult = null; |
| | | temp.Source = ""; |
| | | specList.Add(temp); |
| | | } |
| | | }); |
| | |
| | | resultList.ForEach(u => u.SetResult()); |
| | | var defects = resultList.GetDefectDescList(); |
| | | |
| | | var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()).Where(u => u.MeasureResult != true).Select(u => u.Code); |
| | | var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()).Where(u => u.MeasureResult != true).Select(u => u.Code); |
| | | var ngDefectDescList = p.Details.SelectMany(u => u.DefectList ?? new List<string>()).ToList(); |
| | | |
| | | defects.AddRange(ngSpecCodes); |
| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.M135.Common; |
| | | using MySql.Data.MySqlClient; |
| | | using Newtonsoft.Json; |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Windows.Globalization.PhoneNumberFormatting; |
| | | using static Org.BouncyCastle.Math.EC.ECCurve; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; |
| | | |
| | | namespace Bro.M141.Process |
| | |
| | | connStrAll = $"server={IP};port=3306;user id=root;password=123456;database=BroDB;charset=utf8"; |
| | | } |
| | | |
| | | public void Operatoremysql(string sql, string connStr)//操作 |
| | | public bool Operatoremysql(string sql, string connStr)//操作 |
| | | { |
| | | MySqlConnection con = new MySqlConnection(connStr); |
| | | try |
| | |
| | | con.Open(); |
| | | MySqlCommand coon = new MySqlCommand(sql, con); |
| | | coon.ExecuteNonQuery(); |
| | | con.Close(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库操作异常 {sql} {e.ToString()}"); |
| | | } |
| | | con.Close(); |
| | | return false; |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库操作异常 {sql} {e.ToString()}"); |
| | | } |
| | | return true; |
| | | |
| | | } |
| | | |
| | | public DataTable selectdt(string str, string connStr)//查询表格 |
| | |
| | | con.Open(); |
| | | MySqlDataAdapter da = new MySqlDataAdapter(str, con); |
| | | da.Fill(dt); |
| | | con.Close(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库查询异常 {str} {e.ToString()}"); |
| | | } |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库查询异常 {str} {e.ToString()}"); |
| | | con.Close(); |
| | | return null; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库查询数据异常 {str} {e.ToString()}"); |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库查询数据异常 {str} {e.ToString()}"); |
| | | } |
| | | |
| | | con.Close(); |
| | | return strr; |
| | | } |
| | |
| | | string str1 = "select id from forlocal order by id desc limit 1"; |
| | | string index = selectmysql(str1, connStrLocal); |
| | | |
| | | if (!string.IsNullOrEmpty(index)) |
| | | { |
| | | string str2 = $"delete from forlocal where id < ({index}-1000)"; |
| | | Operatoremysql(str2, connStrLocal); |
| | | } |
| | | |
| | | string mysqlstr = $"insert into forlocal (basketcode,pid,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.PID}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | |
| | | string mysqlstr = $"insert into forlocal (basketcode,pid,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.PID}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro)}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | |
| | | Operatoremysql(mysqlstr, connStrLocal); |
| | | if (Operatoremysql(mysqlstr, connStrLocal)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forlocal插入数据成功"); |
| | | } |
| | | else |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forlocal插入数据异失败 {mysqlstr}"); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | string mysqlstr = $"update forlocal set data='{JsonConvert.SerializeObject(pro)}' where plcnum='{pro.SEQUENCE}'"; |
| | | Operatoremysql(mysqlstr, connStrLocal); |
| | | if (pro.Details!=null) |
| | | { |
| | | foreach (var item in pro.Details) |
| | | { |
| | | if (item.ResultList!=null) |
| | | { |
| | | item.ResultList.ForEach(u => |
| | | { |
| | | if (u.NetResults != null) |
| | | { |
| | | u.NetResults.ForEach(x => |
| | | { |
| | | if (x.DetectDetails != null) |
| | | { |
| | | var distinctItems = x.DetectDetails.GroupBy(i => new { i.ClassName, i.FinalResult }) // 根据Id和Name去重 |
| | | .Select(g => g.First()) // 选择每个组的第一个元素 |
| | | .ToList(); |
| | | x.DetectDetails = distinctItems; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | TypeNameHandling = TypeNameHandling.All |
| | | }; |
| | | |
| | | string jsondata = JsonConvert.SerializeObject(pro, settings); |
| | | |
| | | |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"{jsondata}"); |
| | | |
| | | string mysqlstr = $"update forlocal set data='{jsondata}' where plcnum='{pro.SEQUENCE}'"; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrLocal)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forlocal更新数据成功"); |
| | | } |
| | | else |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forlocal更新数据失败 {mysqlstr}"); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | string str1 = "select id from forall order by id desc limit 1"; |
| | | string index = selectmysql(str1, connStrAll); |
| | | |
| | | if (!string.IsNullOrEmpty(index)) |
| | | { |
| | | string str2 = $"delete from forall where id < ({index}-1000)"; |
| | | Operatoremysql(str2, connStrAll); |
| | | } |
| | | |
| | | |
| | | string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro)}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | |
| | | Operatoremysql(mysqlstr, connStrAll); |
| | | if (Operatoremysql(mysqlstr, connStrAll)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forall插入数据成功"); |
| | | } |
| | | else |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall插入数据异失败 {mysqlstr}"); |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | ProductModel p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | ProductModel p = null; |
| | | p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | return p; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal更新数据异常 {e.ToString()}"); |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal获取对象异常 {e.ToString()}"); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal更新数据异常 {e.ToString()}"); |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal获取异常 {e.ToString()}"); |
| | | } |
| | | return "NoRead"; |
| | | } |
| | |
| | | { |
| | | base.OnProcessUpdated(); |
| | | printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print); |
| | | |
| | | Process141.StartPrinter += StartPrint; |
| | | textBox1.Text = "Broconcentric"; |
| | | } |
| | | |
| | | |
| | | |
| | | PrintDocument printDocument1 = new PrintDocument(); |
| | | int ttwith = (int)(80 * 4); |
| | |
| | | |
| | | public void StartPrint(string str) |
| | | { |
| | | try |
| | | { |
| | | ttwith = 320; |
| | | ttheigh = 160; |
| | | message = str; |
| | | |
| | | if (string.IsNullOrEmpty(message)) |
| | | { |
| | | message = textBox1.Text; |
| | | } |
| | | |
| | | this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)"; |
| | | this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh); |
| | |
| | | this.printDocument1.Print(); |
| | | |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | |
| | | int statuscode = GetPrinterStatusCodeInt(); |
| | | string status = GetPrinterStatusMessage(statuscode); |
| | | |
| | | |
| | | // Config141 |
| | | Process141.PlcwritePrinter(1520, 0); |
| | | |
| | | Process141.PlcwritePrinter(1510, 1); |
| | | |
| | | } |
| | | |
| | | |
| | | private void printDocument_Print(object sender, PrintPageEventArgs e) |
| | |
| | | public override void Open() |
| | | { |
| | | base.Open(); |
| | | |
| | | } |
| | | |
| | | [ProcessMethod("", "PositionCheck_P1", "工位1检测", InvokeType.TestInvoke)] |