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.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-2019 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 HashSet<OtherDemandCell>();
41  
42      /**
43       * @param simulator DEVSSimulatorInterface.TimeDoubleUnit; the finulator
44       */
45      public OtherDemand(final DEVSSimulatorInterface.TimeDoubleUnit simulator)
46      {
47          super();
48          this.simulator = simulator;
49      }
50  
51      /**
52       * @return the demandCells
53       */
54      public final Set<OtherDemandCell> getOtherDemandSet()
55      {
56          return this.otherDemandSet;
57      }
58  
59      /**
60       * add a cell to the demandmap.
61       * @param otherDemandCell OtherDemandCell; demand to add
62       */
63      public final void addDemand(final OtherDemandCell otherDemandCell)
64      {
65          this.otherDemandSet.add(otherDemandCell);
66      }
67  
68      /**
69       * add a cell to the demand map.
70       * @param origin WaterwayLocation; the origin location
71       * @param destination WaterwayLocation; the destination location
72       * @param annualMoves int; the annual number of moves
73       * @param shipType ShipType; the type of ship to use
74       */
75      public final void addDemand(final WaterwayLocation origin, final WaterwayLocation destination, final int annualMoves,
76              final ShipType shipType)
77      {
78          OtherDemandCell otherDemandCell = new OtherDemandCell(origin, destination, annualMoves, shipType);
79          addDemand(otherDemandCell);
80      }
81  
82      /**
83       * A cell of demand from a location along a waterway to another location. <br>
84       * Copyright (c) 2012 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
85       * for project information <a href="http://www.simulation.tudelft.nl/"> www.simulation.tudelft.nl</a>. The source code and
86       * binary code of this software is proprietary information of Delft University of Technology.
87       * @version Sep 29, 2012 <br>
88       * @author <a href="http://tudelft.nl/averbraeck">Alexander Verbraeck </a>
89       */
90      public class OtherDemandCell
91      {
92          /** origin. */
93          private WaterwayLocation origin;
94  
95          /** destination. */
96          private WaterwayLocation destination;
97  
98          /** number of moves per year. */
99          private int annualMoves;
100 
101         /** type of ship. */
102         private ShipType shipType;
103 
104         /**
105          * @param origin WaterwayLocation; the origin location
106          * @param destination WaterwayLocation; the destination location
107          * @param annualMoves int; the annual number of moves
108          * @param shipType ShipType; the type of ship to use
109          */
110         public OtherDemandCell(final WaterwayLocation origin, final WaterwayLocation destination, final int annualMoves,
111                 final ShipType shipType)
112         {
113             this.origin = origin;
114             this.destination = destination;
115             this.annualMoves = annualMoves;
116             this.shipType = shipType;
117         }
118 
119         /**
120          * @return the origin
121          */
122         public final WaterwayLocation getOrigin()
123         {
124             return this.origin;
125         }
126 
127         /**
128          * @return the destination
129          */
130         public final WaterwayLocation getDestination()
131         {
132             return this.destination;
133         }
134 
135         /**
136          * @return the annualMoves
137          */
138         public final int getAnnualMoves()
139         {
140             return this.annualMoves;
141         }
142 
143         /**
144          * @return the shipType
145          */
146         public final ShipType getShipType()
147         {
148             return this.shipType;
149         }
150 
151     }
152 
153     /** {@inheritDoc} */
154     @Override
155     public final DEVSSimulatorInterface.TimeDoubleUnit getSimulator()
156     {
157         return this.simulator;
158     }
159 }