Commit 3f006b78 几米阳光

修改:检测NG时红灯亮

1 个父辈 ecba5851
......@@ -85,6 +85,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="bean\AOIDataResult.cs" />
<Compile Include="bean\BoardInfo.cs" />
<Compile Include="bean\RobotBean.cs" />
<Compile Include="bean\RobotManager.cs" />
......
......@@ -8,7 +8,7 @@ namespace URSoldering.DeviceLibrary
{
public partial class URSolderingRobot : RobotBean
{
private AlarmType alarmType = AlarmType.None;
public string WareCode = "";
public SolderingRobotConfig Config;
public LineStepBean LineStep = new LineStepBean();
......@@ -65,6 +65,7 @@ namespace URSoldering.DeviceLibrary
KNDIOMove(IO_Type.AlarmSingle, IO_VALUE.LOW);
KNDIOMove(IO_Type.WaitSingle, IO_VALUE.LOW);
Status = RobotStatus.Reset;
WeldRobotBean.LastAOIResult = true;
WeldRobotBean.IsInWeld = false;
IsInProcess = false;
ledTimer.Enabled = true;
......
......@@ -9,12 +9,15 @@ namespace URSoldering.DeviceLibrary
partial class WeldRobotBean
{
public static bool IsInWeld=false;
public static bool LastAOIResult = true;
//public delegate void GetCode();
//public static event GetCode GetCodeFun;
public delegate void AOICheck( );
public delegate bool AOICheck( );
public static event AOICheck AOICheckFun;
public delegate List<PositionResult> PositionOffset();
public static event PositionOffset PositionOffsetFun;
public static string StartWeld( )
{
StopSleep();
......@@ -44,6 +47,7 @@ namespace URSoldering.DeviceLibrary
{
return "没有找到需要焊接的焊点,启动焊接失败!";
}
LastAOIResult = true;
IsInWeld = true ;
return "";
}
......@@ -169,7 +173,7 @@ namespace URSoldering.DeviceLibrary
}
else if (WeldMoveStep.moveStep.Equals(MoveStep.W14_AOICheck))
{
AOICheckFun.Invoke();
LastAOIResult= AOICheckFun.Invoke();
Thread.Sleep(300);
IsInWeld = false;
if (WeldCount >= RobotConfig.ClearCount)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace URSoldering.DeviceLibrary
{
public class PositionResult
{
public PositionResult(double x, double y, int type, WeldPointInfo point)
{
this.DataX = x;
this.DataY = y;
this.DataType = type;
this.PointInfo = point;
}
/// <summary>
/// 位置X
/// </summary>
public double DataX = 0;
/// <summary>
/// 位置Y
/// </summary>
public double DataY = 0;
/// <summary>
/// 数据类型,1=少锡,2=多锡
/// </summary>
public int DataType = 0;
/// <summary>
/// 拍照点、基准点坐标
/// </summary>
public WeldPointInfo PointInfo = null;
}
}
......@@ -7,6 +7,7 @@ namespace URSoldering.DeviceLibrary
{
public class RobotBean
{
public AlarmType alarmType = AlarmType.None;
/// <summary>
/// 报警或者警告信息
/// </summary>
......@@ -94,6 +95,17 @@ namespace URSoldering.DeviceLibrary
KNDIOMove(IO_Type.AutoRunSingle, IO_VALUE.HIGH);
}
}
if (Status>RobotStatus.Wait && alarmType.Equals(AlarmType.None))
{
if (WeldRobotBean.LastAOIResult.Equals(false))
{
KNDIOMove(IO_Type.AlarmSingle, IO_VALUE.HIGH);
}
else
{
KNDIOMove(IO_Type.AlarmSingle, IO_VALUE.LOW);
}
}
}
protected virtual void mainTimer_Elapsed(object sender, ElapsedEventArgs e)
......
......@@ -37,7 +37,8 @@ namespace URSoldering.Client
LoadListPoint();
Robot = RobotManager.SolderingRobot;
WeldRobotBean.AOICheckFun += AOICheck;
WeldRobotBean.AOICheckFun += AOICheck;
WeldRobotBean.PositionOffsetFun += RunPositionOffset;
//Robot.GetCodeFun += GetCode;
LogUtil.logBox = this.logBox;
LogUtil.showCount = 1;
......@@ -640,11 +641,15 @@ namespace URSoldering.Client
WeldRobotBean.StopWeld();
}
}
private void AOICheck()
/// <summary>
/// true表示检测OK
/// </summary>
/// <returns></returns>
private bool AOICheck()
{
try
{
this.label1.Text = "视觉/光学检测";
this.label1.Text = "AOI检测";
lblCodeResult.Visible = false;
RunAOI(1);
int result = CKResult("Result",10);
......@@ -654,6 +659,7 @@ namespace URSoldering.Client
lblAOIResult.ForeColor = Color.Blue;
lblAOIResult.Text = "检测OK";
WorkCountManager.AddOKCount();
return true;
}
else
{
......@@ -668,6 +674,7 @@ namespace URSoldering.Client
{
LogUtil.error("AOI检测出错:" + ex.ToString());
}
return false;
}
private bool RunAOI(int num)
......@@ -721,7 +728,112 @@ namespace URSoldering.Client
{
return 0;
}
}
}
private List<PositionResult> RunPositionOffset( )
{
List<PositionResult> pointList = new List<PositionResult>();
try
{
this.label1.Text = "视觉坐标偏移";
lblCodeResult.Visible = false;
RunAOI(0);
Thread.Sleep(100);
string shaoxi = "坐标偏移" ;
int result1 = CKResult(shaoxi, 10);
if (!result1.Equals(1))
{
pointList = GetPhotoResult(shaoxi, 100);
}
string resultList = "";
if (pointList.Count <= 0)
{
lblAOIResult.Text = shaoxi + "未识别到焊点";
}
else
{
lblAOIResult.Text = shaoxi + "识别结果:";
foreach (PositionResult result in pointList)
{
lblAOIResult.Text += " X:" + result.DataX + ",Y:" + result.DataY + ";";
}
}
resultList = lblAOIResult.Text;
LogUtil.info(resultList);
lblAOIResult.Visible = true;
}
catch (Exception ex)
{
LogUtil.error("视觉坐标偏移出错:" + ex.ToString());
}
return pointList;
}
private List<PositionResult> GetPhotoResult(string name, int DataId)
{
WeldPointInfo point = null;
if (WeldRobotBean.WeldMoveStep.CurrPoint != null)
{
point = WeldRobotBean.WeldMoveStep.CurrPoint;
}
List<PositionResult> aOIDataResults = new List<PositionResult>();
string result = "";
try
{
int idTool = axCKVisionCtrl1.GetTool(name);
//NG的话需要获取数量,然后获取数据列表
int num = 0;
string value = "";
object objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, 100, 0, ref objValue) == true)
{
result = objValue.ToString();
num = Convert.ToInt32(result);
}
LogUtil.info("获取【" + name + "】的数量:" + num);
for (int i = 0; i < num; i++)
{
double x = 0, y = 0;
if (name.Equals("少锡"))
{
objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, 102, i, ref objValue) == true)
{
result = objValue.ToString();
x = Convert.ToDouble(result);
}
objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, 103, i, ref objValue) == true)
{
result = objValue.ToString();
y = Convert.ToDouble(result);
}
aOIDataResults.Add(new PositionResult(x, y, 1, point));
}
else
{
objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, 103, i, ref objValue) == true)
{
result = objValue.ToString();
x = Convert.ToDouble(result);
}
objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, 104, i, ref objValue) == true)
{
result = objValue.ToString();
y = Convert.ToDouble(result);
}
aOIDataResults.Add(new PositionResult(x, y, 2, point));
}
}
}
catch (Exception ex)
{
LogUtil.error("获取【" + name + "】出错:" + ex.ToString());
}
return aOIDataResults;
}
private void btnLook_Click(object sender, EventArgs e)
{
FrmWorkCount frm = new FrmWorkCount();
......
......@@ -24,3 +24,12 @@ UR机器人是否到位判断条件修改:只判断X.Y.Z坐标是否一致
拖焊点直接移动,普通焊点先移动至焊点高处,再下降焊接
20181012
最近修改内容:
抬起高度>0时,会先抬起再移动到焊点,抬起高度<=0时直接移动到焊点
配置ISDebug=1时,不检测夹具状态和急停状态
配置ISDebug=0时,才会检测夹具状态和急停状态
AOI检测NG时,红灯亮,等到下次开始焊接时清理红灯。
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!