现场优化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;
}