Пример #1
0
 public LinkDeviceListenerThread(LinkDevice d)
 {
     Dev           = d;
     Task          = new Thread(new ThreadStart(Run));
     Task.Name     = "LinkDeviceListenerThread:" + d.Id;
     Task.Priority = ThreadPriority.AboveNormal;
 }
Пример #2
0
        /// <summary>
        /// Find device in devices list.
        /// </summary>
        /// <param name="instanceId">The string for the device's unique serial number + netIfIndex.</param>
        /// <returns>Returns LinkDevice object for the device or null if not found.</returns>
        public LinkDevice FindDevice(string instanceId)
        {
            LinkDevice d = null;

            lock (Manager) {
                if (String.IsNullOrWhiteSpace(instanceId) || !Devices.TryGetValue(instanceId, out d))
                {
                    d = null;
                }
            }
            return(d);
        }
Пример #3
0
 /// <summary>
 /// Remove device from devices list.
 /// </summary>
 /// <param name="instanceId">The string for the device's unique serial number + netIfIndex.</param>
 public void DeleteDevice(string instanceId)
 {
     lock (Manager) {
         if (!String.IsNullOrWhiteSpace(instanceId) && Devices.ContainsKey(instanceId))
         {
             LinkDevice d = null;
             if (Devices.TryRemove(instanceId, out d))
             {
                 ManagerListeners.NotifyListeners(ComponentEvent.ComponentRemove, d, null);
             }
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Add device to devices list.
        /// Also adds the manager to devices event listener list.
        /// </summary>
        /// <param name="instanceId">The string for the device's unique serial number + netIfIndex.</param>
        /// <param name="d">The device to add.</param>
        /// <returns>Returns false if not added, e.g. because already in list.</returns>
        public bool AddDevice(string instanceId, LinkDevice d)
        {
            bool result = false;

            lock (Manager) {
                if (String.IsNullOrWhiteSpace(instanceId))
                {
                    return(false);
                }
                result = Devices.TryAdd(instanceId, d);
            }
            if (result)
            {
                ManagerListeners.NotifyListeners(ComponentEvent.ComponentAdd, d, null);
                d.AddListener(Manager, ComponentEventListener); // Add the manager as a listener.
            }
            return(result);
        }
Пример #5
0
 public bool Compare(LinkDevice d)
 {
     return(this == d);
 }