public void SetAbsoluteStart(String dataStr) { var sr = new StringReader(dataStr); var contentElement = XElement.Load(sr); contentElement = XMLHelper.RemoveAllNamespaces(contentElement); var startTime = contentElement.Element("StartTime").Value; getResultsCtrl1.AbsoluteStart = ArtifactsHelper.GetDateTime(startTime); AbsolutStartSet = true; }
public static List <Artifact> DeserializeResults(IEnumerable <XElement> newResults) { var toRet = new List <Artifact>(); foreach (var item in newResults) { var curArt = new Artifact(); String curVal = XMLHelper.GetXMLValByLocalName(item, "StartTime"); curArt.StartTime = ArtifactsHelper.GetDateTime(curVal); curVal = XMLHelper.GetXMLValByLocalName(item, "EndTime"); curArt.EndTime = ArtifactsHelper.GetDateTime(curVal); curVal = XMLHelper.GetXMLValByLocalName(item, "Category"); curArt.Category = curVal; var artData = XMLHelper.GetXMLElementByLocalName(item, "ArtifactData"); if (artData == null) { continue; } switch (curVal) { case "Baseline": curArt.ArtifactData = CreateBaselineData(artData); break; case "Contraction": curArt.ArtifactData = CreateContractionData(artData); break; case "Acceleration": curArt.ArtifactData = CreateAccelerationData(artData); break; case "Deceleration": curArt.ArtifactData = CreateDecelerationData(artData); break; default: break; } toRet.Add(curArt); } return(toRet); }
public void AppendTracings(String dataStr) { var sr = new StringReader(dataStr); var contentElement = XElement.Load(sr); contentElement = XMLHelper.RemoveAllNamespaces(contentElement); var fhr = contentElement.Element("Fhr").Value; var fhrTempList = new List <byte>(Convert.FromBase64String(fhr)); var up = contentElement.Element("Up").Value; var upTempList = new List <byte>(Convert.FromBase64String(up)); var startTime = contentElement.Element("StartTime").Value; DateTime start = ArtifactsHelper.GetDateTime(startTime); var diff = start - LastTimeStamp; if (LastTimeStamp == DateTime.MinValue) { LastTimeStamp = start.AddSeconds(-1); } else if (diff.TotalSeconds > 1) // GAP { int secondsToFill = ((int)Math.Floor(diff.TotalSeconds)) - 1; for (int i = 0; i < secondsToFill; i++) { FhrList.Add(255); FhrList.Add(255); FhrList.Add(255); FhrList.Add(255); UpsList.Add(255); } LastTimeStamp = LastTimeStamp.AddSeconds(secondsToFill); } else if (diff.TotalSeconds <= 0) // OVERLAP { int secondsToRemove = (Math.Abs((int)Math.Floor(diff.TotalSeconds))) + 1; upTempList.RemoveRange(0, secondsToRemove); fhrTempList.RemoveRange(0, secondsToRemove * 4); } FhrList.AddRange(fhrTempList); UpsList.AddRange(upTempList); LastTimeStamp = LastTimeStamp.AddSeconds(upTempList.Count); }