PollingOrSelectingRequest.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace TATSUNO_Pump.Messages
  5. {
  6. /// <summary>
  7. /// sample: [04][40][51][05]
  8. /// </summary>
  9. public class PollingOrSelectingRequest : MessageBase
  10. {
  11. public enum RequestTypeEnum { Polling = 1, Selecting = 0 }
  12. public enum DeviceKindEnum { Interface = 0x00, GasPumpOrLpgDispenser = 0x01, LevelMeter = 0x04, CarWasher = 0x06, LargSizedDisplay = 0x07, AutoChanger = 0x08, OilChanger = 0x09 }
  13. /// <summary>
  14. ///
  15. /// </summary>
  16. /// <param name="stationAddress">actual the device address which configed in device side, range from 40H~7FH</param>
  17. /// <param name="requestType"></param>
  18. /// <param name="deviceKind"></param>
  19. public PollingOrSelectingRequest(byte stationAddress, RequestTypeEnum requestType, DeviceKindEnum deviceKind)
  20. {
  21. if (stationAddress < 0x40 || stationAddress > 0x7F)
  22. throw new ArgumentException("stationAddress must in range of 40H~7FH");
  23. base.DataRaw = new List<byte>();
  24. base.DataRaw.AddRange(new byte[] {
  25. 0x04,
  26. stationAddress,
  27. (byte)(((1 + (byte)requestType)<<4) +(byte)deviceKind),
  28. 0x05 });
  29. }
  30. }
  31. }