From bb6c1e03e5b2a678f12c37090d113ceb435210a1 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 25 Sep 2024 16:11:55 +0800 Subject: [PATCH] =?UTF-8?q?add-=E6=B7=BB=E5=8A=A0AGV=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8E=E7=8A=B6=E6=80=81=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converter/AgvAndTask/AgvNameConverter.cs | 34 ++++ .../AgvAndTask/TaskStatusConverter .cs | 34 ++++ SlnMesnac.WPF/MainWindow.xaml | 4 +- SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml | 55 ++++--- .../Page/AgvAndTaskMonitorPage.xaml.cs | 2 +- SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs | 1 - .../ViewModel/AgvAndTaskViewModel.cs | 153 ++++++++++++++++++ .../ViewModel/MainWindowViewModel.cs | 8 +- 8 files changed, 262 insertions(+), 29 deletions(-) create mode 100644 SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs create mode 100644 SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs create mode 100644 SlnMesnac.WPF/ViewModel/AgvAndTaskViewModel.cs diff --git a/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs b/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs new file mode 100644 index 0000000..c6b8ee2 --- /dev/null +++ b/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace SlnMesnac.WPF.Converter.AgvAndTask +{ + public class AgvNameConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is long nextPointId) // 检查是否为 long 类型 + { + return nextPointId switch + { + 8 => "3楼叉车", + 9 => "2楼叉车", + _ => "未知AGV", + }; + } + + return "未知AGV"; // 如果值不是 long 类型,返回未知AGV + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs b/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs new file mode 100644 index 0000000..95940d9 --- /dev/null +++ b/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace SlnMesnac.WPF.Converter.AgvAndTask +{ + public class TaskStatusConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is int status) + { + return status switch + { + 0 => "未下发", + 1 => "已下发", + > 1 and < 6 => "执行中", + >= 6 => "执行完成", + _ => "未知状态", + }; + } + return "未知状态"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 2552eee..8333b75 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -65,8 +65,8 @@