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