Exemple #1
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			var nsDevicesUIDs = new List<Guid>();
			NSDevices = new List<GKDevice>();
			foreach (var NSDevicesUID in NSDeviceUIDs)
			{
				var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == NSDevicesUID);
				if (device != null)
				{
					nsDevicesUIDs.Add(NSDevicesUID);
					NSDevices.Add(device);
					AddDependentElement(device);
				}
			}

			NSDeviceUIDs = nsDevicesUIDs;

			UpdateLogic(deviceConfiguration);

			StartLogic.GetObjects().ForEach(x => AddDependentElement(x));

			StopLogic.GetObjects().ForEach(x => AddDependentElement(x));

			AutomaticOffLogic.GetObjects().ForEach(x => AddDependentElement(x));

		}
		public ConfigurationCompareViewModel(GKDeviceConfiguration localConfiguration, GKDeviceConfiguration remoteConfiguration, GKDevice device, string configFileName = "")
		{
			Title = "Сравнение конфигураций " + device.PresentationName;
			ChangeCurrentGkCommand = new RelayCommand(OnChangeCurrentGk);
			LoadConfigurationFromFileCommand = new RelayCommand(OnLoadConfigurationFromFile);
			NextDifferenceCommand = new RelayCommand(OnNextDifference, CanNextDifference);
			PreviousDifferenceCommand = new RelayCommand(OnPreviousDifference, CanPreviousDifference);

			ConfigFileName = configFileName;
			ConfigFromFile = CanChangeOrOpenConfiguration = !string.IsNullOrEmpty(configFileName);

			var remoteConfig = new ZipFile(ConfigFileName);
			OnlyGKDeviceConfiguration = remoteConfig.Entries.Count == 1;

			LocalConfiguration = localConfiguration;
			RemoteConfiguration = remoteConfiguration;
			RemoteConfiguration.Update();
			RemoteConfiguration.UpdateConfiguration();

			LocalDevice = localConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			RemoteDevice = remoteConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			if (RemoteDevice == null)
			{
				Error = "ГК в удаленной конфигурации имеет невалидный IP адрес";
				return;
			}
			LocalObjectsViewModel = new ObjectsListViewModel(LocalDevice, localConfiguration);
			RemoteObjectsViewModel = new ObjectsListViewModel(RemoteDevice, remoteConfiguration);
			CompareObjectLists();
			InitializeMismatchedIndexes();
		}
Exemple #3
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			var guardZoneDevices = new List<GKGuardZoneDevice>();
			foreach (var guardZoneDevice in GuardZoneDevices)
			{
				var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == guardZoneDevice.DeviceUID);
				if (device != null)
				{
					if (device.DriverType == GKDriverType.RSR2_GuardDetector || device.DriverType == GKDriverType.RSR2_GuardDetectorSound
						|| device.DriverType == GKDriverType.RSR2_HandGuardDetector || device.DriverType == GKDriverType.RSR2_AM_1 || device.DriverType == GKDriverType.RSR2_MAP4 || device.Driver.IsCardReaderOrCodeReader)
					{
						guardZoneDevice.Device = device;
						guardZoneDevices.Add(guardZoneDevice);
					}
					if (device.Driver.IsCardReaderOrCodeReader)
					{
						deviceConfiguration.InvalidateGKCodeReaderSettingsPart(guardZoneDevice.CodeReaderSettings.SetGuardSettings);
						deviceConfiguration.InvalidateGKCodeReaderSettingsPart(guardZoneDevice.CodeReaderSettings.ResetGuardSettings);
						deviceConfiguration.InvalidateGKCodeReaderSettingsPart(guardZoneDevice.CodeReaderSettings.ChangeGuardSettings);
						deviceConfiguration.InvalidateGKCodeReaderSettingsPart(guardZoneDevice.CodeReaderSettings.AlarmSettings);
					}
				}
			}
			GuardZoneDevices = guardZoneDevices;
		}
		override public bool ReadConfiguration(GKDevice mirrorDevice, Guid clientUID)
		{
			MirrorDevice = (GKDevice)mirrorDevice.Clone();
			MirrorDevice.Children = new List<GKDevice>();

			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + mirrorDevice.PresentationName, "Проверка связи", 2, true, GKProgressClientType.Administrator);
			var result = DeviceBytesHelper.Ping(mirrorDevice);
			if (result.HasError)
			{
				Error = "Устройство " + mirrorDevice.PresentationName + " недоступно";
				return false;
			}

			DeviceConfiguration = new GKDeviceConfiguration { RootDevice = MirrorDevice };
			GKProcessorManager.DoProgress("Перевод ПМФ в технологический режим", progressCallback);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(mirrorDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести " + mirrorDevice.PresentationName + " в технологический режим";
				GKProcessorManager.StopProgress(progressCallback);
				return false;
			}

			ReadConfiguration(mirrorDevice);

			GKProcessorManager.DoProgress("Перевод ПМФ в рабочий режим", progressCallback);
			if (!DeviceBytesHelper.GoToWorkingRegime(mirrorDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести  " + mirrorDevice.PresentationName + " в рабочий режим в заданное время";
			}
			GKProcessorManager.StopProgress(progressCallback);
			return Error == null;
		}
		static GKDeviceConfiguration GetDeviceConfiguration()
		{
			var deviceConfiguration = (GKDeviceConfiguration)GetConfiguration("GKDeviceConfiguration.xml", typeof(GKDeviceConfiguration));
			if (deviceConfiguration == null)
				deviceConfiguration = new GKDeviceConfiguration();
			deviceConfiguration.AfterLoad();
			return deviceConfiguration;
		}
Exemple #6
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			UpdateLogic(deviceConfiguration);

			Logic.GetObjects().ForEach(x =>
			{
				AddDependentElement(x);
			});
		}
Exemple #7
0
		public static void SetEmptyConfiguration()
		{
			DeviceConfiguration = new GKDeviceConfiguration();
			var driver = Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.System);
			DeviceConfiguration.RootDevice = new GKDevice()
			{
				DriverUID = driver.UID
			};
			UpdateConfiguration();
		}
Exemple #8
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			UpdateLogic(deviceConfiguration);
			Logic.GetObjects().ForEach(x =>
			{
				if (!InputDependentElements.Contains(x) && x != this)
					InputDependentElements.Add(x);
				if (!x.OutputDependentElements.Contains(this) && x != this)
					x.OutputDependentElements.Add(this);
			});
		}
Exemple #9
0
		GKDevice InvalidateDoorDevice(Guid deviceUid, GKDeviceConfiguration deviceCongiguration)
		{
			if (deviceUid != Guid.Empty)
			{
				var device = deviceCongiguration.Devices.Find(x => x.UID == deviceUid);
				if (device == null)
					return null;
				device.Door = this;
				AddDependentElement(device);
				return device;
			}
			return null;
		}
Exemple #10
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			UpdateLogic(deviceConfiguration);
			OpenRegimeLogic.GetObjects().ForEach(AddDependentElement);
			NormRegimeLogic.GetObjects().ForEach(AddDependentElement);
			CloseRegimeLogic.GetObjects().ForEach(AddDependentElement);

			EnterDevice = InvalidateDoorDevice(EnterDeviceUID, deviceConfiguration);
			EnterDeviceUID = EnterDevice != null ? EnterDevice.UID : Guid.Empty;
			ExitDevice = InvalidateDoorDevice(ExitDeviceUID, deviceConfiguration);
			ExitDeviceUID = ExitDevice != null ? ExitDevice.UID : Guid.Empty;
			LockDevice = InvalidateDoorDevice(LockDeviceUID, deviceConfiguration);
			LockDeviceUID = LockDevice != null ? LockDevice.UID : Guid.Empty;
			LockControlDevice = InvalidateDoorDevice(LockControlDeviceUID, deviceConfiguration);
			LockControlDeviceUID = LockControlDevice != null ? LockControlDevice.UID : Guid.Empty;

			if (DoorType == GKDoorType.AirlockBooth)
			{
				EnterButton = InvalidateDoorDevice(EnterButtonUID, deviceConfiguration);
				EnterButtonUID = EnterButton != null ? EnterButton.UID : Guid.Empty;
				ExitButton = InvalidateDoorDevice(ExitButtonUID, deviceConfiguration);
				ExitButtonUID = ExitButton != null ? ExitButton.UID : Guid.Empty;
			}
			if (DoorType == GKDoorType.AirlockBooth || DoorType == GKDoorType.Barrier)
			{
				LockControlDeviceExit = InvalidateDoorDevice(LockControlDeviceExitUID, deviceConfiguration);
				LockControlDeviceExitUID = LockControlDeviceExit != null ? LockControlDeviceExit.UID : Guid.Empty;
			}
			if (DoorType == GKDoorType.Barrier || DoorType == GKDoorType.Turnstile || DoorType == GKDoorType.OneWay || DoorType == GKDoorType.TwoWay)
			{
				EnterButton = null;
				EnterButtonUID = Guid.Empty;
				ExitButton = null;
				ExitButtonUID = Guid.Empty;
			}
			if (DoorType == GKDoorType.Turnstile || DoorType == GKDoorType.OneWay || DoorType == GKDoorType.TwoWay)
			{
				LockControlDeviceExit = null;
				LockControlDeviceExitUID = Guid.Empty;
			}
			if (DoorType == GKDoorType.AirlockBooth || DoorType == GKDoorType.Barrier || DoorType == GKDoorType.Turnstile)
			{
				LockDeviceExit = InvalidateDoorDevice(LockDeviceExitUID, deviceConfiguration);
				LockDeviceExitUID = LockDeviceExit != null ? LockDeviceExit.UID : Guid.Empty;
			}
			if (DoorType == GKDoorType.OneWay || DoorType == GKDoorType.TwoWay)
			{
				LockDeviceExit = null;
				LockDeviceExitUID = Guid.Empty;
			}
		}
		override public bool ReadConfiguration(GKDevice gkControllerDevice, Guid clientUID)
		{
			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + gkControllerDevice.PresentationName, "Проверка связи", 2, true, GKProgressClientType.Administrator, clientUID);
			var result = DeviceBytesHelper.Ping(gkControllerDevice);
			if (result.HasError)
			{
				Error = "Устройство " + gkControllerDevice.PresentationName + " недоступно";
				return false;
			}
			IpAddress = gkControllerDevice.GetGKIpAddress();
			ControllerDevices = new Dictionary<ushort, GKDevice>();
			DeviceConfiguration = new GKDeviceConfiguration();
			var rootDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.System);
			DeviceConfiguration.RootDevice = new GKDevice
			{
				Driver = rootDriver,
				DriverUID = rootDriver.UID
			};
			GKProcessorManager.DoProgress("Перевод ГК в технологический режим", progressCallback, clientUID);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(gkControllerDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести " + gkControllerDevice.PresentationName + " в технологический режим\n" +
						"Устройство не доступно, либо вашего " +
						"IP адреса нет в списке разрешенного адреса ГК";
				GKProcessorManager.StopProgress(progressCallback, clientUID);
				return false;
			}

			ReadConfiguration(gkControllerDevice, progressCallback, clientUID);

			GKProcessorManager.DoProgress("Перевод ГК в рабочий режим", progressCallback, clientUID);
			if (!DeviceBytesHelper.GoToWorkingRegime(gkControllerDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести устройство в рабочий режим в заданное время";
			}
			GKProcessorManager.StopProgress(progressCallback, clientUID);
			if (Error != null)
				return false;
			DeviceConfiguration.Update();
			return true;
		}
		override public bool ReadConfiguration(GKDevice kauDevice, Guid clientUID)
		{
			KauDevice = (GKDevice)kauDevice.Clone();
			KauDevice.Children = new List<GKDevice>();
			descriptorAddresses = new List<int>();
			for (int i = 0; i < 8; i++)
			{
				var shleif = new GKDevice();
				shleif.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);
				shleif.DriverUID = shleif.Driver.UID;
				shleif.IntAddress = (byte)(i + 1);
				KauDevice.Children.Add(shleif);
			}
			DeviceConfiguration = new GKDeviceConfiguration { RootDevice = KauDevice };
			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + kauDevice.PresentationName, "", descriptorAddresses.Count + 2, true, GKProgressClientType.Administrator, clientUID);
			GKProcessorManager.DoProgress("Перевод КАУ в технологический режим", progressCallback);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(kauDevice, progressCallback, clientUID))
			{ Error = "Не удалось перевести КАУ в технологический режим"; return false; }
			GKProcessorManager.DoProgress("Получение дескрипторов устройств", progressCallback);
			if (GetDescriptorAddresses(kauDevice))
			{
				progressCallback.StepCount = descriptorAddresses.Count + 1;
				for (int i = 1; i < descriptorAddresses.Count; i++)
				{
					if (progressCallback.IsCanceled)
					{
						Error = "Операция отменена";
						break;
					}
					GKProcessorManager.DoProgress("Чтение базы данных объектов. " + i + " из " + descriptorAddresses.Count, progressCallback);
					if (!GetDescriptorInfo(kauDevice, descriptorAddresses[i]))
						break;
				}
			}
			GKProcessorManager.DoProgress("Перевод КАУ в рабочий режим", progressCallback);
			DeviceBytesHelper.GoToWorkingRegime(kauDevice, progressCallback, clientUID);
			GKProcessorManager.StopProgress(progressCallback);
			return String.IsNullOrEmpty(Error);
		}
Exemple #13
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			var newMPTDevices = new List<GKMPTDevice>();
			foreach (var mptDevice in MPTDevices)
			{
				var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == mptDevice.DeviceUID);
				if (device != null)
				{
					newMPTDevices.Add(mptDevice);
					mptDevice.Device = device;
					device.IsInMPT = true;
					AddDependentElement(device);
				}
			}
			MPTDevices = newMPTDevices;

			UpdateLogic(deviceConfiguration);

			MptLogic.GetObjects().ForEach(x =>
			{
				AddDependentElement(x);
			});
		}
		GKMPT CreateMPT(GKDeviceConfiguration deviceConfiguration, string name = "МПТ 1", int no = 1)
		{
			var mpt = new GKMPT()
			{
				Name = name,
				No = no
			};
			var am1Device = CreateAm1(deviceConfiguration.Devices.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif));
            mpt.MPTDevices.Add(CreateMptDevice(am1Device));
			deviceConfiguration.MPTs.Add(mpt);
            return mpt;
		}
Exemple #15
0
		void CreatReflectionDevices(GKDeviceConfiguration deviceConfiguration, bool isDetectorMirror = false)
		{
			var _device = new List<GKDevice>();
			GKReflectionItem.DeviceUIDs.ForEach(x =>
			{
				var device = deviceConfiguration.Devices.FirstOrDefault(y => y.UID == x);
				if (device != null)
				{
					_device.Add(device);
					AddDependentElement(device);
					if (!isDetectorMirror)
						device.AddDependentElement(this);
				}
			});
			GKReflectionItem.Devices = new List<GKDevice>(_device);
			GKReflectionItem.DeviceUIDs = new List<Guid>(_device.Select(x => x.UID));
		}
		GKDoor CreateDoor(GKDeviceConfiguration deviceConfiguration, string name, int no, GKSKDZone enterZone, GKSKDZone exitZone)
		{
			var cardReaderDevice = CreateCardReader();
			var alsDevice = deviceConfiguration.Devices.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);
			var am1Device = CreateAm1(alsDevice);
			var logic = CreateLogic(am1Device);

			var door = new GKDoor
			{
				Name = "Точка доступа",
				No = 1,
				OpenRegimeLogic = logic,
				CloseRegimeLogic = logic,
				NormRegimeLogic = logic,
				EnterZoneUID = enterZone.UID,
				ExitZoneUID = exitZone.UID,
				EnterDevice = cardReaderDevice,
				EnterDeviceUID = cardReaderDevice.UID,
				ExitDevice = cardReaderDevice,
				ExitDeviceUID = cardReaderDevice.UID
			};
			return door;
		}
		GKPumpStation CreatePumpStation(GKDeviceConfiguration deviceConfiguration)
		{
			var alsDevice = deviceConfiguration.Devices.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);
			var bushDrenazhDevice = CreateBushDrenazhDevice(alsDevice);
			var am1Device = CreateAm1(alsDevice);
			var logic = CreateLogic(am1Device);
			var pumpStation = new GKPumpStation
			{
				Name = "Насосная станция",
				No = 1,
				StartLogic = logic,
				StopLogic = logic,
				AutomaticOffLogic = logic
			};
			pumpStation.NSDevices.Add(bushDrenazhDevice);
			pumpStation.NSDeviceUIDs.Add(bushDrenazhDevice.UID);
			deviceConfiguration.PumpStations.Add(pumpStation);
			return pumpStation;
		}
		GKDeviceConfiguration CreateConfiguration()
		{
			var newConfiguration = new GKDeviceConfiguration();
			var drivers = GKManager.Drivers;
			var systemDriver = drivers.FirstOrDefault(x => x.DriverType == GKDriverType.System);
			var gkDriver = drivers.FirstOrDefault(x => x.DriverType == GKDriverType.GK);
			var kauDriver = drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU);
			var alsDriver = drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);

			var alsDevice = new GKDevice { DriverUID = alsDriver.UID };

			var kauDevice = new GKDevice { DriverUID = kauDriver.UID };
			kauDevice.Children.Add(alsDevice);

			var gkDevice = new GKDevice { DriverUID = gkDriver.UID };
			gkDevice.Children.Add(kauDevice);

			newConfiguration.RootDevice = new GKDevice { DriverUID = systemDriver.UID };
			newConfiguration.RootDevice.Children.Add(gkDevice);
			newConfiguration.UpdateConfiguration();
			return newConfiguration;
		}
		GKSKDZone CreateSKDZone(GKDeviceConfiguration deviceConfiguration, string name, int no, Guid uid)
		{
			var cardReader = CreateCardReader();
			var skdZone = new GKSKDZone
			{
				Name = name,
				No = no,
				UID = uid
			};
			deviceConfiguration.SKDZones.Add(skdZone);
			return skdZone;
		}
Exemple #20
0
		public virtual void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
		}
Exemple #21
0
		static GKManager()
		{
			DeviceConfiguration = new GKDeviceConfiguration();
			AutoGeneratedDelays = new List<GKDelay>();
			AutoGeneratedPims = new List<GKPim>();
		}
Exemple #22
0
		public virtual void UpdateLogic(GKDeviceConfiguration deviceConfiguration)
		{
		}
Exemple #23
0
		public override void UpdateLogic(GKDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.InvalidateOneLogic(this, StartLogic);
			deviceConfiguration.InvalidateOneLogic(this, StopLogic);
			deviceConfiguration.InvalidateOneLogic(this, AutomaticOffLogic);
		}
Exemple #24
0
		public override void UpdateLogic(GKDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.InvalidateOneLogic(this, OpenRegimeLogic);
			deviceConfiguration.InvalidateOneLogic(this, NormRegimeLogic);
			deviceConfiguration.InvalidateOneLogic(this, CloseRegimeLogic);
		}
Exemple #25
0
		public static List<byte> CreateHash1(GKDeviceConfiguration deviceConfiguration, GKDevice gkControllerDevice)
		{
			deviceConfiguration.UpdateConfiguration();
			deviceConfiguration.PrepareDescriptors();
			var stringBuilder = new StringBuilder();
			stringBuilder.Append("devices:");
			foreach (var device in deviceConfiguration.Devices)
			{
				if (device.IsRealDevice && device.GKParent == gkControllerDevice)
					stringBuilder.Append(device.PresentationName).Append("@");
			}
			stringBuilder.Append("zones:");
			foreach (var zone in deviceConfiguration.Zones)
			{
				if (zone.GkDatabaseParent == gkControllerDevice)
					stringBuilder.Append(zone.PresentationName).Append("@");
			}
			stringBuilder.Append("directions:");
			foreach (var direction in deviceConfiguration.Directions)
			{
				if (direction.GkDatabaseParent == gkControllerDevice)
					stringBuilder.Append(direction.PresentationName).Append("@");
			}
			stringBuilder.Append("pumpStations:");
			foreach (var pumpStation in deviceConfiguration.PumpStations)
			{
				if (pumpStation.GkDatabaseParent == gkControllerDevice)
				{
					stringBuilder.Append(pumpStation.PresentationName).Append("@");
					if (pumpStation.NSDevices != null)
					{
						stringBuilder.Append("nsDevices:");
						foreach (var nsDevice in pumpStation.NSDevices)
						{
							if (nsDevice.GKParent == gkControllerDevice)
								stringBuilder.Append(nsDevice.PresentationName).Append("@");
						}
					}
				}
			}
			stringBuilder.Append("mpts:");
			foreach (var mpt in deviceConfiguration.MPTs)
			{
				if (mpt.GkDatabaseParent == gkControllerDevice)
				{
					stringBuilder.Append(mpt.PresentationName).Append("@");
					if (mpt.MPTDevices != null)
					{
						stringBuilder.Append("nsDevices:");
						foreach (var mptDevice in mpt.MPTDevices)
						{
							if (mptDevice.Device.GKParent == gkControllerDevice)
								stringBuilder.Append(mptDevice.Device.PresentationName).Append("@");
						}
					}
				}
			}
			stringBuilder.Append("delays:");
			foreach (var delay in deviceConfiguration.Delays)
			{
				if (delay.GkDatabaseParent == gkControllerDevice)
				{
					stringBuilder.Append(delay.PresentationName).Append("@");
				}
			}
			stringBuilder.Append("guardZones:");
			foreach (var guardZone in deviceConfiguration.GuardZones)
			{
				if (guardZone.GkDatabaseParent == gkControllerDevice)
					stringBuilder.Append(guardZone.PresentationName).Append("@");
			}
			stringBuilder.Append("codes:");
			foreach (var code in deviceConfiguration.Codes)
			{
				if (code.GkDatabaseParent == gkControllerDevice)
					stringBuilder.Append(code.PresentationName).Append("@");
			}
			stringBuilder.Append("door:");
			foreach (var door in deviceConfiguration.Doors)
			{
				if (door.GkDatabaseParent == gkControllerDevice)
					stringBuilder.Append(door.PresentationName).Append("@");
			}
			return SHA256.Create().ComputeHash(Encoding.GetEncoding(1251).GetBytes(stringBuilder.ToString())).ToList();
		}
Exemple #26
0
		void CreatReflectionDirection(GKDeviceConfiguration deviceConfiguration)
		{
			var _direction = new List<GKDirection>();
			GKReflectionItem.DiretionUIDs.ForEach(x =>
			{
				var direction = deviceConfiguration.Directions.FirstOrDefault(y => y.UID == x);
				if (direction != null)
				{
					_direction.Add(direction);
					AddDependentElement(direction);
					direction.AddDependentElement(this);
				}
			});
			GKReflectionItem.Diretions = new List<GKDirection>(_direction);
			GKReflectionItem.DiretionUIDs = new List<Guid>(_direction.Select(x => x.UID));
		}
		static GKDeviceConfiguration GetDeviceConfiguration()
		{
			var deviceConfiguration = (GKDeviceConfiguration)GetConfiguration("Config" + Path.DirectorySeparatorChar + "GKDeviceConfiguration.xml", typeof(GKDeviceConfiguration));
			if (deviceConfiguration == null)
				deviceConfiguration = new GKDeviceConfiguration();
			deviceConfiguration.AfterLoad();
			return deviceConfiguration;
		}
Exemple #28
0
		void CreatReflectionFire(GKDeviceConfiguration deviceConfiguration)
		{
			var _zone = new List<GKZone>();
			GKReflectionItem.ZoneUIDs.ForEach(x =>
			{
				var zone = deviceConfiguration.Zones.FirstOrDefault(y => y.UID == x);
				if (zone != null)
				{
					_zone.Add(zone);
					AddDependentElement(zone);
					zone.AddDependentElement(this);
				}
			});
			GKReflectionItem.Zones = new List<GKZone>(_zone);
			GKReflectionItem.ZoneUIDs = new List<Guid>(_zone.Select(x => x.UID));
		}
Exemple #29
0
		public override void UpdateLogic(GKDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.InvalidateOneLogic(this, MptLogic);
		}
Exemple #30
0
		public override void Invalidate(GKDeviceConfiguration deviceConfiguration)
		{
			if (Driver.HasLogic)
			{
				UpdateLogic(deviceConfiguration);
				Logic.GetObjects().ForEach(x =>
				{
					AddDependentElement(x);
				});
				NSLogic.GetObjects().ForEach(x =>
				{
					AddDependentElement(x);
				});
			}
			if (Driver.HasZone)
			{
				var zoneUIDs = new List<Guid>();
				var zones = new List<GKZone>();

				foreach (var zoneUID in ZoneUIDs)
				{
					var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.UID == zoneUID);
					if (zone != null)
					{
						zones.Add(zone);
						zoneUIDs.Add(zoneUID);
						if (!zone.Devices.Contains(this))
							zone.Devices.Add(this);
						AddDependentElement(zone);
					}
				}
				Zones = zones;
				ZoneUIDs = zoneUIDs;
			}
			if (Driver.HasGuardZone)
			{
				var guardZones = new List<GKGuardZone>();

				foreach (var guardZone in deviceConfiguration.GuardZones.Where(x => x.GuardZoneDevices.Any(y => y.DeviceUID == UID)))
				{
					guardZones.Add(guardZone);
					AddDependentElement(guardZone);
				}
				GuardZones = guardZones;
			}
			if (Driver.HasMirror)
			{
				OutputDependentElements = new List<GKBase>();
				var delays = new List<GKDelay>();
				var mpts = new List<GKMPT>();
				var pumpStantoins = new List<GKPumpStation>();
				var guardZones = new List<GKGuardZone>();

				switch (DriverType)
				{
					case GKDriverType.DetectorDevicesMirror:
						CreatReflectionDevices(deviceConfiguration, true);
						break;
					case GKDriverType.ControlDevicesMirror:
						CreatReflectionDevices(deviceConfiguration);
						CreatReflectionDirection(deviceConfiguration);

						GKReflectionItem.DelayUIDs.ForEach(x =>
						{
							var delay = deviceConfiguration.Delays.FirstOrDefault(y => y.UID == x);
							if (delay != null)
							{
								delays.Add(delay);
								AddDependentElement(delay);
								delay.AddDependentElement(this);
							}
						});
						GKReflectionItem.Delays = new List<GKDelay>(delays);
						GKReflectionItem.DelayUIDs = new List<Guid>(delays.Select(x => x.UID));

						GKReflectionItem.MPTUIDs.ForEach(x =>
						{
							var mpt = deviceConfiguration.MPTs.FirstOrDefault(y => y.UID == x);
							if (mpt != null)
							{
								mpts.Add(mpt);
								AddDependentElement(mpt);
								mpt.AddDependentElement(this);
							}
						});
						GKReflectionItem.MPTs = new List<GKMPT>(mpts);
						GKReflectionItem.MPTUIDs = new List<Guid>(mpts.Select(x => x.UID));

						GKReflectionItem.NSUIDs.ForEach(x =>
						{
							var pump = deviceConfiguration.PumpStations.FirstOrDefault(y => y.UID == x);
							if (pump != null)
							{
								pumpStantoins.Add(pump);
								AddDependentElement(pump);
								pump.AddDependentElement(this);
							}
						});
						GKReflectionItem.NSs = new List<GKPumpStation>(pumpStantoins);
						GKReflectionItem.NSUIDs = new List<Guid>(pumpStantoins.Select(x => x.UID));
						break;
					case GKDriverType.DirectionsMirror:
						CreatReflectionDirection(deviceConfiguration);
						break;
					case GKDriverType.FireZonesMirror:
						CreatReflectionFire(deviceConfiguration);
						break;
					case GKDriverType.FirefightingZonesMirror:
						CreatReflectionFire(deviceConfiguration);
						CreatReflectionDirection(deviceConfiguration);
						break;
					case GKDriverType.GuardZonesMirror:
						GKReflectionItem.GuardZoneUIDs.ForEach(x =>
						{
							var zone = deviceConfiguration.GuardZones.FirstOrDefault(y => y.UID == x);
							if (zone != null)
							{
								guardZones.Add(zone);
								AddDependentElement(zone);
								zone.AddDependentElement(this);
							}
						});
						GKReflectionItem.GuardZones = new List<GKGuardZone>(guardZones);
						GKReflectionItem.GuardZoneUIDs = new List<Guid>(guardZones.Select(x => x.UID));
						break;
				}
			}
		}