示例#1
0
        private void NewSensors_AntPlusDeviceEvent(object sender, AntPlusDeviceEventArgs e)
        {
            ListViewItem item = new ListViewItem(e.DeviceType.ToString());

            item.SubItems.Add(e.ExtendedDeviceNumber.ToString());
            //item.SubItems.Add(e.DeviceNumber.ToString());
            //item.SubItems.Add(e.Device.RSSI.ToString());
            item.Tag = e.Device;
            listViewSensors.Items.Add(item);
        }
示例#2
0
        /// <summary>
        /// This method is called when an ANT device is added or removed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _ants_AntPlusDeviceEvent(object sender, AntPlusDeviceEventArgs e)
        {
            // Format data and display
            GroupBox g = CreateDeviceBox(e.Device, e);

            if (g != null)
            {
                MainPanel.Children.Add(g);

                // Register heart rate monitor for data updates
                if (e.DeviceType == AntDeviceType.HeartRateMonitor)
                {
                    ((HeartRateMonitor)(e.Device)).HeartRateMessageEvent += MainWindow_AntMessageEvent;
                }
                else if (e.DeviceType == AntDeviceType.BikeSpeedSensor)
                {
                    ((BikeSpeedSensor)(e.Device)).BikeSpeedMessageEvent += MainWindow_AntMessageEvent;
                }
                else if (e.DeviceType == AntDeviceType.BikePowerSensor)
                {
                    ((BikePowerSensor)(e.Device)).BikePowerOnlyEvent += MainWindow_AntMessageEvent;
                }
                else if (e.DeviceType == AntDeviceType.MuscleOxygenMonitor)
                {
                    ((MuscleOxygenMonitor)(e.Device)).PropertyChanged += MainWindow_AntMessageEvent;
                }
                else if (e.DeviceType == AntDeviceType.FitnessEquipment)
                {
                    ((FitnessEquipment)(e.Device)).FitnessEquipmentEvent += MainWindow_AntMessageEvent;
                }
                else if (e.DeviceType == AntDeviceType.UnknownSensor)
                {
                    ((UnknownDevice)(e.Device)).PropertyChanged += MainWindow_AntMessageEvent;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Returns a list of user-pertinent data from the FitnessEquipment
        /// </summary>
        /// <param name="h">FitnessEquipment device</param>
        /// <param name="a">Device arguments</param>
        /// <returns></returns>
        public static List <string> FormatFitnessEquipment(object h, object a)
        {
            FitnessEquipment fe     = h as FitnessEquipment;
            List <string>    data   = new List <string>();
            string           name   = "Unknown";
            ushort           number = 0;

            if (fe.Manufacturer != null)
            {
                number = fe.Manufacturer.ModelNumber;
                name   = fe.Manufacturer.ManufacturerName;
            }

            AntPlusDeviceEventArgs ap = a as AntPlusDeviceEventArgs;
            {
                if (ap != null)
                {
                    string targetName = string.Format("{0} ID: {1}", ap.DeviceType, ap.ExtendedDeviceNumber);
                    data.Add(targetName);
//                    data.Add("ID: " + fe.ExtendedDeviceNumber.ToString());
                    data.Add("Type: " + fe.DeviceType.ToString());
                    return(data);
                }
            }

            BikeMessageEventArgs bike = a as BikeMessageEventArgs;

            if (bike != null)
            {
                string targetName = string.Format("{0} ID: {1}", ap.DeviceType, ap.ExtendedDeviceNumber);
                data.Add(targetName);
                data.Add("Type: " + fe.DeviceType.ToString());
                data.Add(string.Format("Mfr: {0}", name));
                data.Add(string.Format("Model: {0}", number));
                data.Add(string.Format("Cadence: {0}", bike.InstantaneousCadence));
                data.Add(string.Format("Power: {0}", bike.InstantaneousPower));
            }

            TrainerMessageEventArgs tr = a as TrainerMessageEventArgs;

            if (tr != null)
            {
                string targetName = string.Format("{0} ID: {1}", ap.DeviceType, ap.ExtendedDeviceNumber);
                data.Add(targetName);
                data.Add("Type: " + fe.DeviceType.ToString());
                data.Add(string.Format("Mfr: {0}", name));
                data.Add(string.Format("Model: {0}", number));
                data.Add(string.Format("Cadence: {0}", tr.InstantaneousCadence));
                data.Add(string.Format("Power: {0}", tr.AccumulatedPower));
            }
            else
            {
                RowerMessageEventArgs r = a as RowerMessageEventArgs;
                if (r != null)
                {
                    string targetName = string.Format("{0} ID: {1}", ap.DeviceType, ap.ExtendedDeviceNumber);
                    data.Add(targetName);
                    data.Add("Type: " + fe.DeviceType.ToString());
                    data.Add(string.Format("Mfr: {0}", name));
                    data.Add(string.Format("Model: {0}", number));
                    data.Add(string.Format("Cadence: {0}", r.InstantaneousCadence));
                    data.Add(string.Format("Strokes: {0}", r.AccumulatedStrokeCount));
                }
            }
            return(data);
        }