delete no use code

This commit is contained in:
2025-11-21 17:25:27 +08:00
parent 69e8ab6425
commit 4541dc88cc
5 changed files with 24 additions and 260 deletions

View File

@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace WaferAlignment
{
[XmlRootAttribute("CenterOfRotation", IsNullable = false)]
public class CenterOfRotation
{
private double center_X = 0;
private double center_Y = 0;
[XmlElementAttribute("Center_X")]
public double Center_X
{
get { return center_X; }
set { center_X = value; }
}
[XmlElementAttribute("Center_Y")]
public double Center_Y
{
get { return center_Y; }
set { center_Y = value; }
}
}
}

View File

@@ -1,63 +0,0 @@
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace ConVX.VXData
{
public class ConfigStore
{
public object ReadConfigFromFile(Type objectType, string filePath)
{
try
{
object mxml = new object();
XmlSerializer serializer = new XmlSerializer(objectType);
StreamReader reader = new StreamReader(filePath);
mxml = serializer.Deserialize(reader);
reader.Close();
return mxml;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void WriteConfigToFile(object config, Type objectType, string filePath)
{
try
{
object mConfig = new object();
mConfig = config;
XmlSerializer serializer = new XmlSerializer(objectType);
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = Encoding.Unicode;
StringWriter txtwriter = new StringWriter();
XmlWriter xmlwtr = XmlWriter.Create(txtwriter, settings);
serializer.Serialize(xmlwtr, mConfig);
StreamWriter writer = new StreamWriter(filePath);
writer.Write(txtwriter.ToString());
writer.Close();
txtwriter.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}

View File

@@ -25,14 +25,6 @@ namespace ConVX.VXData
/// 控制任务启动 /// 控制任务启动
/// </summary> /// </summary>
private CancellationTokenSource RuningToken; private CancellationTokenSource RuningToken;
/// <summary>
/// 控制任务终止
/// </summary>
private CancellationTokenSource StopToken;
/// <summary>
/// 最大队列容量
/// </summary>
private int _maxQueueSize = 10;
#endregion #endregion
#region #region
@@ -53,7 +45,6 @@ namespace ConVX.VXData
public DataPostbox() public DataPostbox()
{ {
_queue = new ConcurrentQueue<CogImage8Grey>(); _queue = new ConcurrentQueue<CogImage8Grey>();
//_autoReset = new AutoResetEvent(false);//线程非终止状态
} }
/// <summary> /// <summary>
/// 启动派发 /// 启动派发
@@ -72,7 +63,6 @@ namespace ConVX.VXData
try try
{ {
RuningToken.Cancel(); RuningToken.Cancel();
//_autoReset.Set();//为了避免线程正在执行或等待状态
await _task; await _task;
} }
catch (OperationCanceledException ex) catch (OperationCanceledException ex)
@@ -87,30 +77,17 @@ namespace ConVX.VXData
/// <param name="envelope">信息信件</param> /// <param name="envelope">信息信件</param>
public void Mailing(CogImage8Grey envelope) public void Mailing(CogImage8Grey envelope)
{ {
//if (_queue.Count > _maxQueueSize)
//{
// ErrorEvent(string.Format("数据队列超出队列最大容量{0}", _maxQueueSize));
//}
//else
//{
// _queue.Enqueue(envelope);
// _autoReset.Set();
//}
_queue.Enqueue(envelope); _queue.Enqueue(envelope);
//_autoReset.Set();
} }
#endregion #endregion
#region 线 #region 线
private void EnvelopeProcessing() private void EnvelopeProcessing()
{ {
StopToken = new CancellationTokenSource();
while (!RuningToken.IsCancellationRequested) while (!RuningToken.IsCancellationRequested)
{ {
if (_queue.IsEmpty) if (_queue.IsEmpty)
{ {
//_autoReset.WaitOne();
Thread.Sleep(1); Thread.Sleep(1);
} }
else else
@@ -122,7 +99,6 @@ namespace ConVX.VXData
{ {
DeliverLetterEvent(envelope); DeliverLetterEvent(envelope);
} }
Thread.Sleep(20);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -130,10 +106,7 @@ namespace ConVX.VXData
} }
} }
} }
StopToken.Cancel();
} }
#endregion #endregion
} }
} }

View File

@@ -49,20 +49,12 @@ namespace WaferAlignment
///动作执行完成 ///动作执行完成
/// </summary> /// </summary>
string arOver = "DB7.DBX74.1"; string arOver = "DB7.DBX74.1";
string arLED = "M3.0";
/// <summary>
/// 偏转角度
/// </summary>
string arAngle = "DB7.DBD76";//设置触发拍照的偏转角度
GetCircleToolBlock getCircleMachineToolBlock; GetCircleToolBlock getCircleMachineToolBlock;
FitCircleToolBlock FitCircleMachineToolBlock; FitCircleToolBlock FitCircleMachineToolBlock;
TranslateCirclePoint translateCirclePoint; TranslateCirclePoint translateCirclePoint;
CogGraphicCollection m_graphics; CogGraphicCollection m_graphics;
//XML文件读取与写入
ConfigStore _ConfigStore = new ConfigStore();
CenterOfRotation _center = new CenterOfRotation();
//偏差量 //偏差量
double deviationX; double deviationX;
double deviationY; double deviationY;
@@ -74,10 +66,6 @@ namespace WaferAlignment
string TCP_R = "0"; string TCP_R = "0";
string TCP_RMS = "0"; string TCP_RMS = "0";
bool OKorNG = false;//判断检查是否完成
//
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
@@ -618,110 +606,12 @@ namespace WaferAlignment
} }
FitCircle(); FitCircle();
//////////三轴回零
////////if (_s7 != null)
////////{
//////// _s7.SetValue(arMode, (ushort)4);
//////// _s7.SetValue(arAction, true);
//////// Thread.Sleep(20);
//////// while (true)
//////// {
//////// bool value = false;
//////// if (_s7.GetValue(arOver, out value))
//////// {
//////// if (value)
//////// {
//////// _s7.SetValue(arAction, false);
//////// break;
//////// }
//////// else
//////// {
//////// Thread.Sleep(20);
//////// continue;
//////// }
//////// }
//////// else
//////// {
//////// Thread.Sleep(20);
//////// continue;
//////// }
//////// }
//////// //MessageBox.Show("动作已完成!");
////////}
////////调整圆心到旋转中心
//////if (_s7 != null)
//////{
////// double _angle = angle;
////// //顺时针旋转
////// //if (_angle > 0)
////// //{
////// // _angle = 360 - _angle;
////// //}
////// //else
////// //{
////// // _angle = -_angle;
////// //}
////// //逆时针旋转
////// if (_angle > 0)
////// {
////// _angle = _angle;
////// }
////// else
////// {
////// _angle = 360 + _angle;
////// }
////// _s7.SetValue(arMode, (ushort)0);
////// _s7.SetValue(arSizeX, Convert.ToSingle((double)nud_SizeX.Value + deviationX));
////// _s7.SetValue(arSizeY, Convert.ToSingle((double)nud_SizeY.Value + deviationY));
////// _s7.SetValue(arSizeR, Convert.ToSingle(_angle));
////// _s7.SetValue(arAction, true);
////// Thread.Sleep(20);
////// while (true)
////// {
////// bool value = false;
////// if (_s7.GetValue(arOver, out value))
////// {
////// if (value)
////// {
////// _s7.SetValue(arAction, false);
////// break;
////// }
////// else
////// {
////// Thread.Sleep(20);
////// continue;
////// }
////// }
////// else
////// {
////// Thread.Sleep(20);
////// continue;
////// }
////// }
////// //MessageBox.Show("动作已完成!");
//////}
Task.Run(() => { Save(); }); Task.Run(() => { Save(); });
} }
if (OKorNG) return "OK_RUN";
{
return "OK_RUN";
}
else
{
return "NG_RUN";
}
} }
private CogImage8Grey m_lastImage; private CogImage8Grey m_lastImage;
//所有点
// 调整vpp中CogCaliperTool工具数据需要同时调整Y值与 for (double i = Y; i < 12; i = i + 0.5)中12的值
private void MonitorSpot(CogImage8Grey outputImg) private void MonitorSpot(CogImage8Grey outputImg)
{ {
sw_1 = new Stopwatch();//检测时间 sw_1 = new Stopwatch();//检测时间
@@ -740,38 +630,34 @@ namespace WaferAlignment
DataDisplay(translateCirclePoint.GetCurrentDegree(), 0, 0, ts.TotalMilliseconds); DataDisplay(translateCirclePoint.GetCurrentDegree(), 0, 0, ts.TotalMilliseconds);
testNum++; testNum++;
times += ts.TotalMilliseconds; times += ts.TotalMilliseconds;
OKorNG = true;
} }
private void FitCircle() private void FitCircle()
{ {
if (OKorNG) sw_2 = new Stopwatch();//检测时间
sw_2.Start();
LogHelper.LogInfo("转换机械坐标系下圆弧各点的原始坐标:\n");
var points = translateCirclePoint.DoTranslatePoint();
translateCirclePoint.DoTranslateNashPoint();
LogHelper.LogInfo("拟合机械坐标系下的圆中心:\n");
m_graphics = new CogGraphicCollection();
m_graphics = new CogGraphicCollection();
foreach (PointInfo pointInfo in points)
{ {
sw_2 = new Stopwatch();//检测时间 AddPointMarker(m_graphics, pointInfo.X, pointInfo.Y);
sw_2.Start();
LogHelper.LogInfo("转换机械坐标系下圆弧各点的原始坐标:\n");
var points = translateCirclePoint.DoTranslatePoint();
translateCirclePoint.DoTranslateNashPoint();
LogHelper.LogInfo("拟合机械坐标系下的圆中心:\n");
m_graphics = new CogGraphicCollection();
m_graphics = new CogGraphicCollection();
foreach (PointInfo pointInfo in points)
{
AddPointMarker(m_graphics, pointInfo.X, pointInfo.Y);
}
FitCircleMachineToolBlock.Run(m_lastImage, points);
sw_2.Stop();
TimeSpan ts = sw_2.Elapsed;
times += ts.TotalMilliseconds;
TCP_time = ts.TotalMilliseconds.ToString();
ResultDisplay(times, ts.TotalMilliseconds, TCP_X, TCP_Y, TCP_R, TCP_RMS, deviationX, deviationY, angle);
} }
FitCircleMachineToolBlock.Run(m_lastImage, points);
sw_2.Stop();
TimeSpan ts = sw_2.Elapsed;
times += ts.TotalMilliseconds;
TCP_time = ts.TotalMilliseconds.ToString();
ResultDisplay(times, ts.TotalMilliseconds, TCP_X, TCP_Y, TCP_R, TCP_RMS, deviationX, deviationY, angle);
} }
private void ResultDisplay(double Times,double Time, string X, string Y, string R, string RMS, double dX, double dY, double dR) private void ResultDisplay(double Times,double Time, string X, string Y, string R, string RMS, double dX, double dY, double dR)

View File

@@ -105,8 +105,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Camera.cs" /> <Compile Include="Camera.cs" />
<Compile Include="CenterOfRotation.cs" />
<Compile Include="ConfigStore.cs" />
<Compile Include="DataPostbox.cs" /> <Compile Include="DataPostbox.cs" />
<Compile Include="FitCircleToolBlock.cs" /> <Compile Include="FitCircleToolBlock.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">