对主界面rabbion按钮的 开关门 绑定到硬件库层真实的操作
This commit is contained in:
@@ -21,6 +21,7 @@ using XP.Common.Logging.Interfaces;
|
||||
using XP.Common.GeneralForm.Views;
|
||||
using XP.Common.PdfViewer.Interfaces;
|
||||
using XP.Hardware.MotionControl.Abstractions;
|
||||
using XP.Hardware.MotionControl.Services;
|
||||
|
||||
namespace XplorePlane.ViewModels
|
||||
{
|
||||
@@ -90,6 +91,8 @@ namespace XplorePlane.ViewModels
|
||||
|
||||
// 硬件命令
|
||||
public DelegateCommand AxisResetCommand { get; }
|
||||
public DelegateCommand OpenDoorCommand { get; }
|
||||
public DelegateCommand CloseDoorCommand { get; }
|
||||
public DelegateCommand OpenDetectorConfigCommand { get; }
|
||||
public DelegateCommand OpenMotionDebugCommand { get; }
|
||||
public DelegateCommand OpenPlcAddrConfigCommand { get; }
|
||||
@@ -295,6 +298,8 @@ namespace XplorePlane.ViewModels
|
||||
_eventAggregator.GetEvent<ToggleCrosshairEvent>().Publish());
|
||||
|
||||
AxisResetCommand = new DelegateCommand(ExecuteAxisReset);
|
||||
OpenDoorCommand = new DelegateCommand(ExecuteOpenDoor);
|
||||
CloseDoorCommand = new DelegateCommand(ExecuteCloseDoor);
|
||||
OpenDetectorConfigCommand = new DelegateCommand(ExecuteOpenDetectorConfig);
|
||||
OpenMotionDebugCommand = new DelegateCommand(ExecuteOpenMotionDebug);
|
||||
OpenPlcAddrConfigCommand = new DelegateCommand(ExecuteOpenPlcAddrConfig);
|
||||
@@ -589,6 +594,46 @@ namespace XplorePlane.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteOpenDoor()
|
||||
{
|
||||
try
|
||||
{
|
||||
var motionService = _containerProvider.Resolve<IMotionControlService>();
|
||||
var result = motionService.OpenDoor();
|
||||
if (!result.Success)
|
||||
{
|
||||
MessageBox.Show($"Open door failed: {result.ErrorMessage}", "Error",
|
||||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Open door failed.");
|
||||
MessageBox.Show($"Open door error: {ex.Message}", "Error",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteCloseDoor()
|
||||
{
|
||||
try
|
||||
{
|
||||
var motionService = _containerProvider.Resolve<IMotionControlService>();
|
||||
var result = motionService.CloseDoor();
|
||||
if (!result.Success)
|
||||
{
|
||||
MessageBox.Show($"Close door failed: {result.ErrorMessage}", "Error",
|
||||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Close door failed.");
|
||||
MessageBox.Show($"Close door error: {ex.Message}", "Error",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteOpenDetectorConfig()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -138,12 +138,14 @@
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<telerik:RadRibbonButton
|
||||
telerik:ScreenTip.Title="开门"
|
||||
Command="{Binding OpenDoorCommand}"
|
||||
telerik:ScreenTip.Title="Open Door"
|
||||
Size="Medium"
|
||||
SmallImage="/Assets/Icons/opendoor.png"
|
||||
Text="开门" />
|
||||
<telerik:RadRibbonButton
|
||||
telerik:ScreenTip.Title="关门"
|
||||
Command="{Binding CloseDoorCommand}"
|
||||
telerik:ScreenTip.Title="Close Door"
|
||||
Size="Medium"
|
||||
SmallImage="/Assets/Icons/closedoor.png"
|
||||
Text="关门" />
|
||||
|
||||
Reference in New Issue
Block a user