Ejemplo n.º 1
0
        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++;
        }
Ejemplo n.º 2
0
        protected override void BtHrpLog(BtHrpPacket btHrpPacket)
        {
            DateTime timestamp = DateTime.Now;

            if (!running)
            {
                return;
            }

            write(btHrpPacket, timestamp);
        }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 protected abstract void BtHrpLog(BtHrpPacket btHrpPacket);