From 9f970ab12796705441248ee02970bccc6c8975ba Mon Sep 17 00:00:00 2001 From: MoYue Date: Wed, 24 Apr 2024 17:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=AD=E5=BF=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InSituLaboratory.Base/FaultStateConvert.cs | 41 ++++ InSituLaboratory.Models/SysStatusModel.cs | 203 ++++++++++++++++++ .../ViewModels/Pages/DashboardViewModel.cs | 51 +---- .../Views/Pages/DashboardView.xaml | 23 +- 4 files changed, 262 insertions(+), 56 deletions(-) create mode 100644 InSituLaboratory.Base/FaultStateConvert.cs create mode 100644 InSituLaboratory.Models/SysStatusModel.cs diff --git a/InSituLaboratory.Base/FaultStateConvert.cs b/InSituLaboratory.Base/FaultStateConvert.cs new file mode 100644 index 0000000..acdc4dd --- /dev/null +++ b/InSituLaboratory.Base/FaultStateConvert.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace InSituLaboratory.Base +{ + /// + /// 故障状态转换器 + /// + public class FaultStateConvert : IValueConverter + { + public static object ConvertObject; + + object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Brush background = null; + if ((string)value == "故障") + { + //红色 + background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); + } + else if ((string)value == "正常") + { + //绿色 + background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); + } + + return background; + } + + object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/InSituLaboratory.Models/SysStatusModel.cs b/InSituLaboratory.Models/SysStatusModel.cs new file mode 100644 index 0000000..30d3c17 --- /dev/null +++ b/InSituLaboratory.Models/SysStatusModel.cs @@ -0,0 +1,203 @@ +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace InSituLaboratory.Models +{ + public class SysStatusModel : BindableBase + { + /// + /// 组包时间 + /// + private DateTime? _packagingTime; + public DateTime? PackagingTime + { + get { return _packagingTime; } + set { SetProperty(ref _packagingTime, value); } + } + /// + /// 采样时间 + /// + private DateTime? _samplingTime; + public DateTime? SamplingTime + { + get { return _samplingTime; } + set { SetProperty(ref _samplingTime, value); } + } + + /// + /// 创建时间 + /// + private DateTime? _createTime; + public DateTime? CreateTime + { + get { return _createTime; } + set { SetProperty(ref _createTime, value); } + } + + /// + /// 48V 电压 + /// + private float? _voltage48; + public float? Voltage48 + { + get { return _voltage48; } + set { SetProperty(ref _voltage48, value); } + } + + /// + /// 48V 电流 + /// + private float? _current48; + public float? Current48 + { + get { return _current48; } + set { SetProperty(ref _current48, value); } + } + + /// + /// 基站48V漏电流状态 第0位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _baseStation48VLeakageCS; + public string? BaseStation48VLeakageCS + { + get { return _baseStation48VLeakageCS; } + set { SetProperty(ref _baseStation48VLeakageCS, value); } + } + + /// + /// 电池48V漏电流状态 第2位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _batterz48VLeakageCS; + public string? Batterz48VLeakageCS + { + get { return _batterz48VLeakageCS; } + set { SetProperty(ref _batterz48VLeakageCS, value); } + } + + /// + /// ICL漏电流状态 第4位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _iCLLeakageCS; + public string? ICLLeakageCS + { + get { return _iCLLeakageCS; } + set { SetProperty(ref _iCLLeakageCS, value); } + } + + + /// + /// 工控机漏电流状态 第6位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _iComputerLeakageCS; + public string? IComputerLeakageCS + { + get { return _iComputerLeakageCS; } + set { SetProperty(ref _iComputerLeakageCS, value); } + } + + /// + /// 温度1状态 第8位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _temperatureStaus1; + public string? TemperatureStaus1 + { + get { return _temperatureStaus1; } + set { SetProperty(ref _temperatureStaus1, value); } + } + + /// + /// 温度2状态 第10位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _temperatureStaus2; + public string? TemperatureStaus2 + { + get { return _temperatureStaus2; } + set { SetProperty(ref _temperatureStaus2, value); } + } + + /// + /// 湿度1状态 第12位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _humidityStaus1; + public string? HumidityStaus1 + { + get { return _humidityStaus1; } + set { SetProperty(ref _humidityStaus1, value); } + } + + /// + /// 湿度2状态 第14位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _humidityStaus2; + public string? HumidityStaus2 + { + get { return _humidityStaus2; } + set { SetProperty(ref _humidityStaus2, value); } + } + + /// + /// 漏水1状态 第16位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _leakageStaus1; + public string? LeakageStaus1 + { + get { return _leakageStaus1; } + set { SetProperty(ref _leakageStaus1, value); } + } + + /// + /// 漏水2状态 第18位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _leakageStaus2; + public string? LeakageStaus2 + { + get { return _leakageStaus2; } + set { SetProperty(ref _leakageStaus2, value); } + } + + /// + /// 内部压力1状态 第20位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _iternalPressure1; + public string? InternalPressure1 + { + get { return _iternalPressure1; } + set { SetProperty(ref _iternalPressure1, value); } + } + + + /// + /// 内部压力2状态 第22位 (0表示该状态正常,1表示1级报警,2表示2级报警,3表示故障) + /// + private string? _internalPressure2; + public string? InternalPressure2 + { + get { return _internalPressure2; } + set { SetProperty(ref _internalPressure2, value); } + } + + /// + /// 时序组号 + /// + private string? _timeSeriesGroupNumber; + public string? TimeSeriesGroupNumber + { + get { return _timeSeriesGroupNumber; } + set { SetProperty(ref _timeSeriesGroupNumber, value); } + } + + /// + /// 时序状态 0表示保持,1表示成功,2表示错误 + /// + private string? _groupNumberStatus; + public string? GroupNumberStatus + { + get { return _groupNumberStatus; } + set { SetProperty(ref _groupNumberStatus, value); } + } + } +} diff --git a/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs b/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs index eeac408..804095a 100644 --- a/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs +++ b/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs @@ -17,47 +17,7 @@ namespace InSituLaboratory.ViewModels.Pages public class DashboardViewModel : ViewModelBase { #region 实体类 - /// - /// 组包时间 - /// - private DateTime? _packagingTime; - public DateTime? PackagingTime - { - get { return _packagingTime; } - set { SetProperty(ref _packagingTime, value); } - } - - /// - /// 采样时间 - /// - private DateTime? _samplingTime; - public DateTime? SamplingTime - { - get { return _samplingTime; } - set { SetProperty(ref _samplingTime, value); } - } - - /// - /// 48V 电压 - /// - private float? _voltage48; - public float? Voltage48 - { - get { return _voltage48; } - set { SetProperty(ref _voltage48, value); } - } - - /// - /// 48V 电流 - /// - private float? _current48; - public float? Current48 - { - get { return _current48; } - set { SetProperty(ref _current48, value); } - } - - + public SysStatusModel SysStatusModel { get; set; } = new SysStatusModel(); #endregion @@ -78,10 +38,11 @@ namespace InSituLaboratory.ViewModels.Pages { var data = _sysStatusService.GetSysStauts().First(); - PackagingTime = data.PackagingTime; - SamplingTime = data.SamplingTime; - Voltage48 = data.Voltage48; - Current48 = data.Current48; + SysStatusModel.PackagingTime = data.PackagingTime; + SysStatusModel.SamplingTime = data.SamplingTime; + SysStatusModel.Voltage48 = data.Voltage48; + SysStatusModel.Current48 = data.Current48; + SysStatusModel.BaseStation48VLeakageCS = data.BaseStation48VLeakageCS; } } } diff --git a/InSituLaboratory/Views/Pages/DashboardView.xaml b/InSituLaboratory/Views/Pages/DashboardView.xaml index 6854ac5..24ce84e 100644 --- a/InSituLaboratory/Views/Pages/DashboardView.xaml +++ b/InSituLaboratory/Views/Pages/DashboardView.xaml @@ -11,6 +11,7 @@ +