Inheritance: IDevice
Beispiel #1
0
		static public void Add (Device device)
		{
			spinLock.Enter ();

			if (deviceCount < MaxDevices)
				devices[deviceCount++] = device;

			spinLock.Exit ();
		}
Beispiel #2
0
		static public Device[] GetChildrenOf (Device device)
		{
			spinLock.Enter ();

			uint count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if (devices[i] == device.Parent)
					count++;

			Device[] children = new Device[count];

			count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if (devices[i] == device.Parent)
					children[count++] = devices[i];

			spinLock.Exit ();

			return children;
		}
Beispiel #3
0
		static public Device[] GetDevices ()
		{
			spinLock.Enter ();

			Device[] list = new Device[deviceCount];

			for (uint i = 0; i < deviceCount; i++)
				list[i] = devices[i];

			spinLock.Exit ();

			return list;
		}
Beispiel #4
0
		static public Device[] GetOnlineDevices ()
		{
			spinLock.Enter ();

			uint count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if (devices[i].Status == DeviceStatus.Online)
					count++;

			Device[] children = new Device[count];

			count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if (devices[i].Status == DeviceStatus.Online)
					children[count++] = devices[i];

			spinLock.Exit ();

			return children;
		}
Beispiel #5
0
		//static public Device[] GetDevicesOf (Type type)
		//{
		//    spinLock.Enter ();

		//    uint count = 0;
		//    for (uint i = 0; i < deviceCount; i++) {
		//        Type a = devices[i].GetType ();

		//        if ((a.IsSubclassOf (type)) || (a == type) || (a.IsAssignableFrom (type)) || (type.IsAssignableFrom (a)))
		//            count++;
		//    }

		//    Device[] list = new Device[count];

		//    count = 0;
		//    for (uint i = 0; i < deviceCount; i++) {
		//        Type a = devices[i].GetType ();

		//        if ((a.IsSubclassOf (type)) || (a == type) || (a.IsAssignableFrom (type)) || (type.IsAssignableFrom (a)))
		//            list[count++] = devices[i];
		//    }

		//    spinLock.Exit ();

		//    return list;
		//}

		//static public Device[] GetDevicesOf (Type type, string name)
		//{
		//    spinLock.Enter ();

		//    uint count = 0;
		//    for (uint i = 0; i < deviceCount; i++)
		//        if (devices[i].Name == name) {
		//            Type a = devices[i].GetType ();

		//            if ((a.IsSubclassOf (type)) || (a == type) || (a.IsAssignableFrom (type)) || (type.IsAssignableFrom (a)))
		//                count++;
		//        }

		//    Device[] list = new Device[count];

		//    count = 0;
		//    for (uint i = 0; i < deviceCount; i++)
		//        if (devices[i].Name == name) {
		//            Type a = devices[i].GetType ();

		//            if ((a.IsSubclassOf (type)) || (a == type) || (a.IsAssignableFrom (type)) || (type.IsAssignableFrom (a)))
		//                list[count++] = devices[i];
		//        }

		//    spinLock.Exit ();

		//    return list;
		//}

		static public Device[] GetOnlineDevicesWithName (string name)
		{
			spinLock.Enter ();

			uint count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if ((devices[i].Status == DeviceStatus.Online) && (devices[i].Name == name))
					count++;


			Device[] list = new Device[count];

			count = 0;
			for (uint i = 0; i < deviceCount; i++)
				if ((devices[i].Status == DeviceStatus.Online) && (devices[i].Name == name))
					list[count++] = devices[i];

			spinLock.Exit ();

			return list;
		}
Beispiel #6
0
        public Device(Device parent, string name, DeviceStatus deviceStatus)
        {
            this.parent = parent;
            this.name = name;
			this.deviceStatus = deviceStatus;           
        }
Beispiel #7
0
        public Device()
        {
            name = string.Empty;            
            parent = null;
			deviceStatus = DeviceStatus.Error;
        }