1 package org.opentrafficsim.core.gtu;
2
3 import org.opentrafficsim.core.network.Link;
4 import org.opentrafficsim.core.network.OTSNetwork;
5
6 import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
7
8 /**
9 * <p>
10 * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
12 * </p>
13 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
14 * initial version Nov 13, 2015 <br>
15 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
17 */
18 public abstract class AbstractLinkBasedGTU extends AbstractGTU
19 {
20 /** */
21 private static final long serialVersionUID = 20151114L;
22
23 /** The network in which this GTU is (initially) registered. */
24 private OTSNetwork network;
25
26 /**
27 * @param id the id of the GTU
28 * @param gtuType the type of GTU, e.g. TruckType, CarType, BusType
29 * @param simulator the simulator to schedule plan changes on
30 * @param network the network in which this GTU is (initially) registered
31 * @throws GTUException when the construction of the original waiting path fails
32 */
33 @SuppressWarnings("checkstyle:parameternumber")
34 public AbstractLinkBasedGTU(final String id, final GTUType gtuType, final DEVSSimulatorInterface.TimeDoubleUnit simulator,
35 final OTSNetwork network) throws GTUException
36 {
37 super(id, gtuType, simulator, network);
38 this.network = network;
39 }
40
41 /**
42 * @return the network in which the GTU is registered
43 */
44 public final OTSNetwork getNetwork()
45 {
46 return this.network;
47 }
48
49 /**
50 * @param network change the network this GTU is registered in
51 */
52 public final void setNetwork(final OTSNetwork network)
53 {
54 this.network = network;
55 }
56
57 /*
58 * Return the link on which the given position of the GTU currently is. Returns <b>null</b> if the GTU is not on a link with
59 * this position.
60 * @param referencePosition the position type (FRONT, BACK, etc.) for which we want to know the link
61 * @return Link; the link on which the position of the GTU currently is
62 */
63 // TODO public abstract Link getLink(final RelativePosition.TYPE referencePosition);
64
65 /**
66 * Return the link on which the REFERENCE position of the GTU currently is on. Returns <b>null</b> if the GTU is not on a
67 * link with its reference position.
68 * @return Link; the link on which the REFERENCE position of the GTU currently is on
69 */
70 public abstract Link getLink();
71 }