Exemplo n.º 1
0
		public override void BuildObjects()
		{
			AddKauObjects();
			foreach (var zone in XManager.Zones)
			{
				if (zone.GkDatabaseParent == RootDevice)
				{
					zone.GKDescriptorNo = NextDescriptorNo;
					Zones.Add(zone);
				}
			}
			foreach (var direction in XManager.Directions)
			{
				if (direction.GkDatabaseParent == RootDevice)
				{
					direction.GKDescriptorNo = NextDescriptorNo;
					Directions.Add(direction);
				}
			}
			foreach (var pumpStation in XManager.PumpStations)
			{
				if (pumpStation.GkDatabaseParent == RootDevice)
				{
					//pumpStation.GKDescriptorNo = NextDescriptorNo;
					PumpStations.Add(pumpStation);
				}
			}

			Descriptors = new List<BaseDescriptor>();
			foreach (var device in Devices)
			{
				var deviceDescriptor = new DeviceDescriptor(device, DatabaseType);
				Descriptors.Add(deviceDescriptor);
			}
			foreach (var zone in Zones)
			{
				var zoneDescriptor = new ZoneDescriptor(zone);
				Descriptors.Add(zoneDescriptor);
			}
			foreach (var direction in Directions)
			{
				var directionDescriptor = new DirectionDescriptor(direction);
				Descriptors.Add(directionDescriptor);
			}
			foreach (var pumpStation in PumpStations)
			{
				pumpStation.GKDescriptorNo = NextDescriptorNo;
				var pumpStationDescriptor = new PumpStationDescriptor(this, pumpStation);
				Descriptors.Add(pumpStationDescriptor);

				var pumpStationCreator = new PumpStationCreator(this, pumpStation, pumpStationDescriptor.MainDelay);
				pumpStationCreator.Create();
			}

			Descriptors.ForEach(x => x.InitializeAllBytes());
		}
Exemplo n.º 2
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();
			}
		}