private DashboardSnapshotProviderOutput.ZoneSnapshot BuildZoneSnapshot(ZoneState zoneState, ControllerState state) { var zoneSnapshot = new DashboardSnapshotProviderOutput.ZoneSnapshot { Id = zoneState.Zone.ZoneId, Name = zoneState.Zone.Name, NameDashboardEn = zoneState.Zone.NameDashboardEn, ControlMode = zoneState.ControlMode, OutputState = zoneState.EnableOutputs }; if (zoneState.Zone.IsTemperatureControlled()) { zoneSnapshot.TemperatureControl = new DashboardSnapshotProviderOutput.ZoneSnapshot.TemperatureControlSnapshot { HighSetPoint = zoneState.Zone.TemperatureControlledZone.HighSetPoint, LowSetPoint = zoneState.Zone.TemperatureControlledZone.LowSetPoint, Temperature = _zoneTemperatureProvider.Provide(zoneState.Zone.ZoneId, state)?.AverageTemperature, ScheduleSetPoint = zoneState.ScheduleState.DesiredTemperature ?? 0 }; } else { zoneSnapshot.OnOffControl = new DashboardSnapshotProviderOutput.ZoneSnapshot.OnOffControlSnapshot { ScheduleState = zoneState.ScheduleState.HeatingEnabled ?? false }; } return(zoneSnapshot); }
private bool ProcessTemperatureBasedOutput(ControllerState controllerState, ZoneState zoneState) { var temperatureData = _zoneTemperatureProvider.Provide(zoneState.Zone.ZoneId, controllerState); if (temperatureData == null) { Logger.Warning(Localization.NotificationMessage.NoTemperatureData.FormatWith(zoneState.Zone.TemperatureControlledZone.TemperatureSensorId, zoneState.Zone.Name)); return(false); } var outputState = zoneState.EnableOutputs; if (DateTime.UtcNow - temperatureData.LastRead < TimeSpan.FromMinutes(5)) { var setPoint = 0f; switch (zoneState.ControlMode) { case ZoneControlMode.LowOrDisabled: setPoint = zoneState.Zone.TemperatureControlledZone.LowSetPoint; break; case ZoneControlMode.HighOrEnabled: setPoint = zoneState.Zone.TemperatureControlledZone.HighSetPoint; break; case ZoneControlMode.Schedule: if (zoneState.ScheduleState.DesiredTemperature.HasValue) { setPoint = zoneState.ScheduleState.DesiredTemperature.Value; } break; } outputState = _hysteresisProcessor.Process(temperatureData.AverageTemperature, outputState, setPoint, zoneState.Zone.TemperatureControlledZone.Hysteresis); } else { outputState = false; Logger.Warning(Localization.NotificationMessage.TemperatureValueTooOld.FormatWith(zoneState.Zone.Name)); } return(outputState); }
private ZoneDetailsProviderResult.TemperatureSettings GetTemperatureSettings(ZoneState zone, ControllerState controllerState) { if (!zone.Zone.IsTemperatureControlled()) { return(null); } var temperatureControlledZone = zone.Zone.TemperatureControlledZone; return(new ZoneDetailsProviderResult.TemperatureSettings { HightSetPoint = temperatureControlledZone.HighSetPoint, LowSetPoint = temperatureControlledZone.LowSetPoint, Hysteresis = temperatureControlledZone.Hysteresis, PlotData = _zoneTemperatureProvider.Provide(zone.Zone.ZoneId, controllerState) .HistoricalReads .ToDictionary(x => x.Item1, x => x.Item2) }); }