PolarEcgData.cs 754 B

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