using NEIntelligentControl2.Models.Matrix; using NEIntelligentControl2.Models.PV; using NEIntelligentControl2.Models.Station; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace NEIntelligentControl2.Views.Matrix { /// /// 光伏模块 /// public partial class PVStationBlock : UserControl, IStationInfo { // --------------依赖属性---------------- public static DependencyProperty CountTotalProperty = DependencyProperty.Register("CountTotal", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountConnectProperty = DependencyProperty.Register("CountConnect", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountStandbyProperty = DependencyProperty.Register("CountStandby", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountPowerRestrictionProperty = DependencyProperty.Register("CountPowerRestriction", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountMaintainProperty = DependencyProperty.Register("CountMaintain", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountFaultProperty = DependencyProperty.Register("CountFault", typeof(int), typeof(PVStationBlock)); public static DependencyProperty CountOfflineProperty = DependencyProperty.Register("CountOffline", typeof(int), typeof(PVStationBlock)); /// /// 总接入台数 /// public int CountTotal { get => (int)GetValue(CountTotalProperty); set => SetValue(CountTotalProperty, value); } /// /// 并网台数 /// public int CountConnect { get => (int)GetValue(CountConnectProperty); set => SetValue(CountConnectProperty, value); } /// /// 待机台数 /// public int CountStandby { get => (int)GetValue(CountStandbyProperty); set => SetValue(CountStandbyProperty, value); } /// /// 限电台数 /// public int CountPowerRestriction { get => (int)GetValue(CountPowerRestrictionProperty); set => SetValue(CountPowerRestrictionProperty, value); } /// /// 维护台数 /// public int CountMaintain { get => (int)GetValue(CountMaintainProperty); set => SetValue(CountMaintainProperty, value); } /// /// 故障台数 /// public int CountFault { get => (int)GetValue(CountFaultProperty); set => SetValue(CountFaultProperty, value); } /// /// 离线台数 /// public int CountOffline { get => (int)GetValue(CountOfflineProperty); set => SetValue(CountOfflineProperty, value); } /// /// 场站信息 /// public StationInfo StationInfo { get; set; } private List _PVBlocks; public PVStationBlock() { InitializeComponent(); } public void UpdateData(object obj) { var datas = obj as Dictionary; if (datas == null) return; var ls = datas.Values.Where(wi => wi.Station == StationInfo.Id).ToList(); if (_PVBlocks == null) { InitBlocks(ls); } CountTotal = ls.Count; CountPowerRestriction = ls.Where(s => s.State == PVState.Restriction|| s.State==PVState.RestrictionShutdown).ToList().Count; CountConnect = ls.Where(s => s.State == PVState.GridConnected).ToList().Count; CountStandby = ls.Where(s => s.State == PVState.Standby).ToList().Count; CountMaintain = ls.Where(s => s.State == PVState.Maintain).ToList().Count; CountFault = ls.Where(s => s.State == PVState.Malfunction).ToList().Count; CountOffline = ls.Where(s => s.State == PVState.Offline).ToList().Count; if (_PVBlocks == null) return; foreach (var v in _PVBlocks) { if (!datas.ContainsKey(v.Id)) { continue; } v.Update(datas[v.Id]); } } private void InitBlocks(List ls) { _PVBlocks = new List(); ls.Sort((x, y) => x.Index - y.Index); Dispatcher.Invoke(() => { foreach (var v in ls) { PVBlock pb = new PVBlock() { Id = v.Id, IsSmallModel = true }; _PVBlocks.Add(pb); _UGMain.Children.Add(pb); } }); } } }