PVBlock.xaml.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using NEIntelligentControl2.Models;
  2. using NEIntelligentControl2.Models.Matrix;
  3. using NEIntelligentControl2.Models.PV;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace NEIntelligentControl2.Views.Matrix
  19. {
  20. /// <summary>
  21. /// 光伏卡片
  22. /// </summary>
  23. public partial class PVBlock : UserControl
  24. {
  25. // ----------依赖属性----------
  26. public static readonly DependencyProperty PVNameProperty = DependencyProperty.Register("PVName", typeof(string), typeof(PVBlock));
  27. public static readonly DependencyProperty CurrentProperty = DependencyProperty.Register("Current", typeof(string), typeof(PVBlock));
  28. public static readonly DependencyProperty VoltageProperty = DependencyProperty.Register("Voltage", typeof(string), typeof(PVBlock));
  29. public static readonly DependencyProperty PowerProperty = DependencyProperty.Register("Power", typeof(string), typeof(PVBlock));
  30. public static readonly DependencyProperty StatusProperty = DependencyProperty.Register("Status", typeof(PVState), typeof(PVBlock));
  31. public static readonly DependencyProperty StateStringProperty = DependencyProperty.Register("StateString", typeof(string), typeof(PVBlock));
  32. public static DependencyProperty ToolTipValueProperty = DependencyProperty.Register("ToolTipValue", typeof(string), typeof(PVBlock));
  33. /// <summary>
  34. /// 名称
  35. /// </summary>
  36. public string PVName { get { return GetValue(PVNameProperty) as string; } set { SetValue(PVNameProperty, value); } }
  37. /// <summary>
  38. /// 电流
  39. /// </summary>
  40. public string Current { get { return GetValue(CurrentProperty) as string; } set { SetValue(CurrentProperty, value); } }
  41. /// <summary>
  42. /// 电压
  43. /// </summary>
  44. public string Voltage { get { return GetValue(VoltageProperty) as string; } set { SetValue(VoltageProperty, value); } }
  45. /// <summary>
  46. /// 功率
  47. /// </summary>
  48. public string Power { get { return GetValue(PowerProperty) as string; } set { SetValue(PowerProperty, value); } }
  49. /// <summary>
  50. /// 状态
  51. /// </summary>
  52. public PVState Status { get { return (PVState)GetValue(StatusProperty); } set { SetValue(StatusProperty, value); } }
  53. /// <summary>
  54. /// 状态字符串
  55. /// </summary>
  56. public string StateString { get { return GetValue(StateStringProperty) as string; } set { SetValue(StateStringProperty, value); } }
  57. /// <summary>
  58. /// 提示消息
  59. /// </summary>
  60. public string ToolTipValue { get => GetValue(ToolTipValueProperty) as string; set => SetValue(ToolTipValueProperty, value); }
  61. public string Id { get; set; }
  62. public PVInfo Info;
  63. /// <summary>
  64. /// 小卡片模式
  65. /// </summary>
  66. public bool IsSmallModel { get; set; } = false;
  67. public PVBlock()
  68. {
  69. InitializeComponent();
  70. }
  71. public void Update(object obj)
  72. {
  73. PVInfo pi= obj as PVInfo;
  74. if (pi == null) return;
  75. Info = pi;
  76. Status = pi.State;
  77. PVName = pi.Code;
  78. Current = $"{pi.I.ToString("f2")} A";
  79. Voltage = $"{pi.U.ToString("f2")} V";
  80. Power = $"{pi.P.ToString("f2")} kW";
  81. string time = pi.Ts.GetTimeString();
  82. string timespan = pi.Ts.GetTimeSpanString();
  83. ToolTipValue = $"开始时间:{time} 时长:{timespan}分钟";
  84. }
  85. private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  86. {
  87. if (e.ClickCount < 1) return;
  88. Windows.PV.InverterInfoWindow.Show(this);
  89. }
  90. }
  91. }