Browse Source

Refactor AlarmInfoServerSim tool.

SenGao 3 weeks ago
parent
commit
068bb9707e
24 changed files with 300 additions and 245 deletions
  1. 30 0
      Tools/AlarmInfoServerSim/AlarmInfoServerSim.csproj
  2. 0 1
      Tools/AlarmInfoServerSim/App.xaml.cs
  3. 7 9
      Tools/AlarmInfoServerSim/Services/IInfoSendingService.cs
  4. 7 10
      Tools/AlarmInfoServerSim/Services/ISharedConfig.cs
  5. 83 73
      Tools/AlarmInfoServerSim/Services/InfoSendingService.cs
  6. 22 7
      Tools/AlarmInfoServerSim/Services/SharedConfig.cs
  7. 13 0
      Tools/AlarmInfoServerSim/Settings/Base/BasicInfo.xml
  8. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U2.json
  9. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U3.json
  10. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U4.json
  11. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U5.json
  12. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U7.json
  13. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U8.json
  14. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U9.json
  15. 1 0
      Tools/AlarmInfoServerSim/Settings/Hardwares/HTR4 - U6.json
  16. 4 10
      Tools/AlarmInfoServerSim/ViewModels/LogBarViewModel.cs
  17. 7 6
      Tools/AlarmInfoServerSim/ViewModels/MainWindowViewModel.cs
  18. 31 41
      Tools/AlarmInfoServerSim/ViewModels/StatusBarViewModel.cs
  19. 78 77
      Tools/AlarmInfoServerSim/ViewModels/WorkAreaViewModel.cs
  20. 1 1
      Tools/AlarmInfoServerSim/Views/LogBar.xaml.cs
  21. 1 1
      Tools/AlarmInfoServerSim/Views/MainWindow.xaml
  22. 1 1
      Tools/AlarmInfoServerSim/Views/StatusBar.xaml.cs
  23. 6 7
      Tools/AlarmInfoServerSim/Views/WorkArea.xaml
  24. 1 1
      Tools/AlarmInfoServerSim/Views/WorkArea.xaml.cs

+ 30 - 0
Tools/AlarmInfoServerSim/AlarmInfoServerSim.csproj

@@ -23,4 +23,34 @@
     <ProjectReference Include="..\..\TLVProtocal\TLV_Protocol.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Update="Settings\Base\BasicInfo.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR1 - U2.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR1 - U3.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR1 - U4.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR1 - U5.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR2 - U7.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR2 - U8.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR2 - U9.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="Settings\Hardwares\HTR4 - U6.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
 </Project>

+ 0 - 1
Tools/AlarmInfoServerSim/App.xaml.cs

@@ -1,7 +1,6 @@
 using AlarmInfoServerSim.Services;
 using AlarmInfoServerSim.Views;
 using System.Windows;
-using TLVProtocal;
 
 namespace AlarmInfoServerSim
 {

+ 7 - 9
Tools/AlarmInfoServerSim/Services/IInfoSendingService.cs

@@ -2,15 +2,13 @@
 using TLVProtocal;
 using UniversalNetFrame451.IO;
 
-namespace AlarmInfoServerSim.Services
+namespace AlarmInfoServerSim.Services;
+
+public interface IInfoSendingService
 {
-    public interface IInfoSendingService
-    {
-        bool Open();
-        bool Send(byte tag, ST_ALARM alarm);
+    void Open();
+    void Send(byte tag, ST_ALARM alarm);
 
-        event EventHandler<bool>? ConnectionStatusChanged;
-        event EventHandler<TcpConnection>? TcpConnectionChanged;
-        event EventHandler<(ushort, TlvData)>? DataReceived;
-    }
+    event EventHandler<(bool, TcpConnection)>? ConnectionChanged;
+    event EventHandler<(ushort, TlvData)>? DataReceived;
 }

+ 7 - 10
Tools/AlarmInfoServerSim/Services/ISharedConfig.cs

@@ -1,14 +1,11 @@
 using ConfigOperator;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using RealtimeData;
 
-namespace AlarmInfoServerSim.Services
+namespace AlarmInfoServerSim.Services;
+
+public interface ISharedConfig
 {
-    public interface ISharedConfig
-    {
-        BasicInfo? BasicInfo { get; }
-    }
+    BasicInfo? BasicInfo { get; }
+
+    Hardwares? Hardwares { get; }
 }

+ 83 - 73
Tools/AlarmInfoServerSim/Services/InfoSendingService.cs

@@ -1,111 +1,121 @@
 using RTCommunicatorBase;
-using System.Text;
 using TLVProtocal;
 using UniversalNetFrame451.IO;
 
-namespace AlarmInfoServerSim.Services
+namespace AlarmInfoServerSim.Services;
+
+public class InfoSendingService : IInfoSendingService, ITlvProvider, IDisposable
 {
-    public class InfoSendingService : IInfoSendingService, ITlvProvider, IDisposable
-    {
-        private readonly ISharedConfig _sharedConfig;
-        private readonly ITlvCommunicatorServer _server;
+    private readonly ISharedConfig _sharedConfig;
+    private readonly ITlvCommunicatorServer _server;
 
-        private bool _isConnected = false;
-        private bool disposedValue;
+    private bool _isConnected;
+    private bool disposedValue;
 
-        public InfoSendingService(ISharedConfig sharedConfig) 
+    public InfoSendingService(ISharedConfig sharedConfig) 
+    {
+        _sharedConfig= sharedConfig;
+
+        _server = TlvFactory.GetTlvServer();
+        if(!_server.Initialize(this))
         {
-            _sharedConfig= sharedConfig;
+            throw new InvalidOperationException("Failed to initialize tcp server");
+        }
 
-            _server = TlvFactory.GetTlvServer();
-            _server.Initialize(this);
+        Open();
+    }
 
-            Open();
-        }
+    public event EventHandler<(bool, TcpConnection)>? ConnectionChanged;
 
-        public event EventHandler<bool>? ConnectionStatusChanged;
-        public event EventHandler<TcpConnection>? TcpConnectionChanged;
-        public event EventHandler<(ushort, TlvData)>? DataReceived;
+    public event EventHandler<(ushort, TlvData)>? DataReceived;
 
-        public bool Open()
+    public void Open()
+    {
+        if(_sharedConfig.BasicInfo is null)
         {
-            if (_sharedConfig.BasicInfo is not null)
-            {
-                return _server.Open(_sharedConfig.BasicInfo.RTServerAddress, _sharedConfig.BasicInfo.RTServerPort);
-            }
-            return false;
+            //log
+            return;
         }
 
-        public bool Send(byte tag, ST_ALARM alarm)
+        if (!_server.Open(_sharedConfig.BasicInfo.RTServerAddress, _sharedConfig.BasicInfo.RTServerPort))
         {
-            if (_isConnected)
-            {
-                return _server.Send(tag, alarm);
-            }
-            return false;
+            //log
         }
+    }
 
-        public void Connected(TcpConnection connection)
+    public void Send(byte tag, ST_ALARM alarm)
+    {
+        if(!_isConnected)
         {
-            _isConnected = true;
-            ConnectionStatusChanged?.Invoke(null, _isConnected);
-            TcpConnectionChanged?.Invoke(null, connection);
+            //log
+            return;
         }
 
-        public void Disconnected(TcpConnection connection)
+        if(!_server.Send(tag, alarm))
         {
-            _isConnected = false;
-            ConnectionStatusChanged?.Invoke(null, _isConnected);
-            TcpConnectionChanged?.Invoke(null, connection);
+            //log
         }
+    }
 
-        public void Received(TlvData data)
-        {
-            if (data.RawData is null || data.RawData.Length == 0)
-            {
-                //Log
-                return;
-            }
+    public void Connected(TcpConnection connection)
+    {
+        _isConnected = true;
+        ConnectionChanged?.Invoke(null, (_isConnected, connection));
+    }
 
-            if(data.Tag==1)
-            {
-                DataReceived?.Invoke(null,(data.Tag, data));
-            }
+    public void Disconnected(TcpConnection connection)
+    {
+        _isConnected = false;
+        ConnectionChanged?.Invoke(null, (_isConnected, connection));
+    }
+
+    public void Received(TlvData data)
+    {
+        if (data.RawData is null || data.RawData.Length == 0)
+        {
+            //Log
+            return;
         }
 
-        public TlvData RequestReply(TlvData tlvData)
+        if(data.Tag==1)
         {
-            throw new NotImplementedException();
+            DataReceived?.Invoke(null,(data.Tag, data));
+            //log
         }
+    }
 
-        protected virtual void Dispose(bool disposing)
+    public TlvData RequestReply(TlvData tlvData)
+    {
+        throw new NotImplementedException();
+    }
+
+    protected virtual void Dispose(bool disposing)
+    {
+        if (!disposedValue)
         {
-            if (!disposedValue)
+            if (disposing)
             {
-                if (disposing)
-                {
-                    // TODO: 释放托管状态(托管对象)
-                    _server.Dispose();
-                }
-
-                // TODO: 释放未托管的资源(未托管的对象)并重写终结器
-                // TODO: 将大型字段设置为 null
-                disposedValue = true;
+                // TODO: dispose managed state (managed objects)
+                _server.Dispose();
             }
+
+            // TODO: free unmanaged resources (unmanaged objects) and override finalizer
+            // TODO: set large fields to null
+            disposedValue = true;
         }
+    }
 
-        // // TODO: 仅当“Dispose(bool disposing)”拥有用于释放未托管资源的代码时才替代终结器
-        // ~SendInfoService()
-        // {
-        //     // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
-        //     Dispose(disposing: false);
-        // }
+    // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
+    // ~InfoSendingService()
+    // {
+    //     // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
+    //     Dispose(disposing: false);
+    // }
 
-        public void Dispose()
-        {
-            // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
-            Dispose(disposing: true);
-            GC.SuppressFinalize(this);
-        }
+    public void Dispose()
+    {
+        // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
+        Dispose(disposing: true);
+        GC.SuppressFinalize(this);
     }
 }

+ 22 - 7
Tools/AlarmInfoServerSim/Services/SharedConfig.cs

@@ -1,17 +1,32 @@
 using ConfigOperator;
+using RealtimeData;
 using System.IO;
 
-namespace AlarmInfoServerSim.Services
+namespace AlarmInfoServerSim.Services;
+
+public class SharedConfig : ISharedConfig
 {
-    public class SharedConfig : ISharedConfig
+    private BasicInfo? _basicInfo;
+    private Hardwares? _hardwares;
+    public SharedConfig()
     {
-        private BasicInfo? _basicInfo;
-        public SharedConfig() 
+        string basicInfoPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings", "Base", "BasicInfo.xml");
+        if (!BaseConfigFileLoader.Load(basicInfoPath, out _basicInfo) || _basicInfo is null)
         {
-            string basicInfoPath = Path.Combine(new DirectoryInfo(Paths.LocalPath!)!.Parent!.Parent!.FullName, "Settings", "Base", "BasicInfo.xml");
-            BaseConfigFileLoader.Load(basicInfoPath, out _basicInfo);
+            //log
         }
 
-        public BasicInfo? BasicInfo => _basicInfo;
+        string hardwaresPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings", "Hardwares");
+        _hardwares = new Hardwares();
+        HardwareFileLoader hardwareFileLoader = new HardwareFileLoader(_hardwares);
+        if (!hardwareFileLoader.Load(hardwaresPath))
+        {
+            _hardwares = null;
+            //log
+        }
     }
+
+    public BasicInfo? BasicInfo => _basicInfo;
+
+    public Hardwares? Hardwares => _hardwares;
 }

+ 13 - 0
Tools/AlarmInfoServerSim/Settings/Base/BasicInfo.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<BasicInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	<DBConnectionString>Database=postgres;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True</DBConnectionString>
+	<ServerAddress>127.0.0.1</ServerAddress>
+	<ServerPort>55004</ServerPort>
+	<SelectedDisplay>2</SelectedDisplay>
+	<RTServerAddress>127.0.0.1</RTServerAddress>
+	<RTServerPort>50052</RTServerPort>
+	<GasPanelWindowName>FurnaceGasPanel</GasPanelWindowName>
+	<DBClearTime>2025-05-27T11:28:46.4646633+08:00</DBClearTime>
+	<DBKeepRange>180</DBKeepRange>
+	<AlarmDelaySeconds>30</AlarmDelaySeconds>
+</BasicInfo>

File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U2.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U3.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U4.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR1 - U5.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U7.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U8.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR2 - U9.json


File diff suppressed because it is too large
+ 1 - 0
Tools/AlarmInfoServerSim/Settings/Hardwares/HTR4 - U6.json


+ 4 - 10
Tools/AlarmInfoServerSim/ViewModels/LogBarViewModel.cs

@@ -1,17 +1,11 @@
 using CommunityToolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
-namespace AlarmInfoServerSim.ViewModels
+namespace AlarmInfoServerSim.ViewModels;
+
+public class LogBarViewModel : ObservableObject
 {
-    public class LogBarViewModel : ObservableObject
+    public LogBarViewModel() 
     {
-        public LogBarViewModel() 
-        {
 
-        }
     }
 }

+ 7 - 6
Tools/AlarmInfoServerSim/ViewModels/MainWindowViewModel.cs

@@ -1,10 +1,11 @@
-namespace AlarmInfoServerSim.ViewModels
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace AlarmInfoServerSim.ViewModels;
+
+public class MainWindowViewModel : ObservableObject
 {
-    public class MainWindowViewModel
+    public MainWindowViewModel()
     {
-        public MainWindowViewModel()
-        {
-            
-        }
+        
     }
 }

+ 31 - 41
Tools/AlarmInfoServerSim/ViewModels/StatusBarViewModel.cs

@@ -1,56 +1,46 @@
 using AlarmInfoServerSim.Services;
 using CommunityToolkit.Mvvm.ComponentModel;
 
-namespace AlarmInfoServerSim.ViewModels
+namespace AlarmInfoServerSim.ViewModels;
+
+public partial class StatusBarViewModel : ObservableObject
 {
-    public partial class StatusBarViewModel : ObservableObject
-    {
-        private readonly ISharedConfig _sharedConfig;
-        private readonly IInfoSendingService _sendInfoService;
+    private readonly ISharedConfig _sharedConfig;
+    private readonly IInfoSendingService _infoSendingService;
 
-        [ObservableProperty]
-        private string _status;
+    [ObservableProperty]
+    private string _status;
 
-        [ObservableProperty]
-        private string _remoteIp;
+    [ObservableProperty]
+    private string _remoteIp;
 
-        [ObservableProperty]
-        private string _remotePort;
+    [ObservableProperty]
+    private string _remotePort;
 
-        public StatusBarViewModel(ISharedConfig sharedConfig, IInfoSendingService sendInfoService)
-        {
-            _sharedConfig = sharedConfig;
-            _status = "Disconnected";
-            _remoteIp = "Unknown";
-            _remotePort = "Unknown";
-
-            _sendInfoService = sendInfoService;
-            _sendInfoService.ConnectionStatusChanged += OnConnectionStatusChanged;
-            _sendInfoService.TcpConnectionChanged += OnTcpConnectionChanged;
-        }
+    public StatusBarViewModel(ISharedConfig sharedConfig, IInfoSendingService sendInfoService)
+    {
+        _sharedConfig = sharedConfig;
+        _infoSendingService = sendInfoService;
+        _infoSendingService.ConnectionChanged += OnConnectionChanged;
 
-        private void OnTcpConnectionChanged(object? sender, UniversalNetFrame451.IO.TcpConnection e)
+        _status = "Disconnected";
+        _remoteIp = "Unknown";
+        _remotePort = "Unknown";
+    }
+
+    private void OnConnectionChanged(object? sender, (bool, UniversalNetFrame451.IO.TcpConnection) e)
+    {
+        if(e.Item1)
         {
-            if (Status == "Connected")
-            {
-                RemoteIp = e.RemoteEndPoint.Address.ToString();
-                RemotePort = e.RemoteEndPoint.Port.ToString();
-            }
+            Status = "Connected";
+            RemoteIp = e.Item2.RemoteEndPoint.Address.ToString();
+            RemotePort = e.Item2.RemoteEndPoint.Port.ToString();
         }
-
-        private void OnConnectionStatusChanged(object? sender, bool e)
+        else
         {
-            if(e)
-            {
-                Status = "Connected";
-            }
-            else
-            {
-                Status = "Disconnected";
-                RemoteIp = "Unknown";
-                RemotePort = "Unknown";
-            }
-            
+            Status = "Disconnected";
+            RemoteIp = "Unknown";
+            RemotePort = "Unknown";
         }
     }
 }

+ 78 - 77
Tools/AlarmInfoServerSim/ViewModels/WorkAreaViewModel.cs

@@ -1,117 +1,118 @@
 using AlarmInfoServerSim.Services;
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
-using ConfigOperator;
 using HardwareData;
 using RealtimeData;
 using RTCommunicatorBase;
 using System.Collections.Concurrent;
 using System.Collections.ObjectModel;
-using System.IO;
 
-namespace AlarmInfoServerSim.ViewModels
+namespace AlarmInfoServerSim.ViewModels;
+
+public partial class WorkAreaViewModel : ObservableObject
 {
-    public partial class WorkAreaViewModel : ObservableObject
-    {
-        private readonly IInfoSendingService _infoSendingService;
+    private readonly IInfoSendingService _infoSendingService;
 
-        private readonly Hardwares _hardwares;
+    private readonly Hardwares _hardwares;
 
-        [ObservableProperty]
-        private ConcurrentDictionary<byte, Mini8Data> _mini8;
+    [ObservableProperty]
+    private ConcurrentDictionary<byte, Mini8Data> _mini8;
 
-        [ObservableProperty]
-        private int _selectedMini8Index = -1;
+    [ObservableProperty]
+    private int _selectedMini8Index = -1;
 
-        [ObservableProperty]
-        private ConcurrentDictionary<byte, ChannelData> _mini8Channel;
+    [ObservableProperty]
+    private ConcurrentDictionary<byte, ChannelData> _mini8Channel;
 
-        [ObservableProperty]
-        private int _selectedChannelIndex = -1;
+    [ObservableProperty]
+    private int _selectedChannelIndex = -1;
 
-        [ObservableProperty]
-        private AlarmType[] _alarmTypes;
+    [ObservableProperty]
+    private AlarmType[] _alarmTypes;
 
-        [ObservableProperty]
-        private int _selectedAlarmTypeIndex = -1;
+    [ObservableProperty]
+    private int _selectedAlarmTypeIndex = -1;
 
-        [ObservableProperty]
-        private float _pV;
+    [ObservableProperty]
+    private float _pV;
 
-        [ObservableProperty]
-        private float _caps;
+    [ObservableProperty]
+    private float _caps;
 
-        [ObservableProperty]
-        private float _floor;
+    [ObservableProperty]
+    private float _floor;
 
-        [ObservableProperty]
-        private ObservableCollection<string> _receivingTime;
+    [ObservableProperty]
+    private ObservableCollection<string> _receivingTime;
 
-        [ObservableProperty]
-        [NotifyCanExecuteChangedFor(nameof(SendInfoCommand))]
-        private bool _hasConnection;
+    [ObservableProperty]
+    [NotifyCanExecuteChangedFor(nameof(SendInfoCommand))]
+    private bool _hasConnection;
 
 
 
-        public WorkAreaViewModel(IInfoSendingService infoSendingService)
+    public WorkAreaViewModel(ISharedConfig sharedConfig ,IInfoSendingService infoSendingService)
+    {
+        if(sharedConfig.Hardwares is null)
         {
-            _infoSendingService = infoSendingService;
-            _infoSendingService.ConnectionStatusChanged += OnConnectionStatusChanged;
-            _infoSendingService.DataReceived += OnDataReceived;
+            throw new ArgumentNullException(nameof(sharedConfig.Hardwares));
+        }
+        
+        _hardwares = sharedConfig.Hardwares;
 
-            _hardwares = new Hardwares();
-            HardwareFileLoader hardwareFileLoader = new HardwareFileLoader(_hardwares);
-            string folderPath = Path.Combine(new DirectoryInfo(Paths.LocalPath!)!.Parent!.Parent!.FullName, "Settings", "Hardwares");
+        _mini8 = _hardwares.Mini8s;
+        _mini8Channel = [];
+        _alarmTypes = Enum.GetValues<AlarmType>();
+        _receivingTime = [];
 
-            _mini8 = hardwareFileLoader.Load(folderPath) ? _hardwares.Mini8s : [];
-            _mini8Channel = [];
+        _infoSendingService = infoSendingService;
+        _infoSendingService.ConnectionChanged += OnConnectionChanged;
+        _infoSendingService.DataReceived += OnDataReceived;
+    }
 
-            _alarmTypes = Enum.GetValues<AlarmType>();
-            _receivingTime = [];
-        }
+    partial void OnSelectedMini8IndexChanged(int value)
+    {
+        SelectedChannelIndex = -1;
+        SelectedAlarmTypeIndex = -1;
+        Mini8Channel = _hardwares.Mini8Channels[Mini8.ElementAt(value).Key];
+    }
 
-        partial void OnSelectedMini8IndexChanged(int value)
-        {
-            SelectedChannelIndex = -1;
-            SelectedAlarmTypeIndex = -1;
-            var index = Mini8.ElementAt(value).Key;
-            Mini8Channel = _hardwares.Mini8Channels[index];
-        }
+    partial void OnSelectedChannelIndexChanged(int value)
+    {
+        SelectedAlarmTypeIndex = -1;
+    }
 
-        partial void OnSelectedChannelIndexChanged(int value)
+    [RelayCommand(CanExecute = nameof(HasConnection))]
+    private void SendInfo()
+    {
+        if (SelectedMini8Index == -1 || SelectedChannelIndex == -1 || SelectedAlarmTypeIndex == -1)
         {
-            SelectedAlarmTypeIndex = -1;
+            //log
+            return;
         }
 
-        [RelayCommand(CanExecute = nameof(HasConnection))]
-        private void SendInfo()
+        // ChannelAlarmNotify = 1
+        _infoSendingService.Send(1, new ST_ALARM()
         {
-            if (SelectedMini8Index > -1 && SelectedChannelIndex > -1 && SelectedAlarmTypeIndex > -1)
-            {
-                // ChannelAlarmNotify = 1
-                _infoSendingService.Send(1, new ST_ALARM()
-                {
-                    Mini8Index = Mini8.ElementAt(SelectedMini8Index).Key,
-                    ChannelIndex = Mini8Channel.ElementAt(SelectedChannelIndex).Key,
-                    PV = PV,
-                    Caps = Caps,
-                    Floor = Floor,
-                    AlarmType = (AlarmType)SelectedAlarmTypeIndex
-                });
-            }
-        }
+            Mini8Index = Mini8.ElementAt(SelectedMini8Index).Key,
+            ChannelIndex = Mini8Channel.ElementAt(SelectedChannelIndex).Key,
+            PV = PV,
+            Caps = Caps,
+            Floor = Floor,
+            AlarmType = (AlarmType)SelectedAlarmTypeIndex
+        });
+    }
 
-        private void OnConnectionStatusChanged(object? sender, bool e)
+    private void OnConnectionChanged(object? sender, (bool, UniversalNetFrame451.IO.TcpConnection) e)
+    {
+        App.Current.Dispatcher.Invoke(() =>
         {
-            App.Current.Dispatcher.Invoke(() =>
-            {
-                HasConnection = e;
-            });
-        }
+            HasConnection = e.Item1;
+        });
+    }
 
-        private void OnDataReceived(object? sender, (ushort, TLVProtocal.TlvData) e)
-        {
-            ReceivingTime.Add(e.Item2.DateTime.ToString());
-        }
+    private void OnDataReceived(object? sender, (ushort, TLVProtocal.TlvData) e)
+    {
+        ReceivingTime.Add(e.Item2.DateTime.ToString());
     }
 }

+ 1 - 1
Tools/AlarmInfoServerSim/Views/LogBar.xaml.cs

@@ -16,7 +16,7 @@ using System.Windows.Shapes;
 namespace AlarmInfoServerSim.Views
 {
     /// <summary>
-    /// LogBar.xaml 的交互逻辑
+    /// Interaction logic for LogBar.xaml
     /// </summary>
     public partial class LogBar : UserControl
     {

+ 1 - 1
Tools/AlarmInfoServerSim/Views/MainWindow.xaml

@@ -11,7 +11,7 @@
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="50"/>
-            <RowDefinition Height="*"/>
+            <RowDefinition Height="350"/>
             <RowDefinition Height="200"/>
         </Grid.RowDefinitions>
         <local:StatusBar Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>

+ 1 - 1
Tools/AlarmInfoServerSim/Views/StatusBar.xaml.cs

@@ -16,7 +16,7 @@ using System.Windows.Shapes;
 namespace AlarmInfoServerSim.Views
 {
     /// <summary>
-    /// StatusBar.xaml 的交互逻辑
+    /// Interaction logic for StatusBar.xaml
     /// </summary>
     public partial class StatusBar : UserControl
     {

+ 6 - 7
Tools/AlarmInfoServerSim/Views/WorkArea.xaml

@@ -13,18 +13,17 @@
             <ColumnDefinition Width="300" />
             <ColumnDefinition Width="*"/>
         </Grid.ColumnDefinitions>
-        <StackPanel Grid.Column="0" Orientation="Vertical" Margin="5,10,5
-                    ,10">
+        <StackPanel Grid.Column="0" Orientation="Vertical" Margin="5,10,5,10">
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
-                <Label>Mini8: </Label>
+                <Label>Mini8:</Label>
                 <ComboBox Width="120" SelectedIndex="{Binding SelectedMini8Index}" ItemsSource="{Binding Mini8}" DisplayMemberPath="Value.Name"/>
             </StackPanel>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
-                <Label>Channel: </Label>
+                <Label>Channel:</Label>
                 <ComboBox Width="120" SelectedIndex="{Binding SelectedChannelIndex}" ItemsSource="{Binding Mini8Channel}" DisplayMemberPath="Value.Name"/>
             </StackPanel>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
-                <Label>Alarm Type: </Label>
+                <Label>Alarm Type:</Label>
                 <ComboBox Width="120" SelectedIndex="{Binding SelectedAlarmTypeIndex}" ItemsSource="{Binding AlarmTypes}"/>
             </StackPanel>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
@@ -42,8 +41,8 @@
             <Button Content="Send" Command="{Binding SendInfoCommand}" Margin="20,20,20,20" Width="120" />
         </StackPanel>
         <StackPanel Grid.Column="1" Orientation="Vertical" Margin="5,10,5,10">
-            <ListView MaxHeight="280" ItemsSource="{Binding ReceivingTime}" Margin="5,10,5,10"></ListView>
+            <ListView MaxHeight="280" ItemsSource="{Binding ReceivingTime}" Margin="5,20,5,0"></ListView>
         </StackPanel>
-        
+
     </Grid>
 </UserControl>

+ 1 - 1
Tools/AlarmInfoServerSim/Views/WorkArea.xaml.cs

@@ -16,7 +16,7 @@ using System.Windows.Shapes;
 namespace AlarmInfoServerSim.Views
 {
     /// <summary>
-    /// WorkArea.xaml 的交互逻辑
+    /// Interaction logic for WorkArea.xaml
     /// </summary>
     public partial class WorkArea : UserControl
     {