// Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// 	if (runConfig == null) {
// 		throw new IllegalStateException("Initialize first");
// 	}
// 	return runConfig;
// }
// 
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
// 
// 	protected Dimmer dimmer;
// 
// 	void setDimmer(Dimmer dimmer) {
// 		this.dimmer = dimmer;
// 	}
// }
// 
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
// 
// 	UdpChannelCommand command();
// 
// 	void callBack(String s) throws Exception;
// }
// 
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
// 
// 	VENTILATIE("VENT"),
// 	HEATING_ENABLED("HEATING_ENABLED"),
// 	TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// 	TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// 	TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// 	TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// 	TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// 	TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
// 
// 	private String command;
// 
// 	UdpChannelCommand(String s) {
// 		this.command = s;
// 	}
// 
// 	public static UdpChannelCommand fromString(String s) {
// 		for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// 			if (udpChannelCommand.command.equals(s)) {
// 				return udpChannelCommand;
// 			}
// 		}
// 		throw new IllegalStateException("Unknown command " + s);
// 	}
// 
// 	public static class Constants {
// 		public static final String TEMPERATURE = "TEMP";
// 	}
// 
// }
// 
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
// 
// 	GELIJKVLOERS("Gelijkvloers"),
// 	NACHTHAL("Nachthal"),
// 	BADKAMER("Badkamer"),
// 	DRESSING("Dressing"),
// 	SK1("Slaapkamer1"),
// 	SK2("Slaapkamer2"),
// 	SK3("Slaapkamer3"),
// 	KEUKEN("Keuken"),
// 	EETHOEK("Eethoek"),
// 	INKOMHAL("Inkomhal"),
// 	BERGING("Berging"),
// 	VOORDEUR("Inkom buiten"),
// 	GANG("Gang"),
// 	WC("WC"),
// 	ZITHOEK("Zithoek"),
// 	GARAGE("Garage"),
// 	LZG("LZG"),
// 	AG("AG"),
// 	RZG("RZG"),
// 	VG("VG");
// 
// 	private String dimmerDescription;
// 
// 	LocationId(final String dimmerDescription) {
// 		this.dimmerDescription = dimmerDescription;
// 	}
// }


import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;

	private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();

	private final RoomTemperature roomTemperature;

	public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
		this.roomId = roomId;
		this.heatingController = heatingController;
		this.currentTemperatureGa = currentTemperatureGa;
		this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
		this.roomTemperature = new RoomTemperature(roomId);
	}

	public void start() {
		getInstance().addUdpChannelCallback(new UdpChannelCallback() {
			@Override
			public UdpChannelCommand command() {
				return desiredTempCommand;
			}

			@Override
			public void callBack(final String desiredTemp) throws Exception {
				logger.debug("Receiving desired temperature " + desiredTemp + "for room " + roomId);
				synchronized (roomTemperature) {
					roomTemperature.updateDesiredTemp(desiredTemp);
					processTemperatureChange();
				}
			}
		});

// Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// 	if (runConfig == null) {
// 		throw new IllegalStateException("Initialize first");
// 	}
// 	return runConfig;
// }
// 
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
// 
// 	protected Dimmer dimmer;
// 
// 	void setDimmer(Dimmer dimmer) {
// 		this.dimmer = dimmer;
// 	}
// }
// 
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
// 
// 	UdpChannelCommand command();
// 
// 	void callBack(String s) throws Exception;
// }
// 
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
// 
// 	VENTILATIE("VENT"),
// 	HEATING_ENABLED("HEATING_ENABLED"),
// 	TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// 	TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// 	TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// 	TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// 	TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// 	TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
// 
// 	private String command;
// 
// 	UdpChannelCommand(String s) {
// 		this.command = s;
// 	}
// 
// 	public static UdpChannelCommand fromString(String s) {
// 		for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// 			if (udpChannelCommand.command.equals(s)) {
// 				return udpChannelCommand;
// 			}
// 		}
// 		throw new IllegalStateException("Unknown command " + s);
// 	}
// 
// 	public static class Constants {
// 		public static final String TEMPERATURE = "TEMP";
// 	}
// 
// }
// 
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
// 
// 	GELIJKVLOERS("Gelijkvloers"),
// 	NACHTHAL("Nachthal"),
// 	BADKAMER("Badkamer"),
// 	DRESSING("Dressing"),
// 	SK1("Slaapkamer1"),
// 	SK2("Slaapkamer2"),
// 	SK3("Slaapkamer3"),
// 	KEUKEN("Keuken"),
// 	EETHOEK("Eethoek"),
// 	INKOMHAL("Inkomhal"),
// 	BERGING("Berging"),
// 	VOORDEUR("Inkom buiten"),
// 	GANG("Gang"),
// 	WC("WC"),
// 	ZITHOEK("Zithoek"),
// 	GARAGE("Garage"),
// 	LZG("LZG"),
// 	AG("AG"),
// 	RZG("RZG"),
// 	VG("VG");
// 
// 	private String dimmerDescription;
// 
// 	LocationId(final String dimmerDescription) {
// 		this.dimmerDescription = dimmerDescription;
// 	}
// }


// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;


	private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();

	private final RoomTemperature roomTemperature;

	public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
		this.roomId = roomId;
		this.heatingController = heatingController;
		this.currentTemperatureGa = currentTemperatureGa;
		this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
		this.roomTemperature = new RoomTemperature(roomId);
	}

	public void start() {
		getInstance().addUdpChannelCallback(new UdpChannelCallback() {
			@Override
			public UdpChannelCommand command() {
				return desiredTempCommand;
			}

			@Override
			public void callBack(final String desiredTemp) throws Exception {
				logger.debug("Receiving desired temperature " + desiredTemp + "for room " + roomId);
				synchronized (roomTemperature) {
					roomTemperature.updateDesiredTemp(desiredTemp);
					processTemperatureChange();
				}
			}
		});

		getInstance().getKnxConnectionFactory().addProcessListener(new AbstractDimmerProcessListener() {