protected override void CMS50Log(CMS50Packet cms50Packet) { DateTime timestamp = DateTime.Now; if (!running) { return; } StringBuilder sb = new StringBuilder(); sb.Append(timestamp.ToString()); sb.Append(delimiter); sb.Append(cms50.HeartBeats.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.HeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50.MinHeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50.MaxHeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.SpO2.ToString()); sb.Append(delimiter); sb.Append(cms50.MinSpO2.ToString()); sb.Append(delimiter); sb.Append(cms50.MaxSpO2.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.Waveform.ToString()); sb.Append(delimiter); streamWriter.WriteLine(sb.ToString()); }
private void ClosePacketQueue() { #if DEBUG logger.Debug("Closing packet queue"); #endif packetQueue.Enqueue(receivedData.Dequeue()); try { CMS50Packet cms50Packet = new CMS50Packet(packetQueue.ToArray()); secondLastPacket = lastPacket; lastPacket = cms50Packet; #if DEBUG logger.Debug($"Constructed CMS50 packet = {cms50Packet}"); #endif } catch (CorruptedPacketExcpetion e) { #if DEBUG logger.Debug("Packet construction failed, corrupted packet", e); #endif CorruptedPackets++; } ProcessPackets(); ResetPacketQueue(); }
protected override void CMS50Log(CMS50Packet cms50Packet) { DateTime timestamp = DateTime.Now; heartbeats = cms50.HeartBeats; if (cms50.MinHeartRate < minHeartRate || minHeartRate == null) { minHeartRate = cms50.MinHeartRate; minHeartRateTime = timestamp; } if (cms50.MaxHeartRate > maxHeartRate || maxHeartRate == null) { maxHeartRate = cms50.MaxHeartRate; maxHeartRateTime = timestamp; } if (cms50.MinSpO2 < minSpO2 || minSpO2 == null) { minSpO2 = cms50.MinSpO2; minSpO2Time = timestamp; } if (cms50.MaxSpO2 > maxSpO2 || maxSpO2 == null) { maxSpO2 = cms50.MaxSpO2; maxSpO2Time = timestamp; } if (!running) { return; } xmlWriter.WriteStartElement("Record"); xmlWriter.WriteStartAttribute("time"); xmlWriter.WriteValue(timestamp); xmlWriter.WriteEndAttribute(); xmlWriter.WriteStartElement("BPM"); xmlWriter.WriteValue(cms50Packet.HeartRate); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("SpO2"); xmlWriter.WriteValue(cms50Packet.SpO2); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("Waveform"); xmlWriter.WriteValue(cms50Packet.Waveform); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); }
protected override void CMS50Log(CMS50Packet cms50Packet) { DateTime timestamp = DateTime.Now; heartbeats = cms50.HeartBeats; if (cms50.MinHeartRate < minHeartRate || minHeartRate == null) { minHeartRate = cms50.MinHeartRate; minHeartRateTime = timestamp; } if (cms50.MaxHeartRate > maxHeartRate || maxHeartRate == null) { maxHeartRate = cms50.MaxHeartRate; maxHeartRateTime = timestamp; } if (cms50.MinSpO2 < minSpO2 || minSpO2 == null) { minSpO2 = cms50.MinSpO2; minSpO2Time = timestamp; } if (cms50.MaxSpO2 > maxSpO2 || maxSpO2 == null) { maxSpO2 = cms50.MaxSpO2; maxSpO2Time = timestamp; } if (!running) { return; } excelWorksheet.Cells[row, 1].Value = timestamp; excelWorksheet.Cells[row, 1].Style.Numberformat.Format = dateFormat; excelWorksheet.Cells[row, 2].Value = cms50Packet.HeartRate; excelWorksheet.Cells[row, 3].Value = cms50Packet.SpO2; excelWorksheet.Cells[row, 4].Value = cms50Packet.Waveform; row++; }
protected override void CMS50Log(CMS50Packet cms50Packet) { DateTime timestamp = DateTime.Now; if (!running) { return; } StringBuilder sb = new StringBuilder(); sb.Append((packetIndex++).ToString()); sb.Append(delimiter); sb.Append(timestamp.ToString()); sb.Append(delimiter); sb.Append(cms50.HeartBeats.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.HeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50.MinHeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50.MaxHeartRate.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.SpO2.ToString()); sb.Append(delimiter); sb.Append(cms50.MinSpO2.ToString()); sb.Append(delimiter); sb.Append(cms50.MaxSpO2.ToString()); sb.Append(delimiter); sb.Append(cms50Packet.Waveform.ToString()); sb.Append(delimiter); sb.Append(Environment.NewLine); byte[] payload = Encoding.UTF8.GetBytes(sb.ToString()); udpClient.Send(payload, payload.Length, this.ipAddress, this.destinationPort); }
protected abstract void CMS50Log(CMS50Packet cms50Packet);