Beispiel #1
0
		static void CopyDeviceMeasureParametersStates(GKStates gkStates)
		{
			foreach (var deviceMeasureParameter in gkStates.DeviceMeasureParameters)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == deviceMeasureParameter.DeviceUID);
				if (device != null)
				{
					var diff = device.State.XMeasureParameterValues.Where(p => deviceMeasureParameter.MeasureParameterValues.Any(
						l => p.Name == l.Name && p.StringValue != l.StringValue));

					if (device.State.XMeasureParameterValues.Count != deviceMeasureParameter.MeasureParameterValues.Count || diff.Count() > 0)
					{
						device.State.XMeasureParameterValues = deviceMeasureParameter.MeasureParameterValues;

						if (DeviceParametersUpdaterHub.Instance != null)
							DeviceParametersUpdaterHub.Instance.DeviceParameterUpdate(deviceMeasureParameter);
					}
				}
			}
		}
Beispiel #2
0
		public GKCallbackResult()
		{
			JournalItems = new List<JournalItem>();
			GKStates = new GKStates();
		}
Beispiel #3
0
		static void CopyGKStates(GKStates gkStates)
		{
			foreach (var remoteDeviceState in gkStates.DeviceStates)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == remoteDeviceState.UID);
				if (device != null)
				{
					remoteDeviceState.CopyTo(device.State);
					if (DevicesHub.Instance != null)
					{
						DevicesHub.Instance.DevicesUpdate(device);
					}
				}
			}
			foreach (var remoteZoneState in gkStates.ZoneStates)
			{
				var zone = GKManager.Zones.FirstOrDefault(x => x.UID == remoteZoneState.UID);
				if (zone != null)
				{
					remoteZoneState.CopyTo(zone.State);
					if (FireZonesHub.Instance != null)
					{
						FireZonesHub.Instance.BroadcastFireZone(zone);
					}
				}
			}
			foreach (var remoteDirectionState in gkStates.DirectionStates)
			{
				var direction = GKManager.Directions.FirstOrDefault(x => x.UID == remoteDirectionState.UID);
				if (direction != null)
				{
					remoteDirectionState.CopyTo(direction.State);
					if (DirectionsUpdaterHub.Instance != null)
					{
						DirectionsUpdaterHub.Instance.BroadcastDirection(direction);
					}
				}
			}
			foreach (var remotePumpStationState in gkStates.PumpStationStates)
			{
				var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == remotePumpStationState.UID);
				if (pumpStation != null)
				{
					remotePumpStationState.CopyTo(pumpStation.State);
					if (PumpStationsHub.Instance != null)
						PumpStationsHub.Instance.PumpStationstUpdate(pumpStation);
				}
			}
			foreach (var delayState in gkStates.DelayStates)
			{
				var delay = GKManager.Delays.FirstOrDefault(x => x.UID == delayState.UID);
				if (delay == null)
					delay = GKManager.Delays.FirstOrDefault(x => x.PresentationName == delayState.PresentationName);
				if (delay != null)
				{
					delayState.CopyTo(delay.State);
					if (DelaysUpdaterHub.Instance != null)
						DelaysUpdaterHub.Instance.DelayUpdate(new Delay(delay));
				}
			}
			foreach (var remotePimState in gkStates.PimStates)
			{
				var pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == remotePimState.UID);
				if (pim == null)
					pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.PresentationName == remotePimState.PresentationName);
				if (pim != null)
				{
					remotePimState.CopyTo(pim.State);
				}
			}
			foreach (var mptState in gkStates.MPTStates)
			{
				var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == mptState.UID);
				if (mpt != null)
				{
					mptState.CopyTo(mpt.State);
					if (MptUpdaterHub.Instance != null)
					{
						MptUpdaterHub.Instance.MptUpdate(mpt);
					}
				}
			}
			foreach (var guardZoneState in gkStates.GuardZoneStates)
			{
				var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == guardZoneState.UID);
				if (guardZone != null)
				{
					guardZoneState.CopyTo(guardZone.State);
					if (GuardZonesHub.Instance != null)
						GuardZonesHub.Instance.GuardZoneUpdate(guardZone);
				}
			}
			foreach (var doorState in gkStates.DoorStates)
			{
				var door = GKManager.Doors.FirstOrDefault(x => x.UID == doorState.UID);
				if (door != null)
				{
					doorState.CopyTo(door.State);
					if (DoorsHub.Instance != null)
						DoorsHub.Instance.DoorUpdate(door);
				}
			}
		}
Beispiel #4
0
		void CopyGKStates(GKStates gkStates)
		{
			foreach (var remoteDeviceState in gkStates.DeviceStates)
			{
                var device = GKManager.Devices.FirstOrDefault(x => x.UID == remoteDeviceState.UID);
				if (device != null)
				{
					remoteDeviceState.CopyTo(device.State);
                    device.State.OnStateChanged();
				}
			}
			foreach (var remoteZoneState in gkStates.ZoneStates)
			{
                var zone = GKManager.Zones.FirstOrDefault(x => x.UID == remoteZoneState.UID);
				if (zone != null)
				{
					remoteZoneState.CopyTo(zone.State);
                    zone.State.OnStateChanged();
				}
			}
			foreach (var remoteDirectionState in gkStates.DirectionStates)
			{
                var direction = GKManager.Directions.FirstOrDefault(x => x.UID == remoteDirectionState.UID);
				if (direction != null)
				{
					remoteDirectionState.CopyTo(direction.State);
                    direction.State.OnStateChanged();
				}
			}
			foreach (var remotePumpStationState in gkStates.PumpStationStates)
			{
                var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == remotePumpStationState.UID);
				if (pumpStation != null)
				{
					remotePumpStationState.CopyTo(pumpStation.State);
                    pumpStation.State.OnStateChanged();
				}
			}
			foreach (var delayState in gkStates.DelayStates)
			{
                var delay = GKManager.Delays.FirstOrDefault(x => x.UID == delayState.UID);
				if (delay == null)
                    delay = GKManager.Delays.FirstOrDefault(x => x.PresentationName == delayState.PresentationName);
				if (delay != null)
				{
					delayState.CopyTo(delay.State);
                    delay.State.OnStateChanged();
				}
			}
		}
		void CopyGKStates(GKStates gkStates)
		{
			foreach (var remoteDeviceState in gkStates.DeviceStates)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == remoteDeviceState.UID);
				if (device != null)
				{
					remoteDeviceState.CopyTo(device.State);
					device.State.OnStateChanged();
				}
			}
			foreach (var remoteZoneState in gkStates.ZoneStates)
			{
				var zone = GKManager.Zones.FirstOrDefault(x => x.UID == remoteZoneState.UID);
				if (zone != null)
				{
					remoteZoneState.CopyTo(zone.State);
					zone.State.OnStateChanged();
				}
			}
			foreach (var remoteDirectionState in gkStates.DirectionStates)
			{
				var direction = GKManager.Directions.FirstOrDefault(x => x.UID == remoteDirectionState.UID);
				if (direction != null)
				{
					remoteDirectionState.CopyTo(direction.State);
					direction.State.OnStateChanged();
				}
			}
			foreach (var remotePumpStationState in gkStates.PumpStationStates)
			{
				var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == remotePumpStationState.UID);
				if (pumpStation != null)
				{
					remotePumpStationState.CopyTo(pumpStation.State);
					pumpStation.State.OnStateChanged();
				}
			}
			foreach (var remoteMPTState in gkStates.MPTStates)
			{
				var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == remoteMPTState.UID);
				if (mpt != null)
				{
					remoteMPTState.CopyTo(mpt.State);
					mpt.State.OnStateChanged();
				}
			}
			foreach (var delayState in gkStates.DelayStates)
			{
				var delay = GKManager.Delays.FirstOrDefault(x => x.UID == delayState.UID);
				if (delay != null)
				{
					delayState.CopyTo(delay.State);
					delay.State.OnStateChanged();
				}
				else
				{
					delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.UID == delayState.UID);
					if (delay == null)
						delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.PresentationName == delayState.PresentationName);
					if (delay != null)
					{
						delayState.CopyTo(delay.State);
						delay.State.OnStateChanged();
					}
				}
			}
			foreach (var remotePimState in gkStates.PimStates)
			{
				var pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == remotePimState.UID);
				if (pim == null)
					pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.PresentationName == remotePimState.PresentationName);
				if (pim == null)
					pim = GKManager.GlobalPims.FirstOrDefault(x => x.DeviceUid == remotePimState.ReferenceUid);
				if (pim != null)
				{
					remotePimState.CopyTo(pim.State);
					pim.State.OnStateChanged();
				}
			}
			foreach (var remoteGuardZoneState in gkStates.GuardZoneStates)
			{
				var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == remoteGuardZoneState.UID);
				if (guardZone != null)
				{
					remoteGuardZoneState.CopyTo(guardZone.State);
					guardZone.State.OnStateChanged();
				}
			}
			foreach (var remoteDoorState in gkStates.DoorStates)
			{
				var door = GKManager.Doors.FirstOrDefault(x => x.UID == remoteDoorState.UID);
				if (door != null)
				{
					remoteDoorState.CopyTo(door.State);
					door.State.OnStateChanged();
				}
			}
			foreach (var remoteSKDZoneState in gkStates.SKDZoneStates)
			{
				var skdZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == remoteSKDZoneState.UID);
				if (skdZone != null)
				{
					remoteSKDZoneState.CopyTo(skdZone.State);
					skdZone.State.OnStateChanged();
				}
			}
			foreach (var deviceMeasureParameter in gkStates.DeviceMeasureParameters)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == deviceMeasureParameter.DeviceUID);
				if (device != null)
				{
					device.State.XMeasureParameterValues = deviceMeasureParameter.MeasureParameterValues;
					device.State.OnMeasureParametersChanged();
				}
			}
		}
Beispiel #6
0
		static void CopyGKStates(GKStates gkStates)
		{
			foreach (var remoteDeviceState in gkStates.DeviceStates)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == remoteDeviceState.UID);
				if (device != null)
				{
					remoteDeviceState.CopyTo(device.State);
					device.State.OnStateChanged();
				}
			}
			foreach (var remoteZoneState in gkStates.ZoneStates)
			{
				var zone = GKManager.Zones.FirstOrDefault(x => x.UID == remoteZoneState.UID);
				if (zone != null)
				{
					remoteZoneState.CopyTo(zone.State);
					zone.State.OnStateChanged();
				}
			}
			foreach (var remoteDirectionState in gkStates.DirectionStates)
			{
				var direction = GKManager.Directions.FirstOrDefault(x => x.UID == remoteDirectionState.UID);
				if (direction != null)
				{
					remoteDirectionState.CopyTo(direction.State);
					direction.State.OnStateChanged();
				}
			}
			foreach (var remotePumpStationState in gkStates.PumpStationStates)
			{
				var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == remotePumpStationState.UID);
				if (pumpStation != null)
				{
					remotePumpStationState.CopyTo(pumpStation.State);
					pumpStation.State.OnStateChanged();
				}
			}
			foreach (var delayState in gkStates.DelayStates)
			{
				var delay = GKManager.Delays.FirstOrDefault(x => x.UID == delayState.UID);
				if (delay == null)
					delay = GKManager.Delays.FirstOrDefault(x => x.PresentationName == delayState.PresentationName);
				if (delay != null)
				{
					delayState.CopyTo(delay.State);
					delay.State.OnStateChanged();

				}
			}
			foreach (var remotePimState in gkStates.PimStates)
			{
				var pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == remotePimState.UID);
				if (pim == null)
					pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.PresentationName == remotePimState.PresentationName);
				if (pim != null)
				{
					remotePimState.CopyTo(pim.State);
					pim.State.OnStateChanged();
				}
			}
			foreach (var mptState in gkStates.MPTStates)
			{
				var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == mptState.UID);
				if (mpt != null)
				{
					mptState.CopyTo(mpt.State);
					mpt.State.OnStateChanged();
				}
			}
			foreach (var guardZoneState in gkStates.GuardZoneStates)
			{
				var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == guardZoneState.UID);
				if (guardZone != null)
				{
					guardZoneState.CopyTo(guardZone.State);
					guardZone.State.OnStateChanged();
				}
			}
			foreach (var doorState in gkStates.DoorStates)
			{
				var door = GKManager.Doors.FirstOrDefault(x => x.UID == doorState.UID);
				if (door != null)
				{
					doorState.CopyTo(door.State);
					door.State.OnStateChanged();
				}
			}
		}
Beispiel #7
0
		public static void AddObjectStateToGKStates(GKStates gkStates, GKBase gkBase, bool overrideExistingDeviceStates = true)
		{
			if (gkBase.State != null)
			{
				gkBase.InternalState.CopyToGKState(gkBase.State);
				if (gkBase is GKDevice)
				{
					if (overrideExistingDeviceStates)
					{
						gkStates.DeviceStates.RemoveAll(x => x.UID == gkBase.UID);
					}
					gkStates.DeviceStates.Add(gkBase.State);

				}
				if (gkBase is GKZone)
				{
					gkStates.ZoneStates.Add(gkBase.State);
				}
				if (gkBase is GKDirection)
				{
					gkStates.DirectionStates.Add(gkBase.State);
				}
				if (gkBase is GKPumpStation)
				{
					gkStates.PumpStationStates.Add(gkBase.State);
				}
				if (gkBase is GKMPT)
				{
					gkStates.MPTStates.Add(gkBase.State);
				}
				if (gkBase is GKDelay)
				{
					gkBase.State.PresentationName = gkBase.PresentationName;
					gkStates.DelayStates.Add(gkBase.State);
				}
				if (gkBase is GKPim)
				{
					gkBase.State.PresentationName = gkBase.PresentationName;
					gkStates.PimStates.Add(gkBase.State);
				}
				if (gkBase is GKGuardZone)
				{
					gkStates.GuardZoneStates.Add(gkBase.State);
				}
				if (gkBase is GKDoor)
				{
					gkStates.DoorStates.Add(gkBase.State);
				}
				if (gkBase is GKSKDZone)
				{
					gkStates.SKDZoneStates.Add(gkBase.State);
				}
			}
		}
Beispiel #8
0
		public static GKStates GKGetStates()
		{
			var gkStates = new GKStates();
			foreach (var device in GKManager.Devices)
			{
				Watcher.AddObjectStateToGKStates(gkStates, device);
			}
			foreach (var zone in GKManager.Zones)
			{
				Watcher.AddObjectStateToGKStates(gkStates, zone);
			}
			foreach (var direction in GKManager.Directions)
			{
				Watcher.AddObjectStateToGKStates(gkStates, direction);
			}
			foreach (var pumpStation in GKManager.PumpStations)
			{
				Watcher.AddObjectStateToGKStates(gkStates, pumpStation);
			}
			foreach (var mpt in GKManager.MPTs)
			{
				Watcher.AddObjectStateToGKStates(gkStates, mpt);
			}
			foreach (var delay in GKManager.Delays)
			{
				Watcher.AddObjectStateToGKStates(gkStates, delay);
			}
			foreach (var delay in GKManager.AutoGeneratedDelays)
			{
				Watcher.AddObjectStateToGKStates(gkStates, delay);
			}
			foreach (var pim in GKManager.AutoGeneratedPims)
			{
				Watcher.AddObjectStateToGKStates(gkStates, pim);
			}
			foreach (var pim in GKManager.GlobalPims)
			{
				Watcher.AddObjectStateToGKStates(gkStates, pim);
			}
			foreach (var guardZone in GKManager.GuardZones)
			{
				Watcher.AddObjectStateToGKStates(gkStates, guardZone);
			}
			foreach (var door in GKManager.Doors)
			{
				Watcher.AddObjectStateToGKStates(gkStates, door);
			}
			foreach (var skdZone in GKManager.SKDZones)
			{
				Watcher.AddObjectStateToGKStates(gkStates, skdZone);
				CalculateSKDZone(skdZone);
				var zoneState = gkStates.SKDZoneStates.FirstOrDefault(x => x.UID == skdZone.UID);
				if (zoneState != null)
				{
					zoneState.StateClasses = skdZone.State.StateClasses;
					zoneState.StateClass = GKStatesHelper.GetMinStateClass(skdZone.State.StateClasses);
				}
			}
			return gkStates;
		}