public GKCallbackResult() { JournalItems = new List<JournalItem>(); GKStates = new GKStates(); }
static void CopyGKStates(GKStates gkStates) { foreach (var remoteDeviceState in gkStates.DeviceStates) { var device = XManager.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 = XManager.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 = XManager.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 = XManager.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 = XManager.Delays.FirstOrDefault(x => x.UID == delayState.UID); if (delay == null) delay = XManager.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 = XManager.Pims.FirstOrDefault(x => x.UID == remotePimState.UID); if (pim == null) pim = XManager.Pims.FirstOrDefault(x => x.PresentationName == remotePimState.PresentationName); if (pim != null) { remotePimState.CopyTo(pim.State); pim.State.OnStateChanged(); } } }
public static GKStates GKGetStates() { var gkStates = new GKStates(); foreach (var device in XManager.Devices) { Watcher.AddObjectStateToGKStates(gkStates, device); } foreach (var zone in XManager.Zones) { Watcher.AddObjectStateToGKStates(gkStates, zone); } foreach (var direction in XManager.Directions) { Watcher.AddObjectStateToGKStates(gkStates, direction); } foreach (var pumpStation in XManager.PumpStations) { Watcher.AddObjectStateToGKStates(gkStates, pumpStation); } foreach (var delay in XManager.Delays) { Watcher.AddObjectStateToGKStates(gkStates, delay); } foreach (var pim in XManager.Pims) { Watcher.AddObjectStateToGKStates(gkStates, pim); } return gkStates; }
public static void AddObjectStateToGKStates(GKStates gkStates, XBase xBase) { if (xBase.State != null) { xBase.BaseState.CopyToXState(xBase.State); if (xBase is XDevice) { gkStates.DeviceStates.RemoveAll(x => x.UID == xBase.BaseUID); gkStates.DeviceStates.Add(xBase.State); } if (xBase is XZone) { gkStates.ZoneStates.Add(xBase.State); } if (xBase is XDirection) { gkStates.DirectionStates.Add(xBase.State); } if (xBase is XPumpStation) { gkStates.PumpStationStates.Add(xBase.State); } if (xBase is XDelay) { xBase.State.PresentationName = xBase.PresentationName; gkStates.DelayStates.Add(xBase.State); } if (xBase is XPim) { xBase.State.PresentationName = xBase.PresentationName; gkStates.PimStates.Add(xBase.State); } } }