IPump.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #region --------------- Copyright Dresser Wayne Pignone -------------
  2. /*
  3. * $Log: /Wrk/Support/ForecourtControl/Wrk/ForecourtControl/IPump.cs $
  4. *
  5. * 8 07-05-21 16:28 roger.månsson
  6. * Added TankLevelSwitchStatus property, and OnTankLevelSwitchStatusChange
  7. * event.
  8. *
  9. * 7 07-02-16 9:59 roger.månsson
  10. * FxCop changes
  11. *
  12. * 6 07-02-02 17:17 roger.månsson
  13. * Changed so AuthorizeAsync takes IAuthorizeParameters interface instead
  14. * of class (For COM support). SignalEventAsync uses PumpEventType instead
  15. * of int.
  16. *
  17. * 5 07-01-09 9:28 roger.månsson
  18. * Documentation fixes
  19. *
  20. * 4 07-01-08 16:11 roger.månsson
  21. * Added support for the SignalEvent/OnEventOccured on the pump
  22. * interfaces.
  23. *
  24. * 3 07-01-08 11:22 roger.månsson
  25. * Added Id as a "new" parameter, so we can document it better.
  26. */
  27. #endregion
  28. using System;
  29. namespace Wayne.ForecourtControl
  30. {
  31. /// <summary>
  32. /// The IPump interface represents a logical fuel dispenser. It does only contain the methods that can be called
  33. /// without a pump reservation. When the pump is reserved, the IReservedPump interface is used, with an extended set
  34. /// of methods.
  35. /// </summary>
  36. public interface IPump : Wayne.Lib.IIdentifiableEntity
  37. {
  38. #region Properties
  39. /// <summary>
  40. /// Pump id, zero based pump number. The pump number that will be displayed is 1-based, so in this
  41. /// property, pump 1 will have Id 0.
  42. /// </summary>
  43. new int Id { get;}
  44. /// <summary>
  45. /// State of the pump.
  46. /// </summary>
  47. PumpState State { get;}
  48. /// <summary>
  49. /// Indicates if a valid fuel grade has been selected. Operation may be restricted
  50. /// by <c>CapFuelGradeSelected</c> for pump protocols not supporting this feature.
  51. /// </summary>
  52. bool FuelGradeSelected { get;}
  53. /// <summary>
  54. /// 0 if not reserved.
  55. /// If reserved then this contains the ClientId of the application that has reserved it (using <c>Reserve</c> command).
  56. /// </summary>
  57. int ReservedBy { get;}
  58. /// <summary>
  59. /// An array with Nozzles connected to this pump.
  60. /// </summary>
  61. System.Collections.ObjectModel.ReadOnlyCollection<INozzle> Nozzles { get;}
  62. /// <summary>
  63. /// Enable continous updates on the CurrentFuelling information during a fuelling. Events will be fired on OnFuellingDataChange
  64. /// when the filling data has changed, and current fuelling will be updated.
  65. /// </summary>
  66. bool RunningFuellingUpdates { get;set;}
  67. /// <summary>
  68. /// The running fuelling object. this should reflect what is shown on the pump display.
  69. /// </summary>
  70. IFuelling CurrentFuelling { get;}
  71. /// <summary>
  72. /// Fuelling collection holding the fuellings availiable for payment.
  73. /// </summary>
  74. System.Collections.ObjectModel.ReadOnlyCollection<IFuelling> Fuellings { get;}
  75. /// <summary>
  76. /// Price group that should be used to calculate the fuelling price.
  77. /// It will aslo set the unit price(s) present when the pump is idle.
  78. /// use SetPriceGroup to change the property.
  79. /// </summary>
  80. PriceGroup PriceGroup { get;}
  81. /// <summary>
  82. /// True if Suspend/Resume commands are supported by the pump/protocol.
  83. /// </summary>
  84. bool CapSuspendFuelling { get;}
  85. /// <summary>
  86. /// True if the pump light on/off command is supported by the pump/protocol.
  87. /// </summary>
  88. bool CapSetLight { get;}
  89. /// <summary>
  90. /// True if pump protocol is capable to report nozzle in/out
  91. /// </summary>
  92. bool CapNozzleDetection { get;}
  93. /// <summary>
  94. /// Indicates if the pump is capable to supply information when a fuel grade is selected.
  95. /// </summary>
  96. bool CapFuelGradeSelected { get;}
  97. /// <summary>
  98. /// Indicates if the pump is online to on the link.
  99. /// </summary>
  100. bool Connected { get;}
  101. /// <summary>
  102. /// Indicates if the pump is open.
  103. /// </summary>
  104. bool Open { get;}
  105. /// <summary>
  106. /// Indicates if the pump is blocked by a client
  107. /// </summary>
  108. bool Blocked { get; }
  109. /// <summary>
  110. /// Indicates the status of a low tank level switch. If no tank level switch exists on the pump or if no information has been received from it, the
  111. /// status is 'unknown'.
  112. /// </summary>
  113. TankLevelSwitchStatus TankLevelSwitchStatus { get;}
  114. #endregion
  115. #region Methods
  116. /// <summary>
  117. /// Async version of Reserve() <see cref="IPump.ReserveAsync"/>
  118. /// </summary>
  119. /// <param name="deviceId">The Device id that the pump will be reserved for. For example
  120. /// the terminal number if it is reserved for a specific terminal.</param>
  121. /// <param name="fuellingType">The fuelling type that the pump will be reserved for.</param>
  122. /// <param name="reservedCompleted"></param>
  123. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  124. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
  125. void ReserveAsync(FuellingType fuellingType, byte deviceId, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> reservedCompleted, object userToken);
  126. /// <summary>
  127. /// Cancel pump reservation asynchronously. The reservation allows the the reservation owner to authorize the pump.
  128. /// </summary>
  129. /// <param name="requestCompleted">Delegate that will be called after completion of the request.</param>
  130. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  131. void UnreserveAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  132. /// <summary>
  133. /// This command temporary suspends a running fuelling i.e. stops the pump motors.
  134. /// It may be possible to continue the fuelling again when teh <c>Resume</c> command is
  135. /// called but not all pump modles support Suspend / Resume handling. In this case
  136. /// the fuelling will be stopped without any possibility to resume operation.
  137. /// </summary>
  138. /// <param name="suspendCompleted">Callback delegate that is called on completion.</param>
  139. /// <param name="userToken">User supplied object that will be returned in the suspendCompleted callback.</param>
  140. void SuspendAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> suspendCompleted, object userToken);
  141. /// <summary>
  142. /// Resumes a suspended fuelling
  143. /// </summary>
  144. /// <see cref="IPump.SuspendAsync"/>
  145. /// <param name="resumeCompleted">Callback delegate that is called on completion.</param>
  146. /// <param name="userToken">User supplied object that will be returned in the suspendCompleted callback.</param>
  147. void ResumeAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> resumeCompleted, object userToken);
  148. /// <summary>
  149. /// Stops the current activity on the pump.
  150. /// </summary>
  151. /// <param name="requestCompleted">Delegate that gets called when operation is completed.</param>
  152. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  153. /// <see cref="IPump.StopAsync"/>
  154. void StopAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  155. /// <summary>
  156. /// Blocks or unblocks a pump for operation.
  157. /// </summary>
  158. /// <param name="blocked">True if the pump should be blocked, and false if it should be unblocked.</param>
  159. /// <param name="requestCompleted">Delegate that gets called when operation is completed</param>
  160. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  161. void SetBlockedAsync(bool blocked, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  162. /// <summary>
  163. /// Sets the Idle price group for the pump. This is the price group that will be used to calculate the fuelprice
  164. /// that is shown on the pump display.
  165. /// </summary>
  166. /// <param name="priceGroup"></param>
  167. /// <param name="requestCompleted">Delegate that gets called when operation is completed</param>
  168. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  169. void SetPriceGroupAsync(PriceGroup priceGroup, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  170. /// <summary>
  171. /// Authorize pump for fuelling.
  172. /// The supplied AuthoriseParameters object contains the volume amount and grade restrictions of the
  173. /// release. The AsyncCompletedEventArgs will also contain a result (long) that will contain the AuthorizationId
  174. /// for the authorization. This can be matched with the IFuelling.AuthorizationId when the fuelling is running or
  175. /// is finished. This method may only be called when the pump is successfully reserved.
  176. /// </summary>
  177. /// <see cref="IFuelling.AuthorizationId"/>
  178. /// <param name="authorizeParameters">Object that describes the rules for the authorization.</param>
  179. /// <param name="requestCompleted">Delegate that will be called after completion of the request.</param>
  180. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  181. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
  182. void AuthorizeAsync(IAuthorizeParameters authorizeParameters, EventHandler<Wayne.Lib.AsyncCompletedEventArgs<long>> requestCompleted, object userToken);
  183. /// <summary>
  184. /// Update of the limits for an already authorised pump. This is the asynchronous version of the request, and will call
  185. /// the supplied delegate on completion. This method may only be called when the pump is successfully reserved.
  186. /// </summary>
  187. /// <param name="authorizeParameters">Object that describes the rules for the authorization.</param>
  188. /// <param name="requestCompleted">Delegate that will be called after completion of the request.</param>
  189. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  190. void AuthorizeUpdateAsync(IAuthorizeParameters authorizeParameters, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  191. /// <summary>
  192. /// Cancel of a fuelling authorization.
  193. /// This is the asynchronous version of the request, and will call
  194. /// the supplied delegate on completion. This method may only be called when the pump is successfully reserved.
  195. /// </summary>
  196. /// <param name="requestCompleted">Delegate that will be called after completion of the request.</param>
  197. /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
  198. void UnauthorizeAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);
  199. /// <summary>
  200. /// Signals that something regarding this pump has happened. The event will be signalled to all registered clients
  201. /// using the OnEventOccured event.
  202. /// </summary>
  203. /// <param name="eventType"></param>
  204. /// <param name="signalEventCompleted"></param>
  205. /// <param name="userToken"></param>
  206. void SignalEventAsync(PumpEventType eventType, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> signalEventCompleted, object userToken);
  207. string ToString();
  208. #endregion
  209. #region Events
  210. /// <summary>
  211. /// Fired when a pump state is changed
  212. /// </summary>
  213. event EventHandler<PumpStateChangeEventArgs> OnStateChange;
  214. /// <summary>
  215. /// Fired when a Nozzle has been hooked in or out. Returns a handle to itself. Event firing is dependent on CapNozzleDetection
  216. /// </summary>
  217. event EventHandler<NozzleStateChangeEventArgs> OnNozzleStateChange;
  218. /// <summary>
  219. /// Fired when a fuelling is running and the volume and amount values has changed.
  220. /// </summary>
  221. event EventHandler<FuellingDataChangeEventArgs> OnFuellingDataChange;
  222. /// <summary>
  223. /// Fired when the state or reservation of a fuelling has changed. Returns a handle affected fuelling.
  224. /// </summary>
  225. event EventHandler<FuellingStateChangeEventArgs> OnFuellingStateChange;
  226. /// <summary>
  227. /// Event that is fired when a client has signalled an event using the SignalEventAsync method or from inside the forecourt
  228. /// controller.
  229. /// </summary>
  230. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Occured")]
  231. event EventHandler<PumpEventOccuredEventArgs> OnEventOccured;
  232. /// <summary>
  233. /// Event that is fired when the status of the tank level switch has changed.
  234. /// </summary>
  235. event EventHandler<TankLevelSwitchStatusChangeEventArgs> OnTankLevelSwitchStatusChange;
  236. #endregion
  237. }
  238. }