예제 #1
0
        public void Page0Data()
        {
            var sensor = new HeartRateMonitor();
            byte [] rxData;

            rxData = new byte[] {
                0,
                0,
                0, 0, 0,    // Reserved bytes
                0x10, 0xF0, // Event time
                0x7F,       // Heart beat count
                0x4A,       // Heart rate
            };

            sensor.InterpretReceivedData(rxData);

            Assert.IsNull(sensor.CumulativeOperatingTime);
            Assert.IsNull(sensor.ManufacturerID);
            Assert.IsNull(sensor.SerialNumber);
            Assert.IsNull(sensor.HardwareVersion);
            Assert.IsNull(sensor.SoftwareVersion);
            Assert.IsNull(sensor.ModelNumber);
            Assert.IsNull(sensor.PreviousHeartBeatEventTime);

            Assert.AreEqual(61456, sensor.HeartBeatEventTime);
            Assert.AreEqual(127, sensor.HeartBeatCount);
            Assert.AreEqual(74, sensor.ComputedHeartRate);
        }
예제 #2
0
파일: Main.cs 프로젝트: prograhamer/Truant
        public static void Main(string[] args)
        {
            var connection = AntPlusConnection.GetConnection(0 /* USB device */, 0 /* network no */);

            connection.Connect();

            var hrMonitor = new HeartRateMonitor();
            var speedCadence = new BikeSpeedCadenceSensor(2096);

            connection.AddDevice(hrMonitor);
            connection.AddDevice(speedCadence);

            for(int i = 0; i < 45; i++)
            {
                Thread.Sleep(1000);
                Console.WriteLine("Heart rate: " + hrMonitor.ComputedHeartRate);
                Console.WriteLine("HR device config: " + hrMonitor.Config);
                Console.WriteLine("Instantaneous speed: " + speedCadence.Speed);
                Console.WriteLine ("Instantaneous cadence: " + speedCadence.Cadence);
            }

            connection.Disconnect();
        }