Commit c4a95896 刘韬

1

1 个父辈 291c42bb
......@@ -102,6 +102,7 @@
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\SQLiteHelper.cs" />
<Compile Include="theMachine\BitmapCache.cs" />
<Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\JobList.cs" />
<Compile Include="theMachine\LabelParam.cs" />
......
......@@ -258,10 +258,12 @@ namespace DeviceLibrary
codeList.Clear();
}
}
//if (!hasRightCode)
LogUtil.info("Camera 02");
if (!hasRightCode)
{
bitmapfilename = SaveImageToFile("mimo", cameraName, bmp);
}
BitmapCache.AddBmp(bitmapfilename, bmp);
LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r);
}
catch (AccessViolationException e)
......@@ -280,8 +282,8 @@ namespace DeviceLibrary
{
ho_Image.Dispose();
}
if (bmp != null)
bmp.Dispose();
//if (bmp != null)
// bmp.Dispose();
}
}
catch (AccessViolationException e)
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class BitmapCache
{
static Dictionary<string, Bitmap> Store = new Dictionary<string, Bitmap>();
public static void AddBmp(string name, Bitmap bitmap) {
Store[name] = bitmap;
}
public static Bitmap GetBmp(string name) {
if (!Store.ContainsKey(name))
return null;
return Store[name];
}
public static bool HasBmp(string name)
{
return Store.ContainsKey(name);
}
public static void RemoveBmp(string name)
{
if (!Store.ContainsKey(name))
return;
try
{
Store[name].Dispose();
}
catch { }
Store.Remove(name);
}
}
}
......@@ -113,9 +113,9 @@ namespace DeviceLibrary
Pen Greenpen = new Pen(Color.Green, 10);
Bitmap srcbitmap;
if (File.Exists(labelParam.bitmapfilename))
if (BitmapCache.HasBmp(labelParam.bitmapfilename))
{
srcbitmap = new Bitmap(labelParam.bitmapfilename);
srcbitmap = BitmapCache.GetBmp(labelParam.bitmapfilename);
}
else
{
......@@ -137,10 +137,10 @@ namespace DeviceLibrary
int widthOffset = 0;
g.FillEllipse(blue, new Rectangle(org, pointsize));
List<int> angles = new List<int>();
CodeInfo rightcode=null;
CodeInfo rightcode = null;
int rightangle = 0;
labelParam.codeInfos.ForEach((c) => {
if (c.CodeType== "2/5 Interleaved" || c.CodeType== "2/5 Industrial")
if (c.CodeType == "2/5 Interleaved" || c.CodeType == "2/5 Industrial")
return;
if (c.CodeType != "Code 128" && c.CodeType != "Code 39" && c.CodeType != "Data Matrix ECC 200")
return;
......@@ -149,12 +149,15 @@ namespace DeviceLibrary
a = a < 0 ? 360 + a : a;
LogUtil.info($"{c.CodeType},{c.CodeStr},angles:{a}");
angles.Add(a);
if (c.CodeStr.Contains(labelParam.ReeID) && c.CodeType== "Data Matrix ECC 200")
if (c.CodeStr.Contains(labelParam.ReeID) && c.CodeType == "Data Matrix ECC 200")
{
rightcode = c;
}
});
if (rightcode == null){
rightcode = labelParam.codeInfos[0];
LogUtil.info($"没有发现准确的码, 随机贴标");
}
if (rightcode != null)
{
......@@ -259,7 +262,7 @@ namespace DeviceLibrary
string dir = "/image/labeldebug/";
Directory.CreateDirectory(dir);
bitmap.Save(dir + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".jpg", ImageFormat.Jpeg);
//bitmap.Save(dir + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".jpg", ImageFormat.Jpeg);
bitmap.Dispose();
return p3;
......
......@@ -136,6 +136,8 @@ namespace DeviceLibrary
LastCode = String.Join("##", cc);
CountMoveInfo.log("已完成扫码 Code:" + LastCode);
//Common.codeProcess(CountMoveInfo.MoveParam, out string mmm);
CountMoveInfo.MoveParam.WareCode = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("S20") && c.CodeType== "Data Matrix ECC 200").FirstOrDefault()?.CodeStr;
if (string.IsNullOrWhiteSpace(CountMoveInfo.MoveParam.WareCode))
CountMoveInfo.MoveParam.WareCode = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("S20")).FirstOrDefault().CodeStr;
CountMoveInfo.MoveParam.ReeID = CountMoveInfo.MoveParam.WareCode;
CountMoveInfo.MoveParam.PN = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("AT")).FirstOrDefault()?.CodeStr;
......@@ -315,7 +317,7 @@ namespace DeviceLibrary
int xplate_open_retry_times = 3;
for (int ii = 1; ii <= xplate_getimage_retry_times; ii++)
{
bool rtn = RobotManage.xrayImage.GetImage(1);
bool rtn = RobotManage.xrayImage.GetImage(2);
if (!rtn)
{
if (ii == xplate_getimage_retry_times)
......@@ -413,7 +415,7 @@ namespace DeviceLibrary
if (type == "auto")
{
result = XrayImage.GetLocalCount(xrayImagePath, ShrinkOffset, out countStr, out dst);
CountMoveInfo.log("GetCountResult " + type + " 调用 GetLocalCount 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
CountMoveInfo.log("GetCountResult " + type + ", ShrinkOffset=" + ShrinkOffset + ", 调用 GetLocalCount 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + (countStr != null ? string.Join(",", countStr) : "null") + "】");
}
else if (type.StartsWith("IP_Template_PARTS"))
{
......@@ -423,13 +425,13 @@ namespace DeviceLibrary
template = type.Substring(17 + 1);
}
result = XrayImage.GetLocalCountTemplate(xrayImagePath, ShrinkOffset, template, out countStr, out dst);
CountMoveInfo.log("GetCountResult " + template + " 调用 GetLocalCountTemplate 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
CountMoveInfo.log("GetCountResult " + template + ", ShrinkOffset="+ ShrinkOffset + ", 调用 GetLocalCountTemplate 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + (countStr != null ? string.Join(",", countStr) : "null") + "】");
}
else
{
result = XrayImage.GetLocalCountIrregular(xrayImagePath, ShrinkOffset, type.ToString(), out countStr, out dst);
CountMoveInfo.log("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
CountMoveInfo.log("GetCountResult " + type + ", ShrinkOffset=" + ShrinkOffset + " 调用 GetLocalCountIrregular 【" + xrayImagePath + "】,返回【" + result + "】,结果【" + (countStr != null ? string.Join(",", countStr) : "null") + "】");
}
if (dst != null)
{
......
......@@ -102,6 +102,9 @@ namespace DeviceLibrary
LabelMoveInfo.log($"源坐标:{p}");
var x = p.X;
var y = p.Y;
if (x == 0 && y == 0) {
}
p.Y= 5472 - x;
p.X = y;
......
......@@ -85,9 +85,12 @@ namespace DeviceLibrary
else
{
takeretry++;
OutMoveInfo.MoveParam.PlateH= OutMoveInfo.MoveParam.PlateH-2;
if (OutMoveInfo.MoveParam.PlateH>32)
OutMoveInfo.MoveParam.PlateH-=3;
else
OutMoveInfo.MoveParam.PlateH -= 2;
OutMoveInfo.log($"未取到料盘");
if (takeretry < 3 && OutMoveInfo.MoveParam.PlateH>=8)
if (takeretry < 9 && OutMoveInfo.MoveParam.PlateH>=8)
{
OutMoveInfo.NextMoveStep(MoveStep.Out_05);
OutMoveInfo.log($"重试取盘:"+ OutMoveInfo.MoveParam.PlateH);
......@@ -135,7 +138,7 @@ namespace DeviceLibrary
}
}
else if (OutMoveInfo.IsTimeOut(10)) {
else if (OutMoveInfo.IsTimeOut(20)) {
OutMoveInfo.log($"等待点料结果超时, NG处理");
OutMoveInfo.MoveParam.IsNg = true;
OutMoveInfo.MoveParam.NgMsg = "点料超时";
......
......@@ -35,10 +35,11 @@ namespace TheMachine
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.二维码识别调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.点料算法匹配ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.语言toolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.简体中文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.日本语ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.englishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabc = new System.Windows.Forms.TabControl();
......@@ -59,8 +60,6 @@ namespace TheMachine
this.listView1 = new System.Windows.Forms.ListView();
this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button();
this.点料算法匹配ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.menuStrip1.SuspendLayout();
this.tabc.SuspendLayout();
this.tabP1.SuspendLayout();
......@@ -125,6 +124,18 @@ namespace TheMachine
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(189, 6);
//
// 点料算法匹配ToolStripMenuItem
//
this.点料算法匹配ToolStripMenuItem.Name = "点料算法匹配ToolStripMenuItem";
this.点料算法匹配ToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.点料算法匹配ToolStripMenuItem.Text = "点料算法匹配";
this.点料算法匹配ToolStripMenuItem.Click += new System.EventHandler(this.点料算法匹配ToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(189, 6);
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
......@@ -136,7 +147,6 @@ namespace TheMachine
//
this.语言toolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.简体中文ToolStripMenuItem,
this.日本语ToolStripMenuItem,
this.englishToolStripMenuItem});
this.语言toolStripMenuItem.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.语言toolStripMenuItem.Name = "语言toolStripMenuItem";
......@@ -151,14 +161,6 @@ namespace TheMachine
this.简体中文ToolStripMenuItem.Text = "简体中文";
this.简体中文ToolStripMenuItem.Click += new System.EventHandler(this.简体中文ToolStripMenuItem_Click);
//
// 日本语ToolStripMenuItem
//
this.日本语ToolStripMenuItem.Name = "日本语ToolStripMenuItem";
this.日本语ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.日本语ToolStripMenuItem.Tag = "not";
this.日本语ToolStripMenuItem.Text = "日本語";
this.日本语ToolStripMenuItem.Click += new System.EventHandler(this.日本语ToolStripMenuItem_Click);
//
// englishToolStripMenuItem
//
this.englishToolStripMenuItem.Name = "englishToolStripMenuItem";
......@@ -387,18 +389,6 @@ namespace TheMachine
this.btn_run.UseVisualStyleBackColor = true;
this.btn_run.Click += new System.EventHandler(this.btn_run_Click);
//
// 点料算法匹配ToolStripMenuItem
//
this.点料算法匹配ToolStripMenuItem.Name = "点料算法匹配ToolStripMenuItem";
this.点料算法匹配ToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.点料算法匹配ToolStripMenuItem.Text = "点料算法匹配";
this.点料算法匹配ToolStripMenuItem.Click += new System.EventHandler(this.点料算法匹配ToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(189, 6);
//
// Form1
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -455,7 +445,6 @@ namespace TheMachine
private System.Windows.Forms.Panel pnl;
private System.Windows.Forms.ToolStripMenuItem 语言toolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 简体中文ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 日本语ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ListView listView_reelnfo;
......
......@@ -675,6 +675,7 @@ namespace TheMachine
p.Start();
p.WaitForExit();
Pn_Algo_Match.LoadFile();
Asa.XrayImage.ReloadTpl();
});
}
}
......
......@@ -33,6 +33,7 @@ namespace TheMachine
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.btn_printertest = new System.Windows.Forms.Button();
this.btn_labeledit = new System.Windows.Forms.Button();
this.cb_labelselect = new System.Windows.Forms.ComboBox();
this.btn_Calibration = new System.Windows.Forms.Button();
......@@ -41,7 +42,7 @@ namespace TheMachine
this.btn_takephoto = new System.Windows.Forms.Button();
this.btn_openxray = new System.Windows.Forms.Button();
this.uC_SetUserPassword1 = new TheMachine.UC_SetUserPassword();
this.btn_printertest = new System.Windows.Forms.Button();
this.buttonmunial = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.X光调试.SuspendLayout();
this.SuspendLayout();
......@@ -75,7 +76,7 @@ namespace TheMachine
this.groupBox1.Controls.Add(this.cb_labelselect);
this.groupBox1.Location = new System.Drawing.Point(3, 128);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(340, 126);
this.groupBox1.Size = new System.Drawing.Size(354, 126);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "打印设置";
......@@ -89,6 +90,16 @@ namespace TheMachine
this.label2.Text = "标签名";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btn_printertest
//
this.btn_printertest.Location = new System.Drawing.Point(11, 77);
this.btn_printertest.Name = "btn_printertest";
this.btn_printertest.Size = new System.Drawing.Size(107, 31);
this.btn_printertest.TabIndex = 1;
this.btn_printertest.Text = "打印测试";
this.btn_printertest.UseVisualStyleBackColor = true;
this.btn_printertest.Click += new System.EventHandler(this.btn_printertest_Click);
//
// btn_labeledit
//
this.btn_labeledit.Location = new System.Drawing.Point(208, 77);
......@@ -109,7 +120,7 @@ namespace TheMachine
//
// btn_Calibration
//
this.btn_Calibration.Location = new System.Drawing.Point(182, 115);
this.btn_Calibration.Location = new System.Drawing.Point(178, 76);
this.btn_Calibration.Name = "btn_Calibration";
this.btn_Calibration.Size = new System.Drawing.Size(146, 43);
this.btn_Calibration.TabIndex = 12;
......@@ -119,20 +130,21 @@ namespace TheMachine
//
// X光调试
//
this.X光调试.Controls.Add(this.buttonmunial);
this.X光调试.Controls.Add(this.btn_closexray);
this.X光调试.Controls.Add(this.btn_takephoto);
this.X光调试.Controls.Add(this.btn_openxray);
this.X光调试.Controls.Add(this.btn_Calibration);
this.X光调试.Location = new System.Drawing.Point(317, 313);
this.X光调试.Location = new System.Drawing.Point(3, 273);
this.X光调试.Name = "X光调试";
this.X光调试.Size = new System.Drawing.Size(354, 206);
this.X光调试.Size = new System.Drawing.Size(354, 220);
this.X光调试.TabIndex = 13;
this.X光调试.TabStop = false;
this.X光调试.Text = "groupBox2";
//
// btn_closexray
//
this.btn_closexray.Location = new System.Drawing.Point(182, 39);
this.btn_closexray.Location = new System.Drawing.Point(178, 27);
this.btn_closexray.Name = "btn_closexray";
this.btn_closexray.Size = new System.Drawing.Size(146, 43);
this.btn_closexray.TabIndex = 12;
......@@ -142,7 +154,7 @@ namespace TheMachine
//
// btn_takephoto
//
this.btn_takephoto.Location = new System.Drawing.Point(30, 115);
this.btn_takephoto.Location = new System.Drawing.Point(26, 76);
this.btn_takephoto.Name = "btn_takephoto";
this.btn_takephoto.Size = new System.Drawing.Size(146, 43);
this.btn_takephoto.TabIndex = 12;
......@@ -152,7 +164,7 @@ namespace TheMachine
//
// btn_openxray
//
this.btn_openxray.Location = new System.Drawing.Point(30, 39);
this.btn_openxray.Location = new System.Drawing.Point(26, 27);
this.btn_openxray.Name = "btn_openxray";
this.btn_openxray.Size = new System.Drawing.Size(146, 43);
this.btn_openxray.TabIndex = 12;
......@@ -169,15 +181,15 @@ namespace TheMachine
this.uC_SetUserPassword1.Size = new System.Drawing.Size(405, 272);
this.uC_SetUserPassword1.TabIndex = 10;
//
// btn_printertest
// buttonmunial
//
this.btn_printertest.Location = new System.Drawing.Point(11, 77);
this.btn_printertest.Name = "btn_printertest";
this.btn_printertest.Size = new System.Drawing.Size(107, 31);
this.btn_printertest.TabIndex = 1;
this.btn_printertest.Text = "打印测试";
this.btn_printertest.UseVisualStyleBackColor = true;
this.btn_printertest.Click += new System.EventHandler(this.btn_printertest_Click);
this.buttonmunial.Location = new System.Drawing.Point(26, 125);
this.buttonmunial.Name = "buttonmunial";
this.buttonmunial.Size = new System.Drawing.Size(146, 43);
this.buttonmunial.TabIndex = 13;
this.buttonmunial.Text = "手动点料";
this.buttonmunial.UseVisualStyleBackColor = true;
this.buttonmunial.Click += new System.EventHandler(this.buttonmunial_Click);
//
// SettingControl
//
......@@ -211,5 +223,6 @@ namespace TheMachine
private System.Windows.Forms.Button btn_takephoto;
private System.Windows.Forms.Button btn_openxray;
private System.Windows.Forms.Button btn_printertest;
private System.Windows.Forms.Button buttonmunial;
}
}
......@@ -207,5 +207,26 @@ namespace TheMachine
}else
MessageBox.Show("打印成功");
}
private void buttonmunial_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "PNG files (*.png)|";
openFileDialog.InitialDirectory = "/image/Xray/back/";
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
var file = openFileDialog.FileName;
var filename = Path.GetFileNameWithoutExtension(file);
var f = filename.Split('-');
if (f.Length > 0)
{
RobotManage.mainMachine.CountMoveInfo.MoveParam.PN = f[0];
}
RobotManage.mainMachine.xrayImagePath = file;
var count = RobotManage.mainMachine.GetCountResult();
MessageBox.Show(this, count.ToString(), "点料结果");
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!