Example #1
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);
			}
		}
Example #2
0
		void CreateMainDelay()
		{
			MainDelay.Name = "Тушение " + PumpStation.PresentationName;
			MainDelay.DelayTime = (ushort)(PumpStation.Hold - 5);
			MainDelay.SetTime = 5;
			MainDelay.DelayRegime = DelayRegime.Off;

			var delayDescriptor = new DelayDescriptor(MainDelay);
			GkDatabase.Descriptors.Add(delayDescriptor);
			UpdateConfigurationHelper.LinkXBases(PumpStation, MainDelay);
			UpdateConfigurationHelper.LinkXBases(MainDelay, PumpStation);

			var formula = new FormulaBuilder();

			formula.AddGetBit(XStateBit.On, PumpStation);
			formula.AddGetBit(XStateBit.Norm, PumpStation);
			formula.Add(FormulaOperationType.AND);
			formula.Add(FormulaOperationType.DUP);
			formula.AddGetBit(XStateBit.TurningOn, MainDelay);
			formula.AddGetBit(XStateBit.On, MainDelay);
			formula.Add(FormulaOperationType.OR);
			formula.Add(FormulaOperationType.COM);
			formula.Add(FormulaOperationType.AND);
			formula.AddPutBit(XStateBit.TurnOn_InAutomatic, MainDelay);
			formula.Add(FormulaOperationType.COM);
			formula.AddPutBit(XStateBit.TurnOff_InAutomatic, MainDelay);

			formula.Add(FormulaOperationType.END);
			delayDescriptor.Formula = formula;
			delayDescriptor.FormulaBytes = formula.GetBytes();
		}
Example #3
0
		public override void BuildObjects()
		{
			RestructCollection(Devices);
			Descriptors = new List<BaseDescriptor>();
			AddKauDevices();

			foreach (var device in Devices)
			{
				if (device.Driver.HasMirror)
					Descriptors.Add(new MirrorDescriptor(device));
				else
					Descriptors.Add(new DeviceDescriptor(device));
			}

			AddKauLogicObjects();

			foreach (var zone in GKManager.Zones.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var zoneDescriptor = new ZoneDescriptor(zone);
				Descriptors.Add(zoneDescriptor);
			}

			foreach (var guardZone in GKManager.GuardZones.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var guardZoneDescriptor = new GuardZoneDescriptor(guardZone);
				Descriptors.Add(guardZoneDescriptor);

				if (guardZoneDescriptor.GuardZonePimDescriptor != null)
				{
					Descriptors.Add(guardZoneDescriptor.GuardZonePimDescriptor);
				}
				if (guardZoneDescriptor.GuardZoneChangePimDescriptor != null)
				{
					Descriptors.Add(guardZoneDescriptor.GuardZoneChangePimDescriptor);
				}
			}

			foreach (var direction in GKManager.Directions.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var directionDescriptor = new DirectionDescriptor(direction);
				Descriptors.Add(directionDescriptor);
			}

			foreach (var delay in GKManager.Delays.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var delayDescriptor = new DelayDescriptor(delay);
				Descriptors.Add(delayDescriptor);
			}

			foreach (var pumpStation in GKManager.PumpStations.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var pumpStationDescriptor = new PumpStationDescriptor(GlobalPim, pumpStation);
				Descriptors.Add(pumpStationDescriptor);

				var pumpStationCreator = new PumpStationCreator(this, pumpStation, DatabaseType.Gk);
				pumpStationCreator.Create();
			}

			foreach (var mpt in GKManager.DeviceConfiguration.MPTs.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var mptDescriptor = new MPTDescriptor(GlobalPim, mpt);
				Descriptors.Add(mptDescriptor);

				var mptCreator = new MPTCreator(mpt);
			}

			foreach (var code in GKManager.DeviceConfiguration.Codes.Where(x => x.GkDatabaseParent == RootDevice && x.KauDatabaseParent == null))
			{
				var codeDescriptor = new CodeDescriptor(code);
				Descriptors.Add(codeDescriptor);
			}

			foreach (var door in GKManager.Doors.Where(x => x.GkDatabaseParent == RootDevice))
			{
				var doorDescriptor = new DoorDescriptor(door);
				Descriptors.Add(doorDescriptor);
				if (doorDescriptor.DoorPimDescriptorEnter != null)
				{
					Descriptors.Add(doorDescriptor.DoorPimDescriptorEnter);
				}
				if (doorDescriptor.DoorPimDescriptorExit != null)
				{
					Descriptors.Add(doorDescriptor.DoorPimDescriptorExit);
				}
				if (doorDescriptor.DoorPimDescriptorCrossing != null)
				{
					Descriptors.Add(doorDescriptor.DoorPimDescriptorCrossing);
				}
			}

			Descriptors.Add(GlobalPimDescriptor);

			ushort no = 1;
			foreach (var descriptor in Descriptors)
			{
				descriptor.No = descriptor.GKBase.GKDescriptorNo = no++;
				descriptor.DatabaseType = DatabaseType.Gk;
				descriptor.GKBase.GkDatabaseParent = RootDevice; // для автосгенерированных объектов
			}
			foreach (var descriptor in Descriptors)
			{
				descriptor.Build();
				if (!descriptor.IsFormulaGeneratedOutside && !descriptor.GKBase.IsLogicOnKau)
				{
					descriptor.BuildFormula();
				}
				descriptor.Formula.Resolve(this);
				descriptor.FormulaBytes = descriptor.Formula.GetBytes();
				if (!(descriptor is MirrorDescriptor))
				{
					descriptor.GKBase.InputDescriptors = descriptor.GKBase.InputDescriptors.OrderBy(x => x.No).ToList();
					descriptor.GKBase.OutputDescriptors = descriptor.GKBase.OutputDescriptors.OrderBy(x => x.No).ToList();
				}
				descriptor.InitializeAllBytes();
			}
		}
Example #4
0
		void CreateDelays()
		{
			for (int i = 1; i < FirePumpDevices.Count; i++)
			{
				var pumpDevice = FirePumpDevices[i];
				var delay = new XDelay()
				{
					Name = "Задержка пуска ШУН " + pumpDevice.DottedAddress,
					DelayTime = (ushort)PumpStation.NSDeltaTime,
					SetTime = 2,
					DelayRegime = DelayRegime.Off
				};
				delay.UID = GuidHelper.CreateOn(pumpDevice.UID);

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

				GkDatabase.AddDelay(delay);
				var delayDescriptor = new DelayDescriptor(delay);
				GkDatabase.Descriptors.Add(delayDescriptor);
			}
		}