Example #1
0
		/* RG-890 (Включение табличек "Не входи", "Уходи", и "Сирена", если МПТ включается без задержки на включение)*/
		public void TestMptBoardsOnWhenMptTurnOnWithoutDelay(GKStateBit mode, int delay)
		{
			var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_RM_1);
			var device2 = AddDevice(kauDevice11, GKDriverType.RSR2_RM_1);
			var device3 = AddDevice(kauDevice11, GKDriverType.RSR2_RM_1);
			var mpt = new GKMPT {Name = "МПТ", No = 1, Delay = delay};
			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { kauDevice11.UID }
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.DoNotEnterBoard, DeviceUID = device1.UID });
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.ExitBoard, DeviceUID = device2.UID });
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.Speaker, DeviceUID = device3.UID });
			GKManager.AddMPT(mpt);
			SetConfigAndRestartImitator();

			WaitWhileState(mpt, XStateClass.Off, 10000, "Ждем Норму в МПТ");
			Assert.IsTrue(mpt.State.StateClass == XStateClass.Off, "Проверка того, что МПТ Выключен");
			ConrtolGKBase(mpt, mode, "Включаем МПТ");
			WaitWhileState(mpt, XStateClass.On, 3000, "Ждем Включено в МПТ");
			Assert.IsTrue(mpt.State.StateClass == XStateClass.On, "Проверка того, что МПТ Включен");
			Assert.IsTrue(device1.State.StateClass == XStateClass.On, "Проверка того, что Табличка Не Входи Включена");
			Assert.IsTrue(device2.State.StateClass == XStateClass.On, "Проверка того, что Табличка Уходи Включена");
			Assert.IsTrue(device3.State.StateClass == XStateClass.On, "Проверка того, что Сирена Включена");
			CheckJournal(5, JournalItem(mpt, JournalEventNameType.Включено), JournalItem(device1, JournalEventNameType.Включено),
				JournalItem(device2, JournalEventNameType.Включено), JournalItem(device3, JournalEventNameType.Включено),
				JournalItem(Led("Устройство Включение ПУСК "), JournalEventNameType.Включено));
		}
Example #2
0
		public void ValidateEmptyMPTDevice()
		{
			var mpt = new GKMPT();
			GKManager.AddMPT(mpt);
			var errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Отсутствует логика включения"));
		}
Example #3
0
		public void ValidateEmptyMPTLogic()
		{
			var mpt = new GKMPT();
			GKManager.AddMPT(mpt);
			var errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К МПТ не подключены устройства"));
		}
Example #4
0
		public void TestControlDevice()
		{
			var device = AddDevice(kauDevice, GKDriverType.RSR2_RM_1);
			Test(device, GKDriverType.ControlDevicesMirror);

			var direction = new GKDirection();
			GKManager.AddDirection(direction);
			Test(direction, GKDriverType.ControlDevicesMirror);

			var delay = new GKDelay();
			GKManager.AddDelay(delay);
			Test(delay, GKDriverType.ControlDevicesMirror);

			var mpt = new GKMPT();
			GKManager.AddMPT(mpt);
			Test(mpt, GKDriverType.ControlDevicesMirror);
			var mptDevice = AddDevice(kauDevice, GKDriverType.RSR2_RM_1);
			mpt.MPTDevices.Add(new GKMPTDevice { Device = mptDevice, DeviceUID = mptDevice.UID, MPTDeviceType = GKMPTDeviceType.Speaker });
			Compile();
			CheckDeviceLogicOnGK(mptDevice);

			var pumpStation = new GKPumpStation();
			GKManager.AddPumpStation(pumpStation);
			Test(pumpStation, GKDriverType.ControlDevicesMirror);

			var nsDevice = AddDevice(kauDevice, GKDriverType.RSR2_Bush_Fire);
			GKManager.ChangePumpDevices(pumpStation, new List<GKDevice> { nsDevice });
			Compile();
			CheckDeviceLogicOnGK(nsDevice);
			Assert.IsNotNull(pumpStation.Pim);
			CheckObjectOnGK(pumpStation.Pim);
		}
Example #5
0
		/// <summary>
		/// Валидация того, что к МПТ подключены устройства
		/// </summary>
		/// <param name="mpt"></param>
		void ValidateMPTHasNoDevices(GKMPT mpt)
		{
			if (mpt.MPTDevices.Count == 0)
			{
				AddError(mpt, "К МПТ не подключены устройства", ValidationErrorLevel.CannotWrite);
			}
		}
Example #6
0
		public MPTDetailsViewModel(GKMPT mpt = null)
		{
			if (mpt == null)
			{
				Title = "Создание нового МПТ";

				MPT = new GKMPT()
				{
					Name = "Новый МПТ",
					No = 1,
				};
				if (GKManager.MPTs.Count != 0)
					MPT.No = (GKManager.MPTs.Select(x => x.No).Max() + 1);
			}
			else
			{
				Title = string.Format("Свойства МПТ: {0}", mpt.Name);
				MPT = mpt;
			}
			CopyProperties();
			var availableNames = new HashSet<string>();
			var availableDescription = new HashSet<string>();
			foreach (var existingMPTs in GKManager.MPTs)
			{
				availableNames.Add(existingMPTs.Name);
				availableDescription.Add(existingMPTs.Description);
			}
			AvailableNames = new ObservableCollection<string>(availableNames);
			AvailableDescription = new ObservableCollection<string>(availableDescription);
		}
Example #7
0
		public MPTModel(GKMPT mpt)
			: base(mpt)
		{
			No = mpt.No;
			GKDescriptorNo = mpt.GKDescriptorNo;
			Name = mpt.Name;
			ImageSource = mpt.ImageSource.Replace("/Controls;component/", "");
			OnClausesGroup = GKManager.GetPresentationLogic(mpt.MptLogic.OnClausesGroup);
			StopClausesGroup = GKManager.GetPresentationLogic(mpt.MptLogic.StopClausesGroup);
			OffClausesGroup = GKManager.GetPresentationLogic(mpt.MptLogic.OffClausesGroup);
			Delay = mpt.Delay;

			State = mpt.State.StateClass.ToDescription();
			StateIcon = mpt.State.StateClass.ToString();
			StateClasses = mpt.State.StateClasses.Select(x => new StateClass(x)).ToList();
			StateColor = "'#" + new XStateClassToColorConverter2().Convert(mpt.State.StateClass, null, null, null).ToString().Substring(3) + "'";

			HasOnDelay = mpt.State.StateClasses.Contains(XStateClass.TurningOn) && mpt.State.OnDelay > 0;
			OnDelay = mpt.State.OnDelay != 0 ?  mpt.State.OnDelay.ToString() : string.Empty;
			HasHoldDelay = mpt.State.StateClasses.Contains(XStateClass.On) && mpt.State.HoldDelay > 0;
			HoldDelay = mpt.State.HoldDelay != 0 ? mpt.State.HoldDelay.ToString() : string.Empty;
			var controlRegime = mpt.State.StateClasses.Contains(XStateClass.Ignore)
				? DeviceControlRegime.Ignore
				: !mpt.State.StateClasses.Contains(XStateClass.AutoOff) ? DeviceControlRegime.Automatic : DeviceControlRegime.Manual;
			//ControlRegimeIcon = "data:image/gif;base64," + InternalConverter.GetImageResource(((string)new DeviceControlRegimeToIconConverter().Convert(controlRegime)) ?? string.Empty).Item1;
			ControlRegimeName = controlRegime.ToDescription();
			ControlRegimeIcon = (new DeviceControlRegimeToIconConverter()).Convert(controlRegime);
			CanSetAutomaticState = (controlRegime != DeviceControlRegime.Automatic);
			CanSetManualState = (controlRegime != DeviceControlRegime.Manual);
			CanSetIgnoreState = (controlRegime != DeviceControlRegime.Ignore);
			IsControlRegime = (controlRegime == DeviceControlRegime.Manual);

		}
Example #8
0
		public MPTDescriptor(GKPim globalPim, GKMPT mpt)
			: base(mpt)
		{
			GlobalPim = globalPim;
			DescriptorType = DescriptorType.MPT;
			MPT = mpt;
			MPT.DelayRegime = DelayRegime.On;
		}
Example #9
0
		public void ValidateWrongMPTDevice()
		{
			var device = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1);
			var mpt = new GKMPT();
			GKManager.AddMPT(mpt);
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.Bomb, DeviceUID = device.UID });
			var errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "МПТ содержит устройство неверного типа"));
		}
Example #10
0
		public void ValidateEmptyMPTDeviceDevice()
		{
			var mpt = new GKMPT();
			var emptyMptDevice = (new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.Bomb });
            mpt.MPTDevices.Add(emptyMptDevice);
			GKManager.AddMPT(mpt);
			mpt.Invalidate(GKManager.DeviceConfiguration);
			Assert.IsTrue(mpt.MPTDevices.FirstOrDefault(x => x == emptyMptDevice) == null);
		}
Example #11
0
		public void ValidateMPTSameDevices()
		{
			var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1);
			var mpt = new GKMPT();
			GKManager.AddMPT(mpt);
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.HandStart, DeviceUID = device1.UID });
			mpt.MPTDevices.Add(new GKMPTDevice { MPTDeviceType = GKMPTDeviceType.HandStop, DeviceUID = device1.UID });
			var errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Дублируются устройства, входящие в МПТ"));
		}
Example #12
0
		public MPTSelectionViewModel(GKMPT mpt)
		{
			Title = "Выбор направления";
			MPTs = new ObservableCollection<MPTViewModel>();
			GKManager.MPTs.ForEach(x => MPTs.Add(new MPTViewModel(x)));
			if (mpt != null)
				SelectedMPT = MPTs.FirstOrDefault(x => x.MPT.UID == mpt.UID);
			if (SelectedMPT == null)
				SelectedMPT = MPTs.FirstOrDefault();
		}
Example #13
0
		/// <summary>
		/// Валидация того, что устройства МПТ содержат устройства
		/// </summary>
		/// <param name="mpt"></param>
		void ValidateMPTDeviceHasNoDevice(GKMPT mpt)
		{
			foreach (var mptDevice in mpt.MPTDevices)
			{
				if (mptDevice.Device == null)
				{
					AddError(mpt, "Не настроено устройство МПТ", ValidationErrorLevel.CannotWrite);
					AddError(mpt, "Не настроено устройство МПТ", ValidationErrorLevel.CannotSave);
				}
			}
		}
Example #14
0
		public MPTDetailsViewModel(GKMPT mpt)
		{
			MPT = mpt;
			Title = MPT.PresentationName;
			State.StateChanged += new Action(OnStateChanged);
			PlanLinks = new PlanLinksViewModel(MPT);

			ShowCommand = new RelayCommand(OnShow);
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			SetAutomaticStateCommand = new RelayCommand(OnSetAutomaticState, CanSetAutomaticState);
			SetManualStateCommand = new RelayCommand(OnSetManualState, CanSetManualState);
			SetIgnoreStateCommand = new RelayCommand(OnSetIgnoreState, CanSetIgnoreState);
			TurnOnCommand = new RelayCommand(OnTurnOn);
			TurnOnNowCommand = new RelayCommand(OnTurnOnNow);
			TurnOffCommand = new RelayCommand(OnTurnOff);
			ForbidStartCommand = new RelayCommand(OnForbidStart);
		}
Example #15
0
		/// <summary>
		/// Удаление МПТ
		/// </summary>
		/// <param name="mpt"></param>
		public static void RemoveMPT(GKMPT mpt)
		{
			MPTs.Remove(mpt);
			mpt.InputDependentElements.ForEach(x =>
			{
				x.OutputDependentElements.Remove(mpt);
			});

			mpt.OutputDependentElements.ForEach(x =>
			{
				x.InputDependentElements.Remove(mpt);
				x.UpdateLogic(DeviceConfiguration);
				x.OnChanged();
			});

			mpt.OnChanged();
		}
Example #16
0
		public void TestMPTOnGK()
		{
			var device1 = AddDevice(kauDevice2, GKDriverType.RSR2_HandDetector);
			var device2 = AddDevice(kauDevice1, GKDriverType.RSR2_RM_1);
			var mpt = new GKMPT();
			var clause = new GKClause()
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { device1.UID }
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);
			mpt.MPTDevices.Add(new GKMPTDevice() { MPTDeviceType = GKMPTDeviceType.Bomb, DeviceUID = device2.UID });
			GKManager.MPTs.Add(mpt);
			Compile();

			CheckObjectLogicOnGK(mpt);
			CheckDeviceLogicOnGK(device2);
		}
Example #17
0
		public MPTViewModel(GKMPT mpt)
		{
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowOnPlanOrPropertiesCommand = new RelayCommand(OnShowOnPlanOrProperties);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);

			MPT = mpt;
			MPTDetailsViewModel = new MPTDetailsViewModel(MPT);
			State.StateChanged -= OnStateChanged;
			State.StateChanged += OnStateChanged;
			OnStateChanged();

			MPTDevices = new ObservableCollection<MPTDeviceViewModel>();
			foreach (var mptDevice in MPT.MPTDevices)
			{
				var deviceViewModel = DevicesViewModel.Current.AllDevices.FirstOrDefault(x => x.Device.UID == mptDevice.DeviceUID);
				MPTDevices.Add(new MPTDeviceViewModel(deviceViewModel, mptDevice.MPTDeviceType));
			}
		}
Example #18
0
		public void TestMPTWithCodesOnKau()
		{
			var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_HandDetector);
			var device2 = AddDevice(kauDevice1, GKDriverType.RSR2_CodeReader);
			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			var mpt = new GKMPT();
			var clause = new GKClause()
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { device1.UID }
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);
			mpt.MPTDevices.Add(new GKMPTDevice() { MPTDeviceType = GKMPTDeviceType.HandStart, DeviceUID = device2.UID, CodeReaderSettings = new GKCodeReaderSettings() { MPTSettings = new GKCodeReaderSettingsPart() { CodeUIDs = {code.UID}} } });
			GKManager.MPTs.Add(mpt);
			Compile();

			CheckObjectLogicOnKau(mpt);
			Assert.IsNotNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
		}
Example #19
0
		public MPTViewModel(GKMPT mpt)
		{
			MPT = mpt;
			ChangeStartLogicCommand = new RelayCommand(OnChangeStartLogic);
			ChangeStopLogicCommand = new RelayCommand(OnChangeStopLogic);
			ChangeSuspendLogicCommand = new RelayCommand(OnChangeSuspendLogic);
			AddCommand = new RelayCommand(OnAdd);
			EditCommand = new RelayCommand(OnEdit, () => SelectedDevice != null);
			DeleteCommand = new RelayCommand(OnDelete, () => SelectedDevice != null);
			EditPropertiesCommand = new RelayCommand(OnEditProperties, CanEditProperties);

			MPT.Changed += Update;
			MPT.PlanElementUIDsChanged += UpdateVisualizationState;
			Devices = new ObservableCollection<MPTDeviceViewModel>();
			foreach (var mptDevice in MPT.MPTDevices)
			{
				var deviceViewModel = new MPTDeviceViewModel(mptDevice);
				Devices.Add(deviceViewModel);
			}
			Update();
		}
Example #20
0
		public void AddMptDeviceTest()
		{
			var mpt = new GKMPT();
			var am1Device = CreateDevice(GKDriverType.RSR2_AM_1);
			GKManager.DeviceConfiguration.MPTs.Add(mpt);
			CreateGroupControllerModule();
			var mptViewModel = GroupControllerModule.MPTsViewModel.MPTs[0];
			MockDialogService.OnShowModal += x =>
			{
				var mptDeviceSelectationViewModel = x as MPTDeviceSelectationViewModel;
				mptDeviceSelectationViewModel.SelectedMPTDeviceType =
					mptDeviceSelectationViewModel.AvailableMPTDeviceTypes.FirstOrDefault(type => type.MPTDeviceType == GKMPTDeviceType.HandStart);
				mptDeviceSelectationViewModel.SelectedDevice =
					mptDeviceSelectationViewModel.Devices.FirstOrDefault(device => device.UID == am1Device.UID);
				mptDeviceSelectationViewModel.SaveCommand.Execute();
			};
			mptViewModel.AddCommand.Execute();
			Assert.IsTrue(mpt.MPTDevices.Any(x => x.Device == am1Device && x.MPTDeviceType == GKMPTDeviceType.HandStart));
			Assert.IsTrue(am1Device.IsInMPT);
			Assert.IsTrue(mpt.InputDependentElements.Count == 1 && mpt.InputDependentElements[0] == am1Device);
			Assert.IsTrue(am1Device.OutputDependentElements.Count == 1 && am1Device.OutputDependentElements[0] == mpt);
		}
Example #21
0
		public MPTCreator(GKMPT mpt)
		{
			MPT = mpt;

			foreach (var mptDevice in MPT.MPTDevices.Where(x => x.Device != null))
			{
				if (mptDevice.MPTDeviceType == GKMPTDeviceType.HandStart ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.HandStop ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.HandAutomaticOn ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.HandAutomaticOff)
				{
					MPT.LinkToDescriptor(mptDevice.Device);
				}

				if (mptDevice.MPTDeviceType == GKMPTDeviceType.AutomaticOffBoard ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.DoNotEnterBoard ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.ExitBoard ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.Speaker ||
					mptDevice.MPTDeviceType == GKMPTDeviceType.Bomb)
				{
					mptDevice.Device.LinkToDescriptor(MPT);
				}
			}
		}
		public void RemoveDeviceTestLogicForMptNsDoor()
		{
			var device = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1);
			var device2 = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1);
			GKManager.UpdateConfiguration();

			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				DeviceUIDs = { device.UID }
			};

			var gkLogic = new GKLogic();
			gkLogic.OnClausesGroup.Clauses.Add(clause);

			var mpt = new GKMPT();
			var gkMptDevice = new GKMPTDevice { Device = device, DeviceUID = device.UID };
			GKManager.AddMPT(mpt);
			GKManager.SetMPTLogic(mpt, gkLogic);
			mpt.MPTDevices.Add(gkMptDevice);
			Assert.IsTrue(mpt.MptLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsTrue(mpt.MPTDevices.Any(x => x.DeviceUID == device.UID));
			Assert.IsTrue(mpt.InputDependentElements.Contains(device));
			Assert.IsTrue(device.OutputDependentElements.Contains(mpt));

			var pump = new GKPumpStation();
			GKManager.AddPumpStation(pump);
			GKManager.SetPumpStationStartLogic(pump, gkLogic);
			GKManager.ChangePumpDevices(pump, new List<GKDevice>() {device});
			Assert.IsTrue(pump.StartLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsTrue(pump.NSDevices.Contains(device));
			Assert.IsTrue(pump.InputDependentElements.Contains(device));
			Assert.IsTrue(device.OutputDependentElements.Contains(pump));

			var door = new GKDoor();
			GKManager.AddDoor(door);
			GKManager.SetDoorOpenRegimeLogic(door, gkLogic);
			GKManager.SetDoorCloseRegimeLogic(door, gkLogic);
			GKManager.ChangeEnterButtonDevice(door, device);
			Assert.IsTrue(door.EnterButton == device);
			Assert.IsTrue(door.EnterButtonUID == device.UID);
			Assert.IsTrue(device.Door == door);
			Assert.IsTrue(device.OutputDependentElements.Contains(door));
			Assert.IsTrue(door.InputDependentElements.Contains(device));
			door.EnterButton = null;
			door.EnterButtonUID = Guid.Empty;

			GKManager.ChangeExitButtonDevice(door, device);
			Assert.IsTrue(door.ExitButton == device);
			Assert.IsTrue(door.ExitButtonUID == device.UID);
			Assert.IsTrue(device.Door == door);
			door.ExitButton = null;
			door.ExitButtonUID = Guid.Empty;

			GKManager.ChangeLockControlDevice(door, device);
			Assert.IsTrue(door.LockControlDevice == device);
			Assert.IsTrue(door.LockControlDeviceUID == device.UID);
			Assert.IsTrue(device.Door == door);
			door.LockDevice = null;
			door.LockControlDeviceUID = Guid.Empty;

			GKManager.ChangeLockControlDeviceExit(door, device);
			Assert.IsTrue(door.LockControlDeviceExitUID == device.UID);
			Assert.IsTrue(door.LockControlDeviceExit == device);
			Assert.IsTrue(device.Door == door);
			door.LockDeviceExit = null;
			door.LockControlDeviceExitUID = Guid.Empty;

			GKManager.ChangeLockDevice(door, device);
			Assert.IsTrue(door.LockDevice == device);
			Assert.IsTrue(door.LockDeviceUID == device.UID);
			Assert.IsTrue(device.Door == door);
			door.LockDeviceUID = Guid.Empty;
			door.LockDevice = null;

			GKManager.ChangeLockDeviceExit(door, device);
			Assert.IsTrue(door.LockDeviceExit == device);
			Assert.IsTrue(door.LockDeviceExitUID == device.UID);
			Assert.IsTrue(device.Door == door);
			Assert.IsTrue(door.OpenRegimeLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains( device.UID)));
			Assert.IsTrue(door.CloseRegimeLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));

			GKManager.RemoveDevice(device);
			Assert.IsFalse(mpt.MptLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsFalse(mpt.InputDependentElements.Any(x => x.UID ==  device.UID));
			Assert.IsFalse(pump.StartLogic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsFalse(pump.InputDependentElements.Any(x => x.UID == device.UID));
			Assert.IsFalse(mpt.MPTDevices.Any(x => x.DeviceUID == device.UID));
			Assert.IsFalse(pump.NSDevices.Contains(device));
			Assert.IsFalse(door.InputDependentElements.Any(x => x.UID == device.UID));
		}
Example #23
0
		public void RemoveMptTest()
		{
			MockMessageBoxService.ShowConfirmationResult = true;
			var mpt = new GKMPT();
			var am1Device = CreateDevice(GKDriverType.RSR2_AM_1);
			var mptDevice = new GKMPTDevice { Device = am1Device, DeviceUID = am1Device.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			mpt.MPTDevices.Add(mptDevice);
			GKManager.DeviceConfiguration.MPTs.Add(mpt);
			CreateGroupControllerModule();
			Assert.IsTrue(mpt.MPTDevices.Any(x => x.Device == am1Device && x.MPTDeviceType == GKMPTDeviceType.HandStart));
			Assert.IsTrue(am1Device.IsInMPT);
			Assert.IsTrue(mpt.InputDependentElements.Count == 1);
			Assert.IsTrue(am1Device.OutputDependentElements.Count == 1);
			var mptsViewModel = GroupControllerModule.MPTsViewModel;
			mptsViewModel.SelectedMPT = mptsViewModel.MPTs.FirstOrDefault(x => x.MPT == mpt);
			mptsViewModel.DeleteCommand.Execute();

			Assert.IsTrue(GKManager.DeviceConfiguration.MPTs.Count == 0);
			Assert.IsFalse(am1Device.IsInMPT);
			Assert.IsTrue(am1Device.OutputDependentElements.Count == 0);
		}
Example #24
0
		public MPTViewModel(GKMPT mpt)
		{
			MPT = mpt;
		}
Example #25
0
		public void TestMPTInMultiGk()
		{
			var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_GuardDetector);
			var device2 = AddDevice(kauDevice21, GKDriverType.RSR2_GuardDetector);
			var mpt = new GKMPT();
			GKManager.MPTs.Add(mpt);
			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = {device1.UID, device2.UID}
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);
			var validator = new Validator();
			var errors = validator.Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Содержится в нескольких ГК"));

			mpt.MptLogic = new GKLogic();
			clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { device1.UID }
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);

			foreach (var deviceType in  new List<GKMPTDeviceType>(Enum.GetValues(typeof(GKMPTDeviceType)).Cast<GKMPTDeviceType>()))
			{
				mpt.MPTDevices = new List<GKMPTDevice>();
				var mptDevice = new GKMPTDevice { Device = device2, DeviceUID = device2.UID, MPTDeviceType = deviceType };
				mpt.MPTDevices.Add(mptDevice);
				validator = new Validator();
				errors = validator.Validate();
				Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Содержится в нескольких ГК"));
			}

		}
Example #26
0
		public void DeleteMptDeviceTest()
		{
			var mpt = new GKMPT();
			var am1Device = CreateDevice(GKDriverType.RSR2_AM_1);
			var mptDevice = new GKMPTDevice { Device = am1Device, DeviceUID = am1Device.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			mpt.MPTDevices.Add(mptDevice);
			GKManager.DeviceConfiguration.MPTs.Add(mpt);
			CreateGroupControllerModule();
			var mptViewModel = GroupControllerModule.MPTsViewModel.MPTs[0];
			Assert.IsTrue(mpt.MPTDevices.Any(x => x.Device == am1Device && x.MPTDeviceType == GKMPTDeviceType.HandStart));
			Assert.IsTrue(am1Device.IsInMPT);
			Assert.IsTrue(mpt.InputDependentElements.Count == 1);
			Assert.IsTrue(am1Device.OutputDependentElements.Count == 1);

			mptViewModel.DeleteCommand.Execute();
			Assert.IsFalse(mpt.MPTDevices.Any(x => x.Device == am1Device && x.MPTDeviceType == GKMPTDeviceType.HandStart));
			Assert.IsFalse(am1Device.IsInMPT);
			Assert.IsTrue(mpt.InputDependentElements.Count == 0);
			Assert.IsTrue(am1Device.OutputDependentElements.Count == 0);
		}
Example #27
0
		public void EditMptDeviceFewMptsTest()
		{
			var am1Device1 = CreateDevice(GKDriverType.RSR2_AM_1);
			var am1Device2 = CreateDevice(GKDriverType.RSR2_AM_1);
			var am1Device3 = CreateDevice(GKDriverType.RSR2_AM_1);
			var mpt1 = new GKMPT();
			var mpt2 = new GKMPT();
			var mptDevice1 = new GKMPTDevice { Device = am1Device1, DeviceUID = am1Device1.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			var mptDevice2 = new GKMPTDevice { Device = am1Device2, DeviceUID = am1Device2.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			mpt1.MPTDevices.Add(mptDevice1);
			mpt2.MPTDevices.Add(mptDevice2);
			GKManager.DeviceConfiguration.MPTs.Add(mpt1);
			GKManager.DeviceConfiguration.MPTs.Add(mpt2);
			CreateGroupControllerModule();
			var mptViewModel1 = GroupControllerModule.MPTsViewModel.MPTs[0];
			var mptViewModel2 = GroupControllerModule.MPTsViewModel.MPTs[1];
			MockDialogService.OnShowModal += x =>
			{
				var mptDeviceSelectationViewModel = x as MPTDeviceSelectationViewModel;
				mptDeviceSelectationViewModel.SelectedMPTDeviceType =
					mptDeviceSelectationViewModel.AvailableMPTDeviceTypes.FirstOrDefault(type => type.MPTDeviceType == GKMPTDeviceType.HandStart);
				Assert.IsTrue(mptDeviceSelectationViewModel.Devices.Count == 2
					&& mptDeviceSelectationViewModel.Devices[0] == am1Device1
					&& mptDeviceSelectationViewModel.Devices[1] == am1Device3);
				Assert.IsTrue(mptViewModel1.Devices.Count == 1 && mptViewModel1.Devices[0].MPTDevice.Device.DriverType == GKDriverType.RSR2_AM_1);
			};
			mptViewModel1.EditCommand.Execute();
		}
Example #28
0
		public void ChangeDriverDeviceTest()
		{
			var mpt = new GKMPT();
			var am1Device = CreateDevice(GKDriverType.RSR2_AM_1);
			var mptDevice = new GKMPTDevice { Device = am1Device, DeviceUID = am1Device.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			mpt.MPTDevices.Add(mptDevice);
			GKManager.DeviceConfiguration.MPTs.Add(mpt);
			CreateGroupControllerModule();
			ClientManager.PlansConfiguration = new RubezhAPI.Models.PlansConfiguration();
			var devicesViewModel = new DevicesViewModel();
			devicesViewModel.Initialize();
			var deviceViewModel = devicesViewModel.AllDevices.FirstOrDefault(x => x.Device == am1Device);
			var mptViewModel = GroupControllerModule.MPTsViewModel.MPTs[0];
			Assert.IsTrue(mpt.MPTDevices.Count == 1);
			Assert.IsTrue(mpt.InputDependentElements.Count == 1 && mpt.InputDependentElements[0] == am1Device);
			Assert.IsTrue(mptViewModel.Devices.Count == 1 && mptViewModel.Devices[0].MPTDevice.Device.DriverType == GKDriverType.RSR2_AM_1);

			var cardReaderDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_CardReader);
			deviceViewModel.Driver = cardReaderDriver;
			Assert.IsTrue(mpt.MPTDevices.Count == 0);
			Assert.IsTrue(mpt.InputDependentElements.Count == 0);
			Assert.IsTrue(mptViewModel.Devices.Count == 1);
			GroupControllerModule.MPTsViewModel.OnShow();
			Assert.IsTrue(mptViewModel.Devices.Count == 0);
		}
Example #29
0
		public ObjectViewModel(GKMPT mpt)
		{
			MPT = mpt;
			Name = mpt.PresentationName;
			ImageSource = "/Controls;component/Images/BMPT.png";
			Address = "";
			PresentationZoneOrLogic = "";
			ObjectType = ObjectType.MPT;
			SortingName = "e " + mpt.No;
		}
Example #30
0
		public void RemoveDeviceTest()
		{
			var mpt = new GKMPT();
			var am1Device = CreateDevice(GKDriverType.RSR2_AM_1);
			var mptDevice = new GKMPTDevice { Device = am1Device, DeviceUID = am1Device.UID, MPTDeviceType = GKMPTDeviceType.HandStart };
			mpt.MPTDevices.Add(mptDevice);
			GKManager.DeviceConfiguration.MPTs.Add(mpt);
			CreateGroupControllerModule();
			var devicesViewModel = GroupControllerModule.DevicesViewModel;
			var deviceViewModel = devicesViewModel.AllDevices.FirstOrDefault(x => x.Device == am1Device);
			var mptViewModel = GroupControllerModule.MPTsViewModel.MPTs[0];
			Assert.IsTrue(mpt.MPTDevices.Count == 1);
			Assert.IsTrue(mpt.InputDependentElements.Count == 1 && mpt.InputDependentElements[0] == am1Device);
			Assert.IsTrue(mptViewModel.Devices.Count == 1 && mptViewModel.Devices[0].MPTDevice == mptDevice);

			deviceViewModel.RemoveCommand.Execute();
			Assert.IsTrue(mpt.MPTDevices.Count == 0);
			Assert.IsTrue(mpt.InputDependentElements.Count == 0);
			Assert.IsTrue(mptViewModel.Devices.Count == 1);
			GroupControllerModule.MPTsViewModel.OnShow();
			Assert.IsTrue(mptViewModel.Devices.Count == 0);
		}