Пример #1
0
		public void AddDevice(Device fsDevice, XDevice kauDevice, byte shleifNo)
		{
			var driver = XManager.Drivers.FirstOrDefault(x => x.UID == fsDevice.DriverUID);
			if (driver == null)
			{
				return;
			}

			var device = new XDevice()
			{
				UID = fsDevice.UID,
				DriverUID = driver.UID,
				Driver = driver,
				IntAddress = (byte)(fsDevice.IntAddress & 0xff),
				Description = fsDevice.Description
			};
			XManager.DeviceConfiguration.Devices.Add(device);
			var shleifDevice = kauDevice.Children.FirstOrDefault(x => x.ShleifNo == shleifNo);
			if (shleifDevice != null)
			{
				shleifDevice.Children.Add(device);
				device.Parent = shleifDevice;
			}

			foreach (var fsChildDevice in fsDevice.Children)
			{
				AddDevice(fsChildDevice, device, shleifNo);
			}
		}
		public static void Run(Device device, bool isUsb)
		{
			_device = device;
			_isUsb = isUsb;

			ServiceFactory.ProgressService.Run(OnPropgress, OnCompleted, _device.PresentationAddressAndName + ". Чтение журнала");
		}
		public void SynchronizeChildern(Device device)
		{
			for (int i = device.Children.Count(); i > 0; i--)
			{
				var childDevice = device.Children[i - 1];

				if (device.Driver.AvaliableChildren.Contains(childDevice.Driver.UID) == false)
				{
					device.Children.RemoveAt(i - 1);
				}
			}

			foreach (var autoCreateChildUID in device.Driver.AutoCreateChildren)
			{
				var autoCreateDriver = DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == autoCreateChildUID);

				for (int i = autoCreateDriver.MinAutoCreateAddress; i <= autoCreateDriver.MaxAutoCreateAddress; i++)
				{
					var newDevice = new Device()
					{
						DriverUID = autoCreateDriver.UID,
						Driver = autoCreateDriver,
						IntAddress = i
					};
					if (device.Children.Any(x => x.Driver.DriverType == newDevice.Driver.DriverType && x.IntAddress == newDevice.IntAddress) == false)
					{
						device.Children.Add(newDevice);
						newDevice.Parent = device;
					}
				}
			}

			device.SynchronizeChildern();
		}
Пример #4
0
		public DeviceDetailsViewModel(Device device)
		{
			ExecuteCommand = new RelayCommand(OnExecute);
			DeviceCommands = new List<DeviceCommandViewModel>();
			Device = device;
			DeviceState = Device.DeviceState;
			DeviceState.StateChanged += new Action(OnStateChanged);
			DeviceState.ParametersChanged += new Action(OnParametersChanged);
			OnStateChanged();

			Title = Device.DottedPresentationAddressAndName;
			TopMost = true;

			var tableNo = MetadataHelper.GetDeviceTableNo(device);
			var metadataDeviceCommands = MetadataHelper.Metadata.devicePropInfos.Where(x => x.tableType == tableNo);
			foreach (var metadataDeviceCommand in metadataDeviceCommands)
			{
				var deviceCommandViewModel = new DeviceCommandViewModel()
				{
					Name = metadataDeviceCommand.name,
					Caption = metadataDeviceCommand.caption,
				};
				DeviceCommands.Add(deviceCommandViewModel);
			}
			SelectedDeviceCommand = DeviceCommands.FirstOrDefault();
		}
Пример #5
0
        public static void Run(Device device, bool isUsb)
        {
			_device = device;
            _isUsb = isUsb;

			ServiceFactory.ProgressService.Run(OnPropgress, OnCompleted, device.PresentationAddressAndName + ". Установка времени");
        }
Пример #6
0
		public static List<DevicesOnShleif> GetLocalForZone(Device parentPanel, Zone zone)
		{
			var devicesOnShleifs = new List<DevicesOnShleif>();
			for (int i = 1; i <= parentPanel.Driver.ShleifCount; i++)
			{
				var devicesOnShleif = new DevicesOnShleif()
				{
					ShleifNo = i
				};
				devicesOnShleifs.Add(devicesOnShleif);
			}

			var effectorDevices = GetDevicesInLogic(zone);
			foreach (var device in effectorDevices.OrderBy(x => x.IntAddress))
			{
				if (device.ParentPanel.UID == parentPanel.UID)
				{
					var shleifNo = device.ShleifNo;
					if (device.Driver.DriverType == DriverType.PumpStation)
						shleifNo = 1;
					var devicesOnShleif = devicesOnShleifs.FirstOrDefault(x => x.ShleifNo == shleifNo);
					if (devicesOnShleif != null)
					{
						devicesOnShleif.Devices.Add(device);
					}
				}
			}
			return devicesOnShleifs;
		}
Пример #7
0
		public MPTTimerViewModel(Device device)
		{
			Title = "Включение МПТ. Обратный отсчет" + device.DottedAddress;
			TopMost = true;
			Device = device;
			_guid = device.UID;
		}
		public IndicatorDeviceSelectionViewModel(Device indicatorDevice, Device device)
		{
			Title = "Выбор устройства";
            IndicatorDevice = indicatorDevice;
			InitializeDevices();
			SelectedDevice = device;
		}
Пример #9
0
		public ClauseViewModel(ZoneLogicViewModel zoneLogicViewModel, Device device, Clause clause)
		{
			ShowZonesCommand = new RelayCommand(OnShowZones);
			SelectDeviceCommand = new RelayCommand(OnSelectDevice);

			_zoneLogicViewModel = zoneLogicViewModel;
			Device = device;
			Zones = new List<Guid>(
				from zoneUID in clause.ZoneUIDs
				select zoneUID);
			Zones = clause.ZoneUIDs.ToList();
			_selectedState = clause.State;
			SelectedOperation = clause.Operation;

			if (clause.DeviceUIDs == null)
			{
				clause.DeviceUIDs = new List<Guid>();
			}
			SelectedDevices = new List<Device>();
			foreach (var deviceUID in clause.DeviceUIDs)
			{
				var deviceInClause = FiresecManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
				if (deviceInClause != null)
				{
					SelectedDevices.Add(deviceInClause);
				}
			}

			SelectedMROMessageNo = clause.ZoneLogicMROMessageNo;
			SelectedMROMessageType = clause.ZoneLogicMROMessageType;
		}
Пример #10
0
		public static void SetDevice(ElementDevice element, Device device)
		{
			ResetDevice(element);
			element.DeviceUID = device == null ? Guid.Empty : device.UID;
			if (device != null)
				device.PlanElementUIDs.Add(element.UID);
		}
Пример #11
0
		public PDUPTTable(DevicePDUDirection devicePDUDirection, PanelDatabase panelDatabase)
			: base(null, devicePDUDirection.PDUGroupDevice.Device.DottedPresentationNameAndAddress)
		{
			Device = devicePDUDirection.PDUGroupDevice.Device;

			BytesDatabase = new BytesDatabase(Device.DottedPresentationNameAndAddress);
			BytesDatabase.AddByte(Device.AddressOnShleif, "Адрес");
			BytesDatabase.AddByte((Device.ShleifNo - 1), "Шлейф");
			BytesDatabase.AddByte(Device.Parent.IntAddress, "Адрес прибора");
			var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(Device.Driver.DriverType);
			BytesDatabase.AddByte(deviceCode, "Тип ИУ");

			var tableBase = panelDatabase.FlashDatabase.LocalZonesTableGroup.Tables.FirstOrDefault(x => x.UID == Device.Zone.UID);
			var localZoneNo = (tableBase as ZoneTable).BinaryZone.LocalNo;
			BytesDatabase.AddShort(localZoneNo, "Номер зоны");
			BytesDatabase.AddByte(devicePDUDirection.Device.IntAddress, "Направление");

			foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups)
			{
				tableBase = tableGroup.Tables.FirstOrDefault(x => x.UID == Device.UID);
				if (tableBase != null)
				{
					break;
				}
			}
			var offset = tableBase.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset + 3;
			var offsetBytes = BitConverter.GetBytes(offset);
			for (int i = 0; i < 4; i++)
			{
				BytesDatabase.AddByte(offsetBytes[i], "Смещение");
			}
		}
Пример #12
0
		void UpdateRealChildrenStateOnPanelState(Device panelDevice, BitArray bitArray)
		{
			foreach (var device in panelDevice.GetRealChildren())
			{
				foreach (var metadataDeviceState in MetadataHelper.GetMetadataDeviceStates(device, true))
				{
					if (metadataDeviceState.leave != null)
					{
						foreach (var leaveDeviceState in metadataDeviceState.leave)
						{
							if (leaveDeviceState.panelState != null)
							{
								var pabelBitNo = Int32.Parse(leaveDeviceState.panelState);
								var hasBit = bitArray[pabelBitNo];
								if (!hasBit)
								{
									if (device.DeviceState.States.RemoveAll(x => x.DriverState.Code == metadataDeviceState.ID) > 0)
									{
										ForseUpdateDeviceStates(device);
									}
								}
							}
						}
					}
				}
			}
		}
		public static bool Write(Device device)
		{
			CallbackManager.AddProgress(new FS2ProgressInfo("Формирование базы данных устройств"));
			var systemDatabaseCreator = new SystemDatabaseCreator();
			systemDatabaseCreator.Create(0x3000);
			Device parentPanel;
			if ((device.Driver.DriverType == DriverType.IndicationBlock) || (device.Driver.DriverType == DriverType.PDU) || (device.Driver.DriverType == DriverType.PDU_PT))
			{
				var nonPanelDatabase = systemDatabaseCreator.NonPanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == device.UID);
				if (nonPanelDatabase == null)
					throw new FS2Exception("Не найдена сформированная для устройства база данных");
				parentPanel = nonPanelDatabase.ParentPanel;
				var bytes = nonPanelDatabase.BytesDatabase.GetBytes();
				CallbackManager.AddProgress(new FS2ProgressInfo("Запись базы данных в прибор"));
				return SetConfigurationOperationHelper.WriteNonPanelDeviceConfiguration(parentPanel, bytes);
			}
			var panelDatabase = systemDatabaseCreator.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == device.UID);
			if (panelDatabase == null)
				throw new FS2Exception("Не найдена сформированная для устройства база данных");
			parentPanel = panelDatabase.ParentPanel;
			var bytes1 = panelDatabase.RomDatabase.BytesDatabase.GetBytes();
			var bytes2 = panelDatabase.FlashDatabase.BytesDatabase.GetBytes();
			CallbackManager.AddProgress(new FS2ProgressInfo("Запись базы данных в прибор"));
			return SetConfigurationOperationHelper.WriteDeviceConfiguration(parentPanel, bytes2, bytes1);
		}
Пример #14
0
        public PropertiesViewModel(Device device)
        {
            Device = device;
            StringProperties = new List<StringPropertyViewModel>();
            BoolProperties = new List<BoolPropertyViewModel>();
            EnumProperties = new List<EnumPropertyViewModel>();

            foreach (var driverProperty in device.Driver.Properties)
            {
                if (driverProperty.IsHidden)
                    continue;

                switch (driverProperty.DriverPropertyType)
                {
                    case DriverPropertyTypeEnum.EnumType:
                        EnumProperties.Add(new EnumPropertyViewModel(driverProperty, device));
                        break;

                    case DriverPropertyTypeEnum.StringType:
                    case DriverPropertyTypeEnum.IntType:
                    case DriverPropertyTypeEnum.ByteType:
                        StringProperties.Add(new StringPropertyViewModel(driverProperty, device));
                        break;

                    case DriverPropertyTypeEnum.BoolType:
                        BoolProperties.Add(new BoolPropertyViewModel(driverProperty, device));
                        break;
                }
            }
        }
		public Device AddDevice(Device parentDevice, Driver driver, int intAddress)
		{
			var device = new Device()
			{
				DriverUID = driver.UID,
				Driver = driver,
				IntAddress = intAddress,
				Parent = parentDevice
			};
			if (parentDevice.Driver.DriverType == DriverType.MPT)
			{
				device.ZoneUID = parentDevice.ZoneUID;
			}
            if (driver.DriverType == DriverType.Valve)
            {
                device.Properties.Add(new Property() { Name = "Action", Value = "1" });
            }
			parentDevice.Children.Add(device);
			AddAutoCreateChildren(device);
			AddAutoChildren(device);

			parentDevice.OnChanged();
			DeviceConfiguration.Update();
			return device;
		}
		public IndicatorPageDetailsViewModel(Device device)
		{
			Title = "Свойства страницы индикаторов. Автоматическая привязка к зонам";
			ShowZonesCommand = new RelayCommand(OnShowZones);
			Device = device;
			InitializeZones();
		}
Пример #17
0
		public static List<Device> GetRemoteForZone(Device parentPanel, Zone zone)
		{
			var devices = new HashSet<Device>();
			foreach (var device in GetDevicesInLogic(zone))
			{
				foreach (var clause in device.ZoneLogic.Clauses)
				{
					var allZonesAreRemote = true;
					foreach (var clauseZone in clause.Zones)
					{
						if (clauseZone.DevicesInZone.FirstOrDefault().ParentPanel.UID == device.ParentPanel.UID)
							allZonesAreRemote = false;
					}

					if (clause.Operation.Value == ZoneLogicOperation.Any || allZonesAreRemote)
					{
						foreach (var clauseZone in clause.Zones)
						{
							if (clauseZone.UID == zone.UID)
							{
								if (device.ParentPanel.UID != parentPanel.UID)
								{
									devices.Add(device);
								}
							}
						}
					}
				}
			}
			return devices.ToList();
		}
		public static void DeviceSetGuardUsers(Device device, List<GuardUser> guardUsers)
		{
			for (int i = 0; i < guardUsers.Count; i++)
				guardUsers[i].Id = i + 1;
				SetConfigurationOperationHelper.ConfirmLongTermOperation(device);
			// Данные таблицы
			var guardUsersCount = (byte) guardUsers.Count; // 1 байт
			var guardUsersBytes = GetGuardUsersByte(guardUsers);

			var bytes = USBManager.CreateBytesArray(guardUsersCount, guardUsersBytes);
			foreach (var guardUser in guardUsers)
			{
				bytes.AddRange(GuardUserDataToBytesList(device, guardUser));
			}

			// Добавление пустых пользователей
			var emptyGuardUser = new GuardUser();
			emptyGuardUser.KeyTM = new string('0', 12);
			emptyGuardUser.Password = "";

			for(int i = guardUsers.Count; i < 80; i++)
			{
				bytes.AddRange(GuardUserDataToBytesList(device, emptyGuardUser));
			}

			var begin = 0x14000;
			for (int i = 0; i < bytes.Count; i = i + 0x100)
			{
				CallbackManager.AddProgress(new FS2ProgressInfo("Запись охранных пользователей", (i * 100) / bytes.Count));
				USBManager.Send(device, "Запись охранных пользователей", 0x02, 0x52, BitConverter.GetBytes(begin + i).Reverse(), Math.Min(bytes.Count - i - 1, 0xFF), bytes.GetRange(i, Math.Min(bytes.Count - i, 0x100)));
			}
		}
Пример #19
0
		public static Device SetTempDeviceConfiguration(Device device)
		{
			CurrentDeviceConfiguration = ConfigurationManager.DeviceConfiguration;
			ConfigurationManager.DeviceConfiguration = CreateTempDeviceConfiguration(device);
			USBManager.Initialize();
			return ConfigurationManager.DeviceConfiguration.RootDevice.Children.FirstOrDefault();
		}
Пример #20
0
		public ZoneSelectationViewModel(Device device)
		{
			Title = "Выбор зоны устройства " + device.PresentationAddressAndName;
			CreateCommand = new RelayCommand(OnCreate);
			EditCommand = new RelayCommand(OnEdit, CanEdit);

			Device = device;
			IsGuardDevice = (device.Driver.DeviceType == DeviceType.Sequrity);

			Zones = new BindingList<ZoneViewModel>();
			foreach (var zone in from zone in FiresecManager.Zones orderby zone.No select zone)
			{
				var isGuardZone = (zone.ZoneType == ZoneType.Guard);
				if (isGuardZone ^ IsGuardDevice)
					continue;

				if (device.Driver.DriverType == DriverType.StopButton || device.Driver.DriverType == DriverType.StartButton || device.Driver.DriverType == DriverType.AutomaticButton)
				{
					if (!zone.DevicesInZone.Any(x => x.Driver.DriverType == DriverType.MPT))
						continue;
				}

				var zoneViewModel = new ZoneViewModel(zone);
				Zones.Add(zoneViewModel);
			}
			if (Device.Zone != null)
				SelectedZone = Zones.FirstOrDefault(x => x.Zone == Device.Zone);
		}
		public static void Add(string description, string userName, Device panelDevice = null, Device device = null, Zone zone = null, StateType stateType = StateType.Info)
		{
			var journalItem = new FS2JournalItem
			{
				DeviceTime = DateTime.Now,
				SystemTime = DateTime.Now,
				Description = description,
				UserName = userName,
				PanelDevice = panelDevice,
				Device = device,
				StateType = stateType,
				SubsystemType = SubsystemType.Other,
			};
			if (panelDevice != null)
			{
				journalItem.PanelName = panelDevice.DottedPresentationNameAndAddress;
				journalItem.PanelUID = panelDevice.UID;
			}
			if (device != null)
			{
				journalItem.DeviceName = device.DottedPresentationNameAndAddress;
				journalItem.DeviceUID = device.UID;
			}
			if (zone != null)
			{
				journalItem.ZoneNo = zone.No;
				journalItem.ZoneName = zone.PresentationName;
			}

			AddJournalItem(journalItem);
		}
Пример #22
0
		public FlashDatabase(Device parentPanel)
		{
			ParentPanel = parentPanel;
			BytesDatabase = new BytesDatabase();
			BinaryPanel = SystemDatabaseCreator.BinaryConfigurationHelper.BinaryPanels.FirstOrDefault(x => x.ParentPanel == ParentPanel);

			CreateEmptyTable();
            CreateDirections();
			CreateRemoteZones();
			CreateLocalZones();
			CreateAddressListTable();
			CreateDevices();
			CreateLastTable();

			foreach (var table in Tables)
			{
				table.Create();
			}
			foreach (var table in Tables)
			{
				foreach (var byteDescription in table.BytesDatabase.ByteDescriptions)
				{
					byteDescription.TableHeader = table;
				}
			}
			foreach (var table in Tables)
			{
				if (table.BytesDatabase.Name == "Адресный лист")
				{
					var count = BytesDatabase.ByteDescriptions.Count;
					var bytesBefireEnd = 256 - count % 256;
					if (bytesBefireEnd < 32)
					{
						var leftTable = new TableBase(this, "Дополняюшая таблица");
						for (int i = 0; i < bytesBefireEnd; i++)
						{
							leftTable.BytesDatabase.AddByte(0, "Дополняющий байт");
						}
						BytesDatabase.Add(leftTable.BytesDatabase);
					}
				}
				BytesDatabase.Add(table.BytesDatabase);
			}
			BytesDatabase.Order();
			BytesDatabase.ResolveTableReferences();
			BytesDatabase.ResolveReferences();

			var crcBytes = BytesDatabase.GetBytes();
			crcBytes.RemoveRange(0, 256);
			crcBytes.RemoveRange(crcBytes.Count - 36, 36);
			var md5 = MD5.Create();
			var md5Bytes = md5.ComputeHash(crcBytes.ToArray());
			for (int i = 0; i < 16; i++)
			{
				var md5Byte = md5Bytes[i];
				LastTable.BytesDatabase.ByteDescriptions[i + 1].Value = md5Byte;
			}

			CreateRootBytes();
		}
Пример #23
0
		public SetPasswordViewModel(Device device, bool isUsb)
		{
			_device = device;
			_isUsb = isUsb;
			Title = "Смена пароля";
			DevicePasswordType = DevicePasswordType.Administrator;
		}
Пример #24
0
        public void AddDevice(XDevice parentDevice, Device fsDevice)
        {
            var driver = XManager.DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == fsDevice.DriverUID);
            if (driver == null)
            {
                return;
            }
            var shleifNo = ((shleifPairNo - 1) * 2) + (fsDevice.IntAddress >> 8);

            var xDevice = new XDevice()
            {
                UID = fsDevice.UID,
                DriverUID = driver.UID,
                Driver = driver,
                ShleifNo = (byte)shleifNo,
                IntAddress = (byte)(fsDevice.IntAddress & 0xff),
                Description = fsDevice.Description
            };
            XManager.DeviceConfiguration.Devices.Add(xDevice);
            parentDevice.Children.Add(xDevice);
            xDevice.Parent = parentDevice;

            foreach (var fsChildDevice in fsDevice.Children)
            {
                AddDevice(xDevice, fsChildDevice);
            }
        }
        public static void Run(Device device, string functionCode)
        {
            _device = device;
            _functionCode = functionCode;

            ServiceFactory.ProgressService.Run(OnPropgress, OnlCompleted, device.PresentationAddressAndDriver + ". Выполнение функции");
        }
Пример #26
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;
		}
Пример #27
0
		public static void StartMonitoring(Device device = null)
		{
			if (device == null)
			{
				var deviceStatesManager = new DeviceStatesManager();
				deviceStatesManager.CanNotifyClients = false;
				foreach (var childDevice in ConfigurationManager.Devices)
				{
					if (childDevice.IsMonitoringDisabled)
					{
						deviceStatesManager.ForseUpdateDeviceStates(childDevice);
					}
				}

				USBManager.UsbRemoved += new Action(USBManager_UsbRemoved);

				MonitoringUSBs = new List<MonitoringUSB>();
				foreach (var usbDevice in ConfigurationManager.DeviceConfiguration.RootDevice.Children)
				{
					var monitoringUSB = new MonitoringUSB(usbDevice);
					if (monitoringUSB.MonitoringPanels.Count > 0 || monitoringUSB.MonitoringNonPanels.Count > 0)
					{
						MonitoringUSBs.Add(monitoringUSB);
					}
				}
			}
			foreach (var monitoringUSB in MonitoringUSBs)
			{
				if (device == null || monitoringUSB.USBDevice.UID == device.ParentUSB.UID)
				{
					monitoringUSB.StartMonitoring();
				}
			}
		}
		public void RemoveOneDevice(Device device)
		{
			DeviceConfiguration.Devices.Remove(device);

			var dependentDevices = new List<Device>(device.DependentDevices);
			foreach (var dependentDevice in dependentDevices)
			{
				if (!device.AllParents.Contains(deletingDevice))
				{
					DeviceConfiguration.InvalidateOneDevice(dependentDevice);
					DeviceConfiguration.UpdateOneDeviceCrossReferences(dependentDevice);
					dependentDevice.OnChanged();
				}
			}

			var children = new List<Device>(device.Children);
			foreach (var child in children)
			{
				RemoveOneDevice(child);
			}
			var parentDevice = device.Parent;
			parentDevice.Children.Remove(device);
			parentDevice.OnChanged();
			device.OnChanged();
		}
Пример #29
0
		public ZonesSelectionViewModel(Device device, List<Guid> zones)
		{
			Title = "Выбор зон индикатора";

			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAdd);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemove);

			Zones = zones;
			TargetZones = new ObservableCollection<ZoneViewModel>();
			SourceZones = new ObservableCollection<ZoneViewModel>();

			foreach (var zone in FiresecManager.FiresecConfiguration.GetChannelZones(device))
			{
				var zoneViewModel = new ZoneViewModel(zone);

				if (Zones.Contains(zone.UID))
					TargetZones.Add(zoneViewModel);
				else
					SourceZones.Add(zoneViewModel);
			}

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
        public IndicatorZoneSelectionViewModel(List<int> zones, Device device)
        {
            Title = "Свойства индикатора";

            AddOneCommand = new RelayCommand(OnAddOne, CanAdd);
            RemoveOneCommand = new RelayCommand(OnRemoveOne, CanRemove);
            AddAllCommand = new RelayCommand(OnAddAll, CanAdd);
            RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemove);

            Zones = zones;
            TargetZones = new ObservableCollection<ZoneViewModel>();
            SourceZones = new ObservableCollection<ZoneViewModel>();

            foreach (var zone in FiresecManager.FiresecConfiguration.GetChannelZones(device))
            {
                var zoneViewModel = new ZoneViewModel(zone);

                if (Zones.Contains(zone.No))
                    TargetZones.Add(zoneViewModel);
                else
                    SourceZones.Add(zoneViewModel);
            }

            SelectedTargetZone = TargetZones.FirstOrDefault();
            SelectedSourceZone = SourceZones.FirstOrDefault();
        }