PolarEcgData.cs 804 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace Sensors.Polar
  5. {
  6. public readonly struct EcgData
  7. {
  8. public long Timestamp { get; }
  9. public List<float> Values { get; }
  10. private EcgData(long timestamp, List<float> values)
  11. {
  12. Timestamp = timestamp;
  13. Values = values;
  14. }
  15. public static EcgData FromString(string s)
  16. {
  17. var data = s.Split(';');
  18. if (data.Length == 2)
  19. {
  20. var t = long.Parse(data[0]);
  21. var values = data[1].Split(',').Select(value => float.Parse(value)).ToList();
  22. return new EcgData(t, values);
  23. }
  24. throw new FormatException("EcgData String has wrong format");
  25. }
  26. }
  27. }