View Javadoc
1   /**
2    * 
3    */
4   package org.opentrafficsim.water.demand;
5   
6   import java.io.Serializable;
7   import java.util.HashSet;
8   import java.util.Set;
9   
10  import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
11  import org.opentrafficsim.water.Dynamic;
12  import org.opentrafficsim.water.network.WaterwayLocation;
13  import org.opentrafficsim.water.transport.ShipType;
14  
15  /**
16   * Describes the demand from locations along waterways to other locations. 
17   * <p>
18   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
20   * </p>
21   * <p>
22   * Based on software from the IDVV project, which is Copyright (c) 2013 Rijkswaterstaat - Dienst Water, Verkeer en Leefomgeving
23   * and licensed without restrictions to Delft University of Technology, including the right to sub-license sources and derived
24   * products to third parties.
25   * </p>
26   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
27   * initial version Nov 6, 2016 <br>
28   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
29   */
30  public class OtherDemand implements Dynamic, Serializable
31  {
32      /** */
33      private static final long serialVersionUID = 1L;
34  
35      /** the simulator to schedule on. */
36      private OTSDEVSSimulatorInterface simulator;
37  
38      /** the demand from and to locations. */
39      private Set<OtherDemandCell> otherDemandSet = new HashSet<OtherDemandCell>();
40  
41      /**
42       * @param simulator the finulator
43       */
44      public OtherDemand(final OTSDEVSSimulatorInterface simulator)
45      {
46          super();
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 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 the origin location
70       * @param destination the destination location
71       * @param annualMoves the annual number of moves
72       * @param shipType the type of ship to use
73       */
74      public final void addDemand(final 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 the origin location
105          * @param destination the destination location
106          * @param annualMoves the annual number of moves
107          * @param shipType the type of ship to use
108          */
109         public OtherDemandCell(final 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 OTSDEVSSimulatorInterface getSimulator()
155     {
156         return this.simulator;
157     }
158 }