Example #1
0
        public void ConvertBack(DeviceConfiguration deviceConfiguration, bool includeSecurity)
        {
            DeviceConfiguration = deviceConfiguration;
            DeviceConfiguration.Update();

            foreach (var device in DeviceConfiguration.Devices)
            {
                device.Driver = ConfigurationCash.DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
            }

            if (includeSecurity)
            {
                FiresecConfiguration = FiresecSerializedClient.GetCoreConfig().Result;
                FiresecConfiguration.part = null;
            }
            else
            {
                FiresecConfiguration = new Firesec.CoreConfiguration.config();
            }

            Gid = 0;
            ConvertZonesBack();
            ConvertDevicesBack();
            ConvertDirectionsBack();
            ConvertGuardUsersBack();
        }
		public DeviceConfiguration ConvertDevicesAndZones(Models.CoreConfiguration.config coreConfig)
		{
			var deviceConfiguration = new DeviceConfiguration();
			ConvertZones(deviceConfiguration, coreConfig);
			ConvertDevices(deviceConfiguration, coreConfig);
			return deviceConfiguration;
		}
Example #3
0
		public static FS2JournalItem ReadItem(DeviceConfiguration deviceConfiguration, Device device, int i, byte journalType)
		{
			for (int j = 0; j < 15; j++)
			{
				var response = USBManager.Send(device, "Чтение конкретной записи в журнале", 0x01, 0x20, journalType, BitConverter.GetBytes(i).Reverse());
				if (response != null)
				{
					lock (Locker)
					{
						var journalParser = new JournalParser();
						try
						{
							var fsJournalItem = journalParser.Parce(deviceConfiguration, device, response.Bytes, journalType);
							if (fsJournalItem != null)
							{
								return fsJournalItem;
							}
						}
						catch
						{
							return null;
						}
					}
				}
			}
			return null;
		}
Example #4
0
		public static Device SetTempDeviceConfiguration(Device device)
		{
			CurrentDeviceConfiguration = ConfigurationManager.DeviceConfiguration;
			ConfigurationManager.DeviceConfiguration = CreateTempDeviceConfiguration(device);
			USBManager.Initialize();
			return ConfigurationManager.DeviceConfiguration.RootDevice.Children.FirstOrDefault();
		}
Example #5
0
        public AutoSearchViewModel(DeviceConfiguration autodetectedDeviceConfiguration)
        {
            Title = "Добавление устройств";
            ContinueCommand = new RelayCommand(OnContinue);

            allDevices = new List<AutoSearchDeviceViewModel>();
            Devices = new List<AutoSearchDeviceViewModel>();
            Devices.Add(AddDevice(autodetectedDeviceConfiguration.RootDevice, null));
        }
Example #6
0
 public FullConfiguration()
 {
     DeviceConfiguration = new DeviceConfiguration();
     LibraryConfiguration = new LibraryConfiguration();
     PlansConfiguration = new PlansConfiguration();
     SecurityConfiguration = new SecurityConfiguration();
     SystemConfiguration = new SystemConfiguration();
     XDeviceConfiguration = new XDeviceConfiguration();
 }
		public OperationResult<PlansConfiguration> ConvertPlans(DeviceConfiguration deviceConfiguration)
		{
			var result = FiresecSerializedClient.GetPlans();
			if (result.HasError)
			{
				return new OperationResult<PlansConfiguration>(result.Error);
			}
			var plans = result.Result;
			if (plans == null)
				return new OperationResult<PlansConfiguration>();
			var plansConfiguration = ConvertPlans(plans, deviceConfiguration);
			return new OperationResult<PlansConfiguration>() { Result = plansConfiguration };
		}
		public DeviceConfiguration CopyOneBranch(Device device, bool isUsb)
		{
			var deviceConfiguration = new DeviceConfiguration();

			Device currentDevice = device;
			Device copyChildDevice = null;

			while (true)
			{
				var copyDevice = new Device();
				//{
				//    UID = currentDevice.UID,
				//    DriverUID = currentDevice.DriverUID,
				//    IntAddress = currentDevice.IntAddress,
				//    Description = currentDevice.Description,
				//    ZoneUID = currentDevice.ZoneUID,
				//    Properties = new List<Property>(currentDevice.Properties),
				//    SystemAUProperties = new List<Property>(currentDevice.SystemAUProperties),
				//    DeviceAUProperties = new List<Property>(currentDevice.DeviceAUProperties)
				//};
				copyDevice.UID = currentDevice.UID;
				copyDevice.DriverUID = currentDevice.DriverUID;
				copyDevice.IntAddress = currentDevice.IntAddress;
				copyDevice.Description = currentDevice.Description;
                copyDevice.ZoneUID = currentDevice.ZoneUID;
				copyDevice.Properties = new List<Property>(currentDevice.Properties);
				if (currentDevice.SystemAUProperties != null)
					copyDevice.SystemAUProperties = new List<Property>(currentDevice.SystemAUProperties);
				if (currentDevice.DeviceAUProperties != null)
					copyDevice.DeviceAUProperties = new List<Property>(currentDevice.DeviceAUProperties);

				if ((currentDevice.UID == device.UID))
				{
					copyDevice.IsAltInterface = isUsb;
				}

				if (copyChildDevice != null)
					copyDevice.Children.Add(copyChildDevice);

				if (currentDevice.Parent == null)
				{
					currentDevice = copyDevice;
					break;
				}
				copyChildDevice = copyDevice;
				currentDevice = currentDevice.Parent;
			}

			deviceConfiguration.RootDevice = currentDevice;
			return deviceConfiguration;
		}
Example #9
0
        public DeviceTreeViewModel(Device rootDevice, DeviceConfiguration deviceConfiguration)
        {
            Title = "Сравнение конфигураций";
            RootDevice = rootDevice;
            DeviceConfiguration = deviceConfiguration;
            DeviceConfiguration.Reorder();

            BuildTree(rootDevice);
            if (Devices.Count > 0)
            {
                //CollapseChild(Devices[0]);
                ExpandChild(Devices[0]);
                SelectedDevice = Devices[0];
            }
        }
Example #10
0
        public void Convert()
        {
            FiresecConfiguration = FiresecSerializedClient.GetCoreConfig().Result;
            DeviceConfiguration = new DeviceConfiguration();
            ConvertZones();
            ConvertDirections();
            ConvertGuardUsers();
            ConvertDevices();
            Update();

            ConfigurationCash.DeviceConfiguration = DeviceConfiguration;
            ConfigurationFileManager.SetDeviceConfiguration(DeviceConfiguration);

            var plans = FiresecSerializedClient.GetPlans().Result;
            ConfigurationCash.PlansConfiguration = ConvertPlans(plans);
            ConfigurationFileManager.SetPlansConfiguration(ConfigurationCash.PlansConfiguration);
        }
        void ConvertDevices(DeviceConfiguration deviceConfiguration, Firesec.Models.CoreConfiguration.config coreConfig)
		{
			deviceConfiguration.Devices = new List<Device>();

            if (coreConfig == null || coreConfig.dev == null || coreConfig.dev.Count() == 0 || coreConfig.drv == null)
            {
                Logger.Error("ConfigurationConverter.ConvertDevices coreConfig.dev = null");
                LoadingErrorManager.Add("Пустая коллекция устройств или драйверов при конвертации конфигурации");
                return;
            }

			var rootInnerDevice = coreConfig.dev[0];
            var rootDevice = SetInnerDevice(rootInnerDevice, null, deviceConfiguration, coreConfig);
			deviceConfiguration.Devices.Add(rootDevice);
            AddDevice(rootInnerDevice, rootDevice, deviceConfiguration, coreConfig);
			deviceConfiguration.RootDevice = rootDevice;
		}
Example #12
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;
		}
        void AddDevice(devType parentInnerDevice, Device parentDevice, DeviceConfiguration deviceConfiguration, Firesec.Models.CoreConfiguration.config coreConfig)
		{
			if (parentInnerDevice.dev == null)
				return;

			parentDevice.Children = new List<Device>();
			foreach (var innerDevice in parentInnerDevice.dev)
			{
                var device = SetInnerDevice(innerDevice, parentDevice, deviceConfiguration, coreConfig);
				if (device != null)
				{
					parentDevice.Children.Add(device);
					deviceConfiguration.Devices.Add(device);
                    AddDevice(innerDevice, device, deviceConfiguration, coreConfig);
				}
			}
		}
        public DeviceConfigurationViewModel(Guid deviceUID, DeviceConfiguration deviceConfiguration)
        {
            Title = "Сравнение конфигураций";
            ReplaceCommand = new RelayCommand(OnReplace);
            _deviceUID = deviceUID;
            _deviceConfiguration = deviceConfiguration;
            _deviceConfiguration.Update();
            foreach (var device in _deviceConfiguration.Devices)
            {
                device.Driver = FiresecManager.FiresecConfiguration.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
            }

            LocalRootDevice = FiresecManager.Devices.FirstOrDefault(x => x.UID == _deviceUID);
            RemoteRootDevice = _deviceConfiguration.Devices.FirstOrDefault(x => x.UID == _deviceUID);
            LocalDevices = new DeviceTreeViewModel(LocalRootDevice, FiresecManager.FiresecConfiguration.DeviceConfiguration);
            RemoteDevices = new DeviceTreeViewModel(RemoteRootDevice, _deviceConfiguration);
        }
        public static IndicatorLogic Convert(DeviceConfiguration deviceConfiguration, LEDProperties lEDProperties)
		{
			var indicatorLogic = new IndicatorLogic();

			switch (lEDProperties.type)
			{
				case "0":
					indicatorLogic.IndicatorLogicType = IndicatorLogicType.Zone;
					break;

				case "1":
					indicatorLogic.IndicatorLogicType = IndicatorLogicType.Device;
					break;
			}

			if (lEDProperties.zone != null)
			{
				foreach (var item in lEDProperties.zone)
				{
                    if (string.IsNullOrWhiteSpace(item) == false)
                    {
                        int zoneNo = int.Parse(item);
                        var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.No == zoneNo);
                        if (zone != null)
                        {
                            indicatorLogic.ZoneUIDs.Add(zone.UID);
                        }
                    }
				}
			}

			if (lEDProperties.device != null && lEDProperties.device.Count() > 0)
			{
				var indicatorDevice = lEDProperties.device[0];
				indicatorLogic.DeviceUID = GuidHelper.ToGuid(indicatorDevice.UID);
				indicatorLogic.OnColor = StringToIndicatorColorType(indicatorDevice.state1);
				indicatorLogic.OffColor = StringToIndicatorColorType(indicatorDevice.state2);
				indicatorLogic.FailureColor = StringToIndicatorColorType(indicatorDevice.state3);
				indicatorLogic.ConnectionColor = StringToIndicatorColorType(indicatorDevice.state4);
			}

			return indicatorLogic;
		}
        void ConvertDirections(DeviceConfiguration deviceConfiguration, Firesec.Models.CoreConfiguration.config coreConfig)
		{
			deviceConfiguration.Directions = new List<Direction>();

			if (coreConfig.part != null)
			{
				foreach (var innerDirection in coreConfig.part)
				{
					if (innerDirection.type == "direction")
					{
						var direction = new Direction()
						{
							Id = int.Parse(innerDirection.id),
							Name = innerDirection.name,
							Description = innerDirection.desc
						};

						if (innerDirection.PinZ != null)
						{
							foreach (var item in innerDirection.PinZ)
							{
                                if (string.IsNullOrWhiteSpace(item.pidz) == false)
                                {
                                    var zoneNo = int.Parse(item.pidz);
                                    var zone = deviceConfiguration.Zones.FirstOrDefault(x=>x.No == zoneNo);
                                    direction.ZoneUIDs.Add(zone.UID);
                                }
							}
						}

						if (innerDirection.param != null)
						{
							var rmParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_RM");
							direction.DeviceRm = GuidHelper.ToGuid(rmParameter.value);
							var buttonParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_AM");
							direction.DeviceButton = GuidHelper.ToGuid(buttonParameter.value);
						}

						deviceConfiguration.Directions.Add(direction);
					}
				}
			}
		}
		public OperationResult<DeviceConfiguration> ConvertCoreConfig()
		{
			var result = FiresecSerializedClient.GetCoreConfig();
			if (result.HasError)
			{
				return new OperationResult<DeviceConfiguration>(result.Error);
			}
			var coreConfig = result.Result;
			if (coreConfig == null)
				return null;

			var deviceConfiguration = new DeviceConfiguration();
			ConvertZones(deviceConfiguration, coreConfig);
			ConvertDirections(deviceConfiguration, coreConfig);
			ConvertGuardUsers(deviceConfiguration, coreConfig);
			ConvertDevices(deviceConfiguration, coreConfig);
			Update(deviceConfiguration);
			return new OperationResult<DeviceConfiguration>() { Result = deviceConfiguration };
		}
Example #18
0
		public bool ReadConfigurationAndUpdateStates(Device panelDevice)
		{
			var getConfigurationOperationHelper = new GetConfigurationOperationHelper(true);
			RemoteDeviceConfiguration = getConfigurationOperationHelper.GetDeviceConfiguration(panelDevice);
			if (RemoteDeviceConfiguration == null)
				return false;
			RemoteDeviceConfiguration.Update();

			var isDBMissmatch = !ConfigurationCompareHelper.Compare(panelDevice, RemoteDeviceConfiguration);
			if (panelDevice.DeviceState.IsDBMissmatch != isDBMissmatch)
			{
				panelDevice.DeviceState.IsDBMissmatch = isDBMissmatch;
				ForseUpdateDeviceStates(panelDevice);
			}

			var remoteRealChildren = RemoteDeviceConfiguration.RootDevice.GetRealChildren();
			var localRealChildren = panelDevice.GetRealChildren();

			foreach (var remoteDevice in remoteRealChildren)
			{
				var device = localRealChildren.FirstOrDefault(x => x.IntAddress == remoteDevice.IntAddress);
				if (device != null)
				{
					device.StateWordOffset = remoteDevice.StateWordOffset;
					device.StateWordBytes = remoteDevice.StateWordBytes;
					device.RawParametersOffset = remoteDevice.RawParametersOffset;
					device.RawParametersBytes = remoteDevice.RawParametersBytes;
					ParseDeviceState(device);
				}
			}

			foreach (var remoteZone in RemoteDeviceConfiguration.Zones)
			{
				var zone = ConfigurationManager.Zones.FirstOrDefault(x => x.No == remoteZone.No);
				if (zone != null)
				{
					zone.LocalDeviceNo = remoteZone.LocalDeviceNo;
				}
			}

			return true;
		}
		surfaces ConvertPlansBack(PlansConfiguration plansConfiguration, DeviceConfiguration deviceConfiguration)
		{
			surfaces result = new surfaces();
			var innerPlans = new List<surfacesSurface>();

			foreach (var plan in plansConfiguration.AllPlans)
			{
				var innerPlan = new surfacesSurface();
				innerPlans.Add(innerPlan);
				innerPlan.caption = plan.Caption;
				innerPlan.height = (plan.Height / 10).ToString();
				innerPlan.width = (plan.Width / 10).ToString();

				var layers = new List<surfacesSurfaceLayer>();
				var layer = new surfacesSurfaceLayer();
				layer.name = "Зоны";
				layers.Add(layer);
				innerPlan.layer = layers.ToArray();

				var elements = new List<surfacesSurfaceLayerElementsElement>();

				foreach (var elementRectangle in plan.ElementRectangles)
				{
					var element = new surfacesSurfaceLayerElementsElement();
					elements.Add(element);
					element.@class = "TSCDeRectangle";

					element.rect = new surfacesSurfaceLayerElementsElementRect[1]{new surfacesSurfaceLayerElementsElementRect()};
					element.rect[0].left = elementRectangle.Left.ToString();
					element.rect[0].top = elementRectangle.Top.ToString();
					element.rect[0].bottom = (elementRectangle.Top + elementRectangle.Height).ToString();
					element.rect[0].right = (elementRectangle.Left + elementRectangle.Width).ToString();
					element.rect[0].left = elementRectangle.Top.ToString();
				}

				layer.elements = elements.ToArray();
			}

			result.surface = innerPlans.ToArray();
			return result;
		}
Example #20
0
        public OperationResult<DeviceConfiguration> DeviceAutoDetectChildren(DeviceConfiguration deviceConfiguration, Guid deviceUID, bool fastSearch)
        {
            var firesecConfiguration = FiresecManager.ConvertBack(deviceConfiguration, false);
            var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
            var result = FiresecSerializedClient.DeviceAutoDetectChildren(firesecConfiguration, device.GetPlaceInTree(), fastSearch);

            var operationResult = new OperationResult<DeviceConfiguration>()
            {
                HasError = result.HasError,
                Error = result.ErrorString
            };
            if (operationResult.HasError)
                return operationResult;

            if (result.Result == null)
                return new OperationResult<DeviceConfiguration>("Ошибка. Получена пустая конфигурация");

            var configurationManager = new ConfigurationConverter();
            operationResult.Result = configurationManager.ConvertOnlyDevices(result.Result);
            return operationResult;
        }
Example #21
0
		public Device()
		{
			UID = Guid.NewGuid();
			Children = new List<Device>();
			Properties = new List<Property>();
			SystemAUProperties = new List<Property>();
			DeviceAUProperties = new List<Property>();
			IndicatorLogic = new IndicatorLogic();
			PDUGroupLogic = new PDUGroupLogic();
			PlanElementUIDs = new List<Guid>();
			ZoneLogic = new ZoneLogic();
			IsRmAlarmDevice = false;
			IsNotUsed = false;
			AllowMultipleVizualization = false;

			ShapeIds = new List<string>();
			ZonesInLogic = new List<Zone>();
			DependentDevices = new List<Device>();
			DeviceConfiguration = new DeviceConfiguration();
			StateWordBytes = new List<byte>();
			RawParametersBytes = new List<byte>();
		}
Example #22
0
        public DeviceConfiguration CopyOneBranch(Guid uid, bool isUsb)
        {
            var deviceConfiguration = new DeviceConfiguration();

            var device = Devices.FirstOrDefault(x => x.UID == uid);
            Device currentDevice = device;
            Device copyChildDevice = null;

            while (true)
            {
                var copyDevice = new Device()
                {
                    UID = currentDevice.UID,
                    DriverUID = currentDevice.DriverUID,
                    IntAddress = currentDevice.IntAddress,
                    Description = currentDevice.Description,
                    ZoneNo = currentDevice.ZoneNo,
                    Properties = new List<Property>(currentDevice.Properties)
                };
                if ((currentDevice.UID == uid))
                {
                    copyDevice.IsAltInterface = isUsb;
                }

                if (copyChildDevice != null)
                    copyDevice.Children.Add(copyChildDevice);

                if (currentDevice.Parent == null)
                {
                    currentDevice = copyDevice;
                    break;
                }
                copyChildDevice = copyDevice;
                currentDevice = currentDevice.Parent;
            }

            deviceConfiguration.RootDevice = currentDevice;
            return deviceConfiguration;
        }
		public void SetEmptyConfiguration()
		{
			DeviceConfiguration = new DeviceConfiguration();

			var computerDriver = DriversConfiguration.Drivers.FirstOrDefault(x => x.DriverType == DriverType.Computer);
			if (computerDriver != null)
			{
				DeviceConfiguration.RootDevice = new Device()
				{
					DriverUID = computerDriver.UID,
					Driver = computerDriver
				};
				DeviceConfiguration.Update();
			}
			else
			{
				Logger.Error("FiresecConfiguration.SetEmptyConfiguration computerDriver = null");
			}
		}
		surfaces ConvertPlansBack(PlansConfiguration plansConfiguration, DeviceConfiguration deviceConfiguration)
		{
			var innerPlansConfiguration = new surfaces();

			var innerPlans = new List<surfacesSurface>();
			foreach (var plan in plansConfiguration.Plans.OfType<Plan>())
			{
				surfacesSurface innerPlan = new surfacesSurface()
				{
					caption = plan.Caption,
					height = (plan.Height / 10).ToString(),
					width = (plan.Width / 10).ToString()
				};
				innerPlans.Add(innerPlan);

				var mainLayer = new surfacesSurfaceLayer()
				{
					name = "План"
				};

				var mainLayerElements = new List<surfacesSurfaceLayerElementsElement>();
				foreach (var elementRectangle in plan.ElementRectangles)
				{
					var innerRectangle = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TSCDeRectangle",
						rect = new surfacesSurfaceLayerElementsElementRect[] { GetRect(elementRectangle) }
					};
					mainLayerElements.Add(innerRectangle);
				}
				foreach (var elementEllipse in plan.ElementEllipses)
				{
					var innerEllipse = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TSCDeEllipse",
						rect = new surfacesSurfaceLayerElementsElementRect[] { GetRect(elementEllipse) }
					};
					mainLayerElements.Add(innerEllipse);
				}
				foreach (var elementTextBlock in plan.ElementTextBlocks)
				{
					var innerLable = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TSCDeLabel",
						rect = new surfacesSurfaceLayerElementsElementRect[] { GetRect(elementTextBlock) },
						caption = elementTextBlock.Text
					};
					innerLable.pen = new surfacesSurfaceLayerElementsElementPen[1];
					innerLable.pen[0] = new surfacesSurfaceLayerElementsElementPen()
					{
						color = "cl" + elementTextBlock.ForegroundColor.ToString()
					};
					innerLable.brush = new surfacesSurfaceLayerElementsElementBrush[1];
					innerLable.brush[0] = new surfacesSurfaceLayerElementsElementBrush()
					{
						color = "cl" + elementTextBlock.BackgroundColor.ToString()
					};
					mainLayerElements.Add(innerLable);
				}
				foreach (var elementPolyline in plan.ElementPolylines)
				{
					var innerPolyline = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TSCDePolyLine",
					};
					var innerPointsCollection = new List<surfacesSurfaceLayerElementsElementPointsPoint>();
					foreach (var point in elementPolyline.Points)
					{
						innerPointsCollection.Add(new surfacesSurfaceLayerElementsElementPointsPoint() { x = point.X.ToString(), y = point.Y.ToString() });
					}
					innerPolyline.points = innerPointsCollection.ToArray();
					mainLayerElements.Add(innerPolyline);
				}
				foreach (var elementPolygon in plan.ElementPolygons)
				{
					var innerPolyline = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TSCDePolygon",
					};
					var innerPointsCollection = new List<surfacesSurfaceLayerElementsElementPointsPoint>();
					foreach (var point in elementPolygon.Points)
					{
						innerPointsCollection.Add(new surfacesSurfaceLayerElementsElementPointsPoint() { x = point.X.ToString(), y = point.Y.ToString() });
					}
					innerPolyline.points = innerPointsCollection.ToArray();
					mainLayerElements.Add(innerPolyline);
				}
				mainLayer.elements = mainLayerElements.ToArray();

				var devicesLayer = new surfacesSurfaceLayer()
				{
					name = "Устройства"
				};
				var innerDeviceElements = new List<surfacesSurfaceLayerElementsElement>();
				foreach (var elementDevice in plan.ElementDevices)
				{
					var innerDeviceElement = new surfacesSurfaceLayerElementsElement();
					var innerRect = new surfacesSurfaceLayerElementsElementRect()
					{
						left = elementDevice.Left.ToString(),
						top = elementDevice.Top.ToString(),
						bottom = (elementDevice.Top + 10).ToString(),
						right = (elementDevice.Left + 10).ToString()
					};
					innerDeviceElement.rect = new surfacesSurfaceLayerElementsElementRect[] { innerRect };

					var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == elementDevice.UID);
					if (device != null)
					{
						innerDeviceElement.id = device.ShapeIds.FirstOrDefault();
					}
					innerDeviceElements.Add(innerDeviceElement);
				}
				devicesLayer.elements = innerDeviceElements.ToArray();

				var zonesLayer = new surfacesSurfaceLayer()
				{
					name = "Зоны"
				};
				var zoneLayerElements = new List<surfacesSurfaceLayerElementsElement>();
				foreach (var elementRectangleZone in plan.ElementRectangleZones)
				{
					var innerRectangleZone = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TFS_ZoneShape",
						rect = new surfacesSurfaceLayerElementsElementRect[] { GetRect(elementRectangleZone) }
					};
					var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.UID == elementRectangleZone.UID);
					if (zone != null)
					{
						innerRectangleZone.id = zone.ShapeIds.FirstOrDefault();
					}
					zoneLayerElements.Add(innerRectangleZone);
				}

				foreach (var elementPolygonZone in plan.ElementPolygonZones)
				{
					var innerPolygonZone = new surfacesSurfaceLayerElementsElement()
					{
						@class = "TFS_PolyZoneShape",
					};
					var innerPointsCollection = new List<surfacesSurfaceLayerElementsElementPointsPoint>();
					foreach (var point in elementPolygonZone.Points)
					{
						innerPointsCollection.Add(new surfacesSurfaceLayerElementsElementPointsPoint() { x = point.X.ToString(), y = point.Y.ToString() });
					}
					innerPolygonZone.points = innerPointsCollection.ToArray();
					var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.UID == elementPolygonZone.UID);
					if (zone != null)
					{
						innerPolygonZone.id = zone.ShapeIds.FirstOrDefault();
					}
					zoneLayerElements.Add(innerPolygonZone);
				}
				zonesLayer.elements = innerDeviceElements.ToArray();

				var innerLayers = new List<surfacesSurfaceLayer>();
				innerLayers.Add(mainLayer);
				innerLayers.Add(devicesLayer);
				innerLayers.Add(zonesLayer);
				innerPlan.layer = innerLayers.ToArray();
			}
			innerPlansConfiguration.surface = innerPlans.ToArray();

			return innerPlansConfiguration;
		}
		public OperationResult<string> DeviceVerifyFirmwareVersion(DeviceConfiguration deviceConfiguration, Guid deviceUID, string fileName)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			return FiresecSerializedClient.DeviceVerifyFirmwareVersion(firesecConfiguration, device.GetPlaceInTree(), fileName);
		}
		public OperationResult<bool> DeviceWriteConfiguration(DeviceConfiguration deviceConfiguration, Guid deviceUID)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			return FiresecSerializedClient.DeviceWriteConfig(firesecConfiguration, device.GetPlaceInTree());
		}
		public OperationResult<bool> SetNewConfig(DeviceConfiguration deviceConfiguration)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, true);
			return FiresecSerializedClient.SetNewConfig(firesecConfiguration);
		}
		public Firesec.Models.CoreConfiguration.config ConvertBack(DeviceConfiguration deviceConfiguration, bool includeSecurity)
		{
			ConfigurationConverter.ConvertBack(deviceConfiguration, includeSecurity);
			return ConfigurationConverter.FiresecConfiguration;
		}
		public OperationResult<bool> DeviceSetGuardUsersList(DeviceConfiguration deviceConfiguration, Guid deviceUID, string users)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			return FiresecSerializedClient.DeviceSetGuardUsersList(firesecConfiguration, device.GetPlaceInTree(), users);
		}
		public OperationResult<string> DeviceCustomFunctionExecute(DeviceConfiguration deviceConfiguration, Guid deviceUID, string functionName)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			return FiresecSerializedClient.DeviceCustomFunctionExecute(firesecConfiguration, device.GetPlaceInTree(), functionName);
		}