TemperatureResponse.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using ProGauge_StartItaliana_Probe.MessageEntity.Outgoing;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace ProGauge_StartItaliana_Probe.MessageEntity.Incoming
  7. {
  8. public class TemperatureResponse
  9. {
  10. /// <summary>
  11. /// The first number is always 0.
  12. /// Then you have temperature in 10th of degree starting from the bottom side
  13. /// position in the probe up to the top. Each temperature is signed number
  14. /// in case the temperature is negative.
  15. /// </summary>
  16. public IReadOnlyList<double> Values { get; private set; }
  17. /// <summary>
  18. ///
  19. /// </summary>
  20. /// <param name="raw">Each number is referred to a temperature sensor inside the probe.</param>
  21. public static TemperatureResponse Parse(byte[] raw)
  22. {
  23. var response = new TemperatureResponse();
  24. var msg = Encoding.ASCII.GetString(raw);
  25. var parts = msg.Split(' ');
  26. response.Values = parts.Select(p => double.Parse(p)).ToList();
  27. return response;
  28. }
  29. }
  30. }