Commit 657fdc85 几米阳光

去掉固定点信息,增加AOI程序配置

1 个父辈 b2aabcfe
......@@ -20,15 +20,15 @@ namespace URSoldering.DeviceLibrary
/// 电路板ID
/// </summary>
public int boardId { get; set; }
public string AoiFileName { get; set; }
/// <summary>
/// 条码
/// </summary>
public string WareCode { get; set; }
/// <summary>
/// 机器人焊接时Z轴的高点
/// </summary>
public double ZHighValue { get; set; }
///// <summary>
///// 机器人焊接时Z轴的高点
///// </summary>
//public double ZHighValue { get; set; }
/// <summary>
/// 工位编号,夹具编号(每一个程序需要配置四个夹具的位置,防止位置偏差)
......@@ -56,14 +56,14 @@ namespace URSoldering.DeviceLibrary
/// 焊点列表
/// </summary>
public List<WeldPointInfo> pointList { get; set; }
/// <summary>
/// 原点坐标X
/// </summary>
public double originX { get; set; }
/// <summary>
/// 原点坐标Y
/// </summary>
public double originY { get; set; }
///// <summary>
///// 原点坐标X
///// </summary>
//public double originX { get; set; }
///// <summary>
///// 原点坐标Y
///// </summary>
//public double originY { get; set; }
/// <summary>
/// 图片名称
/// </summary>
......@@ -72,10 +72,10 @@ namespace URSoldering.DeviceLibrary
/// 焊接预估时间
/// </summary>
public double planNeedTime { get; set; }
/// <summary>
/// 固定原点的位置,1=左上角,2=左下角,3=右上角,4=右下角
/// </summary>
public int orgType { get; set; }
///// <summary>
///// 固定原点的位置,1=左上角,2=左下角,3=右上角,4=右下角
///// </summary>
//public int orgType { get; set; }
/// <summary>
/// 已经焊接次数,每次修改板子都会重置
/// </summary>
......@@ -124,39 +124,38 @@ namespace URSoldering.DeviceLibrary
else
{
return myImage;
}
}
}
public double getImageOrgX()
{
double orgX = originX;
if (orgType == 2)
{
orgX = originX + boardLength;
}
//public double getImageOrgX()
//{
// double orgX = originX;
// if (orgType == 2)
// {
// orgX = originX + boardLength;
// }
else if (orgType == 4)
{
orgX = originX + boardLength;
}
return orgX;
}
// else if (orgType == 4)
// {
// orgX = originX + boardLength;
// }
// return orgX;
//}
public double getImageOrgY()
{
double orgY = originY;
//public double getImageOrgY()
//{
// double orgY = originY;
if (orgType == 3)
{
orgY = originY - boardWidth;
}
else if (orgType == 4)
{
orgY = originY - boardWidth;
}
return orgY;
}
// if (orgType == 3)
// {
// orgY = originY - boardWidth;
// }
// else if (orgType == 4)
// {
// orgY = originY - boardWidth;
// }
// return orgY;
//}
}
/// <summary>
......
......@@ -107,10 +107,10 @@ namespace URSoldering.DeviceLibrary
LogUtil.info("加载产品配置:name=" + board.boardName + "为启动时的默认板子!");
CurrBoard = board;
}
if (board.orgType == 0)
{
board.orgType = 1;
}
//if (board.orgType == 0)
//{
// board.orgType = 1;
//}
boardList.Add(board);
}
if (isUpdate)
......@@ -152,22 +152,22 @@ namespace URSoldering.DeviceLibrary
LogUtil.error("设置默认的电路板出错:" + ex.ToString());
}
}
public static void Update(BoardInfo board)
{
int index = 0;
board.myImage = null;
foreach (BoardInfo bo in boardList)
{
if (bo.boardId.Equals(board.boardId))
{
boardList[index] = board;
break;
}
index++;
}
SaveListToFile(boardList);
}
{
int index = 0;
board.myImage = null;
foreach (BoardInfo bo in boardList)
{
if (bo.boardId.Equals(board.boardId))
{
boardList[index] = board;
break;
}
index++;
}
SaveListToFile(boardList);
}
public static void Add(BoardInfo board)
{
......
......@@ -44,8 +44,10 @@ namespace URSoldering.Client
{
try
{
string filePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string path = Path.GetDirectoryName(filePath);
OpenFileDialog openfileDlg = new OpenFileDialog();
openfileDlg.InitialDirectory = path;
openfileDlg.Filter = "vscf files (*.vscf)|*.vscf";
openfileDlg.FilterIndex = 1;
openfileDlg.RestoreDirectory = true;
......@@ -67,8 +69,10 @@ namespace URSoldering.Client
{
try
{
string filePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string path = Path.GetDirectoryName(filePath);
SaveFileDialog savefileDlg = new SaveFileDialog();
savefileDlg.InitialDirectory = path;
savefileDlg.Filter = "ckcf files (*.vscf)|*.vscf";
savefileDlg.FilterIndex = 1;
savefileDlg.RestoreDirectory = true;
......
......@@ -37,8 +37,6 @@
this.label1 = new System.Windows.Forms.Label();
this.btnBack = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.txtRobotZHighValue = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txtBoardName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
......@@ -81,8 +79,6 @@
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.btnBack);
this.groupBox1.Controls.Add(this.btnSave);
this.groupBox1.Controls.Add(this.txtRobotZHighValue);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.txtBoardName);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
......@@ -95,7 +91,7 @@
//
// txtCode
//
this.txtCode.Location = new System.Drawing.Point(131, 96);
this.txtCode.Location = new System.Drawing.Point(131, 98);
this.txtCode.MaxLength = 20;
this.txtCode.Name = "txtCode";
this.txtCode.Size = new System.Drawing.Size(221, 23);
......@@ -104,7 +100,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(73, 100);
this.label1.Location = new System.Drawing.Point(73, 102);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 17);
this.label1.TabIndex = 269;
......@@ -114,7 +110,7 @@
//
this.btnBack.FlatAppearance.BorderSize = 0;
this.btnBack.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBack.Location = new System.Drawing.Point(224, 193);
this.btnBack.Location = new System.Drawing.Point(224, 176);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(107, 37);
this.btnBack.TabIndex = 41;
......@@ -126,7 +122,7 @@
//
this.btnSave.FlatAppearance.BorderSize = 0;
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSave.Location = new System.Drawing.Point(91, 193);
this.btnSave.Location = new System.Drawing.Point(111, 176);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(107, 37);
this.btnSave.TabIndex = 40;
......@@ -134,23 +130,6 @@
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// txtRobotZHighValue
//
this.txtRobotZHighValue.Location = new System.Drawing.Point(131, 142);
this.txtRobotZHighValue.Name = "txtRobotZHighValue";
this.txtRobotZHighValue.Size = new System.Drawing.Size(89, 23);
this.txtRobotZHighValue.TabIndex = 266;
this.txtRobotZHighValue.Text = "-20";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(65, 146);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(51, 17);
this.label9.TabIndex = 265;
this.label9.Text = "高位Z轴";
//
// txtBoardName
//
this.txtBoardName.Location = new System.Drawing.Point(132, 50);
......@@ -207,8 +186,6 @@
private System.Windows.Forms.Label label14;
private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1;
private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn2;
private System.Windows.Forms.TextBox txtRobotZHighValue;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtCode;
private System.Windows.Forms.Label label1;
}
......
......@@ -47,7 +47,7 @@ namespace URSoldering.Client
txtBoardName.Text = newName;
txtRobotZHighValue.Text = oldBoard.ZHighValue.ToString();
//txtRobotZHighValue.Text = oldBoard.ZHighValue.ToString();
}
......@@ -63,11 +63,7 @@ namespace URSoldering.Client
try
{
string newName = FormUtil.getValue(txtBoardName);
string newCode = FormUtil.getValue(txtCode);
int newZHigh = FormUtil.GetIntValue(txtRobotZHighValue);
string newCode = FormUtil.getValue(txtCode);
if (newName.Equals(""))
{
MessageBox.Show("请输入程序名称");
......@@ -79,8 +75,7 @@ namespace URSoldering.Client
{
MessageBox.Show("程序名称【" + newName + "】已存在,复制失败!");
return;
}
}
BoardInfo newBoard = new BoardInfo();
//newBoard.boardCode = oldBoard.boardCode;
......@@ -96,11 +91,11 @@ namespace URSoldering.Client
newBoard.solderingTime = oldBoard.solderingTime;
newBoard.solderTime = oldBoard.solderTime;
newBoard.imgName = oldBoard.imgName;
newBoard.orgType = oldBoard.orgType;
newBoard.originX = oldBoard.originX;
newBoard.originY = oldBoard.originY;
newBoard.ZHighValue = newZHigh;
//newBoard.orgType = oldBoard.orgType;
//newBoard.originX = oldBoard.originX;
//newBoard.originY = oldBoard.originY;
newBoard.AoiFileName=oldBoard.AoiFileName;
//newBoard.ZHighValue = newZHigh;
try
{
if (!oldBoard.imgName.Contains(oldBoard.boardName))
......
......@@ -197,16 +197,15 @@ namespace URSoldering.Client
picBoard.Image = board.GetImage();
picBoard.Refresh();
int orgType = board.orgType;
double orgX = board.getImageOrgX();
double orgY = board.getImageOrgY();
Graphics grfx = picBoard.CreateGraphics();
//int orgType = board.orgType;
//double orgX = board.getImageOrgX();
//double orgY = board.getImageOrgY();
//Graphics grfx = picBoard.CreateGraphics();
//float preX = 0;
//float preY = 0;
int index = 0;
foreach (WeldPointInfo weld in pointList)
{
//int index = 0;
//foreach (WeldPointInfo weld in pointList)
//{
//float x = (float)Math.Abs(weld.PositionX - orgX) * picBoard.Width / width - pointHight / 2;
//float y = (float)Math.Abs(weld.PositionY - orgY) * picBoard.Width / width - pointHight / 2;
//g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight);
......@@ -225,11 +224,11 @@ namespace URSoldering.Client
//}
//preX = x;
//preY = y;
index++;
//index++;
//g.FillEllipse(Brushes.Red, x, y, pointHight, pointHight);
}
//}
g.Dispose();
//g.Dispose();
}
private void FrmBoardList_Shown(object sender, EventArgs e)
......
......@@ -49,11 +49,10 @@ namespace URSoldering.Client
}
private void btnCodeTest_Click(object sender, EventArgs e)
{
//FrmAOISetting frm = new FrmAOISetting(this);
//this.Visible = false;
//frm.Show();
{
FrmAOISetting frm = new FrmAOISetting(this);
this.Visible = false;
frm.Show();
}
private void btnCamera_Click(object sender, EventArgs e)
......
......@@ -65,7 +65,37 @@ namespace URSoldering.Client
Robot.IsAutoRun = chbXunHuan.Checked;
LoadAOI();
}
private bool IsLoad = false;
private void LoadAOI()
{
if (IsLoad)
{
return;
}
//位置配置到文件中
string appPath = Application.StartupPath;
string strFilePathName = ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string path2 = Path.GetDirectoryName(appPath + strFilePathName);
string filePath = path2 + @"\" + BoardManager.CurrBoard.AoiFileName;
if (File.Exists(filePath))
{
try
{
axCKVisionCtrl1.LoadConfigure(filePath);
axCKVisionCtrl1.ZoomView(2);
LogUtil.error("成功加载程序:" + BoardManager.CurrBoard.AoiFileName);
IsLoad = true;
}
catch (Exception ex)
{
LogUtil.error("加载程序【" + BoardManager.CurrBoard.AoiFileName + "】出错:" + ex.ToString());
}
}
else
{
LogUtil.error("未找到AOI程序文件:" + BoardManager.CurrBoard.AoiFileName);
}
}
private int ShowPointIndex = 5;
private void LoadCountPoint(bool isToday)
{
......@@ -158,52 +188,10 @@ namespace URSoldering.Client
weldCount = list[0].WeldCount;
solderCount = list[0].WeldPointCount;
}
}
}
chartLine.Series[0].Points[ShowPointIndex - 1].SetValueY(weldCount);
chartSolder.Series[0].Points[ShowPointIndex - 1].SetValueY(solderCount);
}
private string aoiCheckFile = "";
private string currAOIFile = "";
private void LoadAOI()
{
//位置配置到文件中
string appPath = Application.StartupPath;
string strFilePathName = ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
aoiCheckFile = appPath + strFilePathName;
LoadAOIFile(aoiCheckFile);
}
private bool LoadAOIFile(string filePath)
{
if (currAOIFile.Equals(filePath))
{
return true ;
}
if (File.Exists(filePath))
{
this.axCKVisionCtrl1.UnloadConfigure();
Thread.Sleep(100);
try
{
currAOIFile = filePath;
this.axCKVisionCtrl1.LoadConfigure(filePath);
this.axCKVisionCtrl1.ZoomView(2);
LogUtil.info("成功加载程序:" + filePath);
return true;
}
catch (Exception ex)
{
LogUtil.error("加载程序【" + filePath + "】出错:" + ex.ToString());
}
}
else
{
LogUtil.error("未找到AOI程序文件:" + filePath);
}return false;
}
}
private void LoadListPoint()
{
......@@ -617,98 +605,12 @@ namespace URSoldering.Client
{
WeldRobotBean.StopWeld();
}
}
private void GetCode()
{
//try
//{
// this.label1.Text = "视觉/扫码";
// lblCodeResult.Text = "焊点自动识别中。。。";
// lblCodeResult.ForeColor = Color.Blue;
// lblCodeResult.Visible = true;
// LoadAOIFile(aoiCheckFile);
// //lblAOIResult.Visible = false;
// for (int i = 0; i < 5; i++)
// {
// bool result = RunAOI(2);
// //if (result)
// //{
// string code = getResult("Code",101);
// if (!code.Equals(""))
// {
// Robot.WareCode = code;
// lblCodeResult.ForeColor = Color.Blue;
// lblCodeResult.Text = "识别成功,共找到【" + BoardManager.CurrBoard.pointList.Count + "】个焊点";
// LogUtil.info("扫码成功:" + code);
// lblCodeResult.Visible = true;
// UpdateBoard(code);
// break;
// }
// else
// {
// lblCodeResult.ForeColor = Color.Red;
// lblCodeResult.Text = "焊点识别失败,即将重新识别";
// LogUtil.info("扫码失败,即将重新扫码");
// lblCodeResult.Visible = true;
// }
// //}
// Thread.Sleep(500);
// }
// lblCodeResult.ForeColor = Color.Blue;
// lblCodeResult.Text = "识别成功,共找到【" + BoardManager.CurrBoard.pointList.Count + "】个焊点";
// lblCodeResult.Visible = true;
// if (lblCodeResult.Visible.Equals(false))
// {
// lblCodeResult.ForeColor = Color.Blue;
// //lblCodeResult.Text = "扫码成功:1000001" ;
// LogUtil.info("扫码成功:1000001");
// }
//}
//catch (Exception ex)
//{
// LogUtil.error("读取条码出错:" + ex.ToString());
//}
}
private void UpdateBoard(string code)
{
//string[] str = code.Split('@');
//if (str.Length >= 1)
//{
// string boardCode = str[0];
// if (BoardManager.CurrBoard.WareCode.Equals(boardCode))
// {
// return;
// }
// else
// {
// BoardInfo board = BoardManager.getBoardByCode(boardCode);
// if (board == null)
// {
// LogUtil.error("条码【"+code+"】未找到匹配的程序,使用之前的程序【"+BoardManager.CurrBoard.boardName+"】");
// }
// else
// {
// LogUtil.error("条码【" + code + "】切换新程序【" + board.boardName + "】");
// BoardManager.UpdateCurrBoard(board.boardId);
// LoadPoint(board, -3);
// }
// }
//}
}
}
private void AOICheck()
{
try
{
this.label1.Text = "视觉/光学检测";
LoadAOIFile(aoiCheckFile);
this.label1.Text = "视觉/光学检测";
lblCodeResult.Visible = false;
RunAOI(1);
int result = CKResult("Result",10);
......@@ -785,30 +687,7 @@ namespace URSoldering.Client
{
return 0;
}
}
//private string getResult(string name,int DataId)
//{
// string result = "";
// try
// {
// int idTool = axCKVisionCtrl1.GetTool(name);
// string value = "";
// object objValue = new VariantWrapper(value);
// if (axCKVisionCtrl1.GetValue(idTool, DataId, 0, ref objValue) == true)
// {
// result = objValue.ToString();
// }
// LogUtil.info("获取【" + name + "】:" + result);
// }
// catch (Exception ex)
// {
// LogUtil.error("获取【" + name + "】出错:" + ex.ToString());
// }
// return result;
//}
}
private void btnLook_Click(object sender, EventArgs e)
{
FrmWorkCount frm = new FrmWorkCount();
......
......@@ -73,6 +73,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmAOISetting.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmAOISetting.designer.cs">
<DependentUpon>FrmAOISetting.cs</DependentUpon>
</Compile>
<Compile Include="FrmBase.cs">
<SubType>Form</SubType>
</Compile>
......@@ -109,12 +115,6 @@
<Compile Include="FrmProgramSelect.Designer.cs">
<DependentUpon>FrmProgramSelect.cs</DependentUpon>
</Compile>
<Compile Include="FrmCodeLearn.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmCodeLearn.Designer.cs">
<DependentUpon>FrmCodeLearn.cs</DependentUpon>
</Compile>
<Compile Include="FrmCamera.cs">
<SubType>Form</SubType>
</Compile>
......@@ -183,6 +183,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmAOISetting.resx">
<DependentUpon>FrmAOISetting.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
......@@ -201,9 +204,6 @@
<EmbeddedResource Include="FrmProgramSelect.resx">
<DependentUpon>FrmProgramSelect.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmCodeLearn.resx">
<DependentUpon>FrmCodeLearn.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmCamera.resx">
<DependentUpon>FrmCamera.cs</DependentUpon>
</EmbeddedResource>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!