EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
Interconnector.java
1 /*******************************************************************************
2  * Copyright 2012 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.domain.technology;
17 
18 import java.util.Set;
19 
20 import org.neo4j.graphdb.Direction;
21 import org.springframework.data.neo4j.annotation.NodeEntity;
22 import org.springframework.data.neo4j.annotation.RelatedTo;
23 import org.springframework.transaction.annotation.Transactional;
24 
26 
27 @NodeEntity
28 public class Interconnector {
29 
30  @RelatedTo(type = "INTERCONNECTIONS", elementClass = PowerGridNode.class, direction = Direction.OUTGOING)
31  // TODO: Limit the set to the size of two.
32  private Set<PowerGridNode> connections;
33 
34  @RelatedTo(type = "INTERCONNECTOR_CAPACITY_TREND", elementClass = TimeSeriesImpl.class, direction = Direction.OUTGOING)
35  private TimeSeriesImpl interconnectorCapacityTrend;
36 
37  public Set<PowerGridNode> getConnections() {
38  return connections;
39  }
40 
41  public void setConnections(Set<PowerGridNode> connections) {
42  this.connections = connections;
43  }
44 
45  public void setInterconnectorCapacityTrend(TimeSeriesImpl interconnectorCapacityTrend) {
46  this.interconnectorCapacityTrend = interconnectorCapacityTrend;
47  }
48 
49  public TimeSeriesImpl getInterconnectorCapacityTrend() {
50  return this.interconnectorCapacityTrend;
51  }
52 
53  public double getCapacity(long time) {
54  return getInterconnectorCapacityTrend().getValue(time);
55  }
56 
57 
58  public void setCapacity(long time, double capacity) {
59  interconnectorCapacityTrend.setValue(time, capacity);
60  }
61 
62  @Transactional
63  public void updateCapacity(long time, double capacity) {
64  setCapacity(time, capacity);
65  }
66 
67  @Transactional
68  public void setCapacity(double capacity) {
69  TimeSeriesImpl interconnectorCapacityTrend = new TimeSeriesImpl().persist();
70  interconnectorCapacityTrend.setStartingYear(0);
71  double[] interconnectorCapacityTrendTimeSeries = new double[300];
72  for (int i = 0; i < interconnectorCapacityTrendTimeSeries.length; i++) {
73  interconnectorCapacityTrendTimeSeries[i] = capacity;
74  }
75  interconnectorCapacityTrend.setTimeSeries(interconnectorCapacityTrendTimeSeries);
76  setInterconnectorCapacityTrend(interconnectorCapacityTrend);
77  }
78 
79 }