Commit fa81c6e7 刘韬

出料防撞检测,平板出错检测

1 个父辈 dbedd0e8
......@@ -14,13 +14,13 @@
<add key="ConfigPath_XRay" value="\RobotConfig\Config_XRay.csv" />
<add key="ConfigPath_InputEquip" value="\RobotConfig\Config_InputEquip.csv" />
<add key="ConfigPath_OutputEquip" value="\RobotConfig\Config_OutputEquip.csv" />
<add key="CounParamConfig" value="\XRAY\countParam.csv" />
<!--二维码类型列表配置,用#分割,一维码=Barcode 二维码: QR Code#Data Matrix ECC 200#Micro QR Code-->
<add key="CodeType" value="Data Matrix ECC 200#QR Code" />
<!--<add key="CodeType" value="Data Matrix ECC 200"/>-->
<add key="ACBaudRate" value="115200" />
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" />
<add key="CodeParamPath" value="\CodeParam\\XRAY\countParam.csv" />
<add key="Config_Pwd" value="123456" />
<add key="UseAIOBOX" value="1" />
......
......@@ -61,10 +61,6 @@
<Reference Include="AccImageBox">
<HintPath>..\..\dll\AccImageBox.dll</HintPath>
</Reference>
<Reference Include="Asa.CarerayImage, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\X-Ray\Asa.CarerayImage.dll</HintPath>
</Reference>
<Reference Include="Asa.PrintLabel">
<HintPath>..\..\dll\label\Asa.PrintLabel.dll</HintPath>
</Reference>
......
......@@ -12,6 +12,7 @@ using System.IO;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using static OnlineStore.DeviceLibrary.CountParam;
namespace OnlineStore.AutoCountClient
{
......@@ -96,7 +97,9 @@ namespace OnlineStore.AutoCountClient
if (obj.Sufan >= 0)
{
ParamManager.UpdateParam(new CountParam(obj.PartNum, RobotManager.robot.XrayBean.ThresholdValue, 3, obj.Sufan));
var suanfa = SignType.AUTO;
Enum.TryParse<SignType>(obj.Sufan.ToString(), out suanfa);
ParamManager.UpdateParam(new CountParam(obj.PartNum, RobotManager.robot.XrayBean.ThresholdValue, 3, suanfa));
ParamManager.SaveMapToFile();
}
}
......@@ -134,7 +137,9 @@ namespace OnlineStore.AutoCountClient
groupInfo.Text = "元器件【" + obj.PartNum + "】的基本信息";
if (obj.Sufan >= 0)
{
ParamManager.UpdateParam(new CountParam(obj.PartNum, RobotManager.robot.XrayBean.ThresholdValue, 3, obj.Sufan));
var suanfa = SignType.AUTO;
Enum.TryParse<SignType>(obj.Sufan.ToString(), out suanfa);
ParamManager.UpdateParam(new CountParam(obj.PartNum, RobotManager.robot.XrayBean.ThresholdValue, 3, suanfa));
ParamManager.SaveMapToFile();
}
}
......@@ -387,7 +392,7 @@ namespace OnlineStore.AutoCountClient
CountParam param = ParamManager.GetParamByPN(com.PartNum);
if (param != null)
{
com.Sufan = param.Sign;
com.Sufan = (int)param.Sign;
}
else
{
......
......@@ -35,7 +35,6 @@
this.lblCountInfo = new System.Windows.Forms.Label();
this.imgCurrImg = new Acc.ImageBox.ImageBox();
this.lblPnInfo = new System.Windows.Forms.Label();
this.btnTest = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.numWSize = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
......@@ -48,12 +47,14 @@
this.buttonD = new System.Windows.Forms.Button();
this.buttonC = new System.Windows.Forms.Button();
this.buttonB = new System.Windows.Forms.Button();
this.buttonAuto = new System.Windows.Forms.Button();
this.buttonA = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblPN = new System.Windows.Forms.Label();
this.lblFeng = new System.Windows.Forms.Label();
this.lblDes = new System.Windows.Forms.Label();
this.lblProName = new System.Windows.Forms.Label();
this.label_coutresult = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numWSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numTh)).BeginInit();
......@@ -136,19 +137,6 @@
this.lblPnInfo.Text = "料盘PN:";
this.lblPnInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnTest
//
this.btnTest.BackColor = System.Drawing.Color.White;
this.btnTest.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTest.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnTest.Location = new System.Drawing.Point(31, 337);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(235, 46);
this.btnTest.TabIndex = 285;
this.btnTest.Text = "点料测试";
this.btnTest.UseVisualStyleBackColor = false;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// btnNext
//
this.btnNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
......@@ -166,7 +154,7 @@
// numWSize
//
this.numWSize.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.numWSize.Location = new System.Drawing.Point(246, 47);
this.numWSize.Location = new System.Drawing.Point(271, 57);
this.numWSize.Maximum = new decimal(new int[] {
1000,
0,
......@@ -185,7 +173,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(194, 50);
this.label3.Location = new System.Drawing.Point(219, 60);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(68, 20);
this.label3.TabIndex = 296;
......@@ -195,7 +183,7 @@
// numTh
//
this.numTh.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.numTh.Location = new System.Drawing.Point(246, 9);
this.numTh.Location = new System.Drawing.Point(271, 19);
this.numTh.Name = "numTh";
this.numTh.Size = new System.Drawing.Size(56, 26);
this.numTh.TabIndex = 295;
......@@ -209,7 +197,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(220, 12);
this.label1.Location = new System.Drawing.Point(245, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(40, 20);
this.label1.TabIndex = 294;
......@@ -238,19 +226,20 @@
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.label_coutresult);
this.groupBox4.Controls.Add(this.buttonE);
this.groupBox4.Controls.Add(this.buttonD);
this.groupBox4.Controls.Add(this.buttonC);
this.groupBox4.Controls.Add(this.buttonB);
this.groupBox4.Controls.Add(this.buttonAuto);
this.groupBox4.Controls.Add(this.buttonA);
this.groupBox4.Controls.Add(this.numTh);
this.groupBox4.Controls.Add(this.btnTest);
this.groupBox4.Controls.Add(this.numWSize);
this.groupBox4.Controls.Add(this.label3);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Location = new System.Drawing.Point(990, 162);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(308, 401);
this.groupBox4.Size = new System.Drawing.Size(308, 426);
this.groupBox4.TabIndex = 295;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "请选择参数";
......@@ -260,7 +249,7 @@
this.buttonE.BackColor = System.Drawing.Color.White;
this.buttonE.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonE.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonE.Location = new System.Drawing.Point(82, 272);
this.buttonE.Location = new System.Drawing.Point(80, 310);
this.buttonE.Name = "buttonE";
this.buttonE.Size = new System.Drawing.Size(133, 50);
this.buttonE.TabIndex = 303;
......@@ -273,7 +262,7 @@
this.buttonD.BackColor = System.Drawing.Color.White;
this.buttonD.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonD.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonD.Location = new System.Drawing.Point(82, 215);
this.buttonD.Location = new System.Drawing.Point(80, 253);
this.buttonD.Name = "buttonD";
this.buttonD.Size = new System.Drawing.Size(133, 50);
this.buttonD.TabIndex = 302;
......@@ -286,7 +275,7 @@
this.buttonC.BackColor = System.Drawing.Color.White;
this.buttonC.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonC.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonC.Location = new System.Drawing.Point(82, 158);
this.buttonC.Location = new System.Drawing.Point(80, 196);
this.buttonC.Name = "buttonC";
this.buttonC.Size = new System.Drawing.Size(133, 50);
this.buttonC.TabIndex = 301;
......@@ -299,7 +288,7 @@
this.buttonB.BackColor = System.Drawing.Color.White;
this.buttonB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonB.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonB.Location = new System.Drawing.Point(82, 101);
this.buttonB.Location = new System.Drawing.Point(80, 139);
this.buttonB.Name = "buttonB";
this.buttonB.Size = new System.Drawing.Size(133, 50);
this.buttonB.TabIndex = 300;
......@@ -307,12 +296,25 @@
this.buttonB.UseVisualStyleBackColor = false;
this.buttonB.Click += new System.EventHandler(this.buttonB_Click);
//
// buttonAuto
//
this.buttonAuto.BackColor = System.Drawing.Color.White;
this.buttonAuto.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonAuto.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonAuto.Location = new System.Drawing.Point(80, 26);
this.buttonAuto.Name = "buttonAuto";
this.buttonAuto.Size = new System.Drawing.Size(133, 50);
this.buttonAuto.TabIndex = 299;
this.buttonAuto.Text = "默认算法";
this.buttonAuto.UseVisualStyleBackColor = false;
this.buttonAuto.Click += new System.EventHandler(this.buttonAuto_Click);
//
// buttonA
//
this.buttonA.BackColor = System.Drawing.Color.White;
this.buttonA.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonA.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonA.Location = new System.Drawing.Point(82, 44);
this.buttonA.Location = new System.Drawing.Point(80, 82);
this.buttonA.Name = "buttonA";
this.buttonA.Size = new System.Drawing.Size(133, 50);
this.buttonA.TabIndex = 299;
......@@ -372,6 +374,15 @@
this.lblProName.Text = "产品:";
this.lblProName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label_coutresult
//
this.label_coutresult.AutoSize = true;
this.label_coutresult.Location = new System.Drawing.Point(57, 380);
this.label_coutresult.Name = "label_coutresult";
this.label_coutresult.Size = new System.Drawing.Size(79, 20);
this.label_coutresult.TabIndex = 304;
this.label_coutresult.Text = "点料结果:";
//
// FrmLearning
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
......@@ -407,7 +418,6 @@
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblPnInfo;
private Acc.ImageBox.ImageBox imgCurrImg;
private System.Windows.Forms.Button btnTest;
private System.Windows.Forms.Button btnEnd;
private System.Windows.Forms.NumericUpDown numWSize;
private System.Windows.Forms.Label label3;
......@@ -429,5 +439,7 @@
private System.Windows.Forms.Label lblFeng;
private System.Windows.Forms.Label lblDes;
private System.Windows.Forms.Label lblProName;
private System.Windows.Forms.Button buttonAuto;
private System.Windows.Forms.Label label_coutresult;
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static OnlineStore.DeviceLibrary.CountParam;
namespace OnlineStore.AutoCountClient
{
......@@ -22,25 +23,30 @@ namespace OnlineStore.AutoCountClient
{
InitializeComponent();
}
private int CurrType = -2;
private SignType CurrType = SignType.AUTO;
private string CurrFullFileName = "";
private string CurrPN = "";
internal string ImagePath = ParamManager.NoConfigPath;
internal string[] ImageFiles;
private List<Button> SelBtnList = new List<Button>();
private string gouStr = "✔ ";
private void FrmLearning_Load(object sender, EventArgs e)
{
ParamManager.Init();
SelBtnList.Add(buttonAuto);
SelBtnList.Add(buttonA);
SelBtnList.Add(buttonB);
SelBtnList.Add(buttonC);
SelBtnList.Add(buttonD);
SelBtnList.Add(buttonE);
foreach(Button btn in SelBtnList)
{
btn.Tag = btn.Text;
}
buttonAuto.Tag = 99;
buttonA.Tag = 0;
buttonB.Tag = 1;
buttonC.Tag = 2;
buttonD.Tag = 3;
buttonE.Tag = 4;
LoadImgList();
}
......@@ -48,12 +54,21 @@ namespace OnlineStore.AutoCountClient
private int currIndex = -1;
private void LoadImgList()
{
if (!Directory.Exists(ImagePath))
ParamManager.Init();
string[] fileList=new string[] { };
if (ImageFiles != null)
{
fileList = ImageFiles;
}
else if (!Directory.Exists(ImagePath))
{
MessageBox.Show("未找到文件夹:" + ImagePath);
this.Close();
}
string[] fileList = Directory.GetFiles(ImagePath);
else
{
fileList = Directory.GetFiles(ImagePath);
}
lblFolder.Text = "当前文件夹:" + ImagePath;
List<string> list = (from m in fileList orderby m ascending select m).ToList();
......@@ -93,10 +108,8 @@ namespace OnlineStore.AutoCountClient
string[] array = filename.Split('-');
if (array.Length >= 3)
{
CurrPN = array[0];
}
CurrPN = array[0];
groupBox4.Text = "[" + CurrPN + "] 请选择参数:";
CurrFullFileName = fullFName;
lblPnInfo.Text = fullFName;
......@@ -112,11 +125,11 @@ namespace OnlineStore.AutoCountClient
{
numTh.Value = p.Threshold;
numWSize.Value = p.WindowSize;
ShowType(p.Sign);
CurrType = (p.Sign);
}
else
{
ShowType(-1);
CurrType = (SignType.AUTO);
}
imgCurrImg.HorizontalScroll.Value = 173;
......@@ -125,7 +138,8 @@ namespace OnlineStore.AutoCountClient
{
btnNext.Enabled = false;
}
CurrType = (SignType.AUTO);
btnTest_Click(buttonAuto);
if (LoadCSVLibrary.CSVBomManager.allComMap.ContainsKey(CurrPN))
{
......@@ -146,69 +160,47 @@ namespace OnlineStore.AutoCountClient
timer1.Start();
}
private void ShowType(int type)
{
if (CurrType.Equals(type))
{
return;
}
CurrType = type;
int index = 0;
btnTest.Text = "请选择算法";
bool findsuanfa = false;
foreach (Button btn in SelBtnList)
{
if (index.Equals(type))
{
findsuanfa = true;
btn.Text = gouStr + btn.Tag;
btnTest.Text = btn.Tag + "-点料测试";
btn.BackColor = Color.LightGreen;
}
else
{
btn.Text = btn.Tag.ToString();
btn.BackColor = Color.White;
}
index++;
}
btnTest.Enabled = findsuanfa;
btnNext.Enabled = findsuanfa;
}
private void btnTest_Click(object sender, EventArgs e)
private void btnTest_Click(object sender)
{
int count = 1;
if (imgCurrImg.Image == null || String.IsNullOrEmpty(CurrFullFileName))
{
MessageBox.Show("未加载图片,无法点料");
return;
}
int index = 0;
var btnTest = (Button)sender;
foreach (Button btn in SelBtnList)
{
if (index.Equals(CurrType))
if (btn.Equals(btnTest))
{
btnTest.Text = btn.Tag + "-点料测试";
break;
btn.BackColor = Color.LightGreen;
}
else {
btn.BackColor = Color.White;
}
index++;
btnTest.Enabled = false;
}
Application.DoEvents();
LogUtil.info( Name + "用户点击 "+btnTest.Text);
try
{
btnTest.Enabled = false;
{
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
int th = (int)numTh.Value;
int wsize = (int)numWSize.Value;
Asa.API.EyemImage tpDstImg;
//Asa.API.EyemImage tpDstImg;
string resfile;
CountParam param = new CountParam("", th, wsize, CurrType);
int outCount = RobotManager.robot.XrayBean.GetCountResult(CurrFullFileName, param, out tpDstImg);
btnTest.Text +=" 结果:"+ outCount.ToString();
int outCount = RobotManager.robot.XrayBean.GetCountResult(CurrFullFileName, param, out resfile);
if (System.IO.File.Exists(resfile))
{
Bitmap bmp = FileToBitmap(resfile);
imgCurrImg.Image = bmp;
}
else {
imgCurrImg.Image = KiLighten((Bitmap)ParamManager.FormImage(ImageList[currIndex]), 80);
}
label_coutresult.Text ="点料结果:"+ outCount.ToString();
LogUtil.info( "用户点击 "+ btnTest.Text + "【" + CurrFullFileName + "】 参数 " + param.ToStr() + " 结果:" + outCount);
}
catch (Exception ex)
......@@ -216,9 +208,11 @@ namespace OnlineStore.AutoCountClient
MessageBox.Show(ex.ToString());
LogUtil.error("点料测试出错:" + ex.ToString());
}
btnTest.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default ;
SelBtnList.ForEach((b)=> { b.Enabled = true; });
}
......@@ -238,7 +232,7 @@ namespace OnlineStore.AutoCountClient
int th = (int)numTh.Value;
int wsize = (int)numWSize.Value;
CountParam p = new CountParam(CurrPN, th, wsize, CurrType, 0);
ParamManager.UpdateParam(p);
}
private bool IsSave = false;
......@@ -258,15 +252,8 @@ namespace OnlineStore.AutoCountClient
}
}
ParamManager.SaveMapToFile();
DialogResult result2 = MessageBox.Show("保存成功!是否自动清理已配置算法的图片?\r\n" +
"点击’确定‘:删除已配置算法的物料图片\r\n" +
"点击’取消‘:暂不删除", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
if (result2.Equals(DialogResult.OK))
{
ClearImage();
}
MessageBox.Show("保存成功!");
ClearImage();
IsSave = true;
this.Close();
}
......@@ -283,25 +270,23 @@ namespace OnlineStore.AutoCountClient
{
Directory.CreateDirectory(targetPath);
}
string[] fileList = Directory.GetFiles(ImagePath);
string[] fileList = Directory.GetFiles(ImagePath,"*.png");
List<string> list = (from m in fileList orderby m ascending select m).ToList();
foreach (string f in list)
{
string houzhui = Path.GetExtension(f);
string filename = Path.GetFileNameWithoutExtension(f);
string[] array = filename.Split('-');
if (houzhui.Equals(".png") && array.Length >= 3)
string pn = array[0];
CountParam p = ParamManager.GetParamByPN(pn);
if (p != null && p.Sign >= 0)
{
string pn = array[0];
CountParam p = ParamManager.GetOptimalParamByPN(pn);
if (p != null&&p.Sign>=0)
{
string targetFile = targetPath + filename + houzhui;
File.Copy(f, targetPath + filename + houzhui, true);
File.Delete(f);
LogUtil.info("算法配置后清理:备份文件【" + f + "】到【" + targetFile + "】,并删除原文件");
}
}
string targetFile = targetPath + filename + houzhui;
File.Move(f, targetPath + filename + houzhui);
//File.Delete(f);
LogUtil.info("算法配置后清理:备份文件【" + f + "】到【" + targetFile + "】,并删除原文件");
}
}
}catch(Exception ex)
{
......@@ -403,23 +388,68 @@ namespace OnlineStore.AutoCountClient
private void buttonA_Click(object sender, EventArgs e)
{
ShowType(0);
CurrType = (SignType.IP_SMALL_PARTS);
btnTest_Click(sender);
}
private void buttonB_Click(object sender, EventArgs e)
{
ShowType(1);
CurrType = (SignType.IP_LARGE_PARTS);
btnTest_Click(sender);
}
private void buttonC_Click(object sender, EventArgs e)
{
ShowType(2);
CurrType = (SignType.IP_LONG_PARTS);
btnTest_Click(sender);
}
private void buttonD_Click(object sender, EventArgs e)
{
ShowType(3);
CurrType = (SignType.IP_SQUARE_PARTS);
btnTest_Click(sender);
}
private void buttonE_Click(object sender, EventArgs e)
{
ShowType(4);
CurrType = (SignType.IP_GEN_PARTS);
btnTest_Click(sender);
}
private void buttonAuto_Click(object sender, EventArgs e)
{
CurrType = (SignType.AUTO);
btnTest_Click(sender);
}
public static Bitmap FileToBitmap(string fileName)
{
// 打开文件
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
// 读取文件的 byte[]
byte[] bytes = new byte[fileStream.Length];
fileStream.Read(bytes, 0, bytes.Length);
fileStream.Close();
// 把 byte[] 转换成 Stream
Stream stream = new MemoryStream(bytes);
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
MemoryStream mstream = null;
try
{
mstream = new MemoryStream(bytes);
return new Bitmap((Image)new Bitmap(stream));
}
catch (ArgumentNullException ex)
{
return null;
}
catch (ArgumentException ex)
{
return null;
}
finally
{
stream.Close();
}
}
}
}
......@@ -58,6 +58,8 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.设置TToolStripMenuItem = 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.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator();
this.二维码学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
......@@ -361,11 +363,28 @@
//
// 元器件学习ToolStripMenuItem
//
this.元器件学习ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.批量ToolStripMenuItem,
this.单盘ToolStripMenuItem});
this.元器件学习ToolStripMenuItem.Name = "元器件学习ToolStripMenuItem";
this.元器件学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.元器件学习ToolStripMenuItem.Text = "元器件学习";
this.元器件学习ToolStripMenuItem.Click += new System.EventHandler(this.元器件学习ToolStripMenuItem_Click);
//
// 批量ToolStripMenuItem
//
this.批量ToolStripMenuItem.Name = "批量ToolStripMenuItem";
this.批量ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.批量ToolStripMenuItem.Text = "批量";
this.批量ToolStripMenuItem.Click += new System.EventHandler(this.批量ToolStripMenuItem_Click);
//
// 单盘ToolStripMenuItem
//
this.单盘ToolStripMenuItem.Name = "单盘ToolStripMenuItem";
this.单盘ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.单盘ToolStripMenuItem.Text = "单盘";
this.单盘ToolStripMenuItem.Click += new System.EventHandler(this.单盘ToolStripMenuItem_Click);
//
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
......@@ -388,12 +407,14 @@
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem2.Text = "AGV调试";
this.toolStripMenuItem2.Visible = false;
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator6.Visible = false;
//
// 标签编辑ToolStripMenuItem
//
......@@ -421,55 +442,57 @@
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(144, 26);
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem3.Text = "历史记录";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
//
// 元器件库ToolStripMenuItem
//
this.元器件库ToolStripMenuItem.Name = "元器件库ToolStripMenuItem";
this.元器件库ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.元器件库ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.元器件库ToolStripMenuItem.Text = "元器件库";
this.元器件库ToolStripMenuItem.Visible = false;
this.元器件库ToolStripMenuItem.Click += new System.EventHandler(this.元器件库ToolStripMenuItem_Click);
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator16.Visible = false;
//
// 清空日志ToolStripMenuItem
//
this.清空日志ToolStripMenuItem.Name = "清空日志ToolStripMenuItem";
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.清空日志ToolStripMenuItem.Text = "清空日志";
this.清空日志ToolStripMenuItem.Click += new System.EventHandler(this.清空日志ToolStripMenuItem_Click);
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6);
//
// 复制日志ToolStripMenuItem
//
this.复制日志ToolStripMenuItem.Name = "复制日志ToolStripMenuItem";
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.复制日志ToolStripMenuItem.Text = "复制日志";
this.复制日志ToolStripMenuItem.Click += new System.EventHandler(this.复制日志ToolStripMenuItem_Click);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
this.toolStripSeparator11.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator11.Size = new System.Drawing.Size(177, 6);
//
// 版本号ToolStripMenuItem
//
this.版本号ToolStripMenuItem.Name = "版本号ToolStripMenuItem";
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.版本号ToolStripMenuItem.Text = "关于软件";
this.版本号ToolStripMenuItem.Click += new System.EventHandler(this.版本号ToolStripMenuItem_Click);
//
......@@ -535,7 +558,7 @@
//
this.aGVCancelStateToolStripMenuItem.Name = "aGVCancelStateToolStripMenuItem";
this.aGVCancelStateToolStripMenuItem.Size = new System.Drawing.Size(213, 26);
this.aGVCancelStateToolStripMenuItem.Text = "AGV cancelState";
this.aGVCancelStateToolStripMenuItem.Text = "禁用AGV";
this.aGVCancelStateToolStripMenuItem.Click += new System.EventHandler(this.aGVCancelStateToolStripMenuItem_Click);
//
// toolStripSeparator13
......@@ -681,6 +704,8 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator14;
private System.Windows.Forms.ToolStripMenuItem 启用贴标功能ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 批量ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 单盘ToolStripMenuItem;
}
}
......@@ -257,7 +257,8 @@ namespace OnlineStore.AutoCountClient
{
Camera._cam.CloseAll();
}
robot.sQLite.Close();
if (robot.sQLite!=null)
robot.sQLite.Close();
}
catch (Exception ex)
{
......@@ -486,7 +487,17 @@ namespace OnlineStore.AutoCountClient
{
return;
}
lblXrayWork.Visible = robot.XrayBean.InXWork;
if (robot.XrayBean.carerayImageError)
{
robot.XrayBean.MoveStop = true;
lblXrayWork.Text = "图像平板失效,请及时处理。";
lblXrayWork.Visible = true;
}
string canScanCode = "";
lblStatus.Text = robot.GetRunStr() + canScanCode;
string warnMsg = robot.WarnMsg;
......@@ -535,11 +546,11 @@ namespace OnlineStore.AutoCountClient
//}
if (AgvClient.CurrCancelState)
{
aGVCancelStateToolStripMenuItem.Text = gouStr + " AGV cancelState";
aGVCancelStateToolStripMenuItem.Text = gouStr + "禁用 AGV";
}
else
{
aGVCancelStateToolStripMenuItem.Text = "AGV cancelState";
aGVCancelStateToolStripMenuItem.Text = "禁用 AGV";
}
UpdateListBox();
}
......@@ -707,7 +718,6 @@ namespace OnlineStore.AutoCountClient
ExitApp();
}
private void logBox_VisibleChanged(object sender, EventArgs e)
{
if (!LoadOk)
......@@ -941,7 +951,32 @@ namespace OnlineStore.AutoCountClient
private void 元器件学习ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void 单盘ToolStripMenuItem_Click(object sender, EventArgs e)
{
string backPath = ParamManager.NoConfigPath;
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = ParamManager.NoConfigPath;
ofd.Multiselect = true;
ofd.Filter = "PNG|*.png";
if (DialogResult.OK == ofd.ShowDialog(this)) {
FrmLearning frm = new FrmLearning();
frm.ImageFiles = ofd.FileNames;
frm.ImagePath = ParamManager.NoConfigPath;
frm.Show();
//Task.Run(() => { frm.ShowDialog(); });
}
}
private void 批量ToolStripMenuItem_Click(object sender, EventArgs e)
{
string backPath = ParamManager.NoConfigPath;
FrmLearning frm = new FrmLearning();
frm.ImagePath = backPath;
frm.Show();
/*
folderBrowserDialog1.Description = "请选择需要学习的图片文件夹";
if (!Directory.Exists(backPath))
{
......@@ -954,9 +989,10 @@ namespace OnlineStore.AutoCountClient
string folder = folderBrowserDialog1.SelectedPath;
FrmLearning frm = new FrmLearning();
frm.ImagePath = folder;
frm.ShowDialog();
}
}
frm.Show();
//Task.Run(() => { frm.ShowDialog(); });
}*/
}
private void 元器件库ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmComponentList frm = new FrmComponentList();
......@@ -1012,5 +1048,7 @@ namespace OnlineStore.AutoCountClient
}
LogUtil.info(Name + " 点击:" + 启用贴标功能ToolStripMenuItem.Text);
}
}
}
......@@ -16,13 +16,13 @@ using System.Reflection;
using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
using static OnlineStore.DeviceLibrary.CountParam;
namespace OnlineStore.AutoCountClient
{
internal partial class FrmXRay : FrmEquipBase
{
private int DeviceType = 0;
private SignType DeviceType = SignType.AUTO;
private bool IsLoad = false;
private X_RAY_Equip equipBean;
......@@ -34,10 +34,15 @@ namespace OnlineStore.AutoCountClient
InitializeComponent();
LoadIOList();
}
private void FrmXRay_Shown(object sender, EventArgs e)
{
}
private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{
cmbType.Items.AddRange(new string[] { "小器件", "大器件", "异形三角器件", "异形三脚大器件", "异形长条形器件" });
cmbType.SelectedIndex = DeviceType;
cmbType.Items.AddRange(new string[] { "默认算法", "算法A", "算法B", "算法C", "算法D", "算法E" });
cmbType.SelectedIndex = (DeviceType==SignType.AUTO?0: (int)DeviceType);
chbDebug.Checked = equipBean.IsDebug;
lblCom.Text = "X射线端口号:" + equipBean.Config.XRay_Port;
......@@ -105,6 +110,7 @@ namespace OnlineStore.AutoCountClient
{
return;
}
this.chbMoveStop.Checked = equipBean.MoveStop;
ReadIOList();
ReadBtnDO();
lblOpen.Visible =(! equipBean.OpenXLine);
......@@ -447,9 +453,8 @@ namespace OnlineStore.AutoCountClient
txtResult.Text = "点料中...";
int th = (int)numTh.Value;
int wsize = (int)numWSize.Value;
Asa.API.EyemImage tpDstImg ;
CountParam param = new CountParam("", th, wsize, DeviceType);
int outCount = equipBean.GetCountResult(filePath, param, out tpDstImg);
int outCount = equipBean.GetCountResult(filePath, param, out _);
txtResult.Text = outCount.ToString();
LogUtil.info(equipBean.Name + "用户点击 点料测试【" + filePath + "】【" + th + "】【" + wsize + "】 结果:" + outCount);
}
......@@ -494,7 +499,8 @@ namespace OnlineStore.AutoCountClient
int index = cmbType.SelectedIndex;
if (index >= 0)
{
DeviceType = index;
index--;
Enum.TryParse<SignType>(index.ToString(), out DeviceType);
LogUtil.info(Name + " " + equipBean.Name + " 更改 equipBean.DeviceType=" + index);
}
}
......
......@@ -48,6 +48,8 @@ namespace CodeLibrary
}
public override void CloseAll()
{
if (cameraCurr == null)
return;
for (int i = 0; i < cameraCurr.Length; i++)
{
if (cameraCurr[i] != null)
......
......@@ -41,8 +41,9 @@
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.CarerayImage">
<HintPath>..\..\dll\X-Ray\Asa.CarerayImage.dll</HintPath>
<Reference Include="Asa.CarerayImage, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\CarerayImage\CarerayImage\bin\Debug\Asa.CarerayImage.dll</HintPath>
</Reference>
<Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
......
......@@ -81,6 +81,7 @@ namespace OnlineStore.DeviceLibrary
{
if (Robot.AutoInput && Robot.IOValue(IO_LineIn_Check).Equals(IO_VALUE.HIGH))
{
//WorkLog("启动位置1");
StartWorking(new WorkParam());
}
}
......@@ -106,12 +107,12 @@ namespace OnlineStore.DeviceLibrary
WorkLog("无料串,:通知agv来送料串AgvName:" + AgvName + ",agvcallresult:" + agvcallresult.ToString());
}
}
else// if(AgvClient.GetAction(AgvName)!=Asa.ClientAction.NeedLeave && AgvClient.GetAction(AgvName)!=Asa.ClientAction.MayLeave)
else if (Robot.IOValue(IO_LineIn_Check).Equals(IO_VALUE.HIGH) && Robot.IOValue(IO_LineEnd_Check).Equals(IO_VALUE.HIGH)
&& AgvClient.GetAction(AgvName)!=Asa.ClientAction.NeedLeave && AgvClient.GetAction(AgvName)!=Asa.ClientAction.MayLeave && AgvClient.GetAction(AgvName) != Asa.ClientAction.FinishLeave)
{
shelfWatch.Stop();
//AgvClient.SetToNone(AgvName);
AgvClient.SetToNone(AgvName);
}
}
private Stopwatch shelfWatch = new Stopwatch();
public bool Reset(bool needStop = false)
......
......@@ -181,17 +181,51 @@ namespace OnlineStore.DeviceLibrary
#region 检测到托盘,扫码,取料并放入托盘
else if (MoveInfo.IsStep(StepEnum.IB07_AxisUpMove))
{
{
CheckHasTray();//==>StepEnum.IB09_ScanCode
}
else if (MoveInfo.IsStep(StepEnum.IB09_ScanCode))
{
MoveInfo.NextMoveStep(StepEnum.IB10_ScanOK);
WorkLog("IB09_ScanCode");
MoveInfo.MoveParam = new WorkParam();
MoveInfo.MoveParam.WareCode = CodeManager.GetValidCode(LastCodeList);
if (String.IsNullOrEmpty(MoveInfo.MoveParam.WareCode))
{
MoveInfo.MoveParam.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = "无有效条码";
MoveInfo.MoveParam.TargetPosType = 1;
WorkLog(" 无有效条码,从XRay放到NG箱:" + MoveInfo.MoveParam.ToStr());
string outF = "无有效条码NG.";
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, outF);
}
else if (SServerManager.CanConnect())
{
int needPosition = 0;
string msg = SServerManager.Get_VMICheckRLC(Name, MoveInfo.MoveParam.WareCode, out needPosition);
if (needPosition >= 1 && needPosition <= 3)
{
MoveInfo.MoveParam.TargetPosType = needPosition;
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】通过接口获取目标位置:" + needPosition);
}
else
{
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】获取是否测值失败:" + msg);
MoveInfo.MoveParam.TargetPosType = 1;
MoveInfo.MoveParam.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = msg;
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, msg);
}
}
else {
MoveInfo.MoveParam.TargetPosType = 1;
}
MoveInfo.NextMoveStep(StepEnum.IB10_ScanOK);
var span = DateTime.Now - MoveInfo.LastSetpTime;
LogUtil.ticklog("", MoveInfo.MoveParam.WareCode, span.TotalSeconds, "拍照扫码结束");
WorkLog("料串入料 :扫码结束【" + MoveInfo.MoveParam.WareCode + "】,等待取料机构来取料,拍照识别耗时:" + span.TotalSeconds.ToString());
//LogUtil.ticklog("", MoveInfo.MoveParam.WareCode, span.TotalSeconds, "拍照扫码结束");
WorkLog("料串入料 :扫码结束【" + MoveInfo.MoveParam.WareCode + "】,等待取料机构来取料," + MoveInfo.MoveParam.ToStr());
}
else if (MoveInfo.IsStep(StepEnum.IB11_TrayLeave))
{
......@@ -546,6 +580,11 @@ namespace OnlineStore.DeviceLibrary
{
//入口有料串,暂不处理
LogUtil.error(logName + ",入口已有料架,暂不处理");
Task.Factory.StartNew(delegate
{
Thread.Sleep(3000);
AgvClient.SetStatus(AgvName, "", ClientAction.None, ClientLevel.High, true);
});
}
}
catch (TimeoutException te)
......@@ -601,6 +640,11 @@ namespace OnlineStore.DeviceLibrary
else
{
LogUtil.info(logName + " 未检测到料架,暂不处理");
Task.Factory.StartNew(delegate
{
Thread.Sleep(3000);
AgvClient.SetStatus(AgvName, "", ClientAction.None, ClientLevel.High, true);
});
}
}
catch (TimeoutException te)
......
......@@ -249,13 +249,23 @@ namespace OnlineStore.DeviceLibrary
if (LeftBatchMove.MoveInfo.MoveType.Equals(RobotMoveType.Working) && LeftBatchMove.MoveInfo.IsStep(StepEnum.IB10_ScanOK))
{
WorkLog("左侧开始取料");
string code = LeftBatchMove.MoveInfo.MoveParam.WareCode;
StartWorking(new WorkParam(1, 0, code));
var p = new WorkParam(1, 0, code);
p.IsNgReel = LeftBatchMove.MoveInfo.MoveParam.IsNgReel;
p.TargetPosType = LeftBatchMove.MoveInfo.MoveParam.TargetPosType;
p.NgMsg = LeftBatchMove.MoveInfo.MoveParam.NgMsg;
StartWorking(p);
}
else if (RightBatchMove.MoveInfo.MoveType.Equals(RobotMoveType.Working) && RightBatchMove.MoveInfo.IsStep(StepEnum.IB10_ScanOK))
{
WorkLog("右侧开始取料");
string code = RightBatchMove.MoveInfo.MoveParam.WareCode;
StartWorking(new WorkParam(2, 0, code));
var p = new WorkParam(2, 0, code);
p.IsNgReel = RightBatchMove.MoveInfo.MoveParam.IsNgReel;
p.TargetPosType = RightBatchMove.MoveInfo.MoveParam.TargetPosType;
p.NgMsg = RightBatchMove.MoveInfo.MoveParam.NgMsg;
StartWorking(p);
}
}
if (SecMoveInfo.MoveType.Equals(RobotMoveType.None) && NoErrorAlarm())
......
......@@ -39,7 +39,7 @@ namespace OnlineStore.DeviceLibrary
if (MoveInfo.MoveType.Equals(RobotMoveType.None))
{
MoveInfo.NewMove(RobotMoveType.Working, StepEnum.IW01_InoutToP1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
MoveInfo.MoveParam = param;
//如果升降轴,旋转轴,进出轴都在指定位置,直接进出轴前进
......@@ -127,7 +127,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(StepEnum.IW06_Clamping_Work);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
WorkLog("取料: 夹料气缸夹紧1",0);
WorkLog("取料: 夹料气缸夹紧1", 0);
CylinderMove(MoveInfo, IO_Type.Clamping_Relax, IO_Type.Clamping_Work);
}
else if (MoveInfo.IsStep(StepEnum.IW06_Clamping_Work))
......@@ -135,7 +135,7 @@ namespace OnlineStore.DeviceLibrary
if (CylinderIsOk(IO_Type.Clamping_Relax, IO_Type.Clamping_Work))
{
MoveInfo.NextMoveStep(StepEnum.IW07_UpdownToP1);
WorkLog("取料: 升降轴到待机点P1",0);
WorkLog("取料: 升降轴到待机点P1", 0);
UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1Speed);
WorkLog("取料: 进出轴返回P1", 1);
InOutAxis.AbsMove(MoveInfo, Config.InoutAxis_P1, Config.InoutAxis_P1Speed);
......@@ -144,7 +144,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(StepEnum.IW06_Clamping_Work);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
WorkLog("取料: 夹料气缸夹紧2",0);
WorkLog("取料: 夹料气缸夹紧2", 0);
CylinderMove(MoveInfo, IO_Type.Clamping_Relax, IO_Type.Clamping_Work);
}
}
......@@ -152,9 +152,12 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(StepEnum.IW08_WaitAxisCheck);
WorkLog("取料: 等待伺服检测信号消失");
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_7, IO_VALUE.HIGH));
if (MoveInfo.MoveParam.InPosType.Equals(1))
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.L_AxisTrayCheck, IO_VALUE.LOW));
//
}
else
{
......@@ -164,9 +167,9 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsStep(StepEnum.IW08_WaitAxisCheck))
{
//MoveInfo.NextMoveStep(StepEnum.IW09_InoutToP1);
MoveInfo.NextMoveStep(StepEnum.IW10_SaveSize);
//MoveInfo.NextMoveStep(StepEnum.IW10_SaveSize);
MoveInfo.NextMoveStep(StepEnum.IW11_GetTargetPosition);
if (MoveInfo.MoveParam.InPosType.Equals(1))
{
LeftBatchMove.GetTrayOK();
......@@ -175,7 +178,7 @@ namespace OnlineStore.DeviceLibrary
{
RightBatchMove.GetTrayOK();
}
}
else if (MoveInfo.IsStep(StepEnum.IW09_InoutToP1))
{/*
......@@ -200,23 +203,20 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.IW10_SaveSize))
{
GetTargetPTask = null;
//GetTargetPTask = null;
WorkLog(" IW10_SaveSize");
MoveInfo.NextMoveStep(StepEnum.IW11_GetTargetPosition);
return;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
if (String.IsNullOrEmpty(MoveInfo.MoveParam.WareCode))
{
MoveInfo.MoveParam.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = "无有效条码";
MoveInfo.MoveParam.TargetPosType = 1;
WorkLog(" 无有效条码,从XRay放到NG箱:" + MoveInfo.MoveParam.ToStr(),1);
WorkLog(" 无有效条码,从XRay放到NG箱:" + MoveInfo.MoveParam.ToStr(), 1);
string outF = "无有效条码NG.";
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, outF);
}
//else if (MoveInfo.MoveParam.InPosType.Equals(2))
//{
// MoveInfo.MoveParam.TargetPosType = 1;
// WorkLog(" 右侧入口入料,直接放到XRay:" + MoveInfo.MoveParam.ToStr());
//}
else if (SServerManager.CanConnect())
{
GetTargetPTask = Task.Factory.StartNew(delegate
......@@ -227,18 +227,19 @@ namespace OnlineStore.DeviceLibrary
if (needPosition >= 1 && needPosition <= 3)
{
MoveInfo.MoveParam.TargetPosType = needPosition;
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】通过接口获取目标位置:" + needPosition,1);
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】通过接口获取目标位置:" + needPosition, 1);
//if (needPosition>1)
// RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, msg);
}
// else if (!msg.Equals("") || needPosition.Equals(0))
else
{
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】获取是否测值失败:" + msg,1);
WorkLog(" 【" + MoveInfo.MoveParam.WareCode + "】获取是否测值失败:" + msg, 1);
MoveInfo.MoveParam.TargetPosType = 1;
MoveInfo.MoveParam.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = msg;
string outF = msg;
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, outF);
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, msg);
}
});
}
......@@ -251,60 +252,67 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.MoveParam.TargetPosType = DefautTargetP;
}
}
WorkLog(" 根据条码获取目标位置:" + MoveInfo.MoveParam.ToStr(),1);
WorkLog(" 根据条码获取目标位置:" + MoveInfo.MoveParam.ToStr(), 1);
}
}
#endregion
else if (MoveInfo.IsStep(StepEnum.IW11_GetTargetPosition))
{
if (GetTargetPTask == null || GetTargetPTask.IsCompleted)
WorkLog(" IW11_GetTargetPosition");
if (MoveInfo.MoveParam.TargetPosType.Equals(0))
{
if (MoveInfo.MoveParam.TargetPosType.Equals(0))
WorkLog(" TargetPosType:0");
MoveInfo.MoveParam.TargetPosType = 1;
}
//if (GetTargetPTask == null || GetTargetPTask.IsCompleted)
//{
/*
if (MoveInfo.MoveParam.TargetPosType.Equals(0))
{
if (SServerManager.CanConnect())
{
if (SServerManager.CanConnect())
if (MoveInfo.IsTimeOut(120))
{
if (MoveInfo.IsTimeOut(120))
{
WarnMsg = Name + "等待" + MoveInfo.MoveParam.WareCode + "验证是否测值 超时[" + MoveInfo.TimeOutSeconds + "]秒";
LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
}
WarnMsg = Name + "等待" + MoveInfo.MoveParam.WareCode + "验证是否测值 超时[" + MoveInfo.TimeOutSeconds + "]秒";
LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
}
else
{
////随机目标地址
//Random r = new Random();
//int targetP = r.Next(1, 100) % 3 + 1;
MoveInfo.MoveParam.TargetPosType = 1;
WorkLog(" 随机放料目标:" + 1, 1);
}
}
if (MoveInfo.MoveParam.TargetPosType.Equals(1))
{
ClearTimeoutAlarm("验证是否测值");
MoveInfo.NextMoveStep(StepEnum.IW21_MiddleToP3);
WorkLog(" 开始放料到XRay入口,旋转轴到P3", 1);
MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P3, Config.MiddleAxis_P3Speed);
}
else
{
ClearTimeoutAlarm("验证是否测值");
MoveInfo.NextMoveStep(StepEnum.IW31_MIddleToP4);
WorkLog(" 开始放料到测值工位,旋转轴到P4", 1);
string outF = MoveInfo.MoveParam.TargetPosType.Equals(2)?"电容":"电阻";
outF += "需测值";
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, outF);
MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
////随机目标地址
//Random r = new Random();
//int targetP = r.Next(1, 100) % 3 + 1;
MoveInfo.MoveParam.TargetPosType = 1;
WorkLog(" 随机放料目标:" + 1, 1);
}
}else if (MoveInfo.IsTimeOut(120))
}
*/
if (MoveInfo.MoveParam.TargetPosType.Equals(1))
{
WarnMsg = Name + "等待" + MoveInfo.MoveParam.WareCode + "验证是否测值 超时[" + MoveInfo.TimeOutSeconds + "]秒";
LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
//ClearTimeoutAlarm("验证是否测值");
MoveInfo.NextMoveStep(StepEnum.IW21_MiddleToP3);
WorkLog(" 开始放料到XRay入口,旋转轴到P3", 1);
MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P3, Config.MiddleAxis_P3Speed);
}
else
{
//ClearTimeoutAlarm("验证是否测值");
MoveInfo.NextMoveStep(StepEnum.IW31_MIddleToP4);
WorkLog(" 开始放料到测值工位,旋转轴到P4", 1);
string outF = MoveInfo.MoveParam.TargetPosType.Equals(2) ? "电容" : "电阻";
outF += "需测值";
RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, outF);
MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
// }else if (MoveInfo.IsTimeOut(120))
//{
// WarnMsg = Name + "等待" + MoveInfo.MoveParam.WareCode + "验证是否测值 超时[" + MoveInfo.TimeOutSeconds + "]秒";
// LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
// Alarm(AlarmType.IoSingleTimeOut);
//}
}
else if (MoveInfo.IsStep(StepEnum.IW21_MiddleToP3))
{
if (IOValue(IO_Type.TakeAxis_Location_1).Equals(IO_VALUE.HIGH))
......@@ -320,15 +328,15 @@ namespace OnlineStore.DeviceLibrary
{
WorkLog("旋转轴已经到P3,但X42传感器没有检测到。");
}
else {
else
{
WorkLog("旋转轴没有到位。");
}
}
else if (MoveInfo.IsStep(StepEnum.IW22_UpdownToP3))
{
//向上合并
MoveInfo.NextMoveStep(StepEnum.IW23_InoutToP3);
//MoveInfo.NextMoveStep(StepEnum.IW23_InoutToP3);
bool isOk = MoveInfo.MoveParam.PlateH > 0 && MoveInfo.MoveParam.PlateW > 0;
BatchMoveBean moveBean = MoveInfo.MoveParam.InPosType.Equals(1) ? LeftBatchMove : RightBatchMove;
......@@ -348,12 +356,11 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StepEnum.IW23_InoutToP3))
{
MoveInfo.NextMoveStep(StepEnum.IW24_WaitCanPut);
WorkLog("->XRay:等待XRay可放料",1);
WorkLog("->XRay:等待XRay可放料", 1);
MoveInfo.TimeOutSeconds = 120;
//TODO
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
......@@ -362,10 +369,10 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.IW24_WaitCanPut))
{
TickLog("等待XRay可放料",true);
TickLog("等待XRay可放料", true);
MoveInfo.NextMoveStep(StepEnum.IW41_Clamping_Relax);
RobotManager.robot.XrayBean.In_ReelInfo = MoveInfo.MoveParam.GetReelInfo();
WorkLog("->XRay:夹料气缸放松,更新XRay入口料盘:" + RobotManager.robot.XrayBean.In_ReelInfo.ToStr(),1);
WorkLog("->XRay:夹料气缸放松,更新XRay入口料盘:" + RobotManager.robot.XrayBean.In_ReelInfo.ToStr(), 1);
CylinderMove(MoveInfo, IO_Type.Clamping_Work, IO_Type.Clamping_Relax);
}
......@@ -401,11 +408,11 @@ namespace OnlineStore.DeviceLibrary
{
//可上合并
//MoveInfo.NextMoveStep(StepEnum.IW43_UpdownToP1);
}
else if (MoveInfo.IsStep(StepEnum.IW43_UpdownToP1))
{
MoveInfo.NextMoveStep(StepEnum.IW44_MiddleToP2);
WorkLog("放料完成:旋转轴返回P2");
MiddleAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.Get_Middle_P2(Config), Config.MiddleAxis_P2Speed);
......@@ -416,7 +423,7 @@ namespace OnlineStore.DeviceLibrary
TickLog("放料完成", false);
WorkLog("放料完成,耗时(" + FormUtil.GetSpanStr(span) + ")");
MoveInfo.EndMove();
}
}
......
......@@ -50,7 +50,6 @@ namespace OnlineStore.DeviceLibrary
}
#region 取料
internal bool IsInGetWare()
{
if (MoveInfo.MoveStep >= StepEnum.OT06_MoveXToP2 && MoveInfo.MoveStep <= StepEnum.OT09_MoveZToP1)
......@@ -110,7 +109,6 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.MoveParam.IsNgReel = true;
}
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.X_OLine_Run, IO_VALUE.LOW));
}
......@@ -175,7 +173,6 @@ namespace OnlineStore.DeviceLibrary
}
private void OT03_MoveXToP2()
{
int position = Config.GetMoveXP2(MoveInfo.MoveParam.PlateW);
if (MoveXAxis.IsInPosition(position))
{
......@@ -341,12 +338,13 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StepEnum.OT12_MoveXToP3);
WorkLog("放料:料串可放料,取料X轴移动到P3 ["+ Config.MoveX_P3 + "]");
MoveXAxis.AbsMove(MoveInfo, Config.MoveX_P3, Config.MoveX_P3Speed);
ClearTimeoutAlarm("等待出料料串准备完成");
if (shelfOk)
{
int trayHeight = MoveInfo.MoveParam.PlateH;
ShelfMoveInfo.NextMoveStep(StepEnum.OS_21_BatchDownH);
int currP = BatchAxis.GetAclPosition();
int targetP = currP - (trayHeight + 20) * Config.Height_ChangeValue;
if (targetP < Config.BatchAxisP2)
......@@ -354,6 +352,7 @@ namespace OnlineStore.DeviceLibrary
targetP = Config.BatchAxisP2;
}
ShelfWorkLog("放料: 提升轴下降指定高度 : 盘高【" + trayHeight + "】实时位置【" + currP + "】目标位置【" + targetP + "】");
ShelfMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
BatchAxis.AbsMove(ShelfMoveInfo, targetP, Config.BatchAxis_P2Speed);
}
}
......@@ -367,12 +366,20 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.OT12_MoveXToP3))
{
MoveInfo.NextMoveStep(StepEnum.OT13_MoveZToP3);
int p = Config.GetMoveZP3(MoveInfo.MoveParam.PlateH);
WorkLog("放料:取料Z轴下降到P3 ["+p+"] ",1);
MoveZAxis.AbsMove(MoveInfo, p, Config.MoveZ_P3Speed);
if (IOValue(IO_Type.O_WLine_TrayCheck).Equals(IO_VALUE.HIGH)) {
ShelfMoveInfo.NextMoveStep(StepEnum.OS_20_ShelfReady);
MoveInfo.NextMoveStep(StepEnum.OT11_WaitShelfOk);
WorkLog("放料:料串下降不到位,重新下降 ", 1);
}
else
{
MoveInfo.NextMoveStep(StepEnum.OT13_MoveZToP3);
int p = Config.GetMoveZP3(MoveInfo.MoveParam.PlateH);
WorkLog("放料:取料Z轴下降到P3 [" + p + "] ", 1);
MoveZAxis.AbsMove(MoveInfo, p, Config.MoveZ_P3Speed);
CheckStartLabel();
CheckStartLabel();
}
}
else if (MoveInfo.IsStep(StepEnum.OT13_MoveZToP3))
{
......@@ -424,7 +431,6 @@ namespace OnlineStore.DeviceLibrary
WorkLog("放料完成,耗时(" + FormUtil.GetSpanStr(span) + ")");
TickLog("出口料串,放料完成");
MoveInfo.EndMove();
}
else
{
......@@ -438,10 +444,7 @@ namespace OnlineStore.DeviceLibrary
}
}
}
#region NG
else if (MoveInfo.IsStep(StepEnum.OT21_NG_MoveXToP1))
{
int busyStatus = ACServerManager.GetBusyStatus(MoveZAxis.Config.DeviceName, MoveZAxis.Config.GetAxisValue());
......@@ -477,17 +480,13 @@ namespace OnlineStore.DeviceLibrary
TimeSpan span = DateTime.Now - MoveInfo.MoveStartTime;
TickLog("出口NG,放料完成");
WorkLog("放料完成,耗时(" + FormUtil.GetSpanStr(span) + ")");
MoveInfo.EndMove();
MoveInfo.EndMove();
}
#endregion
}
#endregion
#region 贴标
public override bool StartLabelling(WorkParam param)
{
if (!SecMoveInfo.MoveType.Equals(RobotMoveType.None))
......@@ -508,7 +507,6 @@ namespace OnlineStore.DeviceLibrary
{
LabelZAxis.AbsMove(SecMoveInfo, Config.LabelZ_P1, Config.LabelZ_P1Speed);
}
return true;
}
......@@ -529,8 +527,12 @@ namespace OnlineStore.DeviceLibrary
{
SecMoveInfo.NextMoveStep(StepEnum.OL03_PrintLabel);
RobotManager.LastPrintStatus = Asa.PrintLabel.PrinterStatus.Unknown;
NeedPrint = ConfigAppSettings.GetIntValue(Setting_Init.NeedPrintLabel).Equals(1);
StickingPosJudgment = ConfigAppSettings.GetIntValue(Setting_Init.StickingPosJudgment).Equals(1);
try
{
NeedPrint = ConfigAppSettings.GetIntValue(Setting_Init.NeedPrintLabel).Equals(1);
StickingPosJudgment = ConfigAppSettings.GetIntValue(Setting_Init.StickingPosJudgment).Equals(1);
}
catch { }
SecWorkLog("贴标: 重置PrintLabel状态=Unknown,开始打印标签[" + NeedPrint + "] ,贴标XYR轴到取标签点P2, 等待1s");
SecMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
if (NeedPrint)
......@@ -548,7 +550,6 @@ namespace OnlineStore.DeviceLibrary
LabelXAxis.AbsMove(SecMoveInfo, Config.LabelX_P2, Config.LabelX_P2Speed);
LabelYAxis.AbsMove(SecMoveInfo, Config.LabelY_P2, Config.LabelY_P2Speed);
LabelRAxis.AbsMove(SecMoveInfo, Config.LabelR_P2, Config.LabelR_P2Speed);
}
else if (SecMoveInfo.IsStep(StepEnum.OL03_PrintLabel))
{
......@@ -576,7 +577,6 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(WarnMsg, SecMoveInfo.ErrorLogType, SecMoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (SecMoveInfo.IsStep(StepEnum.OL05_TakeBack))
{
......
......@@ -246,12 +246,12 @@ namespace OnlineStore.DeviceLibrary
else if (ShelfMoveInfo.IsStep(StepEnum.OS_21_BatchDownH))
{
ShelfMoveInfo.NextMoveStep(StepEnum.OS_22_WaitTray);
ShelfWorkLog("等待料盘放入料串");
ShelfWorkLog("等待料盘放入料串,O_WLine_TrayCheck=" + IOValue(IO_Type.O_WLine_TrayCheck).ToString());
}
else if (ShelfMoveInfo.IsStep(StepEnum.OS_23_TrayOK))
{
ShelfMoveInfo.NextMoveStep(StepEnum.OS_24_BatchToP3);
ShelfWorkLog("批量轴匀速到P3或信号亮");
ShelfWorkLog("批量轴匀速到P3或信号亮,O_WLine_TrayCheck=" + IOValue(IO_Type.O_WLine_TrayCheck).ToString()); ;
BatchAxisToP3(ShelfMoveInfo);
}
else if (ShelfMoveInfo.IsStep(StepEnum.OS_24_BatchToP3))
......
using BLL;
using Asa;
using BLL;
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
......@@ -64,6 +65,17 @@ namespace OnlineStore.DeviceLibrary
AgvClient.NodeList.Add(outputEquip.Config.AgvOutName);
AgvClient.NodeList.Add(inputEquip.Config.RightAgvName);
AgvClient.NodeList.Add(inputEquip.Config.LeftAgvName);
/*var carerayImage = new CarerayImage();
if (carerayImage.Open())
{
carerayImage.Close();
}
else {
LogUtil.info(Name + "图像平板打开失败! 系统不允许启动。");
return;
}
*/
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "开始连接IO模块 ");
......
......@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
}
public bool carerayImageError = false;
private void XRayLoad()
{
try
......@@ -69,7 +69,7 @@ namespace OnlineStore.DeviceLibrary
carerayImage = new CarerayImage("XRay");
bool cResult = carerayImage.Open();
LogUtil.info(Name + "carerayImage.Open()=" + cResult);
carerayImageError = !cResult;
xRay = new XRay("XRay");
xRay.WarmUp += XRay_WarmUp;
......@@ -150,7 +150,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NewMove(RobotMoveType.RHome);
LogInfo("开始 原点返回: ");
StartReset();
SetAllTimer(true);
return true;
}
......@@ -346,10 +346,8 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
#endregion
public override string GetMoveStr()
{
string msg = "";
......
......@@ -239,7 +239,9 @@ namespace OnlineStore.DeviceLibrary
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(8000));
WorkLog("点料:清理" + path1_tif + "内容,开始获取X射线图形 ");
CapImage();
if (string.IsNullOrEmpty(CapImage())) {
//Alarm(AlarmType.IoSingleTimeOut);
}
MoveInfo.EndStepWait();
}
......@@ -386,7 +388,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 点料处理
private Task GetResultTask = null;
private string lastFileName = "";
private string lastFileName = "";
private void XW15_GetResult()
{
if (IOValue(IO_Type.X_Lock_On).Equals(IO_VALUE.LOW))
......@@ -398,27 +400,30 @@ namespace OnlineStore.DeviceLibrary
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300000));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
GetResultTask = Task.Factory.StartNew(delegate {
try
GetResultTask = Task.Factory.StartNew(delegate
{
if (xRay.IsRayOpen)
{
xRay.Stop();
}
InXWork = false;
WorkLog("点料:停止X射线,设置 InXWork = false,开始获取点料结果");
bool isNg = false;
string NgMsg = "";
int count = 0;
CountParam lastParam = ParamManager.GetParamByCode(Work_ReelInfo.WareCode);
if (lastParam == null)
{
lastParam = new CountParam("", ThresholdValue, 3);
}
if (lastParam != null)
try
{
if (xRay.IsRayOpen)
{
xRay.Stop();
}
InXWork = false;
WorkLog("点料:停止X射线,设置 InXWork = false,开始获取点料结果");
bool isNg = false;
string NgMsg = "";
int count = 0;
CountParam lastParam = ParamManager.GetParamByCode(Work_ReelInfo.WareCode);
if (lastParam == null)
{
lastParam = new CountParam("", ThresholdValue, 3);
WorkLog("点料:" + "NG:未找到元器件类型,PN[" + ParamManager.GetCodeStrPN(Work_ReelInfo.WareCode) + "]");
BackNoConfigImg(ParamManager.GetCodeStrPN(Work_ReelInfo.WareCode));
}
string fileP = path1_tif + @"\" + lastFileName;
count = GetCountResult(fileP, lastParam, out Asa.API.EyemImage tpDstImg);
count = GetCountResult(fileP, lastParam,out _);
if (count < ResultMinCount)
{
isNg = true;
......@@ -441,35 +446,29 @@ namespace OnlineStore.DeviceLibrary
NgMsg = msg;
}
}
}
else
{
isNg = true;
NgMsg = "NG:未找到元器件类型,PN[" +ParamManager. GetCodeStrPN(Work_ReelInfo.WareCode) + "]";
WorkLog("点料:" + NgMsg);
BackNoConfigImg();
}
string outF = path2_out + lastFileName;
if (!isNg)
{
ReadOutMsg(outF);
string outF = path2_out + lastFileName;
if (!isNg)
{
ReadOutMsg(outF);
}
else
{
MoveInfo.MoveParam.IsNgReel = true;
Work_ReelInfo.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = NgMsg;
Work_ReelInfo.NgMsg = NgMsg;
outF = NgMsg;
}
int c = RobotManager.robot.sQLite.Insert(Work_ReelInfo.WareCode, Work_ReelInfo.PlateW, Work_ReelInfo.PlateH, count, outF);
LogUtil.info("插入数据【" + Work_ReelInfo.WareCode + "】【" + count + "】【" + outF + "】结果:" + c + " ," + RobotManager.robot.sQLite.ErrInfo);
}
else
catch (Exception ex)
{
MoveInfo.MoveParam.IsNgReel = true;
Work_ReelInfo.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = NgMsg;
Work_ReelInfo.NgMsg = NgMsg;
outF = NgMsg;
LogUtil.error("XW15_GetResult出错:" + ex.ToString());
}
int c = RobotManager.robot.sQLite.Insert(Work_ReelInfo.WareCode, Work_ReelInfo.PlateW, Work_ReelInfo.PlateH, count, outF);
LogUtil.info("插入数据【" + Work_ReelInfo.WareCode + "】【" + count + "】【" + outF + "】结果:" + c + " ," + RobotManager.robot.sQLite.ErrInfo);
}
catch (Exception ex)
{
LogUtil.error("XW15_GetResult出错:" + ex.ToString());
}
});
//MoveInfo.EndStepWait();
}
......@@ -521,7 +520,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "carerayImage.GetImage 获取图片失败 = " + imgResult + ", carerayImage.Close 失败");
}
}
carerayImageError = !imgResult;
carerayImage.WindowWidth = Config.WindowWidth;
carerayImage.WindowLevel = Config.WindowLevel;
if (imgResult)
......@@ -552,12 +551,15 @@ namespace OnlineStore.DeviceLibrary
{
WorkLog("点料:获取X射线图形,获取图片失败,carerayImage.Get48bImage()=null");
LogUtil.error(Name + " 获取图片失败,carerayImage.Get48bImage()=null");
lastFileName = "";
}
}
else
{
WorkLog("点料:获取X射线图形,获取图片失败,carerayImage.GetImage()=" + imgResult);
LogUtil.error(Name + " 获取图片失败,carerayImage.GetImage()=" + imgResult);
lastFileName = "";
}
bool result = xRay.Stop();
if (!result)
......@@ -603,21 +605,24 @@ namespace OnlineStore.DeviceLibrary
}
private void BackNoConfigImg()
private void BackNoConfigImg(string pn)
{
//将未找到料号配置的图片保存到新的文件夹
string fileP = path1_tif + @"\" + lastFileName;
string backPath = ParamManager.NoConfigPath ;
string backFile = backPath + lastFileName;
string backFile = Path.Combine(backPath, pn + ".png");
try
{
if (!Directory.Exists(backPath))
{
Directory.CreateDirectory(backPath);
}
System.IO.File.Copy(fileP, backFile);
LogUtil.info("BackNoConfigImg 【" + fileP + "】 -> 【" + backFile + "】");
if (!File.Exists(backFile))
{
System.IO.File.Copy(fileP, backFile);
LogUtil.info("BackNoConfigImg 【" + fileP + "】 -> 【" + backFile + "】");
}
}
catch (Exception ex)
{
......@@ -626,52 +631,46 @@ namespace OnlineStore.DeviceLibrary
}
public int GetCountResult(string fileP, CountParam param, out Asa.API.EyemImage tpDstImg)
public int GetCountResult(string fileP, CountParam param, out string resfile)
{
// 器件类型
//"小器件" GetLocalCount
//"粘连不严重" GetLocalCountIrregular type = 0
//"大器件" GetLocalCountIrregular type = 1
//"长条型器件" GetLocalCountIrregular type = 2
//"E形状" GetLocalCountIrregular type = 3
//返回的数量是string类型,count = "4000,3000,3500,2000"
int count = 0;
tpDstImg = new API.EyemImage();
resfile = "";
//tpDstImg = new API.EyemImage();
try
{
string countStr = "";
int result = 0;
int type = param.Sign;
CountParam.SignType type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize;
/*
if (param.Sign.Equals(0))
int windowsize = param.WindowSize; ;
if (param.Sign == CountParam.SignType.AUTO)
{
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out tpDstImg);
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
else
{
int t = param.Sign ;
result = carerayImage.GetLocalCountIrregular(fileP, threshold, t, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】[" + t + "]【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
else {
result = carerayImage.GetLocalCountIrregular(fileP, threshold, type.ToString(), windowsize, out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
string[] array = countStr.Split(',');
if (array.Length > 0)
if (countStr != null)
{
count= Convert.ToInt32(array[0]);
}*/
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
string[] array = countStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
count = (from a in array where int.TryParse(a, out _) && int.Parse(a) > 0 select int.Parse(a)).FirstOrDefault();
string[] array = countStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
count = (from a in array where int.TryParse(a, out _) && int.Parse(a) > 0 select int.Parse(a)).FirstOrDefault();
}
else {
count = 0;
}
string resfilename = Path.GetFileNameWithoutExtension(fileP)+ "-Mark.png";
string root = Path.Combine(Application.StartupPath, "ResOut");
var n = DateTime.Now;
string destdir = Path.Combine(root, n.Year.ToString() + "-" + n.Month.ToString(), n.Day.ToString(), n.Hour.ToString());
Directory.CreateDirectory(destdir);
Directory.Move(Path.Combine(root, resfilename), Path.Combine(destdir, resfilename));
resfile = Path.Combine(destdir, resfilename);
if (File.Exists(resfile))
File.Delete(resfile);
Directory.Move(Path.Combine(root, resfilename), resfile);
}
catch (Exception ex)
{
......@@ -686,7 +685,6 @@ namespace OnlineStore.DeviceLibrary
Bitmap bit = null;
return bit;
}
#endregion
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static OnlineStore.DeviceLibrary.CountParam;
namespace OnlineStore.DeviceLibrary
{
......@@ -16,13 +17,18 @@ namespace OnlineStore.DeviceLibrary
public static string NoConfigPath = @"D:\NoConfigImg\";
private static Dictionary<string, CountParam> countParamMap = new Dictionary<string, CountParam>();
private static string ConfigFilePath = "";
internal static void Init()
public static void Init()
{
ConfigFilePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
countParamMap = LoadParamMap( );
countParamMap = LoadParamMap();
}
public static string GetSufanStr(int type)
{
SignType sign=SignType.AUTO;
Enum.TryParse<SignType>(type.ToString(), out sign);
return GetSufanStr(sign);
}
public static string GetSufanStr(SignType type)
{
if (type.Equals(0))
{
......@@ -44,7 +50,7 @@ namespace OnlineStore.DeviceLibrary
{
return "算法E";
}
return "";
return "默认算法";
}
public static CountParam GetParamByPN(string pn)
{
......@@ -190,7 +196,7 @@ namespace OnlineStore.DeviceLibrary
List<ComponetInfo> FZList = new List<ComponetInfo>();
Dictionary<int, int> sufaCount = new Dictionary<int, int>();
int maxSufa = -1;
SignType maxSufa = SignType.AUTO;
int maxCount = 0;
foreach (ComponetInfo obj in CSVBomManager.allComMap.Values)
{
......@@ -199,7 +205,7 @@ namespace OnlineStore.DeviceLibrary
CountParam p = GetParamByPN(obj.PartNum);
if (p != null)
{
obj.Sufan = p.Sign;
obj.Sufan = (int)p.Sign;
if (sufaCount.ContainsKey(obj.Sufan))
{
......@@ -213,7 +219,7 @@ namespace OnlineStore.DeviceLibrary
if (sufaCount[obj.Sufan] > maxCount)
{
maxCount = sufaCount[obj.Sufan];
maxSufa = obj.Sufan;
Enum.TryParse<SignType>(obj.Sufan.ToString(),out maxSufa);
}
}
FZList.Add(obj);
......@@ -244,7 +250,7 @@ namespace OnlineStore.DeviceLibrary
}
public class CountParam
{
public CountParam(string pn, int th = 0, int size = 0, int sign = 0, int value = 0)
public CountParam(string pn, int th = 0, int size = 0, SignType sign=SignType.AUTO, int value = 0)
{
this.PN = pn;
this.Threshold = th;
......@@ -256,12 +262,12 @@ namespace OnlineStore.DeviceLibrary
public int Threshold = 0;
public int WindowSize = 0;
public string AreaValue = "";
public int Sign = 0;
public SignType Sign = 0;
public int Value = 0;
public string ToStr()
{
return "【PN=" + PN + ",sign=" + Sign + ",value=" + Value + ",th=" + Threshold + ",wsize=" + WindowSize + "】";
return "【PN=" + PN + ",sign=" + Sign.ToString()+ ",value=" + Value + ",th=" + Threshold + ",wsize=" + WindowSize + "】";
}
public string ToCSVStr()
{
......@@ -277,7 +283,9 @@ namespace OnlineStore.DeviceLibrary
if (array.Length >= 5)
{
string pn = array[0].Trim();
int sign = Convert.ToInt32(array[1].Trim());
SignType sign = SignType.AUTO;
Enum.TryParse<SignType>(array[1].Trim(), out sign);
int value = Convert.ToInt32(array[2].Trim());
int th = Convert.ToInt32(array[3].Trim());
int size = Convert.ToInt32(array[4].Trim());
......@@ -290,7 +298,15 @@ namespace OnlineStore.DeviceLibrary
return null;
}
public enum SignType
{
IP_SMALL_PARTS=0,
IP_LARGE_PARTS = 1,
IP_LONG_PARTS = 2,
IP_SQUARE_PARTS = 3,
IP_GEN_PARTS = 4,
AUTO = 99,
}
internal static string GetCSVTitle()
{
return "type,sign,value,threshold,windowSize";
......
......@@ -275,7 +275,7 @@ namespace OnlineStore.DeviceLibrary
if (IOManager.IOValue(TargetIoType, 0).Equals(TargetIoValue))
{
AxisStopCheckMove();
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动,AclPosition=" + GetAclPosition().ToString());
SuddenStop();
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!