diff --git a/CapMachine.Model/Alarm/AlarmConfig.cs b/CapMachine.Model/Alarm/AlarmConfig.cs new file mode 100644 index 0000000..58b3c43 --- /dev/null +++ b/CapMachine.Model/Alarm/AlarmConfig.cs @@ -0,0 +1,75 @@ +using FreeSql.DataAnnotations; +using System; + +namespace CapMachine.Model.Alarm +{ + /// + /// 报警配置信息 + /// + [Table(Name = "AlarmConfig")] + public class AlarmConfig + { + /// + /// 主键 + /// + [Column(IsPrimary = true, IsIdentity = true)] + public long Id { get; set; } + + /// + /// 报警配置类别 + /// + [Column(Name = "Category", IsNullable = false, StringLength = 20)] + public string? Category { get; set; } + + /// + /// 报警的地址 + /// + [Column(Name = "Address", IsNullable = false, StringLength = 20)] + public string? Address { get; set; } + + /// + /// 报警等级 + /// + [Column(Name = "AlarmLevel", IsNullable = false)] + public AlarmLevel AlarmLevel { get; set; } + + /// + /// 激活类型 + /// + [Column(Name = "ActiveType", IsNullable = false)] + public ActiveType ActiveType { get; set; } + + /// + /// 报警配置名称 + /// + [Column(Name = "Name", IsNullable = false, StringLength = 50)] + public string? Name { get; set; } + + /// + /// 报警消息 + /// + [Column(Name = "Message", IsNullable = false, StringLength = 150)] + public string? Message { get; set; } + + /// + /// 布尔激活的阀值 + /// + [Column(Name = "BoolActiveValue", IsNullable = false)] + public bool BoolActiveValue { get; set; } + + /// + /// 报警上限阀值 + /// + [Column(Name = "ThresholdUp", DbType = "decimal(8, 3)", IsNullable = true)] + public decimal ThresholdUp { get; set; } + + /// + /// 报警下限阀值 + /// + [Column(Name = "ThresholdDown", DbType = "decimal(8, 3)", IsNullable = true)] + public decimal ThresholdDown { get; set; } + + [Column(ServerTime = DateTimeKind.Local, CanUpdate = false)] + public DateTime CreateTime { get; set; } + } +} diff --git a/CapMachine.Model/Alarm/AlarmLevel.cs b/CapMachine.Model/Alarm/AlarmLevel.cs new file mode 100644 index 0000000..93c158d --- /dev/null +++ b/CapMachine.Model/Alarm/AlarmLevel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Model.Alarm +{ + /// + /// 报警等级 + /// + public enum AlarmLevel + { + /// + /// 一级 + /// + Level1=1, + + /// + /// 二级 + /// + Level2 = 2, + + /// + /// 三级 + /// + Level3 = 3, + } + + /// + /// 报警激活类型 + /// + public enum ActiveType + { + /// + /// 阀值 + /// + Threshold = 1, + + /// + /// 布尔类型 + /// + Bool = 2, + } +} diff --git a/CapMachine.Model/Alarm/HistoryAlarm.cs b/CapMachine.Model/Alarm/HistoryAlarm.cs new file mode 100644 index 0000000..6afa977 --- /dev/null +++ b/CapMachine.Model/Alarm/HistoryAlarm.cs @@ -0,0 +1,59 @@ +using FreeSql.DataAnnotations; +using System; + +namespace CapMachine.Model.Alarm +{ + /// + /// PLC报警 HistoryAlarm + /// + [Table(Name = "HistoryAlarm")] + public class HistoryAlarm + { + /// + /// 主键 + /// + [Column(IsPrimary = true, IsIdentity = true)] + public long Id { get; set; } + + /// + /// 报警消息分类 + /// + [Column(Name = "Category", IsNullable = false, StringLength = 20)] + public string? Category { get; set; } + + /// + /// 报警等级 + /// + [Column(Name = "AlarmLevel", IsNullable = false)] + public AlarmLevel AlarmLevel { get; set; } + + /// + /// 报警名称 + /// + [Column(Name = "Name", IsNullable = false, StringLength = 50)] + public string? Name { get; set; } + + /// + /// 报警消息 + /// + [Column(Name = "Message", IsNullable = false, StringLength = 150)] + public string? Message { get; set; } + + /// + /// 报警时长 + /// 秒 + /// + [Column(Name = "Duration")] + public long Duration { get; set; } + + [Column(Name = "CreateTime")] + public DateTime CreateTime { get; set; } + + /// + /// ///////////////////////////////////////////导航属性/////////////////////////////////////////////////////// + /// + + //public Guid? AlarmAddressId { get; set; } + //public AlarmAddress AlarmAddress { get; set; } + } +} diff --git a/CapMachine.Wpf/Alarm/AlarmRunCell.cs b/CapMachine.Wpf/Alarm/AlarmRunCell.cs new file mode 100644 index 0000000..62cee20 --- /dev/null +++ b/CapMachine.Wpf/Alarm/AlarmRunCell.cs @@ -0,0 +1,105 @@ +using CapMachine.Model.Alarm; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Alarm +{ + /// + /// 报警运行单元 + /// + public class AlarmRunCell : BindableBase + { + /// + /// 实例化函数 + /// + public AlarmRunCell(IFreeSql freeSql) + { + CurAlarmConfig = new AlarmConfig(); + FreeSql = freeSql; + } + + /// + /// 更新报警对应的值 + /// + public void UpdateBoolValue(bool Value) + { + if (CurAlarmConfig.ActiveType == ActiveType.Bool) + { + if (CurAlarmConfig.BoolActiveValue == Value) + { + ActiveState = true; + ActiveTime = DateTime.Now; + } + else + { + ActiveState = false; + } + } + } + + /// + /// 布尔类型的变量 序号 + /// + public long Index { get; set; } + + private bool _ActiveState = false; + /// + /// 报警激活状态 + /// + public bool ActiveState + { + get { return _ActiveState; } + set + { + if (_ActiveState != value) + { + _ActiveState = value; + RaisePropertyChanged(); + + //报警结束时保存报警 + if (ActiveState==false) + { + SaveAlarm(); + } + } + + } + } + + /// + /// 保存报警 + /// + private void SaveAlarm() + { + FreeSql.Insert(new HistoryAlarm() + { + AlarmLevel = CurAlarmConfig.AlarmLevel, + Category = CurAlarmConfig.Category, + Message = CurAlarmConfig.Message, + Name = CurAlarmConfig.Name, + Duration = (long)(DateTime.Now - ActiveTime).TotalSeconds, + CreateTime = ActiveTime, + }).ExecuteAffrows(); + } + + /// + /// 报警时长 + /// + public int TimeDuration { get; set; } + + /// + /// 激活时间 + /// + public DateTime ActiveTime { get; set; } + + /// + /// 当前的报警配置 + /// + public AlarmConfig CurAlarmConfig { get; set; } + public IFreeSql FreeSql { get; } + } +} diff --git a/CapMachine.Wpf/App.xaml.cs b/CapMachine.Wpf/App.xaml.cs index c0406ec..dda6b59 100644 --- a/CapMachine.Wpf/App.xaml.cs +++ b/CapMachine.Wpf/App.xaml.cs @@ -92,6 +92,7 @@ namespace CapMachine.Wpf containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); ////注册设备服务 //containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); @@ -99,6 +100,7 @@ namespace CapMachine.Wpf containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); + //注册AutoMapper 将IAutoMapperProvider注入IOC容器,并对外提供IMapper注入类型。 containerRegistry.RegisterSingleton(); @@ -220,6 +222,7 @@ namespace CapMachine.Wpf var appVersionService = ContainerLocator.Container.Resolve(); //var appVersionService1 = ContainerLocator.Container.Resolve(); //var appVersionService2 = ContainerLocator.Container.Resolve(); + var appVersionService12 = ContainerLocator.Container.Resolve(); var appVersionService3 = ContainerLocator.Container.Resolve(); var appVersionService4 = ContainerLocator.Container.Resolve(); var appVersionService5 = ContainerLocator.Container.Resolve(); @@ -229,6 +232,7 @@ namespace CapMachine.Wpf var appVersionService9 = ContainerLocator.Container.Resolve(); var appVersionService10 = ContainerLocator.Container.Resolve(); var appVersionService11 = ContainerLocator.Container.Resolve(); + //给当前的全局异常捕捉服务使用 diff --git a/CapMachine.Wpf/Dtos/ActionLogDto.cs b/CapMachine.Wpf/Dtos/ActionLogDto.cs index e376cd4..aad479c 100644 --- a/CapMachine.Wpf/Dtos/ActionLogDto.cs +++ b/CapMachine.Wpf/Dtos/ActionLogDto.cs @@ -1,6 +1,7 @@ using Prism.Mvvm; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -15,21 +16,25 @@ namespace CapMachine.Wpf.Dtos /// /// 等级 /// + [Description("等级")] public int Level { get; set; } /// /// 分类 /// + [Description("分类")] public string? Category { get; set; } /// /// 内容 /// + [Description("内容")] public string? Content { get; set; } /// /// 创建时间 /// + [Description("创建时间")] public DateTime CreateTime { get; set; } } } diff --git a/CapMachine.Wpf/Dtos/AlarmRtDto.cs b/CapMachine.Wpf/Dtos/AlarmRtDto.cs new file mode 100644 index 0000000..812b615 --- /dev/null +++ b/CapMachine.Wpf/Dtos/AlarmRtDto.cs @@ -0,0 +1,57 @@ +using CapMachine.Model.Alarm; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Dtos +{ + /// + /// 报警实时模型 + /// + public class AlarmRtDto:BindableBase + { + private string? _Name; + /// + /// 报警名称 + /// + public string? Name + { + get { return _Name; } + set { _Name = value; RaisePropertyChanged(); } + } + + private string? _Message; + /// + /// 报警消息 + /// + public string? Message + { + get { return _Message; } + set { _Message = value; RaisePropertyChanged(); } + } + + private string? _Category; + /// + /// 报警消息分类 + /// + public string? Category + { + get { return _Category; } + set { _Category = value; RaisePropertyChanged(); } + } + + private AlarmLevel? _AlarmLevel; + /// + /// 报警等级 + /// + public AlarmLevel? AlarmLevel + { + get { return _AlarmLevel; } + set { _AlarmLevel = value; RaisePropertyChanged(); } + } + + } +} diff --git a/CapMachine.Wpf/Dtos/HistoryAlarmDto.cs b/CapMachine.Wpf/Dtos/HistoryAlarmDto.cs new file mode 100644 index 0000000..99a4364 --- /dev/null +++ b/CapMachine.Wpf/Dtos/HistoryAlarmDto.cs @@ -0,0 +1,56 @@ +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Dtos +{ + /// + /// 历史报警模型 + /// + public class HistoryAlarmDto : BindableBase + { + private string? _Category; + [Description("分类")] + public string? Category + { + get { return _Category; } + set { _Category = value; RaisePropertyChanged(); } + } + + private string? _AlarmLevel; + [Description("报警等级")] + public string? AlarmLevel + { + get { return _AlarmLevel; } + set { _AlarmLevel = value; RaisePropertyChanged(); } + } + + private string? _Name; + [Description("报警名称")] + public string? Name + { + get { return _Name; } + set { _Name = value; RaisePropertyChanged(); } + } + + private long _Duration; + [Description("报警时长")] + public long Duration + { + get { return _Duration; } + set { _Duration = value; RaisePropertyChanged(); } + } + + private DateTime _CreateTime; + [Description("报警时间")] + public DateTime CreateTime + { + get { return _CreateTime; } + set { _CreateTime = value; RaisePropertyChanged(); } + } + } +} diff --git a/CapMachine.Wpf/MapperProfile/HistoryAlarmProfile.cs b/CapMachine.Wpf/MapperProfile/HistoryAlarmProfile.cs new file mode 100644 index 0000000..0e22545 --- /dev/null +++ b/CapMachine.Wpf/MapperProfile/HistoryAlarmProfile.cs @@ -0,0 +1,20 @@ +using AutoMapper; +using CapMachine.Model; +using CapMachine.Model.Alarm; +using CapMachine.Wpf.Dtos; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.MapperProfile +{ + public class HistoryAlarmProfile : Profile + { + public HistoryAlarmProfile() + { + CreateMap().ReverseMap(); + } + } +} diff --git a/CapMachine.Wpf/Services/AlarmService.cs b/CapMachine.Wpf/Services/AlarmService.cs new file mode 100644 index 0000000..6fe3edb --- /dev/null +++ b/CapMachine.Wpf/Services/AlarmService.cs @@ -0,0 +1,235 @@ +using CapMachine.Model.Alarm; +using CapMachine.Wpf.Alarm; +using CapMachine.Wpf.Dtos; +using Prism.Events; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Services +{ + /// + /// 报警服务 + /// + public class AlarmService : BindableBase + { + public AlarmService(ConfigService configService, IEventAggregator eventAggregator,IFreeSql freeSql + ) + { + ConfigService = configService; + //事件服务 + _EventAggregator = eventAggregator; + FreeSql = freeSql; + //DataRecordService = dataRecordService; + //SysRunServer = sysRunService; + + ListAlarmRunCell = new ObservableCollection() + { + new AlarmRunCell(FreeSql){Index=0,CurAlarmConfig=new AlarmConfig() + { + Name="急停报警", + ActiveType=ActiveType.Bool, + Address="V0.0", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="急停报警", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=1,CurAlarmConfig=new AlarmConfig() + { + Name="高压压控", + ActiveType=ActiveType.Bool, + Address="V0.1", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="高压压控", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=2,CurAlarmConfig=new AlarmConfig() + { + Name="低压压控", + ActiveType=ActiveType.Bool, + Address="V0.2", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="低压压控", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=3,CurAlarmConfig=new AlarmConfig() + { + Name="水压低", + ActiveType=ActiveType.Bool, + Address="V0.3", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="水压低", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=4,CurAlarmConfig=new AlarmConfig() + { + Name="水泵过载", + ActiveType=ActiveType.Bool, + Address="V0.4", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="水泵过载", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=5,CurAlarmConfig=new AlarmConfig() + { + Name="冷水机组故障", + ActiveType=ActiveType.Bool, + Address="V0.5", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="冷水机组故障", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=6,CurAlarmConfig=new AlarmConfig() + { + Name="排气压力", + ActiveType=ActiveType.Bool, + Address="V0.6", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="排气压力", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=7,CurAlarmConfig=new AlarmConfig() + { + Name="吸气压力", + ActiveType=ActiveType.Bool, + Address="V0.7", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="吸气压力", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=8,CurAlarmConfig=new AlarmConfig() + { + Name="吸气温度", + ActiveType=ActiveType.Bool, + Address="V1.0", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="吸气温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=9,CurAlarmConfig=new AlarmConfig() + { + Name="吸气混合器温度", + ActiveType=ActiveType.Bool, + Address="V1.1", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="吸气混合器温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=10,CurAlarmConfig=new AlarmConfig() + { + Name="水加热温度", + ActiveType=ActiveType.Bool, + Address="V1.2", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="水加热温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=11,CurAlarmConfig=new AlarmConfig() + { + Name="排气温度", + ActiveType=ActiveType.Bool, + Address="V1.3", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="排气温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=12,CurAlarmConfig=new AlarmConfig() + { + Name="水箱进水温度", + ActiveType=ActiveType.Bool, + Address="V1.4", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="水箱进水温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=13,CurAlarmConfig=new AlarmConfig() + { + Name="压缩机表面温度", + ActiveType=ActiveType.Bool, + Address="V1.5", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="压缩机表面温度", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + new AlarmRunCell(FreeSql){Index=14,CurAlarmConfig=new AlarmConfig() + { + Name="试验箱", + ActiveType=ActiveType.Bool, + Address="V1.6", + AlarmLevel=AlarmLevel.Level1, + Category="一般报警", + Message="试验箱", + ThresholdDown=1, + ThresholdUp=1, + BoolActiveValue=true + }}, + }; + } + public ConfigService ConfigService { get; } + + private IEventAggregator _EventAggregator { get; set; } + public IFreeSql FreeSql { get; } + public DataRecordService DataRecordService { get; } + public SysRunService SysRunServer { get; } + public MachineRtDataService MachineRtDataService { get; } + + + private ObservableCollection _ListAlarmRunCell; + /// + /// 报警实时数据集合 + /// + public ObservableCollection ListAlarmRunCell + { + get { return _ListAlarmRunCell; } + set { _ListAlarmRunCell = value; RaisePropertyChanged(); } + } + + + } +} diff --git a/CapMachine.Wpf/Services/MachineRtDataService.cs b/CapMachine.Wpf/Services/MachineRtDataService.cs index bd4c22c..2d7a5c9 100644 --- a/CapMachine.Wpf/Services/MachineRtDataService.cs +++ b/CapMachine.Wpf/Services/MachineRtDataService.cs @@ -32,6 +32,7 @@ namespace CapMachine.Wpf.Services /// 事件聚合器 /// private IEventAggregator _EventAggregator { get; set; } + public AlarmService AlarmService { get; } /// /// PLCScanTask扫描Task @@ -97,7 +98,7 @@ namespace CapMachine.Wpf.Services /// 实例化函数 /// /// - public MachineRtDataService(IEventAggregator eventAggregator) + public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService)//, AlarmService alarmService { //ConcurrentDictionary keyValuePairs = new ConcurrentDictionary(); @@ -110,6 +111,7 @@ namespace CapMachine.Wpf.Services //事件服务 _EventAggregator = eventAggregator; + AlarmService = alarmService; //秒触发一次 CycleTimer = new System.Timers.Timer(500); @@ -181,7 +183,7 @@ namespace CapMachine.Wpf.Services SVAddress = "VW200", MVAddress = "VW250", IsMeter = true, - AutoHandSwitchAddress= "VW240", + AutoHandSwitchAddress = "VW240", Precision = 1, DecimalPoint = 0, Samp = 1, @@ -895,6 +897,11 @@ namespace CapMachine.Wpf.Services private Random Random { get; set; } = new Random(); + /// + /// 报警结果集合 + /// + private OperateResult OperateResultAlarm { get; set; } + /// /// PLC扫描线程 /// @@ -912,28 +919,8 @@ namespace CapMachine.Wpf.Services //DiagnosticsTime.Start(); try { - //var MyProperty = typeof(int); - - //foreach (var item in TagManger.DicTags) - //{ - // if (item.Value.ValueType == typeof(short)) - // { - // var Tag = TagManger.GetTagByName(item.Key); - // Tag.RtValue.Value++; - // } - // else if (item.Value.ValueType == typeof(double)) - // { - // var Tag = TagManger.GetTagByName(item.Key); - // Tag.RtValue.Value++; - // } - - //} - //TagInfo.RtValue.Value++; - - //RT TODO - //SiemensDrive.Read("VW1", 2); - + //var data = TagManger.DicTags["转速"].ValueType.Name; ////第一次计时 @@ -1001,6 +988,16 @@ namespace CapMachine.Wpf.Services //stopwatch.Stop(); //停止Stopwatch //Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.TotalSeconds.ToString()); //stopwatch.Reset(); + + OperateResultAlarm = SiemensDrive.ReadBool("V0.0", 15); + if (OperateResultAlarm.IsSuccess) + { + foreach (var item in AlarmService.ListAlarmRunCell) + { + item.UpdateBoolValue(OperateResultAlarm.Content[item.Index]); + } + } + } catch (Exception ex) { diff --git a/CapMachine.Wpf/ViewModels/ActionLogViewModel.cs b/CapMachine.Wpf/ViewModels/ActionLogViewModel.cs index 2cacaae..e85168b 100644 --- a/CapMachine.Wpf/ViewModels/ActionLogViewModel.cs +++ b/CapMachine.Wpf/ViewModels/ActionLogViewModel.cs @@ -1,6 +1,7 @@ using AutoMapper; using CapMachine.Core; using CapMachine.Model; +using CapMachine.Model.Alarm; using CapMachine.Wpf.Dtos; using CapMachine.Wpf.Models; using CapMachine.Wpf.Services; @@ -40,13 +41,13 @@ namespace CapMachine.Wpf.ViewModels CategoryComboBoxList = new List() { - new ComboBoxModel(){Key="0",Text="系统" }, + new ComboBoxModel(){Key="0",Text="系统日志" }, new ComboBoxModel(){Key="1",Text="程序步骤" }, - new ComboBoxModel(){Key="2",Text="报警" }, + new ComboBoxModel(){Key="2",Text="历史报警" }, }; } - private string CurrentName = "埋塞敲入螺旋钉安装"; + private string CurrentName = ""; private string CurrentTemplate = "BurPlugInstallTemplate.xlsx"; @@ -89,14 +90,14 @@ namespace CapMachine.Wpf.ViewModels /// /// 列表集合 /// - private ObservableCollection _ListModelDto=new ObservableCollection(); + private ObservableCollection _ListModelDto = new ObservableCollection(); /// /// 列表集合 /// - public ObservableCollection ListModelDto + public ObservableCollection ListModelDto { get { return _ListModelDto; } - set { _ListModelDto = value; } + set { _ListModelDto = value; RaisePropertyChanged(); } } #region 搜索条件属性 @@ -201,32 +202,47 @@ namespace CapMachine.Wpf.ViewModels { try { - var MulConQueryable = FreeSql.Select(); - - //多条件查询 - if (!string.IsNullOrEmpty(SearchCategory)) + switch (SearchCategory) { - MulConQueryable = MulConQueryable.Where(t => t.Category == SearchCategory); - } - //多条件查询 - if (!string.IsNullOrEmpty(SearchStartDate)) - { - MulConQueryable = MulConQueryable.Where(t => t.CreateTime.Date >= Convert.ToDateTime(SearchStartDate)); - } - //多条件查询 - if (!string.IsNullOrEmpty(SearchEndDate)) - { - MulConQueryable = MulConQueryable.Where(t => t.CreateTime.Date < Convert.ToDateTime(SearchEndDate).AddDays(1)); - } - var ListDpI = MulConQueryable.OrderByDescending(a => a.CreateTime).ToList();//.Where(a => a.CreateTime >= DateTime.Now); - ListModelDto.Clear(); + case "历史报警": + var MulConHistoryAlarmQueryable = FreeSql.Select(); + //多条件查询 + if (!string.IsNullOrEmpty(SearchStartDate)) + { + MulConHistoryAlarmQueryable = MulConHistoryAlarmQueryable.Where(t => t.CreateTime.Date >= Convert.ToDateTime(SearchStartDate)); + } + //多条件查询 + if (!string.IsNullOrEmpty(SearchEndDate)) + { + MulConHistoryAlarmQueryable = MulConHistoryAlarmQueryable.Where(t => t.CreateTime.Date < Convert.ToDateTime(SearchEndDate).AddDays(1)); + } + var ListHistoryAlarmDpI = MulConHistoryAlarmQueryable.OrderByDescending(a => a.CreateTime).ToList();//.Where(a => a.CreateTime >= DateTime.Now); - foreach (var item in ListDpI) - { - ListModelDto.Add(Mapper.Map(item)); + ListModelDto = new ObservableCollection(Mapper.Map>(ListHistoryAlarmDpI)); + break; + case "系统日志": + //ActionLog + var MulConActionLogQueryable = FreeSql.Select(); + //多条件查询 + if (!string.IsNullOrEmpty(SearchStartDate)) + { + MulConActionLogQueryable = MulConActionLogQueryable.Where(t => t.CreateTime.Date >= Convert.ToDateTime(SearchStartDate)); + } + //多条件查询 + if (!string.IsNullOrEmpty(SearchEndDate)) + { + MulConActionLogQueryable = MulConActionLogQueryable.Where(t => t.CreateTime.Date < Convert.ToDateTime(SearchEndDate).AddDays(1)); + } + var ListActionLogDpI = MulConActionLogQueryable.OrderByDescending(a => a.CreateTime).ToList();//.Where(a => a.CreateTime >= DateTime.Now); + ListModelDto = new ObservableCollection(Mapper.Map>(ListActionLogDpI)); + + break; + default: + break; } + } catch (Exception ex) { diff --git a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs index b068af2..acff9d9 100644 --- a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs +++ b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs @@ -26,7 +26,7 @@ namespace CapMachine.Wpf.ViewModels /// /// public MonitorViewModel(ConfigService configService, IEventAggregator eventAggregator, - DataRecordService dataRecordService, SysRunService sysRunService, + DataRecordService dataRecordService, SysRunService sysRunService, AlarmService alarmService, MachineRtDataService machineRtDataService, IDialogService dialogService) { ConfigService = configService; @@ -34,6 +34,7 @@ namespace CapMachine.Wpf.ViewModels _EventAggregator = eventAggregator; DataRecordService = dataRecordService; SysRunServer = sysRunService; + AlarmService = alarmService; MachineRtDataService = machineRtDataService; DialogService = dialogService; TagManager = MachineRtDataService.TagManger; @@ -85,6 +86,7 @@ namespace CapMachine.Wpf.ViewModels private IEventAggregator _EventAggregator { get; set; } public DataRecordService DataRecordService { get; } public SysRunService SysRunServer { get; } + public AlarmService AlarmService { get; } public MachineRtDataService MachineRtDataService { get; } public IDialogService DialogService { get; } public List ListChartRtValue { get; set; } = new List() diff --git a/CapMachine.Wpf/Views/ActionLogView.xaml b/CapMachine.Wpf/Views/ActionLogView.xaml index 46473fc..8f36292 100644 --- a/CapMachine.Wpf/Views/ActionLogView.xaml +++ b/CapMachine.Wpf/Views/ActionLogView.xaml @@ -8,14 +8,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:prism="http://prismlibrary.com/" Width="1920" - Height="980" + Height="960" prism:ViewModelLocator.AutoWireViewModel="True"> - + - + @@ -195,6 +195,7 @@ + @@ -216,12 +217,12 @@ Margin="10,0,0,0" VerticalAlignment="Center" FontFamily="/Assets/Fonts/#iconfont" - FontSize="30" + FontSize="26" Text="" /> @@ -239,7 +240,7 @@ Margin="10,0,0,0" VerticalAlignment="Center" FontFamily="/Assets/Fonts/#iconfont" - FontSize="30" + FontSize="26" Text="" /> @@ -264,7 +265,7 @@ Margin="10,0,0,0" VerticalAlignment="Center" FontFamily="/Assets/Fonts/#iconfont" - FontSize="30" + FontSize="26" Text="" /> @@ -476,6 +477,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +