Exemplo n.º 1
0
		void SetFormulaBytes()
		{
			Formula = new FormulaBuilder();
			if (Direction.InputZones.Count > 0 || Direction.InputDevices.Count > 0)
			{
				var inputObjectsCount = 0;
				foreach (var directionZone in Direction.DirectionZones)
				{
					Formula.AddGetBitOff(directionZone.StateBit, directionZone.Zone);
					if (inputObjectsCount > 0)
					{
						Formula.Add(FormulaOperationType.OR);
					}
					inputObjectsCount++;
				}
				foreach (var directionDevice in Direction.DirectionDevices)
				{
					Formula.AddGetBitOff(directionDevice.StateBit, directionDevice.Device);
					if (inputObjectsCount > 0)
					{
						Formula.Add(FormulaOperationType.OR);
					}
					inputObjectsCount++;
				}

				Formula.Add(FormulaOperationType.DUP);

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

				Formula.Add(FormulaOperationType.COM, comment: "Условие Выключения");
				Formula.AddGetBit(XStateBit.Norm, Direction);
				Formula.Add(FormulaOperationType.AND, comment: "Смешивание с битом Дежурный Направления");
				Formula.AddPutBit(XStateBit.TurnOff_InAutomatic, Direction);
			}
			Formula.Add(FormulaOperationType.END);
			FormulaBytes = Formula.GetBytes();
		}