From ddba87a8d4ba28474da35c2b086be46e2a0b942f Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 12 Jan 2024 10:47:43 +0800 Subject: [PATCH] =?UTF-8?q?change-=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=EF=BC=8C=E9=97=A8=E4=BD=93=EF=BC=8C=E7=AE=B1=E4=BD=93=EF=BC=8C?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E7=BB=91=E5=AE=9A=E7=95=8C=E9=9D=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/MainWindowViewModel.cs | 41 +++++++++++++++++- Aucma.Core.BoxFoam/Views/MainWindow.xaml | 11 +++-- Aucma.Core.BoxFoam/appsettings.json | 2 +- .../ViewModels/MainWindowViewModel.cs | 42 +++++++++++++++++++ Aucma.Core.CodeBinding/Views/MainWindow.xaml | 15 ++++--- .../ViewModels/MainWindowViewModel.cs | 41 ++++++++++++++++++ Aucma.Core.DoorFoam/Views/MainWindow.xaml | 15 ++++--- .../ViewModels/MainWindowViewModel.cs | 42 +++++++++++++++++++ .../Views/MainWindow.xaml | 15 ++++--- 9 files changed, 204 insertions(+), 20 deletions(-) diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index e9238fdf..5e6ed735 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -12,6 +12,7 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Threading; namespace Aucma.Core.BoxFoam.ViewModels { @@ -29,10 +30,17 @@ namespace Aucma.Core.BoxFoam.ViewModels FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView(); - + public MainWindowViewModel() { UserContent = firstPage; + + // 创建一个DispatcherTimer对象 + DispatcherTimer timer = new DispatcherTimer(); + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += Timer_Tick; + timer.Start(); + Task.Run(() => { init(); @@ -419,5 +427,36 @@ namespace Aucma.Core.BoxFoam.ViewModels }); } #endregion + + public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + public string CurrentDateTime + { + get => _currentDateTime; + set => SetProperty(ref _currentDateTime, value); + } + + public string _shiftStr = string.Empty; + public string ShiftStr + { + get => _shiftStr; + set => SetProperty(ref _shiftStr, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + DateTime now = DateTime.Now; + + // 判断当前是否是白班时间段 + if (now.Hour >= 8 && now.Hour < 20) + { + ShiftStr = $"白班 08点-20点"; + } + else + { + + ShiftStr = $"夜班 20点-08点"; + } + CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } } } diff --git a/Aucma.Core.BoxFoam/Views/MainWindow.xaml b/Aucma.Core.BoxFoam/Views/MainWindow.xaml index 03fd352d..7846fe06 100644 --- a/Aucma.Core.BoxFoam/Views/MainWindow.xaml +++ b/Aucma.Core.BoxFoam/Views/MainWindow.xaml @@ -38,12 +38,17 @@ - + + + + + + + diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 1fb6db0c..6eb8669d 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -226,7 +226,7 @@ "EquipName": "foamMachinePlc", "PlcType": "Siemens", "Enabled": true, - "IP": "127.0.0.1", + "IP": "10.10.93.180", //"IP": "127.0.0.1", "Port": 102 } diff --git a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs index 396078ac..3214fc5e 100644 --- a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.DependencyInjection; using Admin.Core.Model; using Admin.Core.Tasks; using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData; +using System.Windows.Threading; namespace Aucma.Core.CodeBinding.ViewModels { @@ -40,6 +41,14 @@ namespace Aucma.Core.CodeBinding.ViewModels { UserContent = firstPage; + + // 创建一个DispatcherTimer对象 + DispatcherTimer timer = new DispatcherTimer(); + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += Timer_Tick; + timer.Start(); + + Job_AllState_Quartz.RefreshStateEvent += RefreshStatus; } @@ -402,5 +411,38 @@ namespace Aucma.Core.CodeBinding.ViewModels }); } #endregion + + public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + public string CurrentDateTime + { + get => _currentDateTime; + set => SetProperty(ref _currentDateTime, value); + } + + public string _shiftStr = string.Empty; + public string ShiftStr + { + get => _shiftStr; + set => SetProperty(ref _shiftStr, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + DateTime now = DateTime.Now; + + // 判断当前是否是白班时间段 + if (now.Hour >= 8 && now.Hour < 20) + { + ShiftStr = $"白班 08点-20点"; + } + else + { + + ShiftStr = $"夜班 20点-08点"; + } + CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + } } diff --git a/Aucma.Core.CodeBinding/Views/MainWindow.xaml b/Aucma.Core.CodeBinding/Views/MainWindow.xaml index f7d39b87..d8fa3b02 100644 --- a/Aucma.Core.CodeBinding/Views/MainWindow.xaml +++ b/Aucma.Core.CodeBinding/Views/MainWindow.xaml @@ -36,14 +36,19 @@ - + + + + + + + + diff --git a/Aucma.Core.DoorFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.DoorFoam/ViewModels/MainWindowViewModel.cs index d41f6c4e..43864991 100644 --- a/Aucma.Core.DoorFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.DoorFoam/ViewModels/MainWindowViewModel.cs @@ -11,6 +11,7 @@ using Admin.Core.Common; using Aucma.Core.Scanner; using System.Linq; using Aucma.Core.HwPLc; +using System.Windows.Threading; namespace Aucma.Core.DoorFoam.ViewModels { @@ -24,6 +25,13 @@ namespace Aucma.Core.DoorFoam.ViewModels public MainWindowViewModel() { UserContent = firstPage; + + // 创建一个DispatcherTimer对象 + DispatcherTimer timer = new DispatcherTimer(); + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += Timer_Tick; + timer.Start(); + init(); } public void init() @@ -432,5 +440,38 @@ namespace Aucma.Core.DoorFoam.ViewModels }); } #endregion + + public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + public string CurrentDateTime + { + get => _currentDateTime; + set => SetProperty(ref _currentDateTime, value); + } + + public string _shiftStr = string.Empty; + public string ShiftStr + { + get => _shiftStr; + set => SetProperty(ref _shiftStr, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + DateTime now = DateTime.Now; + + // 判断当前是否是白班时间段 + if (now.Hour >= 8 && now.Hour < 20) + { + ShiftStr = $"白班 08点-20点"; + } + else + { + + ShiftStr = $"夜班 20点-08点"; + } + CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + } } diff --git a/Aucma.Core.DoorFoam/Views/MainWindow.xaml b/Aucma.Core.DoorFoam/Views/MainWindow.xaml index fcb10573..d16946c5 100644 --- a/Aucma.Core.DoorFoam/Views/MainWindow.xaml +++ b/Aucma.Core.DoorFoam/Views/MainWindow.xaml @@ -41,14 +41,19 @@ - + + + + + + + + diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs index 2ab0e351..84d837b9 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs @@ -28,6 +28,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels public MainWindowViewModel() { UserContent = firstPage; + // 创建一个DispatcherTimer对象 + DispatcherTimer timer = new DispatcherTimer(); + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += Timer_Tick; + timer.Start(); + Job_AllState_Quartz.RefreshStateEvent += RefreshStatus; } @@ -425,6 +431,42 @@ namespace Aucma.Core.ProductOffLine.ViewModels } }); } + + + public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + public string CurrentDateTime + { + get => _currentDateTime; + set => SetProperty(ref _currentDateTime, value); + } + + public string _shiftStr = string.Empty; + public string ShiftStr + { + get => _shiftStr; + set => SetProperty(ref _shiftStr, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + DateTime now = DateTime.Now; + + // 判断当前是否是白班时间段 + if (now.Hour >= 8 && now.Hour < 20) + { + ShiftStr = $"白班 08点-20点"; + } + else + { + + ShiftStr = $"夜班 20点-08点"; + } + CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + + + #endregion diff --git a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml index aebf80f9..0247f58d 100644 --- a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml +++ b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml @@ -36,14 +36,19 @@ - + + + + + + + +