SetTankProductLabelRequest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace VeederRoot_ATG_Console.MessageEntity.Outgoing
  5. {
  6. /// <summary>
  7. /// i|I602
  8. /// </summary>
  9. public class SetTankProductLabelRequest : OutgoingMessageBase
  10. {
  11. /// <summary>
  12. ///
  13. /// </summary>
  14. /// <param name="messageFormat"></param>
  15. /// <param name="tankNumber">0 indicates all tanks</param>
  16. /// <param name="productLabel">max 20 ASCII chars from 0x20 to 0x7E, like 'REGULAR UNLEADED', will pad right with space</param>
  17. public SetTankProductLabelRequest(MessageFormat messageFormat
  18. , int tankNumber, string productLabel)
  19. : base(messageFormat, FuncCode.SetTankProductLabel,
  20. tankNumber.ToString())
  21. {
  22. if (tankNumber < 0 || tankNumber > 99) throw new ArgumentOutOfRangeException("Valid tank number is range from 0 to 99");
  23. if (productLabel.Length > 20) throw new ArgumentOutOfRangeException("Valid productLabel must have its length from 0 to 20");
  24. //base.FunctionCodeRaw = base.FunctionCodeRaw.Substring(0, 4) + tankNumber.ToString().PadLeft(2, '0');
  25. base.DataField = new List<byte>();
  26. base.DataField.AddRange(Encoding.ASCII.GetBytes(productLabel.PadRight(20, ' ')));
  27. }
  28. }
  29. }