Пример #1
0
		private void DeviceFound(object sender, DeviceEventArgs args) {
			try {
				INatDevice device = args.Device;

				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine("Device found");
				Console.ResetColor();
				Console.WriteLine("Type: {0}", device.GetType().Name);
				Console.WriteLine("Service Type: {0}", (device as UpnpNatDevice).ServiceType);

				Console.WriteLine("IP: {0}", device.GetExternalIP());
				device.CreatePortMap(new Mapping(Protocol.Tcp, 15001, 15001));
				Console.WriteLine("---");

				//return;
				/******************************************/
				/*         Advanced test suite.           */
				/******************************************/

				// Try to create a new port map:
				var mapping = new Mapping(Protocol.Tcp, 6001, 6001);
				device.CreatePortMap(mapping);
				Console.WriteLine("Create Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort,
				                  mapping.PrivatePort);

				// Try to retrieve confirmation on the port map we just created:
				try {
					Mapping m = device.GetSpecificMapping(Protocol.Tcp, 6001);
					Console.WriteLine("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort,
					                  m.PrivatePort);
				} catch {
					Console.WriteLine("Couldn't get specific mapping");
				}

				// Try deleting the port we opened before:
				try {
					device.DeletePortMap(mapping);
					Console.WriteLine("Deleting Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort,
									  mapping.PrivatePort);
				} catch {
					Console.WriteLine("Couldn't delete specific mapping");
				}

				// Try retrieving all port maps:
				foreach (Mapping mp in device.GetAllMappings()) {
					Console.WriteLine("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort,
					                  mp.PrivatePort);
				}

				Console.WriteLine("External IP: {0}", device.GetExternalIP());
				Console.WriteLine("Done...");
			} catch (Exception ex) {
				Console.WriteLine(ex.Message);
				Console.WriteLine(ex.StackTrace);
			}
		}
Пример #2
0
 void Devices_DeviceDetected(object sender, DeviceEventArgs e)
 {
     BeginInvoke(new MethodInvoker(delegate()
     {
         foreach (ListViewItem item in devicesListView.Items)
         {
             if (object.ReferenceEquals(item.Tag, e.Device))
             {
                 item.SubItems[1].Text = "GPS DETECTED";
                 item.ImageIndex = 0;
             }
         }
         devicesListView.Refresh();
     }));
 }
Пример #3
0
 private void OnDeviceFound(DeviceEventArgs args)
 {
     if (DeviceFound != null)
         DeviceFound(this, args);
 }  
Пример #4
0
 unsafe void OnDeviceRemoveComplete(object sender, DeviceEventArgs args)
     {
     if (args.pHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
         {
         DEV_BROADCAST_DEVICEINTERFACE_W* pintf = (DEV_BROADCAST_DEVICEINTERFACE_W*)args.pHeader;
         Trace("removed", pintf);
         }
     }
        protected void OnDevice(object sender, DeviceEventArgs args)
        {
            deviceInfo = provider.GetDeviceInfo();
              _shouldSetLocalPosition = true;

              if (deviceInfo.type == LeapDeviceType.Invalid) {
            Debug.LogWarning("Invalid Leap Device -> enabled = false");
            enabled = false;
            return;
              }
              //Get a callback right as rendering begins for this frame so we can update the history and warping.
              LeapVRCameraControl.OnValidCameraParams -= onValidCameraParams; //avoid multiple subscription
              LeapVRCameraControl.OnValidCameraParams += onValidCameraParams;
        }
Пример #6
0
 void Devices_DeviceDetectionAttempted(object sender, DeviceEventArgs e)
 {
     BeginInvoke(new MethodInvoker(delegate()
     {
         ListViewItem item = new ListViewItem();
         item.Text = e.Device.Name;
         item.ImageIndex = 2;
         item.Tag = e.Device;
         item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "Detecting..."));
         devicesListView.Items.Add(item);
         devicesListView.Refresh();
     }));
 }
Пример #7
0
 private void OnDeviceRegistered(object sender, DeviceEventArgs ea)
 {
     if (!this.Dispatcher.CheckAccess())
         this.Dispatcher.BeginInvoke(new Action<object, DeviceEventArgs>(OnDeviceRegistered), new object[] { sender, ea });
     else
     {
         tblNumDevices.Text = PushManager.DeviceManager.Devices.Count().ToString();
     }
 }
Пример #8
0
 /// <summary>
 /// Подписка на событие : DeviceBrowserControl : Свойства одного из устройств было изменено.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void deviceBrowserControl_DevicePropertyWasChanged(object sender, DeviceEventArgs e)
 {
     this.tagBrowserControl.Refresh();
 }
Пример #9
0
 private void device_DeviceRemoved(object sender, DeviceEventArgs e)
 {
     SendByeByeNotifications(e.Device, false);
     DisconnectFromDeviceEvents(e.Device);
 }
 public void OnDisconnect(object sender, DeviceEventArgs args)
 {
     Logger.Info("Leap Motion Disconnected");
 }
Пример #11
0
        /// <summary>
        /// 创建订阅
        /// </summary>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public Task <bool> CreateSubScriptions(List <NodeEntity> nodes)
        {
            return(Task.Run(() =>
            {
                if (session == null)
                {
                    return false;;
                }

                OpcUaDeviceOutParamEntity opcUaDeviceOutParamEntity = new OpcUaDeviceOutParamEntity();
                try
                {
                    List <int> intervals = nodes.Select(data => data.Interval).ToList <int>().Distinct().ToList <int>();
                    intervals.Sort();
                    foreach (int interval in intervals)
                    {
                        List <NodeEntity> subNodes = nodes.FindAll((s) => s.Interval == interval);

                        Subscription subscription;
                        if (!subscriptionDic.ContainsKey(interval))
                        {
                            subscription = new Subscription(session.DefaultSubscription);
                            session.AddSubscription(subscription);
                            subscription.Create();
                            subscriptionDic.Add(interval, subscription);
                        }
                        else
                        {
                            subscription = subscriptionDic[interval];
                        }

                        subscription.PublishingInterval = interval;
                        var monitoredItems = new List <MonitoredItem>();
                        foreach (NodeEntity entity in subNodes)
                        {
                            monitoredItems.Add(
                                new MonitoredItem(subscription.DefaultItem)
                            {
                                StartNodeId = entity.NodeId
                            }
                                );
                        }
                        ;
                        //monitoredItems.ForEach(i => i.Notification += OnMonitoredNotification);
                        if (subscription.MonitoredItemCount == 0)
                        {
                            subscription.AddItems(monitoredItems);
                            subscription.ApplyChanges();
                        }
                        else
                        {
                            subscription.RemoveItems(subscription.MonitoredItems);
                            subscription.AddItems(monitoredItems);
                            subscription.ApplyChanges();
                        }
                        subscription.FastDataChangeCallback += OnFastDataChange;
                        subscriptionDic[interval] = subscription;
                    }

                    //delete subscription
                    foreach (var data in subscriptionDic)
                    {
                        if (intervals.FindAll((s) => s == data.Key).Count() <= 0)
                        {
                            session.RemoveSubscription(subscriptionDic[data.Key]);
                        }
                    }
                }
                catch (ServiceResultException e)
                {
                    opcUaDeviceOutParamEntity.Value = e.LocalizedText;
                    opcUaDeviceOutParamEntity.StatusCode = e.StatusCode;
                    return false;
                }
                DeviceEventArgs <DeviceParamEntityBase> args = new DeviceEventArgs <DeviceParamEntityBase>(opcUaDeviceOutParamEntity);
                Notification?.Invoke(this, args);
                return true;
            }));
        }
Пример #12
0
        /// <summary>
        /// 向OPC服务器写入数据
        /// </summary>
        /// <typeparam name="Tin"></typeparam>
        /// <typeparam name="Tout"></typeparam>
        /// <param name="writeParam"></param>
        /// <returns></returns>
        public Task <Tout> Write <Tin, Tout>(Tin writeParam) where Tin : IDeviceParam where Tout : IDeviceParam
        {
            return(Task <Tout> .Factory.StartNew(() =>
            {
                var writeNode = writeParam as OpcUaDeviceInParamEntity;
                OpcUaDeviceOutParamEntity opcUaDeviceOutParamEntity = new OpcUaDeviceOutParamEntity();
                WriteValue valueToWrite = new WriteValue()
                {
                    NodeId = new NodeId(writeNode.NodeId),
                    AttributeId = Attributes.Value
                };
                valueToWrite.Value.Value = Convert.ChangeType(writeNode.Value, writeNode.ValueType);
                //Type type = valueToWrite.Value.Value.GetType();
                //valueToWrite.Value.Value = Convert.ToInt16(writeNode.Value);
                valueToWrite.Value.StatusCode = StatusCodes.Good;
                valueToWrite.Value.ServerTimestamp = DateTime.MinValue;
                valueToWrite.Value.SourceTimestamp = DateTime.MinValue;

                WriteValueCollection valuesToWrite = new WriteValueCollection
                {
                    valueToWrite
                };

                try
                {
                    session.Write(
                        null,
                        valuesToWrite,
                        out StatusCodeCollection results,
                        out DiagnosticInfoCollection diagnosticInfos);

                    ClientBase.ValidateResponse(results, valuesToWrite);
                    ClientBase.ValidateDiagnosticInfos(diagnosticInfos, valuesToWrite);
                    //opcUaDeviceOutParamEntity.StatusCode = StatusCodes.Good;
                    opcUaDeviceOutParamEntity.Value = !StatusCode.IsBad(results[0]);
                    if (!StatusCode.IsBad(results[0]))
                    {
                        opcUaDeviceOutParamEntity.StatusCode = (uint)DeviceStatusCode.WriteOk;
                    }
                    else
                    {
                        opcUaDeviceOutParamEntity.StatusCode = (uint)DeviceStatusCode.WriteFault;
                    }
                }
                catch (ServiceResultException e)
                {
                    opcUaDeviceOutParamEntity.Value = e.LocalizedText;
                    opcUaDeviceOutParamEntity.StatusCode = e.StatusCode;
                }
                catch (Exception ex)
                {
                    opcUaDeviceOutParamEntity.StatusCode = StatusCodes.Bad;
                    opcUaDeviceOutParamEntity.Value = null;
                    opcUaDeviceOutParamEntity.StatusCode = (uint)DeviceStatusCode.WriteFault;
                }
                DeviceEventArgs <DeviceParamEntityBase> args = new DeviceEventArgs <DeviceParamEntityBase>(opcUaDeviceOutParamEntity);
                Notification?.Invoke(this, args);

                return (Tout)(opcUaDeviceOutParamEntity as object);
            }));
        }
Пример #13
0
        private void NatUtility_DeviceFound(object sender, DeviceEventArgs e)
        {
            NatDeviceWrapper dev = new NatDeviceWrapper(e.Device, e.Device.GetExternalIP(), e.Device.NatProtocol);

            AddListItem(dev);
        }
Пример #14
0
 private void OnDeviceDisconnected(object sender, DeviceEventArgs e)
 {
     RefreshLayout(false);
     RefreshToast("Device Disconnected");
 }
Пример #15
0
 void HandleNatUtilityDeviceFound(object sender, DeviceEventArgs e)
 {
     natdevice = e.Device;
     MapDevice();
 }
Пример #16
0
 public void Begin()
 {
     DeviceEventArgs args = new DeviceEventArgs();
     if (GetDevice != null) GetDevice(this, args);
     GraphicsDevice = args.Device;
     renderContext = new XnaRenderingContext(GraphicsDevice);
     initialized = true;
     Start();
 }
Пример #17
0
 private void DevicePoller_DeviceDisconnected(object sender, DeviceEventArgs e)
 {
     USBDevice = null;
     USBDisconnected?.Invoke(this, new EventArgs());
 }
 private void OnDeviceDiscovered(object sender, DeviceEventArgs args)
 {
     AddOrUpdateDevice(args.Device);
 }
Пример #19
0
 void AnnouncementTestClientDeviceAdded (object sender, DeviceEventArgs e)
 {
     lock (mutex) {
         Assert.AreEqual (new DeviceType ("schemas-upnp-org", "mono-upnp-test-device", new Version (1, 0)), e.Device.Type);
         Assert.AreEqual ("uuid:d1", e.Device.Udn);
         Assert.IsTrue (e.Device.Locations.GetEnumerator ().MoveNext ());
         if (flag) {
             Monitor.Pulse (mutex);
         } else {
             flag = true;
         }
     }
 }
Пример #20
0
        private void ActivityClientDeviceAdded(object sender, DeviceEventArgs e)
        {
            if (DeviceList == null)
                DeviceList = new Dictionary<string, Device>();
            if(e.Device.Id != Device.Id)
                DeviceList.Add(e.Device.Id.ToString(), e.Device);

            Log.Out("ActivityClient",e.Device.Id+" joined the workspace");
        }
Пример #21
0
 private void device_DeviceRemoved(object sender, DeviceEventArgs e)
 {
     SendByeByeNotifications(e.Device, false);
     DisconnectFromDeviceEvents(e.Device);
 }
Пример #22
0
 //Xbox 360 device disconnection handler
 private static void Receiver_DeviceDisconnected(object sender, DeviceEventArgs e)
 {
     _Handle360TabletDisconnect(e.Index);
 }
Пример #23
0
 void OnDeviceRemoved (object sender, DeviceEventArgs e)
 {
     if (devices.ContainsKey (e.Device.Udn)) {
         var iter = devices [e.Device.Udn];
         model.Remove (ref iter);
     }
 }
Пример #24
0
 private void device_DeviceAdded(object sender, DeviceEventArgs e)
 {
     SendAliveNotifications(e.Device, false);
     ConnectToDeviceEvents(e.Device);
 }
Пример #25
0
 private void nmeaInterpreter1_Starting(object sender, DeviceEventArgs e)
 {
     BeginInvoke(new MethodInvoker(delegate()
     {
         statusLabel.Text = "Connecting to " + e.Device.Name + "...";
     }));
 }
Пример #26
0
 /*
  * Do when device is lost.
  */
 public static void OnDeviceLost(object sender, DeviceEventArgs args)
 {
     device = args.Device;
     Clog("Forwarding Device Lost");
 }
Пример #27
0
        /// <summary>
        /// Handles the DeviceDiscovered event of the BluetoothDevice control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DotSpatial.Positioning.DeviceEventArgs"/> instance containing the event data.</param>
        private static void BluetoothDevice_DeviceDiscovered(object sender, DeviceEventArgs e)
        {
            /* When this event occurs, a new Bluetooth device has been found.  Check
             * to see if the device is already in our list of known devices.
             */
            BluetoothDevice newDevice = (BluetoothDevice)e.Device;

            // Examine each known device
            if (_bluetoothDevices.Any(device => device.Address.Equals(newDevice.Address)))
            {
                newDevice.Dispose();
                return;
            }

            // If we get here, the device is brand new.  Add it to the list
            _bluetoothDevices.Add(newDevice);

            // Notify of the discovery
            OnDeviceDiscovered(e.Device);

            // And start detection
            newDevice.BeginDetection();
        }
        private void _leapController_DeviceChanged(object sender, DeviceEventArgs e)
        {
            EditorWindow view = EditorWindow.GetWindow <SceneView>();

            view.Repaint();
        }
Пример #29
0
        private async void DeviceFound(object sender, DeviceEventArgs args)
        {
            await locker.WaitAsync();

            try {
                INatDevice device = args.Device;

                // Only interact with one device at a time. Some devices support both
                // upnp and nat-pmp.

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Device found: {0}", device.NatProtocol);
                Console.ResetColor();
                Console.WriteLine("Type: {0}", device.GetType().Name);

                Console.WriteLine("IP: {0}", await device.GetExternalIPAsync());

                Console.WriteLine("---");

                //return;

                /******************************************/
                /*         Advanced test suite.           */
                /******************************************/

                // Try to create a new port map:
                var mapping = new Mapping(Protocol.Tcp, 6001, 6011);
                await device.CreatePortMapAsync(mapping);

                Console.WriteLine("Create Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort,
                                  mapping.PrivatePort);

                // Try to retrieve confirmation on the port map we just created:
                try {
                    Mapping m = await device.GetSpecificMappingAsync(Protocol.Tcp, mapping.PublicPort);

                    Console.WriteLine("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort,
                                      m.PrivatePort);
                } catch {
                    Console.WriteLine("Couldn't get specific mapping");
                }

                // Try retrieving all port maps:
                try {
                    var mappings = await device.GetAllMappingsAsync();

                    if (mappings.Length == 0)
                    {
                        Console.WriteLine("No existing uPnP mappings found.");
                    }
                    foreach (Mapping mp in mappings)
                    {
                        Console.WriteLine("Existing Mappings: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
                    }
                } catch {
                    Console.WriteLine("Couldn't get all mappings");
                }

                // Try deleting the port we opened before:
                try {
                    await device.DeletePortMapAsync(mapping);

                    Console.WriteLine("Deleting Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort, mapping.PrivatePort);
                } catch {
                    Console.WriteLine("Couldn't delete specific mapping");
                }

                // Try retrieving all port maps:
                try {
                    var mappings = await device.GetAllMappingsAsync();

                    if (mappings.Length == 0)
                    {
                        Console.WriteLine("No existing uPnP mappings found.");
                    }
                    foreach (Mapping mp in mappings)
                    {
                        Console.WriteLine("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
                    }
                } catch {
                    Console.WriteLine("Couldn't get all mappings");
                }

                Console.WriteLine("External IP: {0}", await device.GetExternalIPAsync());
                Console.WriteLine("Done...");
            } finally {
                locker.Release();
            }
        }
 private void OnDeviceDisconnected(object sender, DeviceEventArgs e)
 {
     Devices.FirstOrDefault(d => d.Id == e.Device.Id)?.Update();
     _userDialogs.HideLoading();
     _userDialogs.Toast($"Disconnected {e.Device.Name}");
 }
Пример #31
0
 private void DeviceFound(object sender, DeviceEventArgs args)
 {
     this.Router     = args.Device;
     this.ExternalIp = this.Router.GetExternalIP().ToString();
     timerTickAsync(null, null);
 }
Пример #32
0
 public void DeviceEventArgs_ConstructorThrowsOnNullDevice()
 {
     var args = new DeviceEventArgs(null);
 }
Пример #33
0
 private void DevicePoller_DeviceInitialized(object sender, DeviceEventArgs e)
 {
     USBDevice = e.Device;
     USBInitialized?.Invoke(this, new EventArgs());
 }
Пример #34
0
        private void DeviceLost(object sender, DeviceEventArgs args)
        {
            INatDevice device = args.Device;

            device.DeletePortMap(new Mapping(Mono.Nat.Protocol.Tcp, this.port, this.port));
        }
Пример #35
0
 private void OnDeviceDisconnected(object sender, DeviceEventArgs e)
 {
     //Devices.FirstOrDefault(d => d.Id == e.Device.Id)?.Update();
 }
Пример #36
0
 void LeapController_Device(object sender, DeviceEventArgs e)
 {
     UpdateLeapStatus("Connected", "Device Connected.");
 }
Пример #37
0
        private static void BluetoothDevice_DeviceDiscovered(object sender, DeviceEventArgs e)
        {
            /* When this event occurs, a new Bluetooth device has been found.  Check
             * to see if the device is already in our list of known devices.
             */
            BluetoothDevice newDevice = (BluetoothDevice)e.Device;

            // Examine each known device
            for (int index = 0; index < _BluetoothDevices.Count; index++)
            {
                BluetoothDevice device = _BluetoothDevices[index];

                // Is it the same address as this new device?
                if (device.Address.Equals(newDevice.Address))
                {
                    // Yes.  No need to add it again.  Get rid of it.
                    newDevice.Dispose();
                    return;
                }
            }

            // If we get here, the device is brand new.  Add it to the list
            _BluetoothDevices.Add(newDevice);

            // Notify of the discovery
            OnDeviceDiscovered(e.Device);

            // And start detection
            newDevice.BeginDetection();
        }
Пример #38
0
 void LeapController_DeviceLost(object sender, DeviceEventArgs e)
 {
     UpdateLeapStatus("Device lost");
 }
 protected virtual void OnRaiseDeviceDisconnectedEvent(DeviceEventArgs e)
 {
     EventHandler<DeviceEventArgs> handler = this.RaiseDeviceDisconnectedEvent;
     if (handler != null) handler(this, e);
 }
Пример #40
0
 private void Adapter_DeviceDisconnected(object sender, DeviceEventArgs e)
 {
     Status = AccelerometerStatus.NotConnected;
 }
Пример #41
0
 private void device_DeviceAdded(object sender, DeviceEventArgs e)
 {
     SendAliveNotifications(e.Device, false);
     ConnectToDeviceEvents(e.Device);
 }
Пример #42
0
 static void Devices_DeviceDetectionAttempted(object sender, DeviceEventArgs e)
 {
     Log("          " + DateTime.Now.ToLongTimeString() + ": Testing " + e.Device.Name);
 }
Пример #43
0
        /// <summary>
        /// Updates the fix status to the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        protected virtual void SetFixStatus(FixStatus value)
        {
            // If the new value is the same or it's invalid, ignore it
            if (value == _fixStatus || value == FixStatus.Unknown)
                return;

            // Set the new status
            _fixStatus = value;

            DeviceEventArgs e = new DeviceEventArgs(_device);

            // Is a fix acquired or lost?
            if (_fixStatus == FixStatus.Fix)
            {
                // Acquired.
                if (FixAcquired != null)
                    FixAcquired(this, e);

                Devices.RaiseFixAcquired(e);
            }
            else
            {
                // Lost.
                if (FixLost != null)
                    FixLost(this, e);

                Devices.RaiseFixLost(e);
            }
        }
Пример #44
0
 static void Devices_DeviceDetected(object sender, DeviceEventArgs e)
 {
     Log("FOUND     " + DateTime.Now.ToLongTimeString() + ": " + e.Device.Name + " is a GPS device.");
 }
Пример #45
0
 void OnDeviceAdded (object sender, DeviceEventArgs e)
 {
     var device = e.Device.GetDevice ();
     if (device.Services.Any ((s) => s.Type == ContentDirectory1.ContentDirectory.ServiceType)
         && !device.Udn.EndsWith (FSpotUpnpService.ServiceGuid.ToString ())) {
         var iter = model.AppendValues (device.FriendlyName);
         devices.Add (e.Device.Udn, iter);
     }
 }
Пример #46
0
 public void OnConnect(object sender, DeviceEventArgs args)
 {
     Debug.Log("Leap Motion: Connected");
 }
Пример #47
0
		private void DeviceLost(object sender, DeviceEventArgs args) {
			INatDevice device = args.Device;

			Console.WriteLine("Device Lost");
			Console.WriteLine("Type: {0}", device.GetType().Name);
		}
Пример #48
0
 public void OnConnect(object sender, DeviceEventArgs args)
 {
     Console.WriteLine("Connected");
 }
Пример #49
0
        void Devices_DeviceDetectionAttempted(object sender, DeviceEventArgs e)
        {
            BeginInvoke(new MethodInvoker(delegate()
            {
                undetectButton.Enabled = true;

                foreach (ListViewItem existingItem in devicesListView.Items)
                {
                    if (object.ReferenceEquals(existingItem.Tag, e.Device))
                    {
                        existingItem.SubItems[1].Text = "Detecting...";
                        return;
                    }
                }

                ListViewItem item = new ListViewItem();
                item.Text = e.Device.Name;
                item.ImageIndex = 2;
                item.Tag = e.Device;
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "Detecting..."));
                devicesListView.Items.Add(item);
                devicesListView.Refresh();
            }));
        }
Пример #50
0
        // As I said before, this method will be never invoked. You can remove it.
        void NatUtility_DeviceLost(object sender, DeviceEventArgs e)
        {
            var device = e.Device;

            _logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString());
        }
Пример #51
0
 private void OnDisconnect(object sender, DeviceEventArgs args)
 {
     mainModel.Status = "Disconnect";
 }
Пример #52
0
 private static void DeviceFoundHandler(object sender, DeviceEventArgs e)
 {
     _devices.Add(e.Device);
 }
Пример #53
0
 /// <summary>
 /// Raises the <see cref="FixAcquired"/> event.
 /// </summary>
 /// <param name="e">The <see cref="DotSpatial.Positioning.DeviceEventArgs"/> instance containing the event data.</param>
 internal static void RaiseFixAcquired(DeviceEventArgs e)
 {
     EventHandler<DeviceEventArgs> handler = FixAcquired;
     if (handler != null)
     {
         handler(null, e);
     }
 }
Пример #54
0
 private static void DeviceLostHandler(object sender, DeviceEventArgs e)
 {
     _devices.Remove(e.Device);
 }
 protected virtual void OnDeviceDisconnected(DeviceEventArgs e)
 {
     if (DeviceDisconnected == null)
         return;
     DeviceDisconnected(this, e);
 }
Пример #56
0
        //-----------------------------------------------------------------------------------------
        // Win32 Events
        //-----------------------------------------------------------------------------------------

        /*
        On Bob's super-duper-fast new desktop, we occasionally see faults like this:
        
        CommandFailed: System.ArgumentException: 'usbSerialNumber' cannot be null or empty
           at Org.SwerveRobotics.Tools.BotBug.Service.AndroidDeviceDatabase.FromUSB(String usbSerialNumber) in E:\ftc\tools\BotBugService\AndroidDevice.cs:line 77
           at Org.SwerveRobotics.Tools.BotBug.Service.AndroidDeviceDatabase.UpdateFromDevicesConnectedToAdbServer(List`1 devices) in E:\ftc\tools\BotBugService\AndroidDevice.cs:line 98
           at Org.SwerveRobotics.Tools.BotBug.Service.USBMonitor.EnsureUSBConnectedDevicesAreOnTCPIP(String reason) in E:\ftc\tools\BotBugService\USBMonitor.cs:line 308
           at Org.SwerveRobotics.Tools.BotBug.Service.USBMonitor.OnDeviceArrived(Object sender, DeviceEventArgs args) in E:\ftc\tools\BotBugService\USBMonitor.cs:line 650
           at Org.SwerveRobotics.Tools.BotBug.Service.BotBugService.RaiseDeviceEvent(EventHandler`1 evt, DEV_BROADCAST_HDR* pHeader) in E:\ftc\tools\BotBugService\BotBugService.cs:line 148
           at Org.SwerveRobotics.Tools.BotBug.Service.BotBugService.OnDeviceEvent(Int32 eventType, DEV_BROADCAST_HDR* ...

        We hypothesize that the speed of the new machine has uncovered some latent race with the ADB 
        server. For the moment, we just disable this redundant notification pathway until we have time
        to actually track down the root of the problem.
        */
        unsafe void OnDeviceArrived(object sender, DeviceEventArgs args)
            {
            if (args.pHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
                {
                DEV_BROADCAST_DEVICEINTERFACE_W* pintf = (DEV_BROADCAST_DEVICEINTERFACE_W*)args.pHeader;
                Trace("added (ignored)", pintf);
                // EnsureUSBConnectedDevicesAreOnTCPIP("OnDeviceArrived");
                }
            }