VRBoardNozzle.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Application.VaporRecoveryOnlineWatchHubApp;
  2. using Application.VaporRecoveryOnlineWatchHubApp.UnversalApiModels;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using VaporRecoveryOnlineWatchHubApp.Config;
  8. using static Application.VaporRecoveryOnlineWatchHubApp.App;
  9. namespace VaporRecoveryOnlineWatchHubApp.UnversalApiModels
  10. {
  11. /// <summary>
  12. /// VR Board will watch on each nozzels, and for user side, they care about the nozzles, thus here bring in a logical vr nozzle concept.
  13. /// </summary>
  14. public class VRBoardNozzle
  15. {
  16. public int SiteLevelNozzleId { get; set; }
  17. //public int SiteLevelDispenserId { get; set; }
  18. /// <summary>
  19. /// inidcates if this nozzle's vapor recovery facility works good or not.
  20. /// this state is caculated from a period of time.
  21. /// </summary>
  22. public VRBoardNozzleTrxHealthStateEnum HealthState { get; set; }
  23. //public int PayableTrxes { get; set; }
  24. //public double LastTrxVaporVolume { get; set; }
  25. //public double LastTrxLiquidVolume { get; set; }
  26. //public double LastTrxVaporLiquidRatio { get; set; }
  27. public VRBoardNozzleTrxFlowData LatestTrxFlowData { get; set; }
  28. //public bool StatusOk { get; set; }
  29. public VRBoardNozzleFuelingStateEnum FuelingState { get; set; }
  30. public string PerNozzleVRGroupQualificationDefinitionGroupName { get; set; }
  31. public override string ToString()
  32. {
  33. return GetType().GetProperties().Aggregate(string.Empty,
  34. (result, next) => result + $"{next.Name} : {(next.GetValue(this)?.ToString()) ?? string.Empty} ");
  35. }
  36. }
  37. public enum VRBoardNozzleTrxHealthStateEnum
  38. {
  39. NORMAL,
  40. WARNING,
  41. ALARM,
  42. NOT_SET
  43. }
  44. public enum VRBoardNozzleFuelingStateEnum
  45. {
  46. IDLE,
  47. FUELING
  48. }
  49. //public class Nozzles
  50. //{
  51. // public List<LogicalVRNozzle> data { get; set; } = new List<LogicalVRNozzle>();
  52. // public Nozzles Add(LogicalVRNozzle nozzle)
  53. // {
  54. // data.Add(nozzle);
  55. // return this;
  56. // }
  57. // public static Nozzles Build(NozzleConfigs config)
  58. // {
  59. // var nozzleStatus = new Nozzles();
  60. // config.data.ForEach( i =>
  61. // nozzleStatus.Add(new LogicalVRNozzle
  62. // {
  63. // SiteLevelNozzleId = i.SiteLevelNozzleId,
  64. // SiteLevelDispenserId = i.SiteLevelDispenserId,
  65. // OverallVRState = i.DataCollectorDeviceId == 0 ? NozzleOverallVRStateEnum.NO_VR : NozzleOverallVRStateEnum.DISCONNETED,
  66. // PayableTrxes = 0,
  67. // VaporVolume = 0,
  68. // LiquidVolume = 0,
  69. // VaporLiquidRatio = 0,
  70. // FuelingStatus = FuelingStatus.IDLE
  71. // })
  72. // );
  73. // return nozzleStatus;
  74. // }
  75. // public LogicalVRNozzle GetNozzleById(int nozzleId)
  76. // {
  77. // return data.Where(i => i.SiteLevelNozzleId == nozzleId).FirstOrDefault();
  78. // }
  79. //}
  80. //public static class NozzlesExtension
  81. //{
  82. // public static Nozzles Sort(this Nozzles self)
  83. // {
  84. // self.data = self.data.OrderBy(x => x.SiteLevelNozzleId).ToList();
  85. // return self;
  86. // }
  87. // public static Nozzles Update(this Nozzles nozzles, LogicalVRNozzle nozzle)
  88. // {
  89. // nozzles.data.RemoveAll(i => i.SiteLevelNozzleId == nozzle.SiteLevelNozzleId);
  90. // nozzles.Add(nozzle).Sort();
  91. // return nozzles;
  92. // }
  93. // public static Nozzles UpdateVrState(this Nozzles nozzles, List<int> siteLevelNozzleIdList, NozzleOverallVRStateEnum vRState)
  94. // {
  95. // nozzles.data.ForEach(i => {
  96. // if (siteLevelNozzleIdList.Contains(i.SiteLevelNozzleId))
  97. // {
  98. // i.OverallVRState = vRState;
  99. // }
  100. // });
  101. // return nozzles;
  102. // }
  103. //}
  104. }