#0015: 修复etalon 运动到下一代的显示问题

This commit is contained in:
zhengxuan.zhang
2024-09-26 16:33:09 +08:00
parent 9133577da0
commit edeed6bb0e
6 changed files with 55 additions and 34 deletions
+43 -22
View File
@@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Media;
using ACS.SPiiPlusNET; using ACS.SPiiPlusNET;
using HexcalMC.Base; using HexcalMC.Base;
using Plot3D; using Plot3D;
@@ -78,8 +79,8 @@ namespace HexcalMC
private eDemo me_Demo; private eDemo me_Demo;
private eColorScheme me_ColorScheme; private eColorScheme me_ColorScheme;
private System.Windows.Forms.Timer mi_StatusTimer = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer mi_StatusTimer = new System.Windows.Forms.Timer();
private cMessgData mi_MesgTop = new cMessgData("", -7, 7, Color.Blue); // For special hint private cMessgData mi_MesgTop = new cMessgData("", -7, 7, System.Drawing.Color.Blue); // For special hint
private cMessgData mi_MesgBottom = new cMessgData("", -7, -7, Color.Gray); // For selection mode private cMessgData mi_MesgBottom = new cMessgData("", -7, -7, System.Drawing.Color.Gray); // For selection mode
// Only for demo "Animation" // Only for demo "Animation"
private System.Windows.Forms.Timer mi_AnimationTimer = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer mi_AnimationTimer = new System.Windows.Forms.Timer();
@@ -99,6 +100,7 @@ namespace HexcalMC
private readonly MainFrom mainFrom; private readonly MainFrom mainFrom;
private readonly Api _acs; //ACS控制器 private readonly Api _acs; //ACS控制器
private double dwellTime = 2000; //停顿时间
public Axis[] axes = public Axis[] axes =
{ {
@@ -217,7 +219,7 @@ namespace HexcalMC
editor3D.Normalize = eNormalize.Separate; editor3D.Normalize = eNormalize.Separate;
editor3D.AddRenderData(i_ShapeData, i_LineData); editor3D.AddRenderData(i_ShapeData, i_LineData);
editor3D.Selection.HighlightColor = Color.FromArgb(90, 90, 90); editor3D.Selection.HighlightColor = System.Drawing.Color.FromArgb(90, 90, 90);
editor3D.Selection.Callback = OnSelectEvent; editor3D.Selection.Callback = OnSelectEvent;
editor3D.Selection.MultiSelect = true; editor3D.Selection.MultiSelect = true;
editor3D.Selection.Enabled = true; editor3D.Selection.Enabled = true;
@@ -407,7 +409,7 @@ namespace HexcalMC
} }
// 创建多点运动 // 创建多点运动
double dwellTime = dwellTimes.Average() * 1000; //将秒转换为毫秒 dwellTime = dwellTimes.Average() * 1000; //将秒转换为毫秒
DebugDfn.AddLogText("平均停顿时间(毫秒):" + dwellTime); DebugDfn.AddLogText("平均停顿时间(毫秒):" + dwellTime);
_acs.MultiPointM(MotionFlags.ACSC_NONE, axes, dwellTime); _acs.MultiPointM(MotionFlags.ACSC_NONE, axes, dwellTime);
@@ -501,8 +503,6 @@ namespace HexcalMC
refresh_time.Stop(); refresh_time.Stop();
timer_move.Stop(); timer_move.Stop();
currentIndex = 0; currentIndex = 0;
} }
private void btn_etalon_import_Click(object sender, EventArgs e) //解析Etalon文件 private void btn_etalon_import_Click(object sender, EventArgs e) //解析Etalon文件
@@ -561,6 +561,7 @@ namespace HexcalMC
etalon_points.Clear(); etalon_points.Clear();
filteredPoints.Clear(); filteredPoints.Clear();
dwellTimes.Clear(); dwellTimes.Clear();
currentIndex = 0; //重置当前点
//读取文件 //读取文件
string[] lines = File.ReadAllLines(mpf_file_path); string[] lines = File.ReadAllLines(mpf_file_path);
@@ -661,7 +662,7 @@ namespace HexcalMC
editor3D.Normalize = eNormalize.Separate; editor3D.Normalize = eNormalize.Separate;
editor3D.AddRenderData(i_ShapeData, i_LineData); editor3D.AddRenderData(i_ShapeData, i_LineData);
editor3D.Selection.HighlightColor = Color.FromArgb(90, 90, 90); editor3D.Selection.HighlightColor = System.Drawing.Color.FromArgb(90, 90, 90);
editor3D.Selection.Callback = OnSelectEvent; editor3D.Selection.Callback = OnSelectEvent;
editor3D.Selection.MultiSelect = true; editor3D.Selection.MultiSelect = true;
editor3D.Selection.Enabled = true; editor3D.Selection.Enabled = true;
@@ -686,19 +687,16 @@ namespace HexcalMC
cScatterData i_ShapeData = new cScatterData(); cScatterData i_ShapeData = new cScatterData();
//currentIndex = mainFrom.GetInPosCount();//获取当前点的数量 //currentIndex = mainFrom.GetInPosCount();//获取当前点的数量
if (currentIndex < filteredPoints.Count) for (int i = 0; i < filteredPoints.Count; i++) //遍历所有点
{ {
if (i < currentIndex-1) //小于的部分,已跑完 为绿色
// 更新点的颜色
for (int i = 0; i <= currentIndex; i++)
{ {
double d_X = filteredPoints[i].X; double d_X = filteredPoints[i].X;
double d_Y = filteredPoints[i].Y; double d_Y = filteredPoints[i].Y;
double d_Z = filteredPoints[i].Z; double d_Z = filteredPoints[i].Z;
cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point"); cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point");
SolidBrush i_brush = new SolidBrush(Color.Red); SolidBrush i_brush = new SolidBrush(System.Drawing.Color.Green);
// You can store the returned shape in a variable and later modify it's properties // You can store the returned shape in a variable and later modify it's properties
cShape3D i_Shape = i_ShapeData.AddShape( cShape3D i_Shape = i_ShapeData.AddShape(
i_Point, i_Point,
@@ -708,16 +706,31 @@ namespace HexcalMC
null null
); );
} }
else if (i == currentIndex-1) //当前点为橙黄色
// 对于剩余部分的点,不做颜色更新
for (int i = currentIndex; i < filteredPoints.Count; i++)
{ {
double d_X = filteredPoints[i].X; double d_X = filteredPoints[i].X;
double d_Y = filteredPoints[i].Y; double d_Y = filteredPoints[i].Y;
double d_Z = filteredPoints[i].Z; double d_Z = filteredPoints[i].Z;
cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point"); cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point");
SolidBrush i_brush = new SolidBrush(Color.Gray); SolidBrush i_brush = new SolidBrush(System.Drawing.Color.OrangeRed);
// You can store the returned shape in a variable and later modify it's properties
cShape3D i_Shape = i_ShapeData.AddShape(
i_Point,
eScatterShape.Circle,
5,
i_brush,
null
);
}
else
{
double d_X = filteredPoints[i].X;
double d_Y = filteredPoints[i].Y;
double d_Z = filteredPoints[i].Z;
cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point");
SolidBrush i_brush = new SolidBrush(System.Drawing.Color.Gray);
// You can store the returned shape in a variable and later modify it's properties // You can store the returned shape in a variable and later modify it's properties
cShape3D i_Shape = i_ShapeData.AddShape( cShape3D i_Shape = i_ShapeData.AddShape(
i_Point, i_Point,
@@ -752,20 +765,28 @@ namespace HexcalMC
if (filteredPoints.Count > 0 && currentIndex < filteredPoints.Count) if (filteredPoints.Count > 0 && currentIndex < filteredPoints.Count)
{ {
//增加2秒延时 //增加2秒延时
Thread.Sleep(2000); Thread.Sleep((int)dwellTime);
Point nextPoint = filteredPoints[currentIndex]; Point nextPoint = filteredPoints[currentIndex];
//打印 nextPoint //打印 nextPoint
DebugDfn.AddLogText("下发指令:" + currentIndex + " 点:" + nextPoint.X + " " + nextPoint.Y + " " + nextPoint.Z ); DebugDfn.AddLogText(
"下发指令:"
mainFrom.SetPositionXyz(Point.FromPoint(nextPoint)); //移动到下一个点 + currentIndex
+ " 点:"
+ nextPoint.X
+ " "
+ nextPoint.Y
+ " "
+ nextPoint.Z
);
currentIndex++; currentIndex++;
mainFrom.SetPositionXyz(Point.FromPoint(nextPoint)); //移动到下一个点
} }
else else
{ {
DebugDfn.AddLogText("All points have been visited."); DebugDfn.AddLogText("All points have been visited.");
timer_move.Stop(); timer_move.Stop();
currentIndex = 0;
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>5BAu5mmkGH6UcqUDfkL6WCaAYDZ3v+HSBDiHWDwiFF0=</dsig:DigestValue> <dsig:DigestValue>z2mLqy08XuUV8hlnpHyZ0pykJWrtzR1mUJK4Iyn9kS4=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
Binary file not shown.
+1 -1
View File
@@ -62,7 +62,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>cGpoIhg/anGo/O6Lnll6V35Q+gP3ExIYb7ltMw03hpA=</dsig:DigestValue> <dsig:DigestValue>4DR1ksKlokf+OktGK8d+8M0auawSIh8axvkUM7xdmUc=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
Binary file not shown.
Binary file not shown.