|
@@ -6,6 +6,7 @@ using HardwareData;
|
|
|
using RealtimeData;
|
|
|
using RTCommunicatorBase;
|
|
|
using System.Collections.Concurrent;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
using System.IO;
|
|
|
|
|
|
namespace AlarmInfoServerSim.ViewModels
|
|
@@ -43,9 +44,20 @@ namespace AlarmInfoServerSim.ViewModels
|
|
|
[ObservableProperty]
|
|
|
private float _floor;
|
|
|
|
|
|
+ [ObservableProperty]
|
|
|
+ private ObservableCollection<string> _receivingTime;
|
|
|
+
|
|
|
+ [ObservableProperty]
|
|
|
+ [NotifyCanExecuteChangedFor(nameof(SendInfoCommand))]
|
|
|
+ private bool _hasConnection;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public WorkAreaViewModel(IInfoSendingService infoSendingService)
|
|
|
{
|
|
|
_infoSendingService = infoSendingService;
|
|
|
+ _infoSendingService.ConnectionStatusChanged += OnConnectionStatusChanged;
|
|
|
+ _infoSendingService.DataReceived += OnDataReceived;
|
|
|
|
|
|
_hardwares = new Hardwares();
|
|
|
HardwareFileLoader hardwareFileLoader = new HardwareFileLoader(_hardwares);
|
|
@@ -55,10 +67,9 @@ namespace AlarmInfoServerSim.ViewModels
|
|
|
_mini8Channel = [];
|
|
|
|
|
|
_alarmTypes = Enum.GetValues<AlarmType>();
|
|
|
+ _receivingTime = [];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
partial void OnSelectedMini8IndexChanged(int value)
|
|
|
{
|
|
|
SelectedChannelIndex = -1;
|
|
@@ -72,7 +83,7 @@ namespace AlarmInfoServerSim.ViewModels
|
|
|
SelectedAlarmTypeIndex = -1;
|
|
|
}
|
|
|
|
|
|
- [RelayCommand]
|
|
|
+ [RelayCommand(CanExecute = nameof(HasConnection))]
|
|
|
private void SendInfo()
|
|
|
{
|
|
|
if (SelectedMini8Index > -1 && SelectedChannelIndex > -1 && SelectedAlarmTypeIndex > -1)
|
|
@@ -89,5 +100,18 @@ namespace AlarmInfoServerSim.ViewModels
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void OnConnectionStatusChanged(object? sender, bool e)
|
|
|
+ {
|
|
|
+ App.Current.Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ HasConnection = e;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnDataReceived(object? sender, (ushort, TLVProtocal.TlvData) e)
|
|
|
+ {
|
|
|
+ ReceivingTime.Add(e.Item2.DateTime.ToString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|