Beispiel #1
0
            /// <summary>
            /// Constructs a new device search instance
            /// </summary>
            /// <param name="host">The host instance</param>
            /// <param name="address">The device address to search for</param>
            /// <param name="callback">The callback object for the search</param>
            public DeviceSearch(Host host, Address address, IDeviceSearchCallback callback)
            {
                this.Host             = host;
                this.IsInstanceSearch = false;
                this.Address          = address;
                this.Callback         = callback;

                this.Attempt = 0;

                this._timer = new Timer(
                    _tick,
                    null,
                    DeviceSearchInterval,
                    DeviceSearchInterval
                    );
            }
Beispiel #2
0
            /// <summary>
            /// Constructs a new device search instance
            /// </summary>
            /// <param name="host">The host instance</param>
            /// <param name="instance">The device instance to search for</param>
            /// <param name="callback">The callback object for the search</param>
            public DeviceSearch(Host host, uint instance, IDeviceSearchCallback callback)
            {
                this.Host             = host;
                this.IsInstanceSearch = true;
                this.Instance         = instance;
                this.Callback         = callback;

                this.Attempt = 0;

                this._timer = new Timer(
                    _tick,
                    null,
                    DeviceSearchInterval,
                    DeviceSearchInterval
                    );
            }
Beispiel #3
0
 /// <summary>
 /// Searches for a device (Sends a who-is request)
 /// </summary>
 /// <param name="address">The address of the device to search for</param>
 /// <param name="callback">The callback to invoke when the device is found</param>
 public void SearchForDevice(Address address, IDeviceSearchCallback callback)
 {
     lock (_lock)
     {
         var device = _devices.GetByAddress(address);
         if (device != null)
         {
             callback.DeviceFound(device);
         }
         else
         {
             DeviceSearch search = new DeviceSearch(this, address, callback);
             this._deviceSearches.AddLast(search);
             _sendWhoIsForAddress(address);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Searches for a device (Sends a who-is request)
 /// </summary>
 /// <param name="instance">The instance of the device to search for</param>
 /// <param name="callback">The callback to invoke when the device is found</param>
 public void SearchForDevice(uint instance, IDeviceSearchCallback callback)
 {
     lock (_lock)
     {
         var device = _devices.Get(instance);
         if (device != null)
         {
             callback.DeviceFound(device);
         }
         else
         {
             DeviceSearch search = new DeviceSearch(this, instance, callback);
             this._deviceSearches.AddLast(search);
             _sendWhoIsForInstance(instance);
         }
     }
 }