private void write(BtHrpPacket btHrpPacket, DateTime timestamp) { excelWorksheet.Cells[row, 1].Value = timestamp; excelWorksheet.Cells[row, 1].Style.Numberformat.Format = dateFormat; excelWorksheet.Cells[row, 2].Value = btHrpPacket.HeartRate; row++; }
protected override void BtHrpLog(BtHrpPacket btHrpPacket) { DateTime timestamp = DateTime.Now; if (!running) { return; } write(btHrpPacket, timestamp); }
private void write(BtHrpPacket btHrpPacketPacket, DateTime timestamp) { xmlWriter.WriteStartElement("Record"); xmlWriter.WriteStartAttribute("time"); xmlWriter.WriteValue(timestamp); xmlWriter.WriteEndAttribute(); xmlWriter.WriteStartElement("BPM"); xmlWriter.WriteValue(btHrpPacketPacket.HeartRate); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); }
private void ProcessData(byte[] data, DateTimeOffset timestamp) { #if DEBUG logger.Debug("Processing HRP payload, data = " + data); #endif byte currentOffset = 0; byte flags = data[currentOffset]; bool isHeartRateValueSizeLong = ((flags & HEART_RATE_VALUE_FORMAT) != 0); bool hasEnergyExpended = ((flags & ENERGY_EXPANDED_STATUS) != 0); currentOffset++; ushort heartRateMeasurementValue = 0; if (isHeartRateValueSizeLong) { heartRateMeasurementValue = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]); currentOffset += 2; } else { heartRateMeasurementValue = data[currentOffset]; currentOffset++; } ushort expendedEnergyValue = 0; if (hasEnergyExpended) { expendedEnergyValue = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]); currentOffset += 2; } BtHrpPacket btHrpPacket = new BtHrpPacket { HeartRate = heartRateMeasurementValue, HasExpendedEnergy = hasEnergyExpended, ExpendedEnergy = expendedEnergyValue, Timestamp = timestamp }; #if DEBUG logger.Debug("Constructed HRP packet = " + btHrpPacket); #endif TotalPackets++; secondLastPacket = lastPacket; lastPacket = btHrpPacket; ProcessPackets(); }
private void write(BtHrpPacket btHrpPacket, DateTime timestamp) { StringBuilder sb = new StringBuilder(); sb.Append(timestamp.ToString()); sb.Append(delimiter); sb.Append(btHrp.HeartBeats.ToString()); sb.Append(delimiter); sb.Append(btHrpPacket.HeartRate.ToString()); sb.Append(delimiter); sb.Append(btHrp.MinHeartRate.ToString()); sb.Append(delimiter); sb.Append(btHrp.MaxHeartRate.ToString()); sb.Append(delimiter); streamWriter.WriteLine(sb.ToString()); }
private void write(BtHrpPacket btHrpPacket, DateTime timestamp) { StringBuilder sb = new StringBuilder(); sb.Append((packetIndex++).ToString()); sb.Append(delimiter); sb.Append(timestamp.ToString()); sb.Append(delimiter); sb.Append(btHrp.HeartBeats.ToString()); sb.Append(delimiter); sb.Append(btHrpPacket.HeartRate.ToString()); sb.Append(delimiter); sb.Append(btHrp.MinHeartRate.ToString()); sb.Append(delimiter); sb.Append(btHrp.MaxHeartRate.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 override void BtHrpLog(BtHrpPacket btHrpPacket) { DateTime timestamp = DateTime.Now; heartbeats = btHrp.HeartBeats; if (btHrp.MinHeartRate < min || min == null) { min = btHrp.MinHeartRate; minTime = timestamp; } if (btHrp.MaxHeartRate > max || max == null) { max = btHrp.MaxHeartRate; maxTime = timestamp; } if (!running) { return; } write(btHrpPacket, timestamp); }
protected abstract void BtHrpLog(BtHrpPacket btHrpPacket);