View Javadoc

1   package com.adhoco.controller;
2   
3   import com.adhoco.hardware.osgi.Hardware;
4   
5   /**
6    * Ugly hack in order to access the package-private Heating constructor.
7    * 
8    * @author dlindelof
9    * 
10   */
11  public class HeatingAdapter {
12    private Heating heating;
13    private Hardware hardware;
14    
15    public HeatingAdapter(IRoomController roomController, Hardware hardware) {
16      this.hardware = hardware;
17      heating = new Heating(roomController);
18      heating.addHardware(hardware);
19    }
20  
21    // TODO handle the case when more than one Hardware is used.
22    public double getAverageHeating() {
23      return hardware.getValue().doubleValue();
24    }
25    
26    public void heat() { heating.heat(); }
27    public float getTemperatureSetpoint() { return heating.getTemperatureSetpoint(); }
28    public float getWinterSetpoint() { return heating.getWinterSetpoint(); }
29  }