| | |
| | | # Visual Studio Version 17 |
| | | VisualStudioVersion = 17.2.32526.322 |
| | | MinimumVisualStudioVersion = 10.0.40219.1 |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bro.Device.PointLaser_Omron", "src\Bro.Device.PointLaser_Omron\Bro.Device.PointLaser_Omron.csproj", "{5966DFAD-1B67-478A-BA32-ADE05500B2AA}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bro.M135.Common", "src\Bro.M135.Common\Bro.M135.Common.csproj", "{82DF4C52-A0CA-4759-A6C6-64442646E85F}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bro.M141.Process", "src\Bro.M141.Process\Bro.M141.Process.csproj", "{2559EE9D-1C2F-456D-AF5D-755A79066C0F}" |
| | |
| | | Release|Any CPU = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| | | {5966DFAD-1B67-478A-BA32-ADE05500B2AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {5966DFAD-1B67-478A-BA32-ADE05500B2AA}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {5966DFAD-1B67-478A-BA32-ADE05500B2AA}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {5966DFAD-1B67-478A-BA32-ADE05500B2AA}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {82DF4C52-A0CA-4759-A6C6-64442646E85F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {82DF4C52-A0CA-4759-A6C6-64442646E85F}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {82DF4C52-A0CA-4759-A6C6-64442646E85F}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | |
| | | using Bro.Common.Model; |
| | | using Bro.M135.DBManager; |
| | | using Newtonsoft.Json; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; |
| | | |
| | | namespace Bro.M135.Common |
| | | { |
| | |
| | | #endregion |
| | | |
| | | #region PositionCheckTimes |
| | | public void InitialPositionCheckList(string positionName, List<int> checkTimes) |
| | | public void InitialPositionCheckList(string positionName, List<int> checkTimes,string stationName) |
| | | { |
| | | lock (_checkResultLock) |
| | | { |
| | | PositionCheckList[positionName] = new List<int>(checkTimes); |
| | | Details.RemoveAll(u => u.PositionName == positionName); |
| | | |
| | | |
| | | P_PRODUCT_DETAIL detail = new P_PRODUCT_DETAIL(); |
| | | detail.STATION_CODE = stationName; |
| | | detail.PositionName = positionName; |
| | | detail.PID = PID; |
| | | detail.IsDone = false; |
| | | Details.Add(detail); |
| | | } |
| | | } |
| | | |
| | |
| | | public List<Printer> Printers { get; set; } = new List<Printer>(); |
| | | |
| | | |
| | | |
| | | [Category("产品显示界面配置")] |
| | | [Description("字体大小")] |
| | | [DisplayName("字体大小")] |
| | | public int FontSize_p { get; set; } = 15; |
| | | |
| | | |
| | | [Category("产品显示界面配置")] |
| | | [Description("每行列数")] |
| | |
| | | [Editor(typeof(ComplexCollectionEditor<PLCAlarmDetails>), typeof(UITypeEditor))] |
| | | public List<PLCAlarmDetails> AlarmDetails { get; set; } = new List<PLCAlarmDetails>(); |
| | | |
| | | |
| | | |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return plcname + (isused ? "启用" : "禁用"); |
| | | } |
| | | } |
| | | |
| | | public class PLCAlarmDetails : IComplexDisplay |
| | | public class PLCAlarmDetails : IComplexDisplay, IImportFromFileInEditor |
| | | { |
| | | [Category("配置")] |
| | | [DisplayName("首地址")] |
| | |
| | | { |
| | | return alarmname; |
| | | } |
| | | |
| | | |
| | | |
| | | public IImportFromFileInEditor GetImportObject(string data, out string msg) |
| | | { |
| | | msg = ""; |
| | | PLCAlarmDetails ret = new PLCAlarmDetails(); |
| | | try |
| | | { |
| | | var temchar = data.Split(','); |
| | | ret.alarmname = temchar[0]; |
| | | ret.address =Convert.ToInt32(temchar[1]); |
| | | ret.address2 = Convert.ToInt32(temchar[2]); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | return ret; |
| | | |
| | | } |
| | | |
| | | public bool ICSVOutput(object o) |
| | | { |
| | | try |
| | | { |
| | | if (o is List<PLCAlarmDetails> Pl) |
| | | { |
| | | SaveFileDialog saveFileDialog = new SaveFileDialog(); |
| | | saveFileDialog.Filter = "CSV files (*.csv)|*.csv"; // 设置文件过滤器,只显示CSV文件 |
| | | saveFileDialog.Title = "Save CSV File"; // 设置对话框标题 |
| | | saveFileDialog.FileName = "PLCAlarms"; // 默认文件名 |
| | | saveFileDialog.DefaultExt = "csv"; // 默认文件扩展名 |
| | | string filePath = ""; |
| | | if (saveFileDialog.ShowDialog() == DialogResult.OK) |
| | | { |
| | | filePath = saveFileDialog.FileName; // 获取用户选择的文件路径 |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | using (StreamWriter writer = new StreamWriter(filePath)) |
| | | { |
| | | // 写入标题行 |
| | | writer.WriteLine("报警名称,首地址,子地址"); |
| | | // 写入数据行 |
| | | foreach (var row in Pl) |
| | | { |
| | | writer.WriteLine($"{row.alarmname},{row.address},{row.address2}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public static object _productListLock = new object(); |
| | | public List<ProductModel> ProductList = new List<ProductModel>(); |
| | | MachineLearningBase ML = null; |
| | | TcpListenerWrap TcpListener = null; |
| | | Spec _errorSpec = null; |
| | | |
| | | TcpListenerWrap _realTimeServer = null; |
| | | |
| | | volatile int _productIndex = 0; |
| | | |
| | | int _backgroundImageWidth = 2448; |
| | | //volatile int _productIndex = 0; |
| | | |
| | | M141Process_Mysql mysqlhelper = new M141Process_Mysql(); |
| | | |
| | | |
| | | |
| | | |
| | | public override void InitialProcessMethods() |
| | |
| | | public void Heartplc() |
| | | { |
| | | Thread.Sleep(1000); |
| | | |
| | | //Open(); |
| | | |
| | | string _statisticFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Statistic.json"); |
| | | if (File.Exists(_statisticFilePath)) |
| | | { |
| | |
| | | { |
| | | products.ForEach(p => |
| | | { |
| | | var pResults = resultList.Where(u => u.PID == p.PID).ToList(); |
| | | var pResults = resultList.ToList(); |
| | | p.AddNewDetectResults(M141Config.StationCode, measureBind.WorkPosition, pResults); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"产品{p.PID}_{p.SEQUENCE}添加工位{measureBind.WorkPosition}检测结果,数量{pResults.Count}"); |
| | | }); |
| | |
| | | { |
| | | p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE, out string sntem); |
| | | p.SN = sntem; |
| | | p.PID = $"{sntem}_{i}"; |
| | | if ("NoRead".Equals(p.BasketCode)) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"{p.PID}_{p.SEQUENCE}获取框具码失败 赋值Noread"); |
| | |
| | | |
| | | //初始化产品的检测次数 |
| | | var checkIndexList = M141Config.MeasureBindCollection.Where(u => u.WorkPosition == b.WorkPosition && u.ProductIndices.Contains(i)).Select(u => u.CheckIndex).OrderBy(u => u).ToList(); |
| | | p.InitialPositionCheckList(b.WorkPosition, checkIndexList); |
| | | p.InitialPositionCheckList(b.WorkPosition, checkIndexList, M141Config.StationCode); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{p.PID}_{p.SEQUENCE}已清理{b.WorkPosition}检测数据。当前已完成工位{string.Join(",", p.Details.Select(u => u.PositionName))}"); |
| | | |
| | | }); |
| | | |
| | | //初始化工位的检测次数 |
| | |
| | | newp.BasketCode = p.BasketCode; |
| | | newp.Result = p.Result; |
| | | newp.SN = p.SN; |
| | | |
| | | Thread.Sleep(500); |
| | | var plist = mysqlhelper.GetProductList(p.SEQUENCE); |
| | | |
| | | |
| | |
| | | newp.Details.AddRange(item.Details); |
| | | } |
| | | } |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"AllDeviceProductRecord从数据库获取到数据{p.SEQUENCE} plist数量{plist.Count} Details数量{newp.Details.Count}"); |
| | | |
| | | //newp.Details.AddRange(p.Details); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{pid}检测项{s.Code}赋值{s.GetMeasureValueStr()},结果{s.GetMeasureResultStr()}"); |
| | | } |
| | | else |
| | |
| | | { |
| | | isOK = false; |
| | | |
| | | int num = 0; |
| | | |
| | | while (p.Details.Any(u => !u.IsDone) && num < 10) |
| | | { |
| | | num++; |
| | | Thread.Sleep(500); |
| | | } |
| | | |
| | | |
| | | p.InitialDetailSpecs(); |
| | | var resultList = p.Details.SelectMany(u => u.ResultList).ToList(); |
| | | resultList.ForEach(u => u.SetResult()); |
| | |
| | | { |
| | | defects.Add("TBD"); |
| | | } |
| | | |
| | | |
| | | defects = defects.Distinct().ToList(); |
| | | |
| | | isOK = defects.Count <= 0; |
| | |
| | | UpdateResult(DateTime.Now, p.SN, defectClass.ClassName, ""); |
| | | |
| | | //产品序号+1 |
| | | Interlocked.Increment(ref _productIndex); |
| | | //Interlocked.Increment(ref _productIndex); |
| | | |
| | | List<ISpec> specList = new List<ISpec>(); |
| | | specList.AddRange(p.Details.SelectMany(u => u.SpecList).ToList().ConvertAll(u => (ISpec)u)); |
| | |
| | | { |
| | | try |
| | | { |
| | | Thread.Sleep(200); |
| | | if (pro.Details != null) |
| | | { |
| | | foreach (var item in pro.Details) |
| | |
| | | if (item != null) |
| | | { |
| | | var defects = item.ResultList.GetDefectDescList(); |
| | | item.DefectList.AddRange(defects); |
| | | var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code); |
| | | defects.AddRange(ngSpecCodes); |
| | | item.DefectList.AddRange(defects.Distinct()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"{jsondata}"); |
| | | |
| | | string mysqlstr = $"update forlocal set data='{jsondata}' where plcnum='{pro.SEQUENCE}'"; |
| | | string mysqlstr = $"update forlocal set data='{jsondata}',pid='{pro.PID}' where plcnum='{pro.SEQUENCE}'"; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrLocal)) |
| | | { |
| | |
| | | //string destr = "delete from forall where id not in (select id from (select id from forall order BY id desc limit 1000) as subquery)"; |
| | | //Operatoremysql(destr, connStrAll); |
| | | |
| | | if (pro.Details != null) |
| | | { |
| | | foreach (var item in pro.Details) |
| | | { |
| | | if (item != null) |
| | | { |
| | | var defects = item.ResultList.GetDefectDescList(); |
| | | var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code); |
| | | defects.AddRange(ngSpecCodes); |
| | | item.DefectList.AddRange(defects.Distinct()); |
| | | item.DefectList = item.DefectList.Distinct().ToList(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | string strtem = "select * from forall where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' "; |
| | | |
| | | var temdb = selectdt(strtem, connStrAll); |
| | | if (temdb != null && temdb.Rows.Count > 0) |
| | | { |
| | | string mysqlstr = $"update forall set data='" + JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }) + "' where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' "; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrAll)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forall更新数据成功"); |
| | | } |
| | | else |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall更新数据异常 {mysqlstr}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | 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)"; |
| | |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall插入数据异失败 {mysqlstr}"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | |
| | | // |
| | | // button2 |
| | | // |
| | | button2.Location = new Point(283, 127); |
| | | button2.Margin = new Padding(5, 4, 5, 4); |
| | | button2.Location = new Point(180, 90); |
| | | button2.Name = "button2"; |
| | | button2.Size = new Size(170, 85); |
| | | button2.Size = new Size(108, 60); |
| | | button2.TabIndex = 1; |
| | | button2.Text = "预览"; |
| | | button2.UseVisualStyleBackColor = true; |
| | |
| | | // |
| | | // button1 |
| | | // |
| | | button1.Location = new Point(50, 127); |
| | | button1.Margin = new Padding(5, 4, 5, 4); |
| | | button1.Location = new Point(32, 90); |
| | | button1.Name = "button1"; |
| | | button1.Size = new Size(170, 85); |
| | | button1.Size = new Size(108, 60); |
| | | button1.TabIndex = 2; |
| | | button1.Text = "打印"; |
| | | button1.UseVisualStyleBackColor = true; |
| | |
| | | // |
| | | // textBox1 |
| | | // |
| | | textBox1.Location = new Point(178, 49); |
| | | textBox1.Margin = new Padding(5, 4, 5, 4); |
| | | textBox1.Location = new Point(125, 38); |
| | | textBox1.Name = "textBox1"; |
| | | textBox1.Size = new Size(273, 30); |
| | | textBox1.Size = new Size(175, 23); |
| | | textBox1.TabIndex = 3; |
| | | // |
| | | // label1 |
| | | // |
| | | label1.AutoSize = true; |
| | | label1.Location = new Point(82, 54); |
| | | label1.Margin = new Padding(5, 0, 5, 0); |
| | | label1.Location = new Point(52, 38); |
| | | label1.Name = "label1"; |
| | | label1.Size = new Size(82, 24); |
| | | label1.Size = new Size(56, 17); |
| | | label1.TabIndex = 4; |
| | | label1.Text = "打印内容"; |
| | | // |
| | | // button3 |
| | | // |
| | | button3.Location = new Point(50, 308); |
| | | button3.Location = new Point(32, 218); |
| | | button3.Margin = new Padding(2, 2, 2, 2); |
| | | button3.Name = "button3"; |
| | | button3.Size = new Size(127, 61); |
| | | button3.Size = new Size(81, 43); |
| | | button3.TabIndex = 5; |
| | | button3.Text = "获取状态"; |
| | | button3.UseVisualStyleBackColor = true; |
| | |
| | | // |
| | | // textBox2 |
| | | // |
| | | textBox2.Location = new Point(50, 376); |
| | | textBox2.Margin = new Padding(5, 4, 5, 4); |
| | | textBox2.Location = new Point(32, 266); |
| | | textBox2.Name = "textBox2"; |
| | | textBox2.Size = new Size(490, 30); |
| | | textBox2.Size = new Size(313, 23); |
| | | textBox2.TabIndex = 6; |
| | | // |
| | | // UIPrinter |
| | | // |
| | | AutoScaleDimensions = new SizeF(11F, 24F); |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(textBox2); |
| | | Controls.Add(button3); |
| | |
| | | Controls.Add(textBox1); |
| | | Controls.Add(button1); |
| | | Controls.Add(button2); |
| | | Margin = new Padding(3, 4, 3, 4); |
| | | Margin = new Padding(2, 3, 2, 3); |
| | | Name = "UIPrinter"; |
| | | Size = new Size(559, 511); |
| | | Size = new Size(356, 362); |
| | | ResumeLayout(false); |
| | | PerformLayout(); |
| | | } |
| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.UI.Model.Winform; |
| | | using Sunny.UI; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | |
| | | using System.Windows.Forms; |
| | | using ZXing; |
| | | using ZXing.Common; |
| | | using static System.Windows.Forms.AxHost; |
| | | |
| | | //using System.Printing; |
| | | |
| | |
| | | Process141.PlcwritePrinter(1510, 1); |
| | | |
| | | } |
| | | |
| | | |
| | | private void printDocument_Print(object sender, PrintPageEventArgs e) |
| | | { |
| | | Font fntTxt = new Font("黑体", 15, System.Drawing.FontStyle.Bold);//正文文字 |
| | |
| | | try |
| | | { |
| | | string numvalue = message; |
| | | Bitmap bitmap = CreateCode(numvalue); |
| | | |
| | | int with = (ttwith - bitmap.Width) / 2 - 20; |
| | | int heih = (ttheigh - bitmap.Height) / 2; |
| | | float Scale = (float)0.95; |
| | | int startX = 10; |
| | | int startY = 25; |
| | | |
| | | //int length = 320 * Scale; |
| | | //int height = 160 * Scale; |
| | | var g = e.Graphics; |
| | | |
| | | Font font = new Font("Arial", 8 * Scale);//设置字体颜色 |
| | | Font font2 = new Font("Arial", 11 * Scale);//设置字体颜色 |
| | | Font font3 = new Font("Arial", 36 * Scale);//设置字体颜色 |
| | | Font font4 = new Font("Arial", 12 * Scale);//设置字体颜色 |
| | | |
| | | |
| | | Pen p = new Pen(Color.Black, Scale);//定义了一个黑色,宽度为1的画笔 |
| | | g.Clear(Color.White); |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(10,10),宽为80,高为20 |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(90,10),宽为80,高为20 |
| | | g.DrawString("厂商", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);// |
| | | g.DrawString("嘉彰科技", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale); |
| | | |
| | | |
| | | //第二行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("品名", font, brush, (startX + 20) * Scale, (startY + 25) * Scale); |
| | | g.DrawString(@"COVER LG208H-RC100 #2", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale); |
| | | |
| | | //第三行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("料号", font, brush, (startX + 20) * Scale, (startY + 45) * Scale); |
| | | g.DrawString(@"436LG208I000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale); |
| | | |
| | | //第四行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("数量", font, brush, (startX + 20) * Scale, (startY + 65) * Scale); |
| | | g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale); |
| | | |
| | | //第五行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("生产日期", font, brush, (startX + 10) * Scale, (startY + 85) * Scale); |
| | | g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale); |
| | | |
| | | //第六行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale); |
| | | g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale); |
| | | |
| | | |
| | | //侧面 |
| | | g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale); |
| | | g.DrawString(@"#2", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale); |
| | | } |
| | | catch (Exception ee) |
| | | { |
| | | MessageBox.Show(ee.Message); |
| | | } |
| | | } |
| | | |
| | | private void printDocument_Print222(object sender, PrintPageEventArgs e) |
| | | { |
| | | Font fntTxt = new Font("黑体", 15, System.Drawing.FontStyle.Bold);//正文文字 |
| | | System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black);//画刷 |
| | | try |
| | | { |
| | | string numvalue = message; |
| | | //Bitmap bitmap = getexcel();// CreateCode(numvalue); |
| | | |
| | | //int with = (ttwith - bitmap.Width) / 2 - 20; |
| | | //int heih = (ttheigh - bitmap.Height) / 2; |
| | | //條碼的位置 |
| | | e.Graphics.DrawImage(bitmap, new System.Drawing.Point(with, heih)); |
| | | //e.Graphics.DrawImage(bitmap, new System.Drawing.Point(0, 0)); |
| | | //條碼信息數字的位置 |
| | | e.Graphics.DrawString(numvalue, fntTxt, brush, new System.Drawing.Point(bitmap.Width / 4 + with - 10, heih + bitmap.Height + 5)); |
| | | //e.Graphics.DrawString(numvalue, fntTxt, brush, new System.Drawing.Point(bitmap.Width / 4 + with - 10, heih + bitmap.Height + 5)); |
| | | |
| | | |
| | | //e.Graphics.DrawImage(img, new Rectangle(25, 25, bmpwidth, bmpheight), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel); |
| | | int Scale = 1; |
| | | int startX = 10; |
| | | int startY = 25; |
| | | |
| | | int length = 320 * Scale; |
| | | int height = 160 * Scale; |
| | | var g = e.Graphics; |
| | | |
| | | Font font = new Font("Arial", 8 * Scale);//设置字体颜色 |
| | | Font font2 = new Font("Arial", 11 * Scale);//设置字体颜色 |
| | | Font font3 = new Font("Arial", 36 * Scale);//设置字体颜色 |
| | | Font font4 = new Font("Arial", 12 * Scale);//设置字体颜色 |
| | | |
| | | |
| | | //SolidBrush brush = new SolidBrush(Color.Black);//新建一个画刷,到这里为止,我们已经准备好了画板、画刷、和数据 |
| | | |
| | | |
| | | Pen p = new Pen(Color.Black, Scale);//定义了一个黑色,宽度为1的画笔 |
| | | g.Clear(Color.White); //设置白色背景 |
| | | //第一行数据 |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(10,10),宽为80,高为20 |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(90,10),宽为80,高为20 |
| | | g.DrawString("厂商", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);// |
| | | g.DrawString("嘉彰科技", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale); |
| | | |
| | | |
| | | //第二行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("品名", font, brush, (startX + 20) * Scale, (startY + 25) * Scale); |
| | | g.DrawString(@"COVER LG208H-RC100 #2", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale); |
| | | |
| | | //第三行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("料号", font, brush, (startX + 20) * Scale, (startY + 45) * Scale); |
| | | g.DrawString(@"436LG208I000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale); |
| | | |
| | | //第四行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("数量", font, brush, (startX + 20) * Scale, (startY + 65) * Scale); |
| | | g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale); |
| | | |
| | | //第五行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("生产日期", font, brush, (startX + 10) * Scale, (startY + 85) * Scale); |
| | | g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale); |
| | | |
| | | //第六行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale); |
| | | g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale); |
| | | |
| | | |
| | | //侧面 |
| | | g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale); |
| | | g.DrawString(@"#2", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | catch (Exception ee) |
| | |
| | | PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog(); |
| | | this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)"; |
| | | this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh); |
| | | this.printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument_Print); |
| | | //this.printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument_Print); |
| | | printPreviewDialog1.Document = printDocument1; |
| | | DialogResult res = printPreviewDialog1.ShowDialog(); |
| | | printPreviewDialog1.Document.Dispose(); |
| | | } |
| | | |
| | | |
| | | |
| | | public Bitmap getexcel() |
| | | { |
| | | |
| | | |
| | | int startX = 10; |
| | | int startY = 25; |
| | | |
| | | int Scale = 1; |
| | | |
| | | int length = 320 * Scale; |
| | | int height = 160 * Scale; |
| | | |
| | | Bitmap bmp = new Bitmap(length, height);//, System.Drawing.Imaging.PixelFormat.Format32bppArgb);//新建一个图片对象 |
| | | |
| | | //bmp.SetResolution(320, 160); |
| | | |
| | | Graphics g = Graphics.FromImage(bmp);//利用该图片对象生成“画板” |
| | | |
| | | Font font = new Font("Arial", 8 * Scale);//设置字体颜色 |
| | | Font font2 = new Font("Arial", 11 * Scale);//设置字体颜色 |
| | | Font font3 = new Font("Arial", 36 * Scale);//设置字体颜色 |
| | | Font font4 = new Font("Arial", 12 * Scale);//设置字体颜色 |
| | | |
| | | |
| | | SolidBrush brush = new SolidBrush(Color.Black);//新建一个画刷,到这里为止,我们已经准备好了画板、画刷、和数据 |
| | | |
| | | //g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; |
| | | //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
| | | //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; |
| | | |
| | | |
| | | //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; |
| | | //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; |
| | | //g.PixelOffsetMode = PixelOffsetMode.Half; |
| | | |
| | | |
| | | Pen p = new Pen(Color.Black, Scale);//定义了一个黑色,宽度为1的画笔 |
| | | g.Clear(Color.White); //设置白色背景 |
| | | //第一行数据 |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(10,10),宽为80,高为20 |
| | | g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//在画板上画矩形,起始坐标为(90,10),宽为80,高为20 |
| | | g.DrawString("厂商", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);// |
| | | g.DrawString("嘉彰科技", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale); |
| | | |
| | | |
| | | //第二行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("品名", font, brush, (startX + 20) * Scale, (startY + 25) * Scale); |
| | | g.DrawString(@"COVER LG208H-RC100 #2", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale); |
| | | |
| | | //第三行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale); |
| | | g.DrawString("料号", font, brush, (startX + 20) * Scale, (startY + 45) * Scale); |
| | | g.DrawString(@"436LG208I000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale); |
| | | |
| | | //第四行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("数量", font, brush, (startX + 20) * Scale, (startY + 65) * Scale); |
| | | g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale); |
| | | |
| | | //第五行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("生产日期", font, brush, (startX + 10) * Scale, (startY + 85) * Scale); |
| | | g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale); |
| | | |
| | | //第六行数据 |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale); |
| | | g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale); |
| | | g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale); |
| | | g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale); |
| | | |
| | | |
| | | //侧面 |
| | | g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale); |
| | | g.DrawString(@"#2", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //Font font22 = new Font("Arial", 6);//设置字体颜色 |
| | | //for (int i = 0; i < 32;i++) |
| | | //{ |
| | | // g.DrawString(i.ToString(), font22, brush, 0, i*10); |
| | | // g.DrawString(i.ToString(), font22, brush, i * 10, 0); |
| | | //} |
| | | |
| | | //bmp.Save("E:/test.bmp");//保存为输出流,否则页面上显示不出来 |
| | | g.Dispose();//释放掉该资源 |
| | | |
| | | bmp.SetResolution(105 * Scale, 105 * Scale); |
| | | |
| | | |
| | | return bmp; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #region |
| | | [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)] |
| | | private static extern bool OpenPrinter(string pPrinterName, out IntPtr hPrinter, IntPtr pDefault); |
| | |
| | | } |
| | | else |
| | | { |
| | | if (barcode.Split('-').Length > 5) |
| | | { |
| | | int mh = Plc1.Read(4000, 1, out _)[0]; |
| | | string codestr = barcode.Split('-')[4]; |
| | | if (codestr == "L") |
| | | { |
| | | codestr = "10"; |
| | | } |
| | | |
| | | if (codestr.Equals(mh.ToString())) |
| | | { |
| | | ret.Add(1); |
| | | } |
| | | else |
| | | { |
| | | ret.Add(2); |
| | | Plc1.WriteSingleAddress(4010, 1, out _);//给plc报警 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ret.Add(999); |
| | | } |
| | | } |
| | | |
| | | FillSpecResults(results[0].PID, results[0].Specs, ret, opConfig.Products[0].SEQUENCE); |
| | | |
| | | |
| | | opConfig.Products[0].SN = barcode; |
| | | opConfig.Products[0].Details.ForEach(u => u.SN = barcode); |
| | | opConfig.Products[0].PID = barcode + "_1"; |
| | | opConfig.Products[0].Details.ForEach(u => |
| | | { |
| | | u.SN = barcode; |
| | | u.PID = barcode + "_1"; |
| | | u.ResultList.ForEach(x => |
| | | { |
| | | |
| | | x.PID = barcode + "_1"; |
| | | |
| | | }); |
| | | }); |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"产品{opConfig.Products[0].PID}条码获取为{barcode}"); |
| | | } |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | private string BarcodeScannerCommunicate(TcpClientWrapBase client) |
| | |
| | | } |
| | | return isBarcodeValid; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("ImageCheck", "CheckLineProfile", "检测产品线轮廓度", InvokeType.TestInvoke)] |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |