Beispiel #1
0
		public static DeviceConfiguration CreateTempDeviceConfiguration(Device device)
		{
			var deviceConfiguration = new DeviceConfiguration();
			deviceConfiguration.RootDevice = new Device();
			deviceConfiguration.RootDevice.Driver = ConfigurationManager.Drivers.FirstOrDefault(x => x.DriverType == DriverType.Computer);
			deviceConfiguration.RootDevice.DriverUID = deviceConfiguration.RootDevice.Driver.UID;

			Device usbDevice = (Device)device.Clone();
			var driverType = DriverTypeToUSBDriverType(device.Driver.DriverType);

			usbDevice.Driver = ConfigurationManager.Drivers.FirstOrDefault(x => x.DriverType == driverType);
			usbDevice.DriverUID = deviceConfiguration.RootDevice.Driver.UID;

			deviceConfiguration.RootDevice.Children.Add(usbDevice);
			usbDevice.Parent = deviceConfiguration.RootDevice;
			return deviceConfiguration;
		}
		public DeviceConfiguration GetDeviceConfiguration(Device panelDevice)
		{
			PanelDevice = (Device)panelDevice.Clone();
			shleifCount = PanelDevice.Driver.ShleifCount;
			PanelDevice.Children = new List<Device>();
			Zones = new List<Zone>();
			remoteDeviceConfiguration = new DeviceConfiguration();
			remoteDeviceConfiguration.RootDevice = PanelDevice;
			remoteDeviceConfiguration.Devices.Add(PanelDevice);
			var panelDatabaseReader = new ReadPanelDatabaseOperationHelper(PanelDevice, CheckMonitoringSuspend);
			panelDatabaseReader.RomDBFirstIndex = panelDatabaseReader.GetRomFirstIndex(PanelDevice);
			if (panelDatabaseReader.RomDBFirstIndex == -1)
				return null;
			panelDatabaseReader.FlashDBLastIndex = panelDatabaseReader.GetFlashLastIndex(PanelDevice);
			if (panelDatabaseReader.FlashDBLastIndex == -1)
				return null;
			DeviceRom = panelDatabaseReader.GetRomDBBytes(PanelDevice);
			if (DeviceRom == null)
				return null;
			DeviceFlash = panelDatabaseReader.GetFlashDBBytes(PanelDevice);
			if (DeviceFlash == null)
				return null;

			zonePanelRelationsInfo = new ZonePanelRelationsInfo();
			ParseZonesRom(1542, panelDatabaseReader.RomDBFirstIndex);

			outZonesBegin = DeviceRom[1548] * 256 * 256 + DeviceRom[1549] * 256 + DeviceRom[1550];
			outZonesCount = DeviceRom[1552] * 256 + DeviceRom[1553];
			outZonesEnd = outZonesBegin + outZonesCount * 9;

			ParseUIDevicesRom(DriverType.MDU);
			ParseNoUIDevicesRom(DriverType.AM1_T);

			ParseUIDevicesRom(DriverType.RM_1);
			ParseUIDevicesRom(DriverType.MPT);
			ParseUIDevicesRom(DriverType.MRO);
			ParseUIDevicesRom(DriverType.MRO_2);
			ParseUIDevicesRom(DriverType.Exit);

			ParseNoUIDevicesRom(DriverType.SmokeDetector);
			ParseNoUIDevicesRom(DriverType.HeatDetector);
			ParseNoUIDevicesRom(DriverType.CombinedDetector);
			ParseNoUIDevicesRom(DriverType.HandDetector);
			ParseNoUIDevicesRom(DriverType.AM_1);
			ParseNoUIDevicesRom(DriverType.AMP_4);
			ParseNoUIDevicesRom(DriverType.AM1_O);
			ParseNoUIDevicesRom(DriverType.RadioHandDetector);
			ParseNoUIDevicesRom(DriverType.RadioSmokeDetector);
			ParseUIDevicesRom(DriverType.Valve);

			foreach (var childDevice in PanelDevice.Children)
			{
				childDevice.Parent = PanelDevice;
				remoteDeviceConfiguration.Devices.Add(childDevice);
			}
			foreach (var device in remoteDeviceConfiguration.Devices)
			{
				GetCurrentDeviceState(device);
			}
			return remoteDeviceConfiguration;
		}