Beispiel #1
0
 /// <summary>
 /// Called when a WASP is added or removed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Wasps_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         int count = e.NewItems.Count;
         for (int i = 0; i < e.NewItems.Count; i++)
         {
             if (((Wasp)e.NewItems[i]).Name == _deviceNames[0])
             {
                 _waspUT = (Wasp)e.NewItems[i];
                 _waspUT.PropertyChanged += Wasp_PropertyChanged;
                 WaspCollection.SendExtendedWaspQuery(_waspUT.WaspIPAddress);
                 _waspReady.Set();
                 buttonPoE.IsEnabled   = true;
                 buttonRadio.IsEnabled = true;
                 break;
             }
             else if (((Wasp)e.NewItems[i]).Name == _deviceNames[1])
             {
                 _waspUT = (Wasp)e.NewItems[i];
                 _waspReady.Set();
                 buttonOta.IsEnabled = true;
                 break;
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Called after the window has loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            WindowInteropHelper w = new WindowInteropHelper(this);

            _wasps = new WaspCollection(new IPAddress(new byte[] { 239, 78, 80, 1 }), 51113, w.Handle);
            _wasps.CollectionVerbosity = Wasp.WaspLogLevel.None;
            _wasps.CollectionChanged  += Wasps_CollectionChanged;
        }
        public UsbConfigureMainWindow()
        {
            InitializeComponent();

            WindowInteropHelper w = new WindowInteropHelper(this);

            _wasps = new WaspCollection(w.Handle);
            // Register for notification of a new WASP added or removed
            _wasps.CollectionChanged += WASP_CollectionChangedEvent;
        }
Beispiel #4
0
 public MainWindow()
 {
     InitializeComponent();
     buttonPoE.IsEnabled = false;
     buttonOta.IsEnabled = false;
     _wasps = new WaspCollection();
     _wasps.CollectionVerbosity = Wasp.WaspLogLevel.None;
     _wasps.CollectionChanged  += Wasps_CollectionChanged;
     _waspReady    = new EventWaitHandle(false, EventResetMode.AutoReset);
     label.Content = "";
 }
Beispiel #5
0
 /// <summary>
 /// Called upon completion of programming
 /// </summary>
 /// <param name="status">Status update</param>
 private void ProgrammingComplete(ProgrammingStatusCode status)
 {
     if (status == ProgrammingStatusCode.SUCCESS)
     {
         WaspCollection.SendExtendedWaspQuery(_waspUT.WaspIPAddress);
         Progress.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { Progress.Background = Brushes.Green; label.Content = "Programming Complete"; }));
     }
     else
     {
         string statusCode = string.Format("Programming Failed: 0x{0:X}", status);
         Progress.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { Progress.Background = Brushes.OrangeRed; label.Content = statusCode; }));
     }
 }
Beispiel #6
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (checkBoxUsb.Checked)
            {
                _wasps = new WaspCollection(Handle);
            }
            else
            {
                _wasps = new WaspCollection();
            }
            _wasps.CollectionChanged += Wasps_CollectionChanged;
            // connect to ANT device notifications
            _sensors = new AntPlusDevices(_wasps);
            _sensors.AntPlusDeviceEvent += NewSensors_AntPlusDeviceEvent;;

            buttonStart.Enabled = false;
        }
Beispiel #7
0
        /// <summary>
        /// Connect to Wasp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UsbOnly.IsChecked == true)
                {
                    WindowInteropHelper w = new WindowInteropHelper(this);
                    _wasps = new WaspCollection(w.Handle);
                }
                else
                {
                    _wasps = new WaspCollection();
                }

                // Register for notification of a new WASP added or removed
                _wasps.CollectionChanged += WASP_CollectionChangedEvent;
                // Extract the list of ANT devices reported by the WASPs
                _ants = new AntPlusDevices(_wasps);
                // Get the list of KeiserM3i bikes
                _bikes = _ants.KeiserM3Bikes;
                // Register for notification of a bike added or removed
                _bikes.BluetoothNewDeviceEvent += new EventHandler <KeiserM3EventArgs>(Keiser_DataEvent);

                _polarHrms = _ants.PolarH7HeartRateMonitors;
                _polarHrms.CollectionChanged += PolarHrms_CollectionChanged;

                _suuntoHRMs = _ants.SuuntoHeartRateMonitors;
                _suuntoHRMs.CollectionChanged += Suunto_CollectionChanged;

                _ble = _ants.GenericBleDevices;
                _ble.BluetoothNewDeviceEvent += Ble_BluetoothNewDeviceEvent;


                BtnConnect.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Failed to connect: {0}", ex.ToString()));
            }
        }
Beispiel #8
0
        /// <summary>
        /// Creates a WASP collection  which will then accept data from BLE and ANT devices
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a collection of wasps on all available networks
            if (checkBoxUsb.IsChecked == true)
            {
                WindowInteropHelper w = new WindowInteropHelper(this);
                _wasps = new WaspCollection(WaspCollection.DefaultMulticastPort, w.Handle);
            }
            else
            {
                _wasps = new WaspCollection();
            }

            _wasps.CollectionVerbosity = Wasp.WaspLogLevel.All;
            // Get Query response message
            _wasps.CollectionChanged += wasps_CollectionChanged;
            // Extract the list of ANT devices reported by the WASPs
            _ants = new AntPlusDevices(_wasps);
            _ants.AntPlusDeviceEvent += _ants_AntPlusDeviceEvent;
            _ants.KeiserM3Bikes.BluetoothNewDeviceEvent += KeiserM3Bikes_BluetoothNewDeviceEvent;
            StartButton.IsEnabled = false;
        }
Beispiel #9
0
        /// <summary>
        /// Called when a WASP is added or removed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Wasps_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                int count = e.NewItems.Count;
                for (int i = 0; i < e.NewItems.Count; i++)
                {
                    if (((Wasp)e.NewItems[i]).Name == _deviceNames[0])
                    {
                        _waspUT = (Wasp)e.NewItems[i];
                        _waspReady.Set();
                        buttonPoE.IsEnabled   = true;
                        buttonRadio.IsEnabled = true;
                        Progress.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { label1.Content = string.Format("{0} F/W version {1}.{2}.{3}",
                                                                                                                                                         _waspUT.Name, _waspUT.VersionMajor, _waspUT.VersionMinor, _waspUT.ProductVersion); }));
                        break;
                    }
                    else if (((Wasp)e.NewItems[i]).Name == _deviceNames[1])
                    {
                        _waspUT = (Wasp)e.NewItems[i];
                        _waspUT.PropertyChanged += Wasp_PropertyChanged;
                        WaspCollection.SendExtendedWaspQuery(_waspUT.WaspIPAddress);
                        Progress.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => {
                            label1.Content = string.Format("{0} F/W version {1}.{2}.{3}", _waspUT.Name, _waspUT.VersionMajor, _waspUT.VersionMinor, _waspUT.ProductVersion);
                        }));

                        _waspReady.Set();
                        buttonOta.IsEnabled = true;
                        break;
                    }
                    else if (((Wasp)e.NewItems[i]).BasestationMode)
                    {
                        _waspUsb            = (Wasp)e.NewItems[i];
                        buttonUsb.IsEnabled = true;
                    }
                }
            }
        }