Esempio n. 1
0
        protected override void HRMEmulatorLog(HRMEmulatorPacket hrmEmulatorPacket)
        {
            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(hrmEmulator.HeartBeats.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulatorPacket.HeartRate.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulator.MinHeartRate.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulator.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);
        }
Esempio n. 2
0
        protected override void HRMEmulatorLog(HRMEmulatorPacket hrmEmulatorPacket)
        {
            DateTime timestamp = DateTime.Now;

            heartbeats = hrmEmulator.HeartBeats;

            if (hrmEmulator.MinHeartRate < min || min == null)
            {
                min     = hrmEmulator.MinHeartRate;
                minTime = timestamp;
            }
            if (hrmEmulator.MaxHeartRate > max || max == null)
            {
                max     = hrmEmulator.MaxHeartRate;
                maxTime = timestamp;
            }

            if (!running)
            {
                return;
            }

            excelWorksheet.Cells[row, 1].Value = timestamp;
            excelWorksheet.Cells[row, 1].Style.Numberformat.Format = dateFormat;
            excelWorksheet.Cells[row, 2].Value = hrmEmulatorPacket.HeartRate;

            row++;
        }
Esempio n. 3
0
        protected override void HRMEmulatorLog(HRMEmulatorPacket hrmEmulatorPacket)
        {
            DateTime timestamp = DateTime.Now;

            heartbeats = hrmEmulator.HeartBeats;

            if (hrmEmulator.MinHeartRate < min || min == null)
            {
                min     = hrmEmulator.MinHeartRate;
                minTime = timestamp;
            }
            if (hrmEmulator.MaxHeartRate > max || max == null)
            {
                max     = hrmEmulator.MaxHeartRate;
                maxTime = timestamp;
            }

            if (!running)
            {
                return;
            }

            xmlWriter.WriteStartElement("Record");
            xmlWriter.WriteStartAttribute("time");
            xmlWriter.WriteValue(timestamp);
            xmlWriter.WriteEndAttribute();
            xmlWriter.WriteStartElement("BPM");
            xmlWriter.WriteValue(hrmEmulatorPacket.HeartRate);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();
        }
Esempio n. 4
0
        protected override void HRMEmulatorLog(HRMEmulatorPacket hrmEmulatorPacket)
        {
            DateTime timestamp = DateTime.Now;

            if (!running)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(timestamp.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulator.HeartBeats.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulatorPacket.HeartRate.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulator.MinHeartRate.ToString());
            sb.Append(delimiter);
            sb.Append(hrmEmulator.MaxHeartRate.ToString());
            sb.Append(delimiter);

            streamWriter.WriteLine(sb.ToString());
        }
Esempio n. 5
0
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            lastPacket = new HRMEmulatorPacket(bpm);

#if DEBUG
            logger.Debug($"Generated emulated packet = {lastPacket}");
#endif

            if (MinHeartRate == null)
            {
                MinHeartRate = (byte)bpm;
            }
            else
            {
                if (bpm < MinHeartRate)
                {
                    MinHeartRate = (byte)bpm;
                }
            }

            if (MaxHeartRate == null)
            {
                MaxHeartRate = (byte)bpm;
            }
            else
            {
                if (bpm > MaxHeartRate)
                {
                    MaxHeartRate = (byte)bpm;
                }
            }

            if (bpm >= 180)
            {
                maxSlope = 3;
            }
            else if (bpm >= 120)
            {
                maxSlope = 2;
            }
            else
            {
                maxSlope = 1;
            }

            int slopeVar = random.Next(-1, 2);
            slope += slopeVar;
            if (slope > maxSlope)
            {
                slope = maxSlope;
            }
            else if (slope < -maxSlope)
            {
                slope = -maxSlope;
            }
            bpm += slope;

            if (bpm > MAX_BPM)
            {
                bpm   = MAX_BPM;
                slope = 0;
            }
            else if (bpm < MIN_BPM)
            {
                bpm   = MIN_BPM;
                slope = 0;
            }

            TotalPackets++;
            heartBeats += bpm / 60D;
            HeartBeats  = (int)heartBeats;

#if DEBUG
            logger.Debug($"Firing PacketProcessed event, packet = ${lastPacket}");
#endif
            PacketProcessedEventArgs args2 = new PacketProcessedEventArgs(lastPacket);
            base.FirePacketProcessed(args2);
        }
Esempio n. 6
0
 protected abstract void HRMEmulatorLog(HRMEmulatorPacket hrmEmulatorPacket);