Esempio n. 1
0
		public Delay(GKDelay gkDelay)
			: base(gkDelay)
		{
			Number = gkDelay.No;
			Name = gkDelay.Name;
			PresentationLogic = GKManager.GetPresentationLogic(gkDelay.Logic);
			OnDelay = gkDelay.State.OnDelay != 0 ? gkDelay.State.OnDelay.ToString() : string.Empty;
			HoldDelay = gkDelay.State.HoldDelay != 0 ? gkDelay.State.HoldDelay.ToString() : string.Empty;
			StateIcon = gkDelay.State.StateClass.ToString();
			StateColor = "'#" + new XStateClassToColorConverter2().Convert(gkDelay.State.StateClass, null, null, null).ToString().Substring(3) + "'";
			StateClasses = gkDelay.State.StateClasses.Select(x => new StateClass(x)).ToList();
			HasOnDelay = gkDelay.State.StateClasses.Contains(XStateClass.TurningOn) && gkDelay.State.OnDelay > 0;
			HasHoldDelay = gkDelay.State.StateClasses.Contains(XStateClass.On) && gkDelay.State.HoldDelay > 0;
			var controlRegime = gkDelay.State.StateClasses.Contains(XStateClass.Ignore)
				? DeviceControlRegime.Ignore
				: !gkDelay.State.StateClasses.Contains(XStateClass.AutoOff) ? DeviceControlRegime.Automatic : DeviceControlRegime.Manual;
			ControlRegimeName = controlRegime.ToDescription();
			ControlRegimeIcon = (new DeviceControlRegimeToIconConverter()).Convert(controlRegime);
			CanSetAutomaticState = (controlRegime != DeviceControlRegime.Automatic);
			CanSetManualState = (controlRegime != DeviceControlRegime.Manual);
			CanSetIgnoreState = (controlRegime != DeviceControlRegime.Ignore);
			IsControlRegime = controlRegime == DeviceControlRegime.Manual;
			DelayRegimeName = gkDelay.DelayRegime.ToDescription();
			GkDescriptorNo = gkDelay.GKDescriptorNo;
			DelayTime = gkDelay.DelayTime;
			HoldTime = gkDelay.Hold;
		}
Esempio n. 2
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);
		}
Esempio n. 3
0
		void CreateDelays()
		{
			for (int i = 1; i < FirePumpDevices.Count; i++)
			{
				var pumpDevice = FirePumpDevices[i];
				var delay = new GKDelay()
				{
					Name = "Задержка пуска ШУН " + pumpDevice.DottedAddress,
					DelayTime = (ushort)PumpStation.NSDeltaTime,
					Hold = 2,
					DelayRegime = DelayRegime.Off,
					IsAutoGenerated = true,
					PumpStationUID = PumpStation.UID
				};
				delay.UID = Guid.NewGuid(); //GuidHelper.CreateOn(pumpDevice.UID, 0);

				var pumpDelay = new PumpDelay
				{
					Delay = delay,
					Device = pumpDevice
				};
				PumpDelays.Add(pumpDelay);

				var delayDescriptor = new DelayDescriptor(delay);
				Database.Descriptors.Add(delayDescriptor);
			}
		}
Esempio n. 4
0
		public DelayViewModel(GKDelay delay)
		{
			ShowLogicCommand = new RelayCommand(OnShowLogic);
			Delay = delay;
			Delay.Changed += Update;
			Delay.PlanElementUIDsChanged += UpdateVisualizationState;
			Update();
		}
Esempio n. 5
0
		public DelayViewModel(GKDelay delay)
		{
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			ShowOnPlanOrPropertiesCommand = new RelayCommand(OnShowOnPlanOrProperties);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			Delay = delay;
			State.StateChanged += new System.Action(OnStateChanged);
			OnStateChanged();
		}
		public DelayPropertiesViewModel(GKDelay delay)
		{
			Title = "Параметры задержки";
			Delay = delay;

			DelayRegimes = Enum.GetValues(typeof(DelayRegime)).Cast<DelayRegime>().ToList();
			DelayRegime = delay.DelayRegime;
			DelayTime = delay.DelayTime;
			Hold = delay.Hold;
		}
Esempio n. 7
0
		public DelaySelectionViewModel(GKDelay delay)
		{
			Title = "Выбор задержки";
			Delays = new ObservableCollection<DelayViewModel>();
			GKManager.Delays.ForEach(x => Delays.Add(new DelayViewModel(x)));
			if (delay != null)
				SelectedDelay = Delays.FirstOrDefault(x => x.Delay.UID == delay.UID);
			if (SelectedDelay == null)
				SelectedDelay = Delays.FirstOrDefault();
		}
Esempio n. 8
0
		public DelayDetailsViewModel(GKDelay delay)
		{
			Delay = delay;
			Title = Delay.PresentationName;
			State.StateChanged += new Action(OnStateChanged);
			PlanLinks = new PlanLinksViewModel(Delay);

			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);
		}
Esempio n. 9
0
		/// <summary>
		/// Удаление задержки
		/// </summary>
		/// <param name="delay"></param>
		public static void RemoveDelay(GKDelay delay)
		{
			Delays.Remove(delay);
			delay.InputDependentElements.ForEach(x =>
			{
				x.OutputDependentElements.Remove(delay);
			});

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

			delay.OnChanged();
		}
Esempio n. 10
0
		public void TestDelayInMultiGk()
		{
			var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_GuardDetector);
			var device2 = AddDevice(kauDevice21, GKDriverType.RSR2_GuardDetector);
			var delay = new GKDelay();
			GKManager.Delays.Add(delay);
			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = {device1.UID, device2.UID}
			};
			delay.Logic.OnClausesGroup.Clauses.Add(clause);
			var validator = new Validator();
			var errors = validator.Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Содержится в нескольких ГК"));
		}
Esempio n. 11
0
		public DelayDetailsViewModel(GKDelay delay = null)
		{
			ReadPropertiesCommand = new RelayCommand(OnReadProperties);
			WritePropertiesCommand = new RelayCommand(OnWriteProperties);
			ResetPropertiesCommand = new RelayCommand(OnResetProperties);
			DelayRegimes = Enum.GetValues(typeof(DelayRegime)).Cast<DelayRegime>().ToList();

			if (delay == null)
			{
				Title = "Создание новой задержки";
				IsEdit = false;
				Delay = new GKDelay()
				{
					Name = "Задержка",
					No = 1,
				};
				if (GKManager.Delays.Count != 0)
					Delay.No = (GKManager.Delays.Select(x => x.No).Max() + 1);
			}
			else
			{
				IsEdit = true;
				Title = string.Format("Свойства задержки: {0}", delay.PresentationName);
				Delay = delay;
			}
			CopyProperties();

			var availableNames = new HashSet<string>();
			var availableDescriptions = new HashSet<string>();
			foreach (var existingDelay in GKManager.Delays)
			{
				availableNames.Add(existingDelay.Name);
				availableDescriptions.Add(existingDelay.Description);
			}
			AvailableNames = new ObservableCollection<string>(availableNames);
			AvailableDescriptions = new ObservableCollection<string>(availableDescriptions);
		}
Esempio n. 12
0
		/* RG-1015 (Если у задержки задан Режим после удержания "Включено", то после окончания отсчета удержания она не должена переходить в режим "Включается")*/
		public void TestDelayRegimeDelay(DelayRegime regime, XStateClass state)
		{
			var delay = new GKDelay { Name = "Задержка", No = 1 };
			var zone = new GKZone { Name = "Пожарная зона", No = 1 };
			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllZones,
				StateType = GKStateBit.Fire1,
				ZoneUIDs = { zone.UID }
			};
			var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_HeatDetector);
			var device2 = AddDevice(kauDevice11, GKDriverType.RSR2_HeatDetector);
			var device3 = AddDevice(kauDevice11, GKDriverType.RSR2_HeatDetector);
			delay.Logic.OnClausesGroup.Clauses.Add(clause);
			delay.DelayTime = 3;
			delay.Hold = 3;
			delay.DelayRegime = regime;
			GKManager.AddZone(zone);
			GKManager.AddDelay(delay);
			GKManager.AddDeviceToZone(device1, zone);
			GKManager.AddDeviceToZone(device2, zone);
			GKManager.AddDeviceToZone(device3, zone);
			SetConfigAndRestartImitator();

			WaitWhileState(zone, XStateClass.Norm, 10000, "Ждем Норму в зоне");
			Assert.IsTrue(zone.State.StateClass == XStateClass.Norm, "Проверка того, что зона в Норме");
			ConrtolGKBase(device1, GKStateBit.Fire1, "Сработка1 у датчика1");
			ConrtolGKBase(device2, GKStateBit.Fire1, "Сработка1 у датчика2");
			WaitWhileState(delay, XStateClass.On, 5000, "Ждем пока задрежка не Включится");
			Assert.IsTrue(delay.State.StateClass == XStateClass.On, "Проверка того, что задержка Включена");
			WaitWhileState(delay, XStateClass.TurningOn, 6000, "Ждем 6 секунд, задрежка не должена перейти в режим Включается");
			Assert.IsFalse(delay.State.StateClass == XStateClass.TurningOn, "Проверка того, что задрежка не перешла в режим Включается");
			Assert.IsTrue(delay.State.StateClass == state, "Проверка того, что задрежка Включена/Выключена");
			if (delay.DelayRegime == DelayRegime.On)
				CheckJournal(3, JournalItem(delay, JournalEventNameType.Включается), JournalItem(Led("Устройство Пожар 1 "), JournalEventNameType.Включено), JournalItem(delay, JournalEventNameType.Включено));
			else
				CheckJournal(4, JournalItem(delay, JournalEventNameType.Включается), JournalItem(Led("Устройство Пожар 1 "), JournalEventNameType.Включено), JournalItem(delay, JournalEventNameType.Включено), JournalItem(delay, JournalEventNameType.Выключено));
		}
Esempio n. 13
0
		public GKDelay Clone()
		{
			var delay = new GKDelay();
			delay.Name = Name;
			delay.Description = Description;
			delay.DelayTime = DelayTime;
			delay.Hold = Hold;
			delay.DelayRegime = DelayRegime;
			delay.Logic.OnClausesGroup = Logic.OnClausesGroup.Clone();
			delay.Logic.OffClausesGroup = Logic.OffClausesGroup.Clone();
			delay.Logic.StopClausesGroup = Logic.StopClausesGroup.Clone();
			delay.Logic.OnNowClausesGroup = Logic.OnNowClausesGroup.Clone();
			delay.Logic.OffNowClausesGroup = Logic.OffNowClausesGroup.Clone();
			return delay;
		}
Esempio n. 14
0
		/// <summary>
		/// Изменение задержки
		/// </summary>
		/// <param name="delay"></param>
		public static void EditDelay(GKDelay delay)
		{
			delay.OutputDependentElements.ForEach(x => x.OnChanged());
			delay.OnChanged();
		}
Esempio n. 15
0
		/// <summary>
		/// Изменение логики задержки
		/// </summary>
		/// <param name="delay"></param>
		/// <param name="logic"></param>
		public static void SetDelayLogic(GKDelay delay, GKLogic logic)
		{
			delay.Logic = logic;
			delay.ChangedLogic();
		}
Esempio n. 16
0
		/// <summary>
		/// Добавление задержки
		/// </summary>
		/// <param name="delay"></param>
		public static void AddDelay(GKDelay delay)
		{
			Delays.Add(delay);
		}
Esempio n. 17
0
		public void AddIdenticalDelayTest()
		{
			var delay = new GKDelay()
			{
				No = 1,
				Name = "Test 1 Delay"
			};
			GKManager.AddDelay(delay);
			CreateGroupControllerModule();
			MockDialogService.OnShowModal += x =>
			{
				(x as DelayDetailsViewModel).No = 1;
				(x as DelayDetailsViewModel).Name = "Test Delay";
				(x as DelayDetailsViewModel).SaveCommand.Execute();
			};
			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name.CompareTo("Test 1 Delay") == 0);
			delaysViewModel.AddCommand.Execute();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Test 1 Delay");
		}
Esempio n. 18
0
		public DelayViewModel(GKDelay delay)
		{
			Delay = delay;
		}
Esempio n. 19
0
		public void TestEmptyObjects()
		{
			var zone = new GKZone();
			GKManager.Zones.Add(zone);

			var direction = new GKDirection();
			GKManager.Directions.Add(direction);

			var delay = new GKDelay();
			GKManager.Delays.Add(delay);

			var guardZone = new GKGuardZone();
			GKManager.GuardZones.Add(guardZone);

			var pumpStation = new GKPumpStation();
			GKManager.PumpStations.Add(pumpStation);

			var mpt = new GKMPT();
			GKManager.MPTs.Add(mpt);

			var door = new GKDoor();
			GKManager.Doors.Add(door);

			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			Compile();

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == zone));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == zone));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == zone));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == direction));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == direction));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == direction));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == delay));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == delay));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == delay));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == mpt));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == mpt));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == mpt));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == door));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == door));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == door));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == code));
		}
Esempio n. 20
0
		public void CheckExistingDelayTest()
		{
			var delay = new GKDelay()
			{
				Name = "Delay 1"
			};
			GKManager.AddDelay(delay);
			CreateGroupControllerModule();
			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Delay 1");
		}
Esempio n. 21
0
		public void TestDependencyToGKAndKau()
		{
			var delay1 = new GKDelay();
			delay1.Logic.OnClausesGroup.Clauses.Add(new GKClause() { ClauseOperationType = ClauseOperationType.AllDevices, StateType = GKStateBit.Failure, DeviceUIDs = { kauDevice1.UID } });
			delay1.Logic.OnClausesGroup.Clauses.Add(new GKClause() { ClauseOperationType = ClauseOperationType.AllDevices, StateType = GKStateBit.On, DeviceUIDs = { gkDevice.AllChildren.FirstOrDefault(x => x.DriverType == GKDriverType.GKIndicator).UID } });
			GKManager.Delays.Add(delay1);
			Compile();

			CheckObjectLogicOnGK(delay1);
		}
Esempio n. 22
0
		public void TestDelayLogicOnGK()
		{
			var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_HandDetector);
			var device2 = AddDevice(kauDevice2, GKDriverType.RSR2_HandDetector);
			var delay = new GKDelay();
			GKManager.Delays.Add(delay);
			var clause = new GKClause()
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { device1.UID, device2.UID }
			};
			delay.Logic.OnClausesGroup.Clauses.Add(clause);
			Compile();

			CheckObjectLogicOnGK(delay);
		}
Esempio n. 23
0
		public void DeleteAllEmptyDelayTest()
		{
			MockMessageBoxService.ShowConfirmationResult = true;
			var delay1 = new GKDelay()
			{
				Name = "Delay1"
			};
			var delay2 = new GKDelay()
			{
				Name = "Delay2"
			};
			var delay3 = new GKDelay()
			{
				Name = "Delay3"
			};
			GKManager.AddDelay(delay1);
			GKManager.AddDelay(delay2);
			GKManager.AddDelay(delay3);
			CreateGroupControllerModule();

			MockDialogService.OnShowModal += x =>
			{
				var logicViewModel = x as LogicViewModel;
				if (logicViewModel != null)
				{
					logicViewModel.OnClausesGroup.Clauses[0].SelectedClauseOperationType = ClauseOperationType.AnyDevice;
					logicViewModel.OnClausesGroup.Clauses[0].SelectedStateType = logicViewModel.OnClausesGroup.Clauses[0].StateTypes.FirstOrDefault(y => y.StateBit == GKStateBit.Failure);
					logicViewModel.OnClausesGroup.Clauses[0].SelectDevicesCommand.Execute();
					logicViewModel.SaveCommand.Execute();
				}
			};

			MockDialogService.OnShowModal += x =>
			{
				var devicesSelectationViewModel = x as DevicesSelectationViewModel;
				if (devicesSelectationViewModel != null)
				{
					devicesSelectationViewModel.AddCommand.Execute(devicesSelectationViewModel.AvailableDevices.Where(y => y.DriverType == GKDriverType.RSR2_KAU).ToList());
					devicesSelectationViewModel.SaveCommand.Execute();
				}
			};

			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			delaysViewModel.SelectedDelay = delaysViewModel.Delays[2];
			Assert.IsTrue(delaysViewModel.Delays.Count == 3);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Delay3");
			delaysViewModel.SelectedDelay.ShowLogicCommand.Execute();
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Logic.OnClausesGroup.Clauses.Count == 1);
			delaysViewModel.DeleteAllEmptyCommand.Execute();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Delay3");
		}
Esempio n. 24
0
		public void DeleteDelayTest()
		{
			MockMessageBoxService.ShowConfirmationResult = true;
			var delay = new GKDelay();
			GKManager.AddDelay(delay);
			CreateGroupControllerModule();
			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			delaysViewModel.DeleteCommand.Execute();
			Assert.IsTrue(delaysViewModel.Delays.Count == 0);
		}
Esempio n. 25
0
		public void CopyDelayTest()
		{
			var delay = new GKDelay()
			{
				No = 3
			};
			GKManager.AddDelay(delay);
			CreateGroupControllerModule();

			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.No == 3);
			delaysViewModel.CopyCommand.Execute();
			delaysViewModel.PasteCommand.Execute();
			Assert.IsTrue(delaysViewModel.Delays.Count == 2);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.No == 4);
		}
Esempio n. 26
0
		public void EditDelayPropertiesTest()
		{
			var delay = new GKDelay()
			{
				No = 1,
				Name = "Delay Properties",
				Description = "Примечание",
				DelayTime = 1,
				Hold = 2,
				DelayRegime = DelayRegime.Off,
			};
			GKManager.AddDelay(delay);
			CreateGroupControllerModule();

			MockDialogService.OnShowModal += x =>
			{
				(x as DelayDetailsViewModel).Name = "Edit Delay Properties";
				(x as DelayDetailsViewModel).Description = "Удалено";
				(x as DelayDetailsViewModel).No = 2;
				(x as DelayDetailsViewModel).DelayTime = 11;
				(x as DelayDetailsViewModel).Hold = 12;
				(x as DelayDetailsViewModel).DelayRegime = DelayRegime.On;
				(x as DelayDetailsViewModel).SaveCommand.Execute();
			};
			var delaysViewModel = GroupControllerModule.DelaysViewModel;
			delaysViewModel.OnShow();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.No == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Delay Properties");
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.DelayTime == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Hold == 2);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.DelayRegime == DelayRegime.Off);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Description == "Примечание");
			delaysViewModel.EditCommand.Execute();
			Assert.IsTrue(delaysViewModel.Delays.Count == 1);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.No == 2);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Name == "Edit Delay Properties");
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.DelayTime == 11);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Hold == 12);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.DelayRegime == DelayRegime.On);
			Assert.IsTrue(delaysViewModel.SelectedDelay.Delay.Description == "Удалено");
		}
Esempio n. 27
0
		public void RemoveDeviceTestLogicForDelayAndDirection()
		{
			var device = AddDevice(kauDevice11, GKDriverType.RSR2_MDU);
			GKManager.UpdateConfiguration();

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

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

			GKManager.SetDeviceLogic(device, gkLogic);
			Assert.IsTrue(device.Logic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsFalse(device.OutputDependentElements.Any(x => x.UID == device.UID));
			Assert.IsFalse(device.InputDependentElements.Any(x => x.UID == device.UID));

			var delay = new GKDelay();
			GKManager.AddDelay(delay);
			GKManager.SetDelayLogic(delay, gkLogic);
			Assert.IsTrue(delay.Logic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsTrue(device.OutputDependentElements.Any(x => x.UID == delay.UID));
			Assert.IsTrue(delay.InputDependentElements.Any(x => x.UID == device.UID));

			var direction = new GKDirection();
			GKManager.AddDirection(direction);
			GKManager.SetDirectionLogic(direction,gkLogic);
			Assert.IsTrue(direction.Logic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Any()));
			Assert.IsTrue(device.OutputDependentElements.Any(x => x.UID == direction.UID));
			Assert.IsTrue(direction.InputDependentElements.Any(x => x.UID == device.UID));

			GKManager.RemoveDevice(device);
			Assert.IsFalse(delay.Logic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsFalse(direction.Logic.OnClausesGroup.Clauses.Any(x => x.DeviceUIDs.Contains(device.UID)));
			Assert.IsFalse(delay.InputDependentElements.Any(x => x.UID == device.UID));
			Assert.IsFalse(direction.InputDependentElements.Any(x => x.UID == device.UID));

		}
Esempio n. 28
0
		public void ChangeGroupDeviceWithLogicTest()
		{
			SetMokForNewDeviceViewModel(GKDriverType.RSR2_MDU);
			var devicesViewModel = GroupControllerModule.DevicesViewModel;
			var selectedDevice = devicesViewModel.SelectedDevice = devicesViewModel.AllDevices.FirstOrDefault(x => x.Driver.DriverType == GKDriverType.RSR2_KAU_Shleif);
			devicesViewModel.SelectedDevice.AddCommand.Execute();
			GKManager.UpdateConfiguration();
			var delay = new GKDelay();
			var clause = new GKClause
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				DeviceUIDs = { selectedDevice.Device.Children[0].UID }
			};

			var gkLogic = new GKLogic();
			gkLogic.OnClausesGroup.Clauses.Add(clause);
			GKManager.AddDelay(delay);
			GKManager.SetDelayLogic(delay, gkLogic);
			GKManager.SetDeviceLogic(selectedDevice.Device.Children[0], gkLogic);
			selectedDevice = devicesViewModel.AllDevices.FirstOrDefault(x => x.Device == selectedDevice.Device.Children[0]);
			selectedDevice.Driver = RSR2_RM_2_Helper.Create();
			selectedDevice = devicesViewModel.SelectedDevice = devicesViewModel.AllDevices.FirstOrDefault(x => x.Driver.DriverType == GKDriverType.RSR2_KAU_Shleif);
			var device = selectedDevice.Device.Children[0];
			Assert.IsTrue(device.DriverType == GKDriverType.RSR2_RM_2);
			Assert.IsTrue(device.Logic.GetObjects().Count == 0);
			Assert.IsTrue(device.InputDependentElements.Count == 0);
			Assert.IsTrue(delay.OutputDependentElements.Count == 0);
			Assert.IsTrue(delay.Logic.GetObjects().Count == 0);
		}
Esempio n. 29
0
		public ObjectViewModel(GKDelay delay)
		{
			Delay = delay;
			Name = delay.PresentationName;
			ImageSource = "/Controls;component/Images/Delay.png";
			Address = "";
			PresentationZoneOrLogic = GKManager.GetPresentationLogic(delay.Logic);
			ObjectType = ObjectType.Delay;
			SortingName = "f " + delay.No;
		}
Esempio n. 30
0
		public void TestDependencyToKau()
		{
			var delay1 = new GKDelay();
			delay1.Logic.OnClausesGroup.Clauses.Add(new GKClause() { ClauseOperationType = ClauseOperationType.AllDevices, StateType = GKStateBit.Failure, DeviceUIDs = { kauDevice1.UID } });
			GKManager.Delays.Add(delay1);
			Compile();

			CheckObjectLogicOnKau(delay1);
		}