FUSIONNozzle.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using Wayne.Lib;
  3. using Wayne.Lib.Log;
  4. namespace Wayne.ForecourtControl.Fusion
  5. {
  6. internal class FUSIONNozzle : INozzle, IIdentifiableEntity
  7. {
  8. // Fields
  9. private int fuelGrade;
  10. private int id;
  11. private NozzleState nozzleState = NozzleState.In;
  12. private FUSIONPump pump;
  13. private IIdentifiableEntity parentDevice;
  14. private int primaryTankGroupId;
  15. private int primaryTankGroupPercentage;
  16. private int secondaryTankGroupId;
  17. private FUSIONManager manager;
  18. private readonly DebugLogger debugLogger;
  19. // Methods
  20. public FUSIONNozzle(int id, FUSIONManager manager, FUSIONPump pump)
  21. {
  22. this.id = id;
  23. this.pump = pump;
  24. this.manager = manager;
  25. debugLogger = manager.DebugLogger;
  26. }
  27. internal void Dispose()
  28. {
  29. }
  30. public void ReadPumpAccumulatorAsync(EventHandler<AsyncCompletedEventArgs<PumpAccumulatorReading>> accumulatorsRead, object userToken)
  31. {
  32. this.pump.Manager.ifsfManager.GetFuelPointTotals(this.pump.realId, this.id, accumulatorsRead, userToken, this);
  33. }
  34. // Properties
  35. public string EntitySubType
  36. {
  37. get
  38. {
  39. return "";
  40. }
  41. }
  42. public string EntityType
  43. {
  44. get
  45. {
  46. return "Nozzle";
  47. }
  48. }
  49. /// <summary>
  50. /// This is used by the logger and should never be set by inheriting classes
  51. /// </summary>
  52. public string FullEntityName { get; set; }
  53. public int FuelGrade
  54. {
  55. get
  56. {
  57. if (manager.FuelGradeShift != 0)
  58. return this.fuelGrade + manager.FuelGradeShift;
  59. else
  60. return this.fuelGrade;
  61. }
  62. }
  63. /// <summary>
  64. /// use this property to move the values internally, this removes interference from the fuelgradeshift
  65. /// </summary>
  66. internal int WritableFuelGrade
  67. {
  68. get { return this.fuelGrade; }
  69. set { this.fuelGrade = value; }
  70. }
  71. public int Id
  72. {
  73. get
  74. {
  75. if (pump.Manager.IdNozzleShift > 0)
  76. return this.id + pump.Manager.IdNozzleShift;
  77. else
  78. return this.id + pump.Manager.IdShift;
  79. }
  80. }
  81. public int realId
  82. {
  83. get
  84. {
  85. return this.id;
  86. }
  87. set
  88. {
  89. this.id = value;
  90. }
  91. }
  92. public IIdentifiableEntity ParentEntity
  93. {
  94. get
  95. {
  96. return this.parentDevice;
  97. }
  98. }
  99. public int PrimaryTankGroupId
  100. {
  101. get
  102. {
  103. return this.primaryTankGroupId;
  104. }
  105. set
  106. {
  107. this.primaryTankGroupId = value;
  108. }
  109. }
  110. public int PrimaryTankGroupPercentage
  111. {
  112. get
  113. {
  114. return this.primaryTankGroupPercentage;
  115. }
  116. set
  117. {
  118. this.primaryTankGroupPercentage = value;
  119. }
  120. }
  121. public int SecondaryTankGroupId
  122. {
  123. get
  124. {
  125. return this.secondaryTankGroupId;
  126. }
  127. set
  128. {
  129. this.secondaryTankGroupId = value;
  130. }
  131. }
  132. /// <summary>
  133. /// Tank that nozzle is connected to
  134. /// </summary>
  135. public int PrimaryTankNo { get; set; }
  136. /// <summary>
  137. /// Tank that nozzle is connected to
  138. /// </summary>
  139. public int SecondaryTankNo { get; set; }
  140. public NozzleState State
  141. {
  142. get
  143. {
  144. return this.nozzleState;
  145. }
  146. set
  147. {
  148. if (debugLogger.IsActive())
  149. debugLogger.Add(string.Format("old State={0}, new State={1}", nozzleState, value));
  150. if (this.nozzleState != value)
  151. {
  152. this.nozzleState = value;
  153. pump.NozzleStateChange(this, this.nozzleState);
  154. }
  155. }
  156. }
  157. }
  158. }