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 @@
-
-
+
+
diff --git a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml
index 332fd5c..7b709d9 100644
--- a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml
+++ b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml
@@ -4,8 +4,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
- mc:Ignorable="d"
+ mc:Ignorable="d" FontFamily="Microsoft YaHei"
+ xmlns:local1="clr-namespace:SlnMesnac.WPF.Converter.AgvAndTask"
d:DesignHeight="750" d:DesignWidth="1920" Background="Transparent">
+
+
+
+
+
+
@@ -25,26 +32,26 @@
-
+
-
-
+
-
-
+
+
-
+
-
+
@@ -59,26 +66,28 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
diff --git a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml.cs
index 6c341cc..4ab8282 100644
--- a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml.cs
+++ b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml.cs
@@ -25,7 +25,7 @@ namespace SlnMesnac.WPF.Page
{
InitializeComponent();
- this.DataContext = new ProdStatisticsViewModel();
+ this.DataContext = new AgvAndTaskViewModel();
}
}
}
diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
index b56d7f0..0bfccb7 100644
--- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
+++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
@@ -2151,7 +2151,6 @@ namespace SlnMesnac.WPF.Page
}));
-
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1019;
machineStatusDto.status = signal1_2 && signal2_2;
diff --git a/SlnMesnac.WPF/ViewModel/AgvAndTaskViewModel.cs b/SlnMesnac.WPF/ViewModel/AgvAndTaskViewModel.cs
new file mode 100644
index 0000000..daf7696
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/AgvAndTaskViewModel.cs
@@ -0,0 +1,153 @@
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+using Microsoft.Extensions.DependencyInjection;
+using SlnMesnac.Business;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Model.dto;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.WPF.ViewModel
+* 唯一标识:14008fcc-0a31-4f1e-bc80-9f9ea84d3de5
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-10 16:18:57
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.WPF.ViewModel
+{
+ ///
+ /// 生产统计ViewModel
+ ///
+ internal class AgvAndTaskViewModel : ViewModelBase
+ {
+ private readonly ISqlSugarClient? sqlSugarClient;
+ // private readonly ProdCompletionBusiness _prodCompletionBusiness;
+
+ private System.Timers.Timer refreshTimer = new System.Timers.Timer(5000);
+ public AgvAndTaskViewModel()
+ {
+ sqlSugarClient = App.ServiceProvider.GetService();
+ // _prodCompletionBusiness = App.ServiceProvider.GetService();
+
+ // DeletePalletCommand = new RelayCommand(DeletePallet);
+
+ // DeleteBarCodeCommand = new RelayCommand (DeleteBarCode);
+
+
+ // _palletStowBusiness.RefreshPalletTaskListEvent += RefreshPalletTaskDataGrid;
+
+
+ refreshTimer.Elapsed += OnTimedEvent;
+ refreshTimer.AutoReset = true; // 设置为自动重置
+ refreshTimer.Enabled = true; // 启用定时器
+
+
+
+ }
+ private async void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
+ {
+
+ await RefreshWcsAgvStatusDataGrid();
+
+ await RefreshWcsTaskDataGrid();
+ }
+
+
+
+ #region 参数定义
+ ///
+ /// AGV任务队列DataGrid
+ ///
+ private ObservableCollection wcsTaskDataGrid = new ObservableCollection();
+
+ public ObservableCollection WcsTaskDataGrid
+ {
+ get { return wcsTaskDataGrid; }
+ set { wcsTaskDataGrid = value; RaisePropertyChanged(() => WcsTaskDataGrid); }
+
+ }
+
+ ///
+ /// AGV状态队列DataGrid
+ ///
+ private ObservableCollection wcsAgvStatusDataGrid = new ObservableCollection();
+
+ public ObservableCollection WcsAgvStatusDataGrid
+ {
+ get { return wcsAgvStatusDataGrid; }
+ set { wcsAgvStatusDataGrid = value; RaisePropertyChanged(() => WcsAgvStatusDataGrid); }
+
+ }
+ #endregion
+
+ #region 事件定义
+
+ // public RelayCommand DeletePalletCommand { get;set; }
+
+ // public RelayCommand DeleteBarCodeCommand { get; set; }
+
+ #endregion
+
+ ///
+ /// 刷新AGV状态信息
+ ///
+ ///
+ private async Task RefreshWcsAgvStatusDataGrid()
+ {
+ List agvList = await sqlSugarClient.AsTenant().GetConnection("mes").Queryable().ToListAsync();
+ await App.Current.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ WcsAgvStatusDataGrid.Clear();
+ foreach (var agv in agvList)
+ {
+ WcsAgvStatusDataGrid.Add(agv);
+ }
+ }));
+
+ }
+
+ ///
+ /// 刷新AGV状态信息
+ ///
+ ///
+ private async Task RefreshWcsTaskDataGrid()
+ {
+ List agvList = await sqlSugarClient.AsTenant().GetConnection("mes").Queryable().Where(x => x.NextPointId == 8 || x.NextPointId==9).ToListAsync();
+ await App.Current.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ WcsTaskDataGrid.Clear();
+ foreach (var agv in agvList)
+ {
+ WcsTaskDataGrid.Add(agv);
+ }
+ }));
+
+ }
+
+
+
+
+
+ }
+}
diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
index adda4ed..3d6268e 100644
--- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
@@ -25,6 +25,7 @@ namespace SlnMesnac.WPF.ViewModel
private readonly GenerateControl generateControl = new GenerateControl();
private readonly BaseConfigInfoPage configInfoPage = new BaseConfigInfoPage();
private readonly RecipeManagePage recipeManagePage = new RecipeManagePage();
+ private readonly AgvAndTaskMonitorPage agvAndTaskMonitorPage = new AgvAndTaskMonitorPage();
#region 参数定义
///
@@ -97,10 +98,10 @@ namespace SlnMesnac.WPF.ViewModel
ControlOnClickCommand = new RelayCommand