1 /**
2 *
3 */
4 package org.opentrafficsim.water.demand;
5
6 import java.io.Serializable;
7 import java.util.LinkedHashSet;
8 import java.util.Set;
9
10 import org.opentrafficsim.water.Dynamic;
11 import org.opentrafficsim.water.network.WaterwayLocation;
12 import org.opentrafficsim.water.transport.ShipType;
13
14 import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
15
16 /**
17 * Describes the demand from locations along waterways to other locations.
18 * <p>
19 * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20 * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
21 * </p>
22 * <p>
23 * Based on software from the IDVV project, which is Copyright (c) 2013 Rijkswaterstaat - Dienst Water, Verkeer en Leefomgeving
24 * and licensed without restrictions to Delft University of Technology, including the right to sub-license sources and derived
25 * products to third parties.
26 * </p>
27 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
28 * initial version Nov 6, 2016 <br>
29 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
30 */
31 public class OtherDemand implements Dynamic, Serializable
32 {
33 /** */
34 private static final long serialVersionUID = 1L;
35
36 /** the simulator to schedule on. */
37 private DEVSSimulatorInterface.TimeDoubleUnit simulator;
38
39 /** the demand from and to locations. */
40 private Set<OtherDemandCell> otherDemandSet = new LinkedHashSet<OtherDemandCell>();
41
42 /**
43 * @param simulator DEVSSimulatorInterface.TimeDoubleUnit; the finulator
44 */
45 public OtherDemand(final DEVSSimulatorInterface.TimeDoubleUnit simulator)
46 {
47 this.simulator = simulator;
48 }
49
50 /**
51 * @return the demandCells
52 */
53 public final Set<OtherDemandCell> getOtherDemandSet()
54 {
55 return this.otherDemandSet;
56 }
57
58 /**
59 * add a cell to the demandmap.
60 * @param otherDemandCell OtherDemandCell; demand to add
61 */
62 public final void addDemand(final OtherDemandCell otherDemandCell)
63 {
64 this.otherDemandSet.add(otherDemandCell);
65 }
66
67 /**
68 * add a cell to the demand map.
69 * @param origin WaterwayLocation; the origin location
70 * @param destination WaterwayLocation; the destination location
71 * @param annualMoves int; the annual number of moves
72 * @param shipType ShipType; the type of ship to use
73 */
74 public final void addDemand(final WaterwayLocationayLocation.html#WaterwayLocation">WaterwayLocation origin, final WaterwayLocation destination, final int annualMoves,
75 final ShipType shipType)
76 {
77 OtherDemandCell otherDemandCell = new OtherDemandCell(origin, destination, annualMoves, shipType);
78 addDemand(otherDemandCell);
79 }
80
81 /**
82 * A cell of demand from a location along a waterway to another location. <br>
83 * Copyright (c) 2012 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
84 * for project information <a href="http://www.simulation.tudelft.nl/"> www.simulation.tudelft.nl</a>. The source code and
85 * binary code of this software is proprietary information of Delft University of Technology.
86 * @version Sep 29, 2012 <br>
87 * @author <a href="http://tudelft.nl/averbraeck">Alexander Verbraeck </a>
88 */
89 public class OtherDemandCell
90 {
91 /** origin. */
92 private WaterwayLocation origin;
93
94 /** destination. */
95 private WaterwayLocation destination;
96
97 /** number of moves per year. */
98 private int annualMoves;
99
100 /** type of ship. */
101 private ShipType shipType;
102
103 /**
104 * @param origin WaterwayLocation; the origin location
105 * @param destination WaterwayLocation; the destination location
106 * @param annualMoves int; the annual number of moves
107 * @param shipType ShipType; the type of ship to use
108 */
109 public OtherDemandCell(final WaterwayLocationayLocation.html#WaterwayLocation">WaterwayLocation origin, final WaterwayLocation destination, final int annualMoves,
110 final ShipType shipType)
111 {
112 this.origin = origin;
113 this.destination = destination;
114 this.annualMoves = annualMoves;
115 this.shipType = shipType;
116 }
117
118 /**
119 * @return the origin
120 */
121 public final WaterwayLocation getOrigin()
122 {
123 return this.origin;
124 }
125
126 /**
127 * @return the destination
128 */
129 public final WaterwayLocation getDestination()
130 {
131 return this.destination;
132 }
133
134 /**
135 * @return the annualMoves
136 */
137 public final int getAnnualMoves()
138 {
139 return this.annualMoves;
140 }
141
142 /**
143 * @return the shipType
144 */
145 public final ShipType getShipType()
146 {
147 return this.shipType;
148 }
149
150 }
151
152 /** {@inheritDoc} */
153 @Override
154 public final DEVSSimulatorInterface.TimeDoubleUnit getSimulator()
155 {
156 return this.simulator;
157 }
158 }