2025-03-17 01:56:27 +08:00
|
|
|
using System.Collections.ObjectModel;
|
2025-03-19 20:29:11 +08:00
|
|
|
using System.Windows.Threading;
|
2025-03-17 01:56:27 +08:00
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
using Seyounth.Hyosung.Data.Models;
|
2025-03-17 03:26:29 +08:00
|
|
|
using Seyounth.Hyosung.Data.Models.Plc;
|
2025-03-17 01:56:27 +08:00
|
|
|
using Seyounth.Hyosung.Data.Services;
|
2025-03-17 02:37:39 +08:00
|
|
|
using Seyounth.Hyosung.Runtime;
|
|
|
|
using Seyounth.Hyosung.Runtime.Models;
|
2025-03-17 01:56:27 +08:00
|
|
|
|
|
|
|
namespace Seyounth.Hyosung.ViewModels;
|
|
|
|
|
|
|
|
public partial class HomeViewModel : ObservableObject
|
|
|
|
{
|
2025-03-17 02:37:39 +08:00
|
|
|
[ObservableProperty] private StackStationModel _stack1;
|
2025-03-17 01:56:27 +08:00
|
|
|
|
2025-03-17 02:37:39 +08:00
|
|
|
[ObservableProperty] private StackStationModel _stack2;
|
2025-03-17 01:56:27 +08:00
|
|
|
|
|
|
|
[ObservableProperty] private ObservableCollection<Variety> _varieties;
|
|
|
|
|
|
|
|
[ObservableProperty] private List<string> _yarnCarTypes;
|
2025-03-17 02:37:39 +08:00
|
|
|
|
2025-03-17 01:56:27 +08:00
|
|
|
[ObservableProperty] private Variety _selectedVariety;
|
|
|
|
|
2025-03-17 03:26:29 +08:00
|
|
|
[ObservableProperty] private PackLineOption _packLineOption;
|
|
|
|
|
2025-03-17 02:37:39 +08:00
|
|
|
private readonly IHyosungRuntime _runtime;
|
|
|
|
|
|
|
|
public HomeViewModel(IVarietyService varietyService, IHyosungRuntime runtime)
|
2025-03-17 01:56:27 +08:00
|
|
|
{
|
2025-03-17 03:26:29 +08:00
|
|
|
PackLineOption = runtime.PackLineOption;
|
2025-03-17 02:37:39 +08:00
|
|
|
_runtime = runtime;
|
|
|
|
_stack1 = _runtime.Stack1;
|
|
|
|
_stack2 = _runtime.Stack2;
|
2025-03-17 01:56:27 +08:00
|
|
|
_yarnCarTypes = new List<string>();
|
|
|
|
_yarnCarTypes.Add("A");
|
|
|
|
_yarnCarTypes.Add("B");
|
|
|
|
_yarnCarTypes.Add("C");
|
|
|
|
_yarnCarTypes.Add("D");
|
|
|
|
_varieties = new ObservableCollection<Variety>(varietyService.GetAll());
|
2025-03-19 20:29:11 +08:00
|
|
|
DispatcherTimer timer = new DispatcherTimer();
|
|
|
|
timer = new DispatcherTimer();
|
|
|
|
// 设置定时器间隔,这里设置为 1 秒,可根据实际需求调整
|
|
|
|
timer.Interval = TimeSpan.FromSeconds(1);
|
|
|
|
// 为定时器的 Tick 事件添加处理方法
|
|
|
|
timer.Tick += Timer_Tick;
|
|
|
|
// 启动定时器
|
|
|
|
timer.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Timer_Tick(object? sender, EventArgs e)
|
|
|
|
{
|
|
|
|
Stack1 = _runtime.Stack1;
|
|
|
|
Stack2 = _runtime.Stack2;
|
2025-03-20 19:33:55 +08:00
|
|
|
PackLineOption = _runtime.PackLineOption;
|
2025-03-17 01:56:27 +08:00
|
|
|
}
|
|
|
|
}
|