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