Exemplo n.º 1
0
        private ComputrainerDataSample ReadSample()
        {
            var sample = new ComputrainerDataSample();

            // 1 byte heart rate, in BPM
            sample.HeartRateBpm = input.ReadByte();

            // 1 byte cadence, in RPM
            sample.CadenceRpm = input.ReadByte();

            // 2 unsigned bytes of watts
            sample.PowerWatts = input.ReadUInt16();

            // 4 bytes of floating point speed (in mph/160 !!)
            sample.SpeedMph = input.ReadSingle() * 160;

            // 4 bytes of total elapsed time, in milliseconds
            sample.TimeMilisecondElapsed = input.ReadUInt32();

            // 2 signed bytes of 100 * [percent grade]
            // (i.e., grade == 100 * 100 * rise/run !!)
            sample.GradePercent = input.ReadInt16() / (100.0f * 100.0f);

            // not sure what the next 2 bytes are
            input.Skip(2);

            // 4 bytes of floating point total distance traveled, in KM
            sample.DistanceKilometerElapsed = input.ReadSingle();

            // not sure what the next 28 bytes are.
            input.Skip(0x1c);

            return(sample);
        }
        private ComputrainerDataSample ReadSample()
        {
            var sample = new ComputrainerDataSample();
            // 1 byte heart rate, in BPM
            sample.HeartRateBpm = input.ReadByte();

            // 1 byte cadence, in RPM
            sample.CadenceRpm = input.ReadByte();

            // 2 unsigned bytes of watts
            sample.PowerWatts = input.ReadUInt16();

            // 4 bytes of floating point speed (in mph/160 !!)
            sample.SpeedMph = input.ReadSingle() * 160;

            // 4 bytes of total elapsed time, in milliseconds
            sample.TimeMilisecondElapsed = input.ReadUInt32();

            // 2 signed bytes of 100 * [percent grade]
            // (i.e., grade == 100 * 100 * rise/run !!)
            sample.GradePercent = input.ReadInt16() / (100.0f * 100.0f);

            // not sure what the next 2 bytes are
            input.Skip(2);

            // 4 bytes of floating point total distance traveled, in KM
            sample.DistanceKilometerElapsed = input.ReadSingle();

            // not sure what the next 28 bytes are.
            input.Skip(0x1c);

            return sample;
        }