Skip to content

Commit

Permalink
Renamed classes for consistency (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Apr 9, 2024
1 parent f3060dd commit c3c4247
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.sf.dz3r.runtime.config.model;

import net.sf.dz3r.common.HCCObjects;
import net.sf.dz3r.device.actuator.economizer.EconomizerConfig;
import net.sf.dz3r.device.actuator.economizer.EconomizerContext;
import net.sf.dz3r.device.actuator.economizer.EconomizerSettings;
import net.sf.dz3r.model.Range;
import net.sf.dz3r.model.Thermostat;
import net.sf.dz3r.model.Zone;
Expand Down Expand Up @@ -49,7 +49,7 @@ private Map.Entry<String, Zone> createZone(ZoneConfig cf) {
return new ImmutablePair<>(cf.id(), zone);
}

private EconomizerContext createEconomizer(String zoneName, EconomizerConfig cf) {
private EconomizerContext createEconomizer(String zoneName, net.sf.dz3r.runtime.config.model.EconomizerConfig cf) {

if (cf == null) {
return null;
Expand All @@ -76,7 +76,7 @@ private EconomizerContext createEconomizer(String zoneName, EconomizerConfig cf)
}

return new EconomizerContext(
new EconomizerSettings(
new EconomizerConfig(
cf.mode(),
cf.settings().changeoverDelta(),
cf.settings().targetTemperature(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class AbstractEconomizer implements SignalProcessor<Double, Doub

public final String name;

private EconomizerSettings settings;
private EconomizerConfig settings;

private final HvacDevice device;

Expand Down Expand Up @@ -78,7 +78,7 @@ public abstract class AbstractEconomizer implements SignalProcessor<Double, Doub
protected AbstractEconomizer(
Clock clock,
String name,
EconomizerSettings settings,
EconomizerConfig settings,
HvacDevice device,
Duration timeout) {

Expand All @@ -101,7 +101,7 @@ protected AbstractEconomizer(
.subscribe(s -> logger.debug("{}: HVAC device state/done: {}", getAddress(), s));

this.economizerStatus = new EconomizerStatus(
new EconomizerTransientSettings(settings),
new EconomizerSettings(settings),
null, 0, false, null);

// Don't forget to connect fluxes; this can only be done in subclasses after all the
Expand All @@ -119,7 +119,7 @@ private void checkModes(HvacMode mode, HvacDevice device) {
}
}

public void setSettings(EconomizerSettings settings) {
public void setSettings(EconomizerConfig settings) {
if (settings == null) {
throw new IllegalArgumentException("settings can't be null");
}
Expand Down Expand Up @@ -206,7 +206,7 @@ private Boolean recordDeviceState(Signal<Boolean, ProcessController.Status<Doubl
var demand = stateSignal.payload == null ? 0 : stateSignal.payload.signal;

economizerStatus = new EconomizerStatus(
new EconomizerTransientSettings(settings),
new EconomizerSettings(settings),
sample,
demand,
stateSignal.getValue(),
Expand Down Expand Up @@ -356,7 +356,7 @@ protected double computeCombined(Double indoorTemperature, Double ambientTempera
}

/**
* Get the {@link EconomizerSettings#changeoverDelta ambient} delta signal.
* Get the {@link EconomizerConfig#changeoverDelta ambient} delta signal.
*
* @return Positive value indicates demand, negative indicates lack thereof, regardless of mode.
*/
Expand All @@ -368,7 +368,7 @@ protected double computeCombined(Double indoorTemperature, Double ambientTempera
}

/**
* Get the {@link EconomizerSettings#targetTemperature} delta signal.
* Get the {@link EconomizerConfig#targetTemperature} delta signal.
*
* @return Positive value indicates demand, negative indicates lack thereof, regardless of mode.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package net.sf.dz3r.device.actuator.economizer;

import net.sf.dz3r.model.HvacMode;

/**
* Full set of economizer settings, both permanent and user changeable.
*
* @author Copyright &copy; <a href="mailto:[email protected]">Vadim Tkachenko</a> 2001-2024
*/
public class EconomizerConfig extends EconomizerSettings {

/**
* Which mode this device is active in. This mode may be different from the zone mode; it is the user's
* responsibility to make sure the system doesn't enter a runaway loop.
*/
public final HvacMode mode;

public final Double P;

public final Double I;

public final Double saturationLimit;

/**
* All except {@code enabled} argument constructor (defaults to {@code true}, for common sense.
*
* @param keepHvacOn See {@link #keepHvacOn}. Think twice before setting this to {@code true}.
* @param P Internal {@link net.sf.dz3r.controller.pid.PidController} P component.
* @param I Internal {@link net.sf.dz3r.controller.pid.PidController} I component.
* @param saturationLimit Internal {@link net.sf.dz3r.controller.pid.PidController} saturation limit.
*/
public EconomizerConfig(HvacMode mode,
Double changeoverDelta, Double targetTemperature,
Boolean keepHvacOn,
Double P, Double I, Double saturationLimit) {
this(mode, true, changeoverDelta, targetTemperature, keepHvacOn, P, I, saturationLimit);
}

/**
* All argument constructor.
*
* @param keepHvacOn See {@link #keepHvacOn}. Think twice before setting this to {@code true}.
* @param P Internal {@link net.sf.dz3r.controller.pid.PidController} P component.
* @param I Internal {@link net.sf.dz3r.controller.pid.PidController} I component.
* @param saturationLimit Internal {@link net.sf.dz3r.controller.pid.PidController} saturation limit.
*/
public EconomizerConfig(HvacMode mode,
Boolean enabled,
Double changeoverDelta, Double targetTemperature,
Boolean keepHvacOn,
Double P, Double I, Double saturationLimit) {
super(enabled, changeoverDelta, targetTemperature, keepHvacOn);

this.mode = mode;

this.P = P;
this.I = I;
this.saturationLimit = saturationLimit;

checkArgs();
}

protected void checkArgs() {

if (mode == null) {
throw new IllegalArgumentException("mode can't be null");
}

if (changeoverDelta < 0) {
throw new IllegalArgumentException("changeoverDelta must be non-negative");
}
}

/**
* Merge this instance with an update.
*
* @param from Adjustment instance. Non-null values take precedence over this object's values.
*/
public EconomizerConfig merge(EconomizerConfig from) {

return new EconomizerConfig(
from.mode != null ? from.mode : mode,
from.enabled != null ? from.enabled : enabled,
from.changeoverDelta != null ? from.changeoverDelta : changeoverDelta,
from.targetTemperature != null ? from.targetTemperature : targetTemperature,
from.keepHvacOn != null ? from.keepHvacOn : keepHvacOn,
from.P != null ? from.P : P,
from.I != null ? from.I : I,
from.saturationLimit != null ? from.saturationLimit : saturationLimit);
}

@Override
public String toString() {
return "{mode=" + mode
+ ", enabled=" + enabled
+ ", changeoverDelta=" + changeoverDelta
+ ", targetTemperature=" + targetTemperature
+ ", keepHvacOn=" + keepHvacOn
+ ", P=" + P
+ ", I=" + I
+ ", saturationLimit=" + saturationLimit
+ "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import java.time.Duration;

/**
* A bridge between {@link EconomizerSettings}, {@link AbstractEconomizer economizer}, and {@link net.sf.dz3r.model.Zone}.
* A bridge between {@link EconomizerConfig}, {@link AbstractEconomizer economizer}, and {@link net.sf.dz3r.model.Zone}.
*/
public class EconomizerContext {

public final EconomizerSettings settings;
public final EconomizerConfig settings;
public final Flux<Signal<Double, Void>> ambientFlux;
public final HvacDevice device;
public final Duration timeout;

public EconomizerContext(EconomizerSettings settings, Flux<Signal<Double, Void>> ambientFlux, HvacDevice device, Duration timeout) {
public EconomizerContext(EconomizerConfig settings, Flux<Signal<Double, Void>> ambientFlux, HvacDevice device, Duration timeout) {
this.settings = settings;
this.ambientFlux = ambientFlux;
this.device = device;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,104 +1,53 @@
package net.sf.dz3r.device.actuator.economizer;

import net.sf.dz3r.model.HvacMode;

/**
* Full set of economizer settings.
* Set of user changeable economizer settings.
*
* @author Copyright &copy; <a href="mailto:[email protected]">Vadim Tkachenko</a> 2001-2024
*/
public class EconomizerSettings extends EconomizerTransientSettings {
public class EconomizerSettings {

public final Boolean enabled;

/**
* Which mode this device is active in. This mode may be different from the zone mode; it is the user's
* responsibility to make sure the system doesn't enter a runaway loop.
* Temperature difference between indoor and outdoor temperature necessary to turn the device on.
*/
public final HvacMode mode;

public final Double P;

public final Double I;

public final Double saturationLimit;
public final Double changeoverDelta;

/**
* All except {@code enabled} argument constructor (defaults to {@code true}, for common sense.
*
* @param keepHvacOn See {@link #keepHvacOn}. Think twice before setting this to {@code true}.
* @param P Internal {@link net.sf.dz3r.controller.pid.PidController} P component.
* @param I Internal {@link net.sf.dz3r.controller.pid.PidController} I component.
* @param saturationLimit Internal {@link net.sf.dz3r.controller.pid.PidController} saturation limit.
* When this temperature is reached, the device is shut off.
*/
public EconomizerSettings(HvacMode mode,
Double changeoverDelta, Double targetTemperature,
Boolean keepHvacOn,
Double P, Double I, Double saturationLimit) {
this(mode, true, changeoverDelta, targetTemperature, keepHvacOn, P, I, saturationLimit);
}
public final Double targetTemperature;

/**
* All argument constructor.
*
* @param keepHvacOn See {@link #keepHvacOn}. Think twice before setting this to {@code true}.
* @param P Internal {@link net.sf.dz3r.controller.pid.PidController} P component.
* @param I Internal {@link net.sf.dz3r.controller.pid.PidController} I component.
* @param saturationLimit Internal {@link net.sf.dz3r.controller.pid.PidController} saturation limit.
* {@code true} means that turning on the device will NOT turn the HVAC off.
* You probably want to keep this at {@code false}, unless the indoor temperature is measured at HVAC return
* and fresh air is injected into HVAC return.
*/
public EconomizerSettings(HvacMode mode,
Boolean enabled,
Double changeoverDelta, Double targetTemperature,
Boolean keepHvacOn,
Double P, Double I, Double saturationLimit) {
super(enabled, changeoverDelta, targetTemperature, keepHvacOn);

this.mode = mode;
public final Boolean keepHvacOn;

this.P = P;
this.I = I;
this.saturationLimit = saturationLimit;
public EconomizerSettings(Boolean enabled, Double changeoverDelta, Double targetTemperature, Boolean keepHvacOn) {

checkArgs();
this.enabled = enabled;
this.changeoverDelta = changeoverDelta;
this.targetTemperature = targetTemperature;
this.keepHvacOn = keepHvacOn;
}

protected void checkArgs() {

if (mode == null) {
throw new IllegalArgumentException("mode can't be null");
}

if (changeoverDelta < 0) {
throw new IllegalArgumentException("changeoverDelta must be non-negative");
}
}

/**
* Merge this instance with an update.
*
* @param from Adjustment instance. Non-null values take precedence over this object's values.
*/
public EconomizerSettings merge(EconomizerSettings from) {
public EconomizerSettings(EconomizerConfig source) {

return new EconomizerSettings(
from.mode != null ? from.mode : mode,
from.enabled != null ? from.enabled : enabled,
from.changeoverDelta != null ? from.changeoverDelta : changeoverDelta,
from.targetTemperature != null ? from.targetTemperature : targetTemperature,
from.keepHvacOn != null ? from.keepHvacOn : keepHvacOn,
from.P != null ? from.P : P,
from.I != null ? from.I : I,
from.saturationLimit != null ? from.saturationLimit : saturationLimit);
this.enabled = source.enabled;
this.changeoverDelta = source.changeoverDelta;
this.targetTemperature = source.targetTemperature;
this.keepHvacOn = source.keepHvacOn;
}

@Override
public String toString() {
return "{mode=" + mode
+ ", enabled=" + enabled
return "{enabled=" + enabled
+ ", changeoverDelta=" + changeoverDelta
+ ", targetTemperature=" + targetTemperature
+ ", keepHvacOn=" + keepHvacOn
+ ", P=" + P
+ ", I=" + I
+ ", saturationLimit=" + saturationLimit
+ "}";
}
}

This file was deleted.

Loading

0 comments on commit c3c4247

Please sign in to comment.