feat: 新增成都东站检票口立柱看板

This commit is contained in:
denglihong2007
2025-05-01 02:12:43 +08:00
parent cf207e5b48
commit 7761d08528
9 changed files with 177 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CRSim.Core.Models;
using CRSim.Core.Services;
using CRSim.ScreenSimulator.Models;
using System.Windows;
namespace CRSim.ScreenSimulator.ViewModels.ChengduDong
{
public partial class PillarTicketCheckScreenViewModel : ScreenViewModel
{
[ObservableProperty]
private TrainInfo _firstTrain = new();
[ObservableProperty]
private TrainInfo _secondTrain = new();
[ObservableProperty]
private TrainInfo _checkingTrain = new();
public PillarTicketCheckScreenViewModel(ITimeService timeService, ISettingsService settingsService)
: base(timeService, settingsService)
{
StationType = StationType.Departure;
timeService.RefreshSecondsElapsed += RefreshDisplay;
Initialize();
}
private async void Initialize()
{
await WaitForDataLoadAsync();
RefreshDisplay(null, null);
}
private void RefreshDisplay(object? sender, EventArgs e)
{
Application.Current.Dispatcher.Invoke(() =>
{
var now = _timeService.GetDateTimeNow();
var departureTime = TrainInfo[0].DepartureTime!.Value;
TimeSpan checkInStartOffset = TrainInfo[0].ArrivalTime is DateTime
? _settings.PassingCheckInAdvanceDuration // 过路站
: _settings.DepartureCheckInAdvanceDuration; // 始发站
bool checking = now > departureTime - checkInStartOffset && now < departureTime - _settings.StopCheckInAdvanceDuration;
if (checking)
{
CheckingTrain = TrainInfo[0];
FirstTrain = TrainInfo.ElementAtOrDefault(1);
SecondTrain = TrainInfo.ElementAtOrDefault(2);
}
else
{
CheckingTrain = null;
FirstTrain = TrainInfo.ElementAtOrDefault(0);
SecondTrain = TrainInfo.ElementAtOrDefault(1);
}
});
}
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels
{
public partial class ScreenViewModel : ObservableObject
{
private readonly ITimeService _timeService;
public readonly ITimeService _timeService;
public readonly Settings _settings;
private readonly TaskCompletionSource<bool> _dataLoaded = new();
[ObservableProperty]