现场优化2

This commit is contained in:
2026-08-13 13:35:43 +08:00
parent 30f5f6f8d6
commit e392527592
4 changed files with 203 additions and 161 deletions
@@ -221,8 +221,8 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetAxisTargetPositionAsync(1, TargetX);
await _gantry.StartSingleAxisAsync(1);
await _gantry!.设置轴目标位置(1, TargetX);
await _gantry.启动单轴(1);
LoggerHelper.Info($"[BenchMovement] X轴移动到 {TargetX}");
}
catch (Exception ex)
@@ -237,8 +237,8 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetAxisTargetPositionAsync(2, TargetY);
await _gantry.StartSingleAxisAsync(2);
await _gantry!.设置轴目标位置(2, TargetY);
await _gantry.启动单轴(2);
LoggerHelper.Info($"[BenchMovement] Y轴移动到 {TargetY}");
}
catch (Exception ex)
@@ -253,8 +253,8 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetAxisTargetPositionAsync(3, TargetZ);
await _gantry.StartSingleAxisAsync(3);
await _gantry!.设置轴目标位置(3, TargetZ);
await _gantry.启动单轴(3);
LoggerHelper.Info($"[BenchMovement] Z轴移动到 {TargetZ}");
}
catch (Exception ex)
@@ -269,10 +269,10 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetAxisTargetPositionAsync(1, TargetX);
await _gantry.SetAxisTargetPositionAsync(2, TargetY);
await _gantry.SetAxisTargetPositionAsync(3, TargetZ);
await _gantry.StartAllAxesAsync();
await _gantry!.设置轴目标位置(1, TargetX);
await _gantry.设置轴目标位置(2, TargetY);
await _gantry.设置轴目标位置(3, TargetZ);
await _gantry.启动全部轴();
LoggerHelper.Info($"[BenchMovement] 三轴同时移动: X={TargetX}, Y={TargetY}, Z={TargetZ}");
}
catch (Exception ex)
@@ -287,7 +287,7 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.HomeAsync();
await _gantry!.回零();
LoggerHelper.Info("[BenchMovement] 回原点已触发");
}
catch (Exception ex)
@@ -302,7 +302,7 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetEStopStateAsync(true);
await _gantry!.设置急停状态(true);
LoggerHelper.Info("[BenchMovement] 急停已触发");
}
catch (Exception ex)
@@ -316,9 +316,9 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetStopStateAsync(1, true);
await _gantry!.设置轴停止状态(1, true);
await Task.Delay(100);
await _gantry.SetStopStateAsync(1, false);
await _gantry.设置轴停止状态(1, false);
}
catch (Exception ex)
{
@@ -331,9 +331,9 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetStopStateAsync(2, true);
await _gantry!.设置轴停止状态(2, true);
await Task.Delay(100);
await _gantry.SetStopStateAsync(2, false);
await _gantry.设置轴停止状态(2, false);
}
catch (Exception ex)
{
@@ -346,9 +346,9 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetStopStateAsync(3, true);
await _gantry!.设置轴停止状态(3, true);
await Task.Delay(100);
await _gantry.SetStopStateAsync(3, false);
await _gantry.设置轴停止状态(3, false);
}
catch (Exception ex)
{
@@ -361,10 +361,10 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetAxisSpeedAsync(1, SpeedX);
await _gantry.SetAxisSpeedAsync(2, SpeedY);
await _gantry.SetAxisSpeedAsync(3, SpeedZ);
await _gantry.SetHomePositionSpeedAsync(HomeSpeed);
await _gantry!.设置轴速度(1, SpeedX);
await _gantry.设置轴速度(2, SpeedY);
await _gantry.设置轴速度(3, SpeedZ);
await _gantry.设置回零速度(HomeSpeed);
LoggerHelper.Info($"[BenchMovement] 速度设定完成: X={SpeedX}, Y={SpeedY}, Z={SpeedZ}, 回零={HomeSpeed}");
}
catch (Exception ex)
@@ -379,7 +379,7 @@ namespace BenchMovementModule.ViewModels
if (!EnsureConnected()) return;
try
{
await _gantry!.SetHomePositionAsync(HomeX, HomeY, HomeZ);
await _gantry!.设置原点位置(HomeX, HomeY, HomeZ);
LoggerHelper.Info($"[BenchMovement] 零点设定完成: X={HomeX}, Y={HomeY}, Z={HomeZ}");
}
catch (Exception ex)
@@ -419,16 +419,16 @@ namespace BenchMovementModule.ViewModels
if (_gantry == null || !_gantry.IsConnected) return;
try
{
var (x, y, z) = await _gantry.GetHomePositionAsync();
var (x, y, z) = await _gantry.查询原点位置();
HomeX = x; HomeY = y; HomeZ = z;
SpeedX = await _gantry.GetAxisSpeedAsync(1);
SpeedY = await _gantry.GetAxisSpeedAsync(2);
SpeedZ = await _gantry.GetAxisSpeedAsync(3);
HomeSpeed = await _gantry.GetHomePositionSpeedAsync();
SpeedX = await _gantry.查询轴速度(1);
SpeedY = await _gantry.查询轴速度(2);
SpeedZ = await _gantry.查询轴速度(3);
HomeSpeed = await _gantry.查询回零速度();
// 读取 6 轴绝对位置
var positions = await _gantry.GetAllAbsolutePositionsAsync();
var positions = await _gantry.查询全部轴绝对位置();
AbsPos1 = positions.Axis1; AbsPos2 = positions.Axis2; AbsPos3 = positions.Axis3;
AbsPos4 = positions.Axis4; AbsPos5 = positions.Axis5; AbsPos6 = positions.Axis6;
}
@@ -444,7 +444,7 @@ namespace BenchMovementModule.ViewModels
try
{
// 批量读取 6 轴绝对位置(一次性通信,高效)
var pos = await _gantry.GetAllAbsolutePositionsAsync();
var pos = await _gantry.查询全部轴绝对位置();
AbsPos1 = pos.Axis1; AbsPos2 = pos.Axis2; AbsPos3 = pos.Axis3;
AbsPos4 = pos.Axis4; AbsPos5 = pos.Axis5; AbsPos6 = pos.Axis6;
}