IOpt.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using Wayne.Lib;
  3. namespace Wayne.ForecourtControl.OptBridge
  4. {
  5. /// <summary>
  6. /// The OPT object is used to communicate with an outdoor payment terminal connected to the forecourt server.
  7. /// Only one client can control the interface, and the interface must be reserverd by the client before the write() method is accepted.
  8. /// OnDataRead is also only signalled to the client that owns the reservation.
  9. /// </summary>
  10. public interface IOpt
  11. {
  12. #region Properties
  13. /// <summary>
  14. /// Logical terminal number / filling position.
  15. /// </summary>
  16. int Id { get;}
  17. /// <summary>
  18. /// Current state of the connection to the terminal. The Connection state will only be either Connected when
  19. /// the terminal is online or Connecting if the terminal is not responding.
  20. /// </summary>
  21. DeviceConnectionState ConnectionState { get;}
  22. /// <summary>
  23. /// If the terminal is reserved, the clientId of the reserving IOptBridge client will be reported here.
  24. /// If the terminal not is reserved, it will be 0.
  25. /// </summary>
  26. int ReservedByClientId { get;}
  27. #endregion
  28. #region Events
  29. /// <summary>
  30. /// Event signalling that the connection state of the terminal has changed.
  31. /// </summary>
  32. event EventHandler<ConnectionChangedEventArgs> OnConnectionStateChange;
  33. /// <summary>
  34. /// Fired when data has been read from the terminal. Only the client that has reserved the terminal will receive this event.
  35. /// </summary>
  36. event EventHandler<OptDataEventArgs> OnDataRead;
  37. #endregion
  38. #region Methods
  39. /// <summary>
  40. /// Reserves this device for exclusve control from this instance.
  41. /// </summary>
  42. /// <param name="reserveCompleted">Callback delegate that will be invoked on completion.</param>
  43. /// <param name="userToken">User token object that will be returned in the completion callback</param>
  44. void ReserveAsync(EventHandler<AsyncCompletedEventArgs> reserveCompleted, object userToken);
  45. /// <summary>
  46. /// Cancel device reservation. This command is only allowed after a successful call to ReserveAsync() by the same client.
  47. /// </summary>
  48. /// <param name="unreserveCompleted">Callback delegate that will be invoked on completion.</param>
  49. /// <param name="userToken">User token object that will be returned in the completion callback</param>
  50. void UnreserveAsync(EventHandler<AsyncCompletedEventArgs> unreserveCompleted, object userToken);
  51. /// <summary>
  52. /// The data is transparently sent to the terminal, only appending protocol specific information. If waitForSendOk=false,
  53. /// the request will complete as soon as the data has been sent to the forecourt server. If it is true, the request will
  54. /// be complete after the data is actually sent to the terminal.
  55. /// </summary>
  56. /// <param name="terminalData"></param>
  57. /// <param name="waitForSendOk">If this flag is set, the writeCompleted will not be invoked until the data is actually sent to the terminal.</param>
  58. /// <param name="writeCompleted"></param>
  59. /// <param name="userToken"></param>
  60. void WriteAsync(byte[] terminalData, bool waitForSendOk, EventHandler<OptWriteCompletedEventArgs> writeCompleted, object userToken);
  61. #endregion
  62. }
  63. }