Esempio n. 1
0
		void SetFormulaBytes()
		{
			Formula = new FormulaBuilder();
			if (DatabaseType == DatabaseType.Gk)
			{
				if (Device.Driver.HasLogic)
				{
					if (Device.DeviceLogic.Clauses.Count > 0)
					{
						Formula.AddClauseFormula(Device.DeviceLogic.Clauses);
						AddMro2MFormula();
						if (Device.DeviceLogic.OffClauses == null || Device.DeviceLogic.OffClauses.Count == 0)
						{
							Formula.AddStandardTurning(Device);
						}
						else
						{
							Formula.AddGetBit(XStateBit.Norm, Device);
							Formula.Add(FormulaOperationType.AND, comment: "Смешивание с битом Дежурный Устройства");
							Formula.AddPutBit(XStateBit.TurnOn_InAutomatic, Device);
						}
					}
					if (Device.DeviceLogic.OffClauses.Count > 0)
					{
						Formula.AddClauseFormula(Device.DeviceLogic.OffClauses);
						Formula.AddGetBit(XStateBit.Norm, Device);
						Formula.Add(FormulaOperationType.AND, comment: "Смешивание с битом Дежурный Устройства");
						Formula.AddPutBit(XStateBit.TurnOff_InAutomatic, Device);
					}
				}
			}
			Formula.Add(FormulaOperationType.END);
			FormulaBytes = Formula.GetBytes();
		}
        void SetFormulaBytes()
        {
            Formula = new FormulaBuilder();

			Formula.AddGetBit(XStateBit.On, MainDelay);
			Formula.AddGetBit(XStateBit.Norm, PumpStation);
			Formula.Add(FormulaOperationType.AND);
			if (PumpStation.AutomaticOffLogic.Clauses.Count > 0)
			{
				Formula.AddClauseFormula(PumpStation.AutomaticOffLogic.Clauses);
				Formula.Add(FormulaOperationType.AND);
			}
			Formula.AddPutBit(XStateBit.SetRegime_Manual, PumpStation);

			if (PumpStation.StartLogic.Clauses.Count > 0)
				Formula.AddClauseFormula(PumpStation.StartLogic.Clauses);
			if (PumpStation.StopLogic.Clauses.Count > 0)
			{
				Formula.AddClauseFormula(PumpStation.StopLogic.Clauses);
				Formula.Add(FormulaOperationType.DUP);
				Formula.AddGetBit(XStateBit.Norm, PumpStation);
				Formula.Add(FormulaOperationType.AND, comment: "Смешивание с битом Дежурный НС");
				Formula.AddPutBit(XStateBit.TurnOff_InAutomatic, PumpStation);

				Formula.Add(FormulaOperationType.COM);
				Formula.Add(FormulaOperationType.AND);
			}

			Formula.AddGetBit(XStateBit.Norm, PumpStation);
			Formula.Add(FormulaOperationType.AND, comment: "Смешивание с битом Дежурный НС");
			Formula.AddPutBit(XStateBit.TurnOn_InAutomatic, PumpStation);

            Formula.Add(FormulaOperationType.END);
            FormulaBytes = Formula.GetBytes();
        }
Esempio n. 3
0
		public override void BuildFormula()
		{
			Formula = new FormulaBuilder();
			if ((DatabaseType == DatabaseType.Gk && GKBase.IsLogicOnKau) || (DatabaseType == DatabaseType.Kau && !GKBase.IsLogicOnKau))
			{
				Formula.Add(FormulaOperationType.END);
				return;
			}

			MPT.LinkToDescriptor(GlobalPim);
			Formula.AddGetBit(GKStateBit.On, GlobalPim);
			Formula.Add(FormulaOperationType.BR, 2, 1);
			Formula.Add(FormulaOperationType.EXIT);

			var mirrorParents = MPT.GetMirrorParents();
			Formula.AddMirrorLogic(MPT, mirrorParents);

			if (MPT.MptLogic.StopClausesGroup.GetObjects().Count > 0)
			{
				Formula.AddClauseFormula(MPT.MptLogic.StopClausesGroup);
				if (MPT.MptLogic.OnClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.DUP);
				Formula.AddPutBit(GKStateBit.Stop_InManual, MPT);
			}

			if (MPT.MptLogic.OnClausesGroup.GetObjects().Count > 0)
			{
				if (MPT.MptLogic.StopClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.COM);
				Formula.AddClauseFormula(MPT.MptLogic.OnClausesGroup);
				if (MPT.MptLogic.StopClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.AND);
				Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, MPT);
				if (MPT.MptLogic.UseOffCounterLogic)
				{
					Formula.AddClauseFormula(MPT.MptLogic.OnClausesGroup);
					Formula.Add(FormulaOperationType.COM);
					Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, MPT);
				}
			}

			if (!MPT.MptLogic.UseOffCounterLogic && MPT.MptLogic.OffClausesGroup.GetObjects().Count > 0)
			{
				Formula.AddClauseFormula(MPT.MptLogic.OffClausesGroup);
				Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, MPT);
			}

			SetRegime(GKMPTDeviceType.HandStart, GKStateBit.TurnOn_InManual);
			SetRegime(GKMPTDeviceType.HandStop, GKStateBit.TurnOff_InManual);
			SetRegime(GKMPTDeviceType.HandAutomaticOn, GKStateBit.SetRegime_Automatic);
			SetRegime(GKMPTDeviceType.HandAutomaticOff, GKStateBit.SetRegime_Manual);

			Formula.Add(FormulaOperationType.END);
		}
Esempio n. 4
0
		public override void BuildFormula()
		{
			Formula = new FormulaBuilder();
			if ((DatabaseType == DatabaseType.Gk && GKBase.IsLogicOnKau) || (DatabaseType == DatabaseType.Kau && !GKBase.IsLogicOnKau))
			{
				Formula.Add(FormulaOperationType.END);
				return;
			}

			PumpStation.LinkToDescriptor(GlobalPim);
			Formula.AddGetBit(GKStateBit.On, GlobalPim);
			Formula.Add(FormulaOperationType.BR, 2, 1);
			Formula.Add(FormulaOperationType.EXIT);

			var mirrorParents = PumpStation.GetMirrorParents();
			Formula.AddMirrorLogic(PumpStation, mirrorParents);

			var hasAutomaticOffLogic = PumpStation.AutomaticOffLogic.OnClausesGroup.Clauses.Count + PumpStation.AutomaticOffLogic.OnClausesGroup.ClauseGroups.Count > 0;
			var hasStartLogic = PumpStation.StartLogic.OnClausesGroup.Clauses.Count + PumpStation.StartLogic.OnClausesGroup.ClauseGroups.Count > 0;
			var hasStopLogic = PumpStation.StopLogic.OnClausesGroup.Clauses.Count + PumpStation.StopLogic.OnClausesGroup.ClauseGroups.Count > 0;
			if (hasAutomaticOffLogic)
			{
				Formula.AddClauseFormula(PumpStation.AutomaticOffLogic.OnClausesGroup);
				Formula.AddPutBit(GKStateBit.SetRegime_Manual, PumpStation);
			}

			if (hasStartLogic)
			{
				Formula.AddClauseFormula(PumpStation.StartLogic.OnClausesGroup);

				if (hasStopLogic)
				{
					Formula.AddClauseFormula(PumpStation.StopLogic.OnClausesGroup);
					Formula.Add(FormulaOperationType.COM);
					Formula.Add(FormulaOperationType.AND);
				}

				Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, PumpStation);
			}
			if (hasStopLogic)
			{
				Formula.AddClauseFormula(PumpStation.StopLogic.OnClausesGroup);
				Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, PumpStation);
			}

			Formula.Add(FormulaOperationType.END);
		}
Esempio n. 5
0
		public override void BuildFormula()
		{
			Formula = new FormulaBuilder();
			if ((DatabaseType == DatabaseType.Gk && GKBase.IsLogicOnKau) || (DatabaseType == DatabaseType.Kau && !GKBase.IsLogicOnKau))
			{
				Formula.Add(FormulaOperationType.END);
				return;
			}

			var mirrorParents = Direction.GetMirrorParents();
			Formula.AddMirrorLogic(Direction, mirrorParents);

			if (Direction.Logic.StopClausesGroup.GetObjects().Count > 0)
			{
				Formula.AddClauseFormula(Direction.Logic.StopClausesGroup);
				if (Direction.Logic.OnClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.DUP);
				Formula.AddPutBit(GKStateBit.Stop_InManual, Direction);
			}
			if (Direction.Logic.OnClausesGroup.Clauses.Count + Direction.Logic.OnClausesGroup.ClauseGroups.Count > 0)
			{
				if (Direction.Logic.StopClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.COM);
				Formula.AddClauseFormula(Direction.Logic.OnClausesGroup);
				if (Direction.Logic.StopClausesGroup.GetObjects().Count > 0)
					Formula.Add(FormulaOperationType.AND);
				Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Direction);
				if (Direction.Logic.UseOffCounterLogic)
				{
					Formula.AddClauseFormula(Direction.Logic.OnClausesGroup);
					Formula.Add(FormulaOperationType.COM);
					Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Direction);
				}
			}

			if (!Direction.Logic.UseOffCounterLogic && Direction.Logic.OffClausesGroup.GetObjects().Count > 0)
			{
				Formula.AddClauseFormula(Direction.Logic.OffClausesGroup);
				Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Direction);
			}
			Formula.Add(FormulaOperationType.END);
		}
Esempio n. 6
0
		public override void BuildFormula()
		{
			Formula = new FormulaBuilder();
			if ((DatabaseType == DatabaseType.Gk && GKBase.IsLogicOnKau) || (DatabaseType == DatabaseType.Kau && !GKBase.IsLogicOnKau))
			{
				Formula.Add(FormulaOperationType.END);
				return;
			}

			var mirrorParents = Device.GetMirrorParents();
			Formula.AddMirrorLogic(Device, mirrorParents);

			if (CreateMPTLogic())
				return;

			if (Device.Driver.HasLogic)
			{
				var hasOn1 = Device.Logic.OnClausesGroup.IsNotEmpty();
				var hasOn2 = Device.Logic.On2ClausesGroup.IsNotEmpty();
				if (hasOn1 && ! hasOn2)
				{
					Formula.AddClauseFormula(Device.Logic.OnClausesGroup);
					Formula.Add(FormulaOperationType.CONST, 0, 0);
					Formula.Add(FormulaOperationType.CONST, 0, 0);
					Formula.Add(FormulaOperationType.CONST, 0, 0);
					Formula.Add(FormulaOperationType.CONST, 0, 0);
					Formula.Add(FormulaOperationType.CONST, 0, 0);
					Formula.AddPutBit(31, Device);
					Formula.AddPutBit(30, Device);
					Formula.AddPutBit(29, Device);
					Formula.AddPutBit(28, Device);
					Formula.AddPutBit(27, Device);
					if (Device.Logic.UseOffCounterLogic)
						Formula.AddStandardTurning(Device);
					else
						Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
				}
				if (!hasOn1 && hasOn2)
				{
					Formula.AddClauseFormula(Device.Logic.On2ClausesGroup);
					Formula.Add(FormulaOperationType.CONST, 0, 1);
					Formula.Add(FormulaOperationType.CONST, 0, 1);
					Formula.Add(FormulaOperationType.CONST, 0, 1);
					Formula.Add(FormulaOperationType.CONST, 0, 1);
					Formula.Add(FormulaOperationType.CONST, 0, 1);
					Formula.AddPutBit(31, Device);
					Formula.AddPutBit(30, Device);
					Formula.AddPutBit(29, Device);
					Formula.AddPutBit(28, Device);
					Formula.AddPutBit(27, Device);
					if (Device.Logic.UseOffCounterLogic)
						Formula.AddStandardTurning(Device);
					else
						Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
				}
				if (hasOn1 && hasOn2)
				{
					Formula.AddClauseFormula(Device.Logic.OnClausesGroup);
					Formula.AddClauseFormula(Device.Logic.On2ClausesGroup);
					Formula.Add(FormulaOperationType.DUP);
					Formula.Add(FormulaOperationType.DUP);
					Formula.Add(FormulaOperationType.DUP);
					Formula.Add(FormulaOperationType.DUP);
					Formula.Add(FormulaOperationType.DUP);
					Formula.AddPutBit(31, Device);
					Formula.AddPutBit(30, Device);
					Formula.AddPutBit(29, Device);
					Formula.AddPutBit(28, Device);
					Formula.AddPutBit(27, Device);
					Formula.Add(FormulaOperationType.OR);
					if (Device.Logic.UseOffCounterLogic)
						Formula.AddStandardTurning(Device);
					else
						Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
				}
				
				if (!Device.Logic.UseOffCounterLogic && Device.Logic.OffClausesGroup.IsNotEmpty())
				{
					Formula.AddClauseFormula(Device.Logic.OffClausesGroup);
					Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
				}
				if (Device.Logic.OnNowClausesGroup.IsNotEmpty())
				{
					Formula.AddClauseFormula(Device.Logic.OnNowClausesGroup);
					Formula.AddPutBit(GKStateBit.TurnOnNow_InAutomatic, Device);
				}
				if (Device.Logic.OffNowClausesGroup.IsNotEmpty())
				{
					Formula.AddClauseFormula(Device.Logic.OffNowClausesGroup);
					Formula.AddPutBit(GKStateBit.TurnOffNow_InAutomatic, Device);
				}
				if (Device.Logic.StopClausesGroup.IsNotEmpty())
				{
					Formula.AddClauseFormula(Device.Logic.StopClausesGroup);
					Formula.AddPutBit(GKStateBit.Stop_InManual, Device);
				}

				SetICLogic();
			}

			if ((Device.DriverType == GKDriverType.RSR2_GuardDetector || Device.DriverType == GKDriverType.RSR2_GuardDetectorSound || Device.DriverType == GKDriverType.RSR2_HandGuardDetector)
				&& Device.GuardZones != null && Device.GuardZones.Count > 0)
			{
				Formula.AddGetBit(GKStateBit.On, Device.GuardZones.FirstOrDefault());
				Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
				Formula.AddGetBit(GKStateBit.Off, Device.GuardZones.FirstOrDefault());
				Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
			}

			if (Device.DriverType == GKDriverType.RSR2_MAP4 && Device.Zones.Count > 0)
			{
				int count = 0;
				foreach (var zone in Device.Zones)
				{
					Formula.AddGetBit(GKStateBit.Fire1, zone);
					if (count > 0)
						Formula.Add(FormulaOperationType.OR);
					Formula.AddGetBit(GKStateBit.Fire2, zone);
					Formula.Add(FormulaOperationType.OR);
					Formula.AddGetBit(GKStateBit.Attention, zone);
					Formula.Add(FormulaOperationType.OR);
					count++;
					Device.LinkToDescriptor(zone);
				}
				Formula.AddPutBit(GKStateBit.Reset, Device);
			}

			if (Device.Door != null && (Device.Door.LockDeviceUID == Device.UID || Device.Door.LockDeviceExitUID == Device.UID))
			{
				switch (Device.Door.DoorType)
				{
					case GKDoorType.AirlockBooth:
					case GKDoorType.Turnstile:
						var device = Device.Door.LockDeviceUID == Device.UID ? Device.Door.ExitDevice : Device.Door.EnterDevice;
						var button = Device.Door.LockDeviceUID == Device.UID ? Device.Door.EnterButton : Device.Door.ExitButton;
						if (device != null)
						{
							Formula.AddGetBit(GKStateBit.Attention, device);
							if (button != null)
							{
								Formula.Add(FormulaOperationType.BR, 2, 8);
								Formula.AddGetBit(GKStateBit.Fire1, button);
							}
							Formula.Add(FormulaOperationType.BR, 2, 6);
						}

						Formula.AddGetBit(GKStateBit.On, Device.Door);
						Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
						Formula.AddGetBit(GKStateBit.TurningOff, Device.Door);
						Formula.AddGetBit(GKStateBit.Off, Device.Door);
						Formula.Add(FormulaOperationType.OR);
						Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
						break;

					case GKDoorType.Barrier:
						if (Device.Door.LockDeviceUID == Device.UID)
						{
							Formula.AddGetBit(GKStateBit.On, Device.Door);
							Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
							Formula.AddGetBit(GKStateBit.Off, Device.Door);
							Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
						}
						else
						{
							Formula.AddGetBit(GKStateBit.Fire1, Device.Door.LockControlDevice);
							Formula.AddGetBit(GKStateBit.Fire1, Device.Door.LockControlDeviceExit);
							Formula.Add(FormulaOperationType.OR);
							Formula.Add(FormulaOperationType.COM);
							Formula.AddGetBit(GKStateBit.Off, Device.Door);
							Formula.Add(FormulaOperationType.AND);
							Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
							Formula.AddGetBit(GKStateBit.On, Device.Door);
							Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
						}
						break;

					default:
						Formula.AddGetBit(GKStateBit.On, Device.Door);
						Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Device);
						Formula.AddGetBit(GKStateBit.TurningOff, Device.Door);
						Formula.AddGetBit(GKStateBit.Off, Device.Door);
						Formula.Add(FormulaOperationType.OR);
						Formula.AddPutBit(GKStateBit.TurnOff_InAutomatic, Device);
						break;
				}
				Formula.Add(FormulaOperationType.END);
			}
		}
Esempio n. 7
0
		void SetFirePumpDevicesLogic()
		{
			for (int i = 0; i < FirePumpDevices.Count; i++)
			{
				var pumpDevice = FirePumpDevices[i];
				var pumpDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.Device != null && x.Device.UID == pumpDevice.UID);
				if (pumpDescriptor != null)
				{
					var formula = new FormulaBuilder();
					AddCountFirePumpDevicesFormula(formula);
					if (i > 0)
					{
						var pumpDelay = PumpDelays.FirstOrDefault(x => x.Device.UID == pumpDevice.UID);
						formula.AddGetBit(XStateBit.On, pumpDelay.Delay);
						formula.Add(FormulaOperationType.AND);
					}

					if (pumpDevice.NSLogic.Clauses.Count > 0)
					{
						formula.AddClauseFormula(pumpDevice.NSLogic.Clauses);
						formula.Add(FormulaOperationType.AND);
					}

					formula.AddGetBit(XStateBit.On, pumpDevice);
					formula.AddGetBit(XStateBit.TurningOn, pumpDevice);
					formula.Add(FormulaOperationType.OR);
					formula.AddGetBit(XStateBit.Failure, pumpDevice);
					formula.Add(FormulaOperationType.OR);
					formula.Add(FormulaOperationType.COM);
					formula.Add(FormulaOperationType.AND, comment: "Запрет на включение, если насос включен и не включается");

					formula.AddGetBit(XStateBit.On, PumpStation);
					formula.Add(FormulaOperationType.AND);

					formula.AddGetBit(XStateBit.Norm, pumpDevice);
					formula.Add(FormulaOperationType.AND);
					formula.AddPutBit(XStateBit.TurnOn_InAutomatic, pumpDevice);

					formula.AddGetBit(XStateBit.Off, PumpStation);
					formula.AddGetBit(XStateBit.Norm, pumpDevice);
					formula.Add(FormulaOperationType.AND);
					formula.AddPutBit(XStateBit.TurnOff_InAutomatic, pumpDevice);

					formula.Add(FormulaOperationType.END);

					pumpDescriptor.Formula = formula;
					pumpDescriptor.FormulaBytes = formula.GetBytes();
				}
			}
		}
Esempio n. 8
0
		public override void BuildFormula()
		{
			Formula = new FormulaBuilder();

			var hasOpenRegimeLogic = Door.OpenRegimeLogic.OnClausesGroup.IsNotEmpty();
			if (hasOpenRegimeLogic)
			{
				Formula.AddClauseFormula(Door.OpenRegimeLogic.OnClausesGroup);
				Formula.Add(FormulaOperationType.BR, 1, 7);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.AddPutBit(GKStateBit.SetRegime_Manual, Door);
				Formula.AddPutBit(GKStateBit.TurnOn_InAutomatic, Door);
				Formula.AddPutBit(GKStateBit.TurnOn_InManual, Door);
				Formula.Add(FormulaOperationType.EXIT);
			}

			var hasCloseRegimeLogic = Door.CloseRegimeLogic.OnClausesGroup.IsNotEmpty();
			if (hasCloseRegimeLogic)
			{
				Formula.AddClauseFormula(Door.CloseRegimeLogic.OnClausesGroup);
				Formula.Add(FormulaOperationType.BR, 1, 7);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.AddPutBit(GKStateBit.SetRegime_Manual, Door);
				Formula.AddPutBit(GKStateBit.TurnOffNow_InAutomatic, Door);
				Formula.AddPutBit(GKStateBit.TurnOffNow_InManual, Door);
				Formula.Add(FormulaOperationType.EXIT);
			}

			var hasNormRegimeLogic = Door.NormRegimeLogic.OnClausesGroup.IsNotEmpty();
			if (hasNormRegimeLogic)
			{
				Formula.AddClauseFormula(Door.NormRegimeLogic.OnClausesGroup);
				Formula.AddGetBit(GKStateBit.Norm, Door);
				Formula.Add(FormulaOperationType.COM);
				Formula.Add(FormulaOperationType.AND);
				Formula.Add(FormulaOperationType.BR, 1, 7);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.Add(FormulaOperationType.CONST, 0, 1);
				Formula.AddPutBit(GKStateBit.SetRegime_Automatic, Door);
				Formula.AddPutBit(GKStateBit.TurnOffNow_InAutomatic, Door);
				Formula.AddPutBit(GKStateBit.TurnOffNow_InManual, Door);
				Formula.Add(FormulaOperationType.EXIT);
			}

			switch (Door.DoorType)
			{
				case GKDoorType.OneWay:
				case GKDoorType.TwoWay:
				case GKDoorType.Turnstile:
					SetFormulaDoor();
					break;
				case GKDoorType.Barrier:
					SetFormulaBarrier();
					break;
				case GKDoorType.AirlockBooth:
					SetFormulaAirlockBooth();
					break;
			}

			Formula.Add(FormulaOperationType.END);
		}