public void TestPumpStationOnGK()
		{
			var device1 = AddDevice(kauDevice2, GKDriverType.RSR2_HandDetector);
			var device2 = AddDevice(kauDevice1, GKDriverType.RSR2_Bush_Fire);
			var device3 = AddDevice(kauDevice1, GKDriverType.RSR2_Bush_Fire);
			var clause = new GKClause()
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure
			};
			clause.DeviceUIDs.Add(device1.UID);
			var pumpStation = new GKPumpStation()
			{
				NSDeviceUIDs = { device2.UID, device3.UID }
			};
			pumpStation.StartLogic.OnClausesGroup.Clauses.Add(clause);
			GKManager.PumpStations.Add(pumpStation);
			Compile();

			CheckObjectLogicOnGK(pumpStation);

			var kau1DelayDescriptor = Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase is GKDelay && (x.GKBase as GKDelay).PumpStationUID == pumpStation.UID);
			var gkDelayDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase is GKDelay && (x.GKBase as GKDelay).PumpStationUID == pumpStation.UID);
			Assert.IsNull(kau1DelayDescriptor, "На КАУ присутствует компонент НС");
			Assert.IsTrue(gkDelayDescriptor.Formula.FormulaOperations.Count > 1, "Отсутствует логика на ГК");

			var kau1PimDescriptor = Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase is GKPim && (x.GKBase as GKPim).PumpStationUID == pumpStation.UID);
			var gkPimDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase is GKPim && (x.GKBase as GKPim).PumpStationUID == pumpStation.UID);
			Assert.IsNull(kau1PimDescriptor, "На КАУ присутствует компонент НС");
			Assert.IsTrue(gkPimDescriptor.Formula.FormulaOperations.Count > 1, "Отсутствует логика на ГК");

			CheckDeviceLogicOnGK(device2);
		}
Example #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);
		}
Example #3
0
		public PumpStationDescriptor(GKPim globalPim, GKPumpStation pumpStation)
			: base(pumpStation)
		{
			GlobalPim = globalPim;
			DescriptorType = DescriptorType.PumpStation;
			PumpStation = pumpStation;
		}
		/// <summary>
		/// НС должно содержать в списке устройств только насосы
		/// Конфигурация этого не дает сделать, но на всякий случай
		/// </summary>
		/// <param name="pumpStation"></param>
		void ValidatePumpStationHasValidDriverTypes(GKPumpStation pumpStation)
		{
			if (pumpStation.NSDevices.Any(x => !x.Driver.IsPump))
			{
				AddError(pumpStation, "В НС отсутствуют насосы", ValidationErrorLevel.CannotWrite);
			}
		}
		public PumpStationPropertiesViewModel(GKPumpStation pumpStation)
		{
			Title = "Параметры НС";
			PumpStation = pumpStation;
			Delay = PumpStation.Delay;
			Hold = PumpStation.Hold;
			DelayRegime = PumpStation.DelayRegime;
			AvailableDelayRegimeTypes = new List<DelayRegime>(Enum.GetValues(typeof(DelayRegime)).Cast<DelayRegime>());
		}
		public PumpStationSelectionViewModel(GKPumpStation pumpStation)
		{
			Title = "Выбор насосной станции";
			PumpStations = new ObservableCollection<PumpStationViewModel>();
			GKManager.PumpStations.ForEach(x => PumpStations.Add(new PumpStationViewModel(x)));
			if (pumpStation != null)
				SelectedPumpStation = PumpStations.FirstOrDefault(x => x.PumpStation.UID == pumpStation.UID);
			if (SelectedPumpStation == null)
				SelectedPumpStation = PumpStations.FirstOrDefault();
		}
Example #7
0
		public PumpStationViewModel(GKPumpStation pumpStation)
		{
			ChangeStartLogicCommand = new RelayCommand(OnChangeStartLogic);
			ChangeStopLogicCommand = new RelayCommand(OnChangeStopLogic);
			ChangeAutomaticOffLogicCommand = new RelayCommand(OnChangeAutomaticOffLogic);

			PumpStation = pumpStation;
			PumpStation.Changed += Update;
			PumpStation.PlanElementUIDsChanged += UpdateVisualizationState;
			Update();
		}
Example #8
0
		public PumpStationCreator(CommonDatabase database, GKPumpStation pumpStation, DatabaseType dataBaseType)
		{
			Database = database;
			PumpStation = pumpStation;
			DatabaseType = dataBaseType;

			foreach (var nsDevice in pumpStation.NSDevices)
			{
				if (nsDevice.DriverType == GKDriverType.RSR2_Bush_Fire)
					FirePumpDevices.Add(nsDevice);
				if (nsDevice.DriverType == GKDriverType.RSR2_Bush_Jokey)
					JockeyPumpDevices.Add(nsDevice);
			}
		}
		/* RG-1004 (Включение НС по условию - пожар1 в зоне)*/
		public void TestPumpStaitionStartLogicWithFirezone()
		{
			var pumpStaition = new GKPumpStation {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);
			var pump = AddDevice(kauDevice11, GKDriverType.RSR2_Bush_Fire);
			var gkpim = AddPim(gkDevice1);
			var kaupim = AddPim(kauDevice11);
			pumpStaition.StartLogic.OnClausesGroup.Clauses.Add(clause);
			pumpStaition.NSDeviceUIDs.Add(pump.UID);
			pumpStaition.NSDevices.Add(pump);
			pumpStaition.Delay = 3;
			GKManager.AddZone(zone);
			GKManager.AddPumpStation(pumpStaition);
			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, "Проверка того, что зона в Норме");
			TurnOnPim(gkpim);
			TurnOnPim(kaupim);
			ConrtolGKBase(device1, GKStateBit.Fire1, "Сработка1 у датчика1");
			WaitWhileState(zone, XStateClass.Attention, 4000, "Ждем пока зона не перейдёт во Внимание");
			Assert.IsTrue(zone.State.StateClass == XStateClass.Attention, "Проверка того, что зона во Внимание");
			Assert.IsTrue(pumpStaition.State.StateClass == XStateClass.Off, "Проверка того, что НС Выключен");
			CheckJournal(3, JournalItem(device1, JournalEventNameType.Сработка_1),
				JournalItem(zone, JournalEventNameType.Внимание), JournalItem(Led("Устройство Внимание "), JournalEventNameType.Включено));
			ConrtolGKBase(device2, GKStateBit.Fire1, "Сработка1 у датчика2");
			WaitWhileState(zone, XStateClass.Fire1, 3000, "Ждем пока зона не перейдёт в Пожар");
			Assert.IsTrue(zone.State.StateClass == XStateClass.Fire1, "Проверка того, что зона перешла в Пожар");
			Assert.IsTrue(pumpStaition.State.StateClass == XStateClass.TurningOn, "Проверка того, что НС Включается");
			WaitWhileState(zone, XStateClass.On, 4000, "Ждем пока НС не Включится");
			Assert.IsTrue(pumpStaition.State.StateClass == XStateClass.On, "Проверка того, что НС Включен");
			Assert.IsTrue(pump.State.StateClass == XStateClass.On, "Проверка того, что насос Включен");
			CheckJournal(8, JournalItem(device2, JournalEventNameType.Сработка_1), JournalItem(Led("Устройство Внимание "), JournalEventNameType.Выключено),
				JournalItem(zone, JournalEventNameType.Пожар_1), JournalItem(pumpStaition, JournalEventNameType.Включается),
				JournalItem(Led("Устройство Включение ПУСК "), JournalEventNameType.Включено), JournalItem(Led("Устройство Пожар 1 "), JournalEventNameType.Включено),
				JournalItem(pumpStaition, JournalEventNameType.Включено), JournalItem(pump, JournalEventNameType.Включено));
		}
Example #10
0
		public PumpStationViewModel(GKPumpStation pumpStation)
		{
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			ShowOnPlanOrPropertiesCommand = new RelayCommand(ShowOnPlanOrProperties);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
			PumpStation = pumpStation;
			State.StateChanged += new System.Action(OnStateChanged);
			OnStateChanged();

			Pumps = new ObservableCollection<DeviceViewModel>();
			foreach (var device in PumpStation.NSDevices)
			{
				var deviceViewModel = DevicesViewModel.Current.AllDevices.FirstOrDefault(x => x.Device == device);
				Pumps.Add(deviceViewModel);
			}
		}
Example #11
0
		/// <summary>
		/// Удаление НС
		/// </summary>
		/// <param name="pumpStation"></param>
		public static void RemovePumpStation(GKPumpStation pumpStation)
		{
			PumpStations.Remove(pumpStation);
			pumpStation.InputDependentElements.ForEach(x =>
			{
				x.OutputDependentElements.Remove(pumpStation);
			});

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

			pumpStation.OnChanged();
		}
		public PumpStationDetailsViewModel(GKPumpStation pumpStation)
		{
			PumpStation = pumpStation;
			Title = PumpStation.PresentationName;
			State.StateChanged += new Action(OnStateChanged);
			PlanLinks = new PlanLinksViewModel(PumpStation);

			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);
		}
		/* RG-1015 (Если у НС задан Режим после удержания "Включено", то после окончания отсчета удержания он не должен переходить в режим "Включается")*/
		public void TestPumpStationDelayRegime(DelayRegime regime, XStateClass state, JournalEventNameType eventname)
		{
			var pumpStaition = new GKPumpStation { 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);
			var pump = AddDevice(kauDevice11, GKDriverType.RSR2_Bush_Fire);
			var gkpim = AddPim(gkDevice1);
			var kaupim = AddPim(kauDevice11);
			pumpStaition.StartLogic.OnClausesGroup.Clauses.Add(clause);
			pumpStaition.NSDeviceUIDs.Add(pump.UID);
			pumpStaition.NSDevices.Add(pump);
			pumpStaition.Delay = 3;
			pumpStaition.Hold = 3;
			pumpStaition.DelayRegime = regime;
			GKManager.AddZone(zone);
			GKManager.AddPumpStation(pumpStaition);
			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, "Проверка того, что зона в Норме");
			TurnOnPim(gkpim);
			TurnOnPim(kaupim);
			ConrtolGKBase(device1, GKStateBit.Fire1, "Сработка1 у датчика1");
			ConrtolGKBase(device2, GKStateBit.Fire1, "Сработка1 у датчика2");
			WaitWhileState(pumpStaition, XStateClass.On, 5000, "Ждем пока НС не Включится");
			Assert.IsTrue(pumpStaition.State.StateClass == XStateClass.On, "Проверка того, что НС Включен");
			WaitWhileState(pumpStaition, XStateClass.TurningOn, 6000, "Ждем 6 секунд, НС не должен перейти в режим Включается");
			Assert.IsFalse(pumpStaition.State.StateClass == XStateClass.TurningOn, "Проверка того, что НС не перешёл в режим Включается");
			Assert.IsTrue(pumpStaition.State.StateClass == state, "Проверка того, что НС Включен/Выключен");
			Assert.IsTrue(pump.State.StateClass == state, "Проверка того, что насос Включен/Выключен");
			WaitWhileState(Led("Устройство Включение ПУСК "), state, 2000,"Ждём пока индикатор не будет Включен/Выключен");
			// RG-1340 CheckJournal(3, JournalItem(pumpStaition, eventname), JournalItem(pump, eventname), JournalItem(Led("Устройство Включение ПУСК "), eventname));
		}
Example #14
0
		public PumpStation(GKPumpStation pumpStation)
			: base(pumpStation)
		{
			No = pumpStation.No;
			GKDescriptorNo = pumpStation.GKDescriptorNo;
			Name = pumpStation.Name;
			StartLogic = GKManager.GetPresentationLogic(pumpStation.StartLogic.OnClausesGroup);
			StopLogic = GKManager.GetPresentationLogic(pumpStation.StopLogic.OnClausesGroup);
			AutomaticOffLogic = GKManager.GetPresentationLogic(pumpStation.AutomaticOffLogic.OnClausesGroup);
			Delay = pumpStation.Delay;
			Hold = pumpStation.Hold;
			DelayRegime = pumpStation.DelayRegime.ToDescription();
			NSPumpsCount = pumpStation.NSPumpsCount;
			NSDeltaTime = pumpStation.NSDeltaTime;
			ImageSource = pumpStation.ImageSource.Replace("/Controls;component/", "");

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

			HasOnDelay = pumpStation.State.StateClasses.Contains(XStateClass.TurningOn) && pumpStation.State.OnDelay > 0;
			OnDelay = pumpStation.State.OnDelay != 0 ? pumpStation.State.OnDelay.ToString() : string.Empty;
			HoldDelay = pumpStation.State.HoldDelay != 0 ?  pumpStation.State.HoldDelay.ToString() : string.Empty;
			HasHoldDelay = pumpStation.State.StateClasses.Contains(XStateClass.On) && pumpStation.State.HoldDelay > 0;

			var controlRegime = pumpStation.State.StateClasses.Contains(XStateClass.Ignore)
				? DeviceControlRegime.Ignore
				: !pumpStation.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);

		}
		public PumpStationDetailsViewModel(GKPumpStation pumpStation = null)
		{
			ReadPropertiesCommand = new RelayCommand(OnReadProperties);
			WritePropertiesCommand = new RelayCommand(OnWriteProperties);
			ResetPropertiesCommand = new RelayCommand(OnResetProperties);

			IsEdit = pumpStation != null;
			if (pumpStation == null)
			{
				Title = "Создание новой насосной станции";

				PumpStation = new GKPumpStation()
				{
					Name = "Насосная станция",
					No = 1
				};
				if (GKManager.PumpStations.Count != 0)
					PumpStation.No = (GKManager.PumpStations.Select(x => x.No).Max() + 1);
			}
			else
			{
				Title = string.Format("Свойства Насосной станции: {0}", pumpStation.PresentationName);
				PumpStation = pumpStation;
			}
			CopyProperties();

			AvailableDelayRegimeTypes = new ObservableCollection<DelayRegime>(Enum.GetValues(typeof(DelayRegime)).Cast<DelayRegime>());
			var availableNames = new HashSet<string>();
			var availableDescription = new HashSet<string>();
			foreach (var existingPumpStation in GKManager.PumpStations)
			{
				availableNames.Add(existingPumpStation.Name);
				availableDescription.Add(existingPumpStation.Description);
			}
			AvailableNames = new ObservableCollection<string>(availableNames);
			AvailableDescription = new ObservableCollection<string>(availableDescription);
		}
Example #16
0
		public static void ChangePumpDevices(GKPumpStation pumpStation, List<GKDevice> devices)
		{
			pumpStation.NSDevices.ForEach(x =>
				{
					if (!devices.Contains(x))
					{
						x.OutputDependentElements.Remove(pumpStation);
						pumpStation.InputDependentElements.Remove(x);
						x.NSLogic = new GKLogic();
						x.OnChanged();
					}
				});

			pumpStation.NSDevices = devices;
			pumpStation.NSDeviceUIDs = new List<Guid>();

			foreach (var device in pumpStation.NSDevices)
			{
				pumpStation.NSDeviceUIDs.Add(device.UID);
				device.Logic = new GKLogic();
				pumpStation.AddDependentElement(device);
			}
			pumpStation.OnChanged();
		}
Example #17
0
		public GKState(GKPumpStation pumpStation)
			: this()
		{
			PumpStation = pumpStation;
			UID = pumpStation.UID;
			BaseObjectType = GKBaseObjectType.PumpStation;
		}
Example #18
0
		public void PumpStationstUpdate(GKPumpStation pumpStation)
		{ 
			var _pumpStation = new PumpStation(pumpStation);
			Clients.All.pumpStationstUpdate(_pumpStation);
		}
Example #19
0
		/// <summary>
		/// Изменение НС
		/// </summary>
		/// <param name="pumpStation"></param>
		public static void EditPumpStation(GKPumpStation pumpStation)
		{
			pumpStation.OutputDependentElements.ForEach(x => x.OnChanged());
			pumpStation.OnChanged();
		}
Example #20
0
		public static void SetPumpStationAutomaticOffLogic(GKPumpStation pumpStation, GKLogic newLogic)
		{
			pumpStation.AutomaticOffLogic = newLogic;
			pumpStation.ChangedLogic();
		}
Example #21
0
		/// <summary>
		/// Добавление НС
		/// </summary>
		/// <param name="pumpStation"></param>
		public static void AddPumpStation(GKPumpStation pumpStation)
		{
			PumpStations.Add(pumpStation);
		}
Example #22
0
		public GKPumpStation Clone()
		{
			var delay = new GKPumpStation();
			delay.Name = this.Name;
			delay.Description = this.Description;
			delay.Delay = this.Delay;
			delay.Hold = this.Hold;
			delay.DelayRegime = this.DelayRegime;
			delay.NSPumpsCount = this.NSPumpsCount;
			delay.NSDeltaTime = this.NSDeltaTime;
			delay.NSDeviceUIDs = new List<Guid>(this.NSDeviceUIDs);

			delay.StartLogic.OnClausesGroup = this.StartLogic.OnClausesGroup.Clone();
			delay.StartLogic.OffClausesGroup = this.StartLogic.OffClausesGroup.Clone();
			delay.StartLogic.StopClausesGroup = this.StartLogic.StopClausesGroup.Clone();
			delay.StartLogic.OnNowClausesGroup = this.StartLogic.OnNowClausesGroup.Clone();
			delay.StartLogic.OffNowClausesGroup = this.StartLogic.OffNowClausesGroup.Clone();

			delay.StopLogic.OnClausesGroup = this.StartLogic.OnClausesGroup.Clone();
			delay.StopLogic.OffClausesGroup = this.StartLogic.OffClausesGroup.Clone();
			delay.StopLogic.StopClausesGroup = this.StartLogic.StopClausesGroup.Clone();
			delay.StopLogic.OnNowClausesGroup = this.StartLogic.OnNowClausesGroup.Clone();
			delay.StopLogic.OffNowClausesGroup = this.StartLogic.OffNowClausesGroup.Clone();

			delay.AutomaticOffLogic.OnClausesGroup = this.StartLogic.OnClausesGroup.Clone();
			delay.AutomaticOffLogic.OffClausesGroup = this.StartLogic.OffClausesGroup.Clone();
			delay.AutomaticOffLogic.StopClausesGroup = this.StartLogic.StopClausesGroup.Clone();
			delay.AutomaticOffLogic.OnNowClausesGroup = this.StartLogic.OnNowClausesGroup.Clone();
			delay.AutomaticOffLogic.OffNowClausesGroup = this.StartLogic.OffNowClausesGroup.Clone();

			return delay;
		}
Example #23
0
		/// <summary>
		/// Количество устройств, входящих в НС, должно быть больше количества основных насосов
		/// Таким же образом проверяется отсутствие насосов вообще
		/// </summary>
		/// <param name="pumpStation"></param>
		void ValidatePumpStationPumpsCount(GKPumpStation pumpStation)
		{
			if (pumpStation.NSPumpsCount > pumpStation.NSDevices.Count)
				AddError(pumpStation, "В НС основных насосов меньше реально располагаемых", ValidationErrorLevel.CannotWrite);
		}
Example #24
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));
		}
		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;
		}
Example #26
0
		public static void SetPumpStationStopLogic(GKPumpStation pumpStation, GKLogic newLogic)
		{
			pumpStation.StopLogic = newLogic;
			pumpStation.ChangedLogic();
		}
		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 #28
0
		bool Parse(List<byte> bytes, int descriptorNo)
		{
			var internalType = BytesHelper.SubstructShort(bytes, 0);
			var controllerAdress = BytesHelper.SubstructShort(bytes, 2);
			var adressOnController = BytesHelper.SubstructShort(bytes, 4);
			var physicalAdress = BytesHelper.SubstructShort(bytes, 6);
			if (internalType == 0)
				return true;
			var description = BytesHelper.BytesToStringDescription(bytes);
			var driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == internalType);
			if (driver != null)
			{
				if (driver.DriverType == GKDriverType.GK && descriptorNo > 1)
				{
					if (bytes.Count <= 0x3a)
					{
						driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.GKMirror);
					}
					else if (bytes[0x3a] == 1)
					{
						driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU);
					}
				}

				var shleifNo = (byte)(physicalAdress / 256) + 1;
				var device = new GKDevice
				{
					Driver = driver,
					DriverUID = driver.UID,
					IntAddress = (byte)(physicalAdress % 256),
				};
				if (driver.DriverType == GKDriverType.GK)
				{
					device.Properties.Add(new GKProperty { Name = "IPAddress", StringValue = IpAddress });
					ControllerDevices.Add(controllerAdress, device);
					DeviceConfiguration.RootDevice.Children.Add(device);
					GkDevice = device;
				}
				if (driver.IsKau)
				{
					device.IntAddress = (byte)(controllerAdress % 256);
					var modeProperty = new GKProperty
					{
						Name = "Mode",
						Value = (byte)(controllerAdress / 256)
					};
					device.DeviceProperties.Add(modeProperty);
					ControllerDevices.Add(controllerAdress, device);
					GkDevice.Children.Add(device);
					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);
						device.Children.Add(shleif);
					}
				}

				if (driver.DriverType == GKDriverType.GKMirror)
				{
					device.IntAddress = (byte)(controllerAdress % 256);
					var modeProperty = new GKProperty
					{
						Name = "Mode",
						Value = (byte)(controllerAdress / 256)
					};
					device.DeviceProperties.Add(modeProperty);
					ControllerDevices.Add(controllerAdress, device);
					GkDevice.Children.Add(device);
				}

				if (driver.DriverType != GKDriverType.GK && !driver.IsKau && driver.DriverType != GKDriverType.GKMirror && driver.DriverType != GKDriverType.System)
				{
					var controllerDevice = ControllerDevices.FirstOrDefault(x => x.Key == controllerAdress);
					if (controllerDevice.Value != null)
					{
						if (driver.DriverType == GKDriverType.GKIndicator && controllerDevice.Value.Driver.IsKau)
						{
							device.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.KAUIndicator);
							device.DriverUID = device.Driver.UID;
						}
						if (1 <= shleifNo && shleifNo <= 8 && physicalAdress != 0)
						{
							var shleif = controllerDevice.Value.Children.FirstOrDefault(x => (x.DriverType == GKDriverType.RSR2_KAU_Shleif) && x.IntAddress == shleifNo);
							shleif.Children.Add(device);
						}
						else
						{
							if (controllerDevice.Value.Driver.DriverType == GKDriverType.GK)
								device.IntAddress = (byte)(controllerDevice.Value.Children.Count(x => !x.Driver.HasAddress) + 2);
							else
								device.IntAddress = (byte)(controllerDevice.Value.Children.Count(x => !x.Driver.HasAddress) + 1);
							controllerDevice.Value.Children.Add(device);
						}
					}
				}
				return true;
			}

			if (internalType == 0x100 || internalType == 0x106 || internalType == 0x108 || internalType == 0x109 || internalType == 0x104)
			{
				var isMPT = false;
				var isPumpStation = false;
				ushort no = 0;

				try
				{
					if (description.StartsWith("MПТ."))
					{
						isMPT = true;
					}
					else
					{
						if (description[0] == '0')
							isPumpStation = true;
						no = (ushort)Int32.Parse(description.Substring(0, description.IndexOf(".")));
					}
					description = description.Substring(description.IndexOf(".") + 1);
				}
				catch
				{
					Error = "Невозможно получить номер объекта с дескриптором " + descriptorNo;
					return false;
				}

				if (internalType == 0x100)
				{
					var zone = new GKZone
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Zones.Add(zone);
					return true;
				}
				if (internalType == 0x106)
				{
					if (isPumpStation)
					{
						var pumpStation = new GKPumpStation()
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.PumpStations.Add(pumpStation);
					}
					else if (isMPT)
					{
						var mpt = new GKMPT()
						{
							Name = description,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.MPTs.Add(mpt);
					}
					else
					{
						var direction = new GKDirection
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.Directions.Add(direction);
					}
					return true;
				}
				if (internalType == 0x108)
				{
					var guardZone = new GKGuardZone
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.GuardZones.Add(guardZone);
					return true;
				}
				if (internalType == 0x109)
				{
					var code = new GKCode
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Codes.Add(code);
					return true;
				}
				if (internalType == 0x104)
				{
					var door = new GKDoor
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Doors.Add(door);
					return true;
				}
			}
			return true;
		}
Example #29
0
		public ObjectViewModel(GKPumpStation pumpStation)
		{
			PumpStation = pumpStation;
			Name = pumpStation.PresentationName;
			ImageSource = "/Controls;component/Images/BPumpStation.png";
			Address = "";
			PresentationZoneOrLogic = "";
			ObjectType = ObjectType.PumpStation;
			SortingName = "d " + pumpStation.No;
		}
Example #30
0
		/// <summary>
		/// Условие запуска НС должно иметь объекты
		/// </summary>
		/// <param name="pumpStation"></param>
		void ValidatePumpStationEmptyStartLogic(GKPumpStation pumpStation)
		{
			if (pumpStation.StartLogic.GetObjects().Count == 0)
				AddError(pumpStation, "В НС отсутствует условие для запуска", ValidationErrorLevel.CannotWrite);
		}