コード例 #1
0
		public ObjectsListViewModel (XDevice device, XDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.Update();
			Objects = new List<ObjectViewModel>();

			foreach (var childDevice in deviceConfiguration.Devices)
			{
				var objectViewModel = new ObjectViewModel(childDevice);
				var parent = childDevice.AllParents.FirstOrDefault(x => x.ShortName == device.ShortName && x.Address == device.Address);
				if (parent != null && childDevice.IsRealDevice)
					Objects.Add(objectViewModel);
			}
			if (deviceConfiguration.Zones != null)
				foreach (var zone in deviceConfiguration.Zones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(zone);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Directions != null)
				foreach (var direction in deviceConfiguration.Directions.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(direction) { ObjectType = ObjectType.Direction };
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.PumpStations != null)
				foreach (var pumpStation in deviceConfiguration.PumpStations.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(pumpStation) { ObjectType = ObjectType.PumpStation };
					Objects.Add(objectViewModel);
				}
		}
コード例 #2
0
		string GetPumpStationsDifferences(ObjectViewModel object1, ObjectViewModel object2, bool isLocalConfig)
		{
            var pumpStationsDifferences = new StringBuilder();
			if (object1.Name != object2.Name)
                pumpStationsDifferences.Append("Не совпадает название");
			if (object1.PumpStation.NSDevices.Any(nsDevice => object2.PumpStation.NSDevices.All(x => new ObjectViewModel(x).Compare(new ObjectViewModel(x), new ObjectViewModel(nsDevice)) != 0)))
            {
                if (pumpStationsDifferences.Length != 0)
                    pumpStationsDifferences.Append(". ");
			    pumpStationsDifferences.Append("Не совпадает количество насосов");
            }
            bool startDiff = XManager.GetPresentationZone(object1.PumpStation.StartLogic) != XManager.GetPresentationZone(object2.PumpStation.StartLogic);
            bool stopDiff = XManager.GetPresentationZone(object1.PumpStation.StopLogic) != XManager.GetPresentationZone(object2.PumpStation.StopLogic);
            bool automaticDiff = XManager.GetPresentationZone(object1.PumpStation.AutomaticOffLogic) != XManager.GetPresentationZone(object2.PumpStation.AutomaticOffLogic);
		    if (startDiff || stopDiff || automaticDiff)
		    {
		        if (pumpStationsDifferences.Length != 0)
		            pumpStationsDifferences.Append(". ");
		        pumpStationsDifferences.Append("Не совпадают следующие условия: ");
                var logics = new List<string>();
                if(startDiff)
                    logics.Add("Запуска");
                if(stopDiff)
                    logics.Add("Запрета пуска");
                if(automaticDiff)
                    logics.Add("Отключения");
		        pumpStationsDifferences.Append(String.Join(", ", logics));
		    }
		    bool delayDiff = object1.PumpStation.Delay != object2.PumpStation.Delay;
		    bool holdDiff = object1.PumpStation.Hold != object2.PumpStation.Hold;
		    bool nsPumpsCountDiff = object1.PumpStation.NSPumpsCount != object2.PumpStation.NSPumpsCount;
		    bool nsDeltaTimeDiff = object1.PumpStation.NSDeltaTime != object2.PumpStation.NSDeltaTime;
		    if (delayDiff || holdDiff || nsPumpsCountDiff || nsDeltaTimeDiff)
		    {
                if (pumpStationsDifferences.Length != 0)
                    pumpStationsDifferences.Append(". ");
		        pumpStationsDifferences.Append("Не совпадают следующие параметры: ");
                var parameters = new List<string>();
                if (delayDiff)
                    parameters.Add("Задержка");
                if (holdDiff)
                    parameters.Add("Время тушения");
                if (nsPumpsCountDiff)
                    parameters.Add("Количество основных насосов");
                if (nsDeltaTimeDiff)
                    parameters.Add("Интервал разновременного пуска");
                pumpStationsDifferences.Append(String.Join(", ", parameters));
		    }
		    return pumpStationsDifferences.ToString() == "" ? null : pumpStationsDifferences.ToString();
		}
コード例 #3
0
		string GetDirectionsDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var directionsDifferences = new StringBuilder();
			if (object1.Name != object2.Name)
                directionsDifferences.Append("Не совпадает название");
            bool delayDiff = object1.Direction.Delay != object2.Direction.Delay;
            bool holdDiff = object1.Direction.Hold != object2.Direction.Hold;
            bool regimeDiff = object1.Direction.DelayRegime != object2.Direction.DelayRegime;
		    if (delayDiff || holdDiff || regimeDiff)
		    {
                if (directionsDifferences.Length != 0)
                    directionsDifferences.Append(". ");
                directionsDifferences.Append("Не совпадают следующие параметры: ");
		        var parameters = new List<string>();
                if(delayDiff)
                    parameters.Add("Задержка");
                if (holdDiff)
                    parameters.Add("Удержание");
                if (regimeDiff)
                    parameters.Add("Режим работы");
		        directionsDifferences.Append(String.Join(", ", parameters));
		    }
		    return directionsDifferences.ToString() == "" ? null : directionsDifferences.ToString();
		}
コード例 #4
0
		string GetZonesDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
            var zonesDifferences = new StringBuilder();
			if (object1.Name != object2.Name)
                zonesDifferences.Append("Не совпадает название");
		    var fire1CountDiff = object1.Zone.Fire1Count != object2.Zone.Fire1Count;
            var fire2CountDiff = object1.Zone.Fire2Count != object2.Zone.Fire2Count;
		    if (fire1CountDiff || fire2CountDiff)
		    {
                if (zonesDifferences.Length != 0)
                    zonesDifferences.Append(". ");
                zonesDifferences.Append("Не совпадает число датчиков для формирования: ");
                var fires = new List<string>();
                if (fire1CountDiff)
                    fires.Add("Пожар1");
                if (fire2CountDiff)
                    fires.Add("Пожар2");
                zonesDifferences.Append(String.Join(", ", fires));
		    }
			return zonesDifferences.ToString() == "" ? null : zonesDifferences.ToString();
		}
コード例 #5
0
		bool IsEqual(ObjectViewModel viewModel1, ObjectViewModel viewModel2)
		{
			if (viewModel1.ObjectType != viewModel2.ObjectType)
				return false;

			if (viewModel1.ObjectType == ObjectType.Device)
			{
				return IsEqualDevice(viewModel1.Device, viewModel2.Device);
			}

			if (viewModel1.ObjectType == ObjectType.Zone)
				return viewModel1.Zone.No == viewModel2.Zone.No;

			if (viewModel1.ObjectType == ObjectType.Direction)
				return viewModel1.Direction.No == viewModel2.Direction.No;

			if (viewModel1.ObjectType == ObjectType.PumpStation)
				return viewModel1.PumpStation.No == viewModel2.PumpStation.No;

			if (viewModel1.ObjectType == ObjectType.MPT)
				return viewModel1.MPT.No == viewModel2.MPT.No;

			if (viewModel1.ObjectType == ObjectType.Delay)
				return viewModel1.Delay.No == viewModel2.Delay.No;

			if (viewModel1.ObjectType == ObjectType.GuardZone)
				return viewModel1.GuardZone.No == viewModel2.GuardZone.No;

			if (viewModel1.ObjectType == ObjectType.Code)
				return viewModel1.Code.No == viewModel2.Code.No;

			if (viewModel1.ObjectType == ObjectType.Door)
				return viewModel1.Door.No == viewModel2.Door.No;

			if (viewModel1.ObjectType == ObjectType.SKDZone)
				return viewModel1.SKDZone.No == viewModel2.SKDZone.No;

			return true;
		}
コード例 #6
0
		public ObjectsListViewModel (GKDevice device, GKDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.Update();
			deviceConfiguration.UpdateConfiguration();
			deviceConfiguration.PrepareDescriptors();
			Objects = new List<ObjectViewModel>();

			foreach (var childDevice in deviceConfiguration.Devices)
			{
				var objectViewModel = new ObjectViewModel(childDevice);
				var parent = childDevice.AllParents.FirstOrDefault(x => x.ShortName == device.ShortName && x.Address == device.Address);
				if (parent != null && childDevice.IsRealDevice)
					Objects.Add(objectViewModel);
			}
			if (deviceConfiguration.Zones != null)
				foreach (var zone in deviceConfiguration.Zones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(zone);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Directions != null)
				foreach (var direction in deviceConfiguration.Directions.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(direction);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.PumpStations != null)
				foreach (var pumpStation in deviceConfiguration.PumpStations.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(pumpStation);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.MPTs != null)
				foreach (var mpt in deviceConfiguration.MPTs.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(mpt);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Delays != null)
				foreach (var delay in deviceConfiguration.Delays.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(delay);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.GuardZones != null)
				foreach (var guardZone in deviceConfiguration.GuardZones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(guardZone);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Codes != null)
				foreach (var code in deviceConfiguration.Codes.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(code);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Doors != null)
				foreach (var door in deviceConfiguration.Doors.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(door);
					Objects.Add(objectViewModel);
				}
		}
コード例 #7
0
		string GetDoorsDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var differences = new List<string>();
			if (object1.Name != object2.Name)
				differences.Add("Не совпадает название");
			if (object1.Door.DoorType != object2.Door.DoorType)
			{
				differences.Add("Не совпадает тип");
			}

			if (!IsEqualDevice(object1.Door.EnterDevice, object2.Door.EnterDevice) || !IsEqualDevice(object1.Door.ExitDevice, object2.Door.ExitDevice)
				|| !IsEqualDevice(object1.Door.LockDevice, object2.Door.LockDevice) || !IsEqualDevice(object1.Door.LockDeviceExit, object2.Door.LockDeviceExit)
				|| !IsEqualDevice(object1.Door.LockControlDevice, object2.Door.LockControlDevice) || !IsEqualDevice(object1.Door.LockControlDeviceExit, object2.Door.LockControlDeviceExit))
			{
				differences.Add("Не совпадают устройства");
			}
			if (object1.Door.Delay != object2.Door.Delay)
			{
				differences.Add("Не совпадает задержка");
			}
			if (object1.Door.Hold != object2.Door.Hold)
			{
				differences.Add("Не совпадает удержание");
			}
			if (object1.Door.EnterZoneUID != object2.Door.EnterZoneUID)
			{
				differences.Add("Не совпадает зона входа");
			}
			if (object1.Door.ExitZoneUID != object2.Door.ExitZoneUID)
			{
				differences.Add("Не совпадает зона выхода");
			}
			bool openLogicDiff = GKManager.GetPresentationLogic(object1.Door.OpenRegimeLogic) != GKManager.GetPresentationLogic(object2.Door.OpenRegimeLogic);
			if (openLogicDiff)
			{
				differences.Add("Не совпадают условия перевода в режим Всегда Включено");
			}
			return string.Join(". ", differences);
		}
コード例 #8
0
		string GetCodesDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var differences = new List<string>();
			if (object1.Name != object2.Name)
				differences.Add("Не совпадает название");
			if (object1.Code.Password != object2.Code.Password)
			{
				differences.Add("Не совпадает пароль");
			}
			return string.Join(". ", differences);
		}
コード例 #9
0
		string GetGuardZonesDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var guardZonesDifferences = new StringBuilder();
			if (object1.Name != object2.Name)
				guardZonesDifferences.Append("Не совпадает название");
			if (object1.GuardZone.SetDelay != object2.GuardZone.SetDelay)
			{
				if (guardZonesDifferences.Length != 0)
					guardZonesDifferences.Append(". ");
				guardZonesDifferences.Append("Не совпадает задержка");
			}
			return guardZonesDifferences.ToString() == "" ? null : guardZonesDifferences.ToString();
		}
コード例 #10
0
		string GetDelaysDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var delaysDifferences = new StringBuilder();
			if (object1.Name != object2.Name)
				delaysDifferences.Append("Не совпадает название");
			bool delayDiff = object1.Delay.DelayTime != object2.Delay.DelayTime;
			bool holdDiff = object1.Delay.Hold != object2.Delay.Hold;
			bool regimeDiff = object1.Delay.DelayRegime != object2.Delay.DelayRegime;
			bool logicDiff = GKManager.GetPresentationLogic(object1.Delay.Logic) != GKManager.GetPresentationLogic(object2.Delay.Logic);
			if (delayDiff || holdDiff || regimeDiff || logicDiff)
			{
				if (delaysDifferences.Length != 0)
					delaysDifferences.Append(". ");
				delaysDifferences.Append("Не совпадают следующие параметры: ");
				var parameters = new List<string>();
				if (delayDiff)
					parameters.Add("Задержка");
				if (holdDiff)
					parameters.Add("Удержание");
				if (regimeDiff)
					parameters.Add("Режим работы");
				if (logicDiff)
					parameters.Add("Логика");
				delaysDifferences.Append(String.Join(", ", parameters));
			}
			return delaysDifferences.ToString() == "" ? null : delaysDifferences.ToString();
		}
コード例 #11
0
		string GetMPTsDifferences(ObjectViewModel object1, ObjectViewModel object2)
		{
			var mptsDifferences = new List<string>();
			if (object1.Name != object2.Name)
				mptsDifferences.Add("Не совпадает название");
			var devices1 = object1.MPT.MPTDevices.Select(x => x.Device);
			var devices2 = object2.MPT.MPTDevices.Select(x => x.Device);
			if (devices1.Any(nsDevice1 => devices2.All(nsDevice2 => !IsEqualDevice(nsDevice1, nsDevice2)))
				|| devices1.Count() < devices2.Count())
			{
				mptsDifferences.Add("Не совпадают устройства");
			}
			bool startDiff = GKManager.GetPresentationLogic(object1.MPT.MptLogic.OnClausesGroup) != GKManager.GetPresentationLogic(object2.MPT.MptLogic.OnClausesGroup);
			if (startDiff)
			{
				mptsDifferences.Add("Не совпадают условия включения");
			}
			bool stopDiff = GKManager.GetPresentationLogic(object1.MPT.MptLogic.OffClausesGroup) != GKManager.GetPresentationLogic(object2.MPT.MptLogic.OffClausesGroup);
			if (stopDiff)
			{
				mptsDifferences.Add("Не совпадают условия выключения");
			}
			bool suspendDiff = GKManager.GetPresentationLogic(object1.MPT.MptLogic.StopClausesGroup) != GKManager.GetPresentationLogic(object2.MPT.MptLogic.StopClausesGroup);
			if (suspendDiff)
			{
				mptsDifferences.Add("Не совпадают условия приостановки");
			}
			bool delayDiff = object1.MPT.Delay != object2.MPT.Delay;
			if (delayDiff)
			{
				mptsDifferences.Add("Не совпадают задержки");
			}
			return String.Join(". ", mptsDifferences);
		}