View Javadoc

1   package ch.visnet.heartbreak;
2   
3   import java.util.Calendar;
4   import java.util.HashSet;
5   import java.util.Set;
6   
7   public abstract class AbstractThermalNode implements ThermalNode {
8     static final double C2K = 273;
9     static final int DEFAULT_TIMESTEP = 1000; // ms
10    static final int TIME_RESOLUTION = 10; // ms
11    static final double DEFAULT_TEMP = 20;
12    final Set<NodeConnection> connections;
13    final Calendar timeProvider;
14    double lastComputedTemperature;
15  
16    public AbstractThermalNode(Calendar timeProvider) {
17      this.timeProvider = timeProvider;
18      connections = new HashSet<NodeConnection>();
19    }
20  
21    public void addConnection(NodeConnection connection) {
22      if (!connections.add(connection))
23        throw new RuntimeException("Duplicate definition of node connection.");
24    }
25  
26    double getLastComputedTemperature() { return lastComputedTemperature; }
27    
28    abstract void step(long milis);
29  }