Commit fa81c6e7 刘韬

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

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