View Javadoc
1   package org.opentrafficsim.water.network.infra;
2   
3   import org.djunits.value.vdouble.scalar.Duration;
4   import org.djunits.value.vdouble.scalar.Length;
5   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
6   import org.opentrafficsim.water.network.Waterway;
7   import org.opentrafficsim.water.network.WaterwayLocation;
8   
9   /**
10   * Movable bridge which can cause delay.
11   * <p>
12   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * <p>
16   * Based on software from the IDVV project, which is Copyright (c) 2013 Rijkswaterstaat - Dienst Water, Verkeer en Leefomgeving
17   * and licensed without restrictions to Delft University of Technology, including the right to sub-license sources and derived
18   * products to third parties.
19   * </p>
20   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
21   * initial version Nov 6, 2016 <br>
22   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
23   */
24  public class MovableBridge extends FixedBridge implements OperatedObstacle
25  {
26      /** */
27      private static final long serialVersionUID = 1L;
28  
29      /** the simulator to schedule on. */
30      private OTSDEVSSimulatorInterface simulator;
31  
32      /** hours per day. */
33      private int operationHoursPerDay;
34  
35      /** days per week. */
36      private int operationDaysPerWeek;
37  
38      /** max height when bridge is closed. */
39      private Length maxHeightClosed;
40  
41      /** max height when bridge is opened. */
42      private Length maxHeightOpened;
43  
44      /** average waiting time. */
45      private Duration waitingTime;
46  
47      /**
48       * @param simulator the simulator to schedule on
49       * @param name the name of the bridge
50       * @param waterwayLocation the location along a waterway
51       * @param operationHoursPerDay hours per day operated
52       * @param operationDaysPerWeek days per week operated
53       * @param maxHeightClosed max height when bridge is closed
54       * @param maxHeightOpened max height when bridge is opened
55       */
56      public MovableBridge(final OTSDEVSSimulatorInterface simulator, final String name, final WaterwayLocation waterwayLocation,
57              final int operationHoursPerDay, final int operationDaysPerWeek, final Length maxHeightClosed,
58              final Length maxHeightOpened)
59      {
60          super(name, waterwayLocation, maxHeightOpened);
61          this.simulator = simulator;
62          this.operationHoursPerDay = operationHoursPerDay;
63          this.operationDaysPerWeek = operationDaysPerWeek;
64          this.maxHeightClosed = maxHeightClosed;
65          this.maxHeightOpened = maxHeightOpened;
66  
67          // this.waitingTime = GlobalIDVV.theModel.getNumberParameter("WTBR") / 60.0;
68          // if (this.operationHoursPerDay < 18)
69          // this.waitingTime *= 2.0;
70          // else if (this.operationHoursPerDay < 24)
71          // this.waitingTime *= 1.5;
72      }
73  
74      /**
75       * @param simulator the simulator to schedule on
76       * @param name the name of the bridge
77       * @param waterway the waterway
78       * @param distance the distance along the waterway in the design direction
79       * @param operationHoursPerDay hours per day operated
80       * @param operationDaysPerWeek days per week operated
81       * @param maxHeightClosed max height when bridge is closed
82       * @param maxHeightOpened max height when bridge is opened
83       */
84      @SuppressWarnings("checkstyle:parameternumber")
85      public MovableBridge(final OTSDEVSSimulatorInterface simulator, final String name, final Waterway waterway,
86              final Length distance, final int operationHoursPerDay, final int operationDaysPerWeek, final Length maxHeightClosed,
87              final Length maxHeightOpened)
88      {
89          this(simulator, name, new WaterwayLocation(waterway, distance), operationHoursPerDay, operationDaysPerWeek,
90                  maxHeightClosed, maxHeightOpened);
91      }
92  
93      /**
94       * @return an estimate of the delay for opening the bridge
95       */
96      public final Duration estimateOpeningDelay()
97      {
98          return this.waitingTime;
99      }
100 
101     /**
102      * @return an estimate of the delay for opening the bridge
103      */
104     public final Duration drawOpeningDelay()
105     {
106         return this.waitingTime;
107     }
108 
109     /** {@inheritDoc} */
110     @Override
111     public final int getOperationHoursPerDay()
112     {
113         return this.operationHoursPerDay;
114     }
115 
116     /** {@inheritDoc} */
117     @Override
118     public final int getOperationDaysPerWeek()
119     {
120         return this.operationDaysPerWeek;
121     }
122 
123     /**
124      * @return maxHeightClosed
125      */
126     public final Length getMaxHeightClosed()
127     {
128         return this.maxHeightClosed;
129     }
130 
131     /**
132      * @return maxHeightOpened
133      */
134     public final Length getMaxHeightOpened()
135     {
136         return this.maxHeightOpened;
137     }
138 
139     /** {@inheritDoc} */
140     @Override
141     public final OTSDEVSSimulatorInterface getSimulator()
142     {
143         return this.simulator;
144     }
145 
146     /** {@inheritDoc} */
147     @Override
148     @SuppressWarnings("checkstyle:designforextension")
149     public String toString()
150     {
151         return "Movable Bridge " + this.getName() + " at " + this.getWaterwayLocation();
152     }
153 
154 }