public abstract class AbstractGTU extends EventProducer implements GTU
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_COUNT
aligned schedule count.
|
static boolean |
ALIGNED
aligned or not.
|
protected Historical<OperationalPlan> |
operationalPlan
The current operational plan, which provides a short-term movement over time.
|
listeners
DESTROY_EVENT, INIT_EVENT, MOVE_EVENT
FIRST_POSITION, LAST_POSITION
Constructor and Description |
---|
AbstractGTU(IdGenerator idGenerator,
GTUType gtuType,
OTSSimulatorInterface simulator,
PerceivableContext perceivableContext) |
AbstractGTU(String id,
GTUType gtuType,
OTSSimulatorInterface simulator,
PerceivableContext perceivableContext) |
Modifier and Type | Method and Description |
---|---|
void |
addGtu(GTU gtu)
Adds the provided GTU to this GTU, meaning it moves with this GTU.
|
void |
destroy()
Destructor.
|
boolean |
equals(Object obj) |
Acceleration |
getAcceleration() |
Acceleration |
getAcceleration(Time time) |
Set<GTU> |
getChildren()
Returns the children GTU's.
|
GTUType |
getGTUType() |
String |
getId() |
DirectedPoint |
getLocation() |
Acceleration |
getMaximumAcceleration() |
Acceleration |
getMaximumDeceleration() |
SimEvent<SimTimeDoubleUnit> |
getNextMoveEvent()
Note that destroying the next move event of the GTU can be dangerous!
|
Length |
getOdometer() |
Length |
getOdometer(Time time) |
OperationalPlan |
getOperationalPlan() |
OperationalPlan |
getOperationalPlan(Time time) |
Parameters |
getParameters() |
GTU |
getParent()
Returns the parent GTU, or
null if this GTU has no parent. |
PerceivableContext |
getPerceivableContext() |
RelativePosition |
getReference() |
OTSSimulatorInterface |
getSimulator() |
Speed |
getSpeed() |
Speed |
getSpeed(Time time) |
StrategicalPlanner |
getStrategicalPlanner() |
StrategicalPlanner |
getStrategicalPlanner(Time time) |
int |
hashCode() |
void |
init(StrategicalPlanner strategicalPlanner,
DirectedPoint initialLocation,
Speed initialSpeed)
Initialize the GTU at a location and speed, and give it a mission to fulfill through the strategical planner.
|
protected void |
interruptMove()
Interrupt the move and ask for a new plan.
|
boolean |
isDestroyed()
Returns whether the GTU is destroyed.
|
protected void |
move(DirectedPoint fromLocation)
Move from the current location according to an operational plan to a location that will bring us nearer to reaching the
location provided by the strategical planner.
|
void |
removeGtu(GTU gtu)
Removes the provided GTU from this GTU, meaning it no longer moves with this GTU.
|
void |
setMaximumAcceleration(Acceleration maximumAcceleration) |
void |
setMaximumDeceleration(Acceleration maximumDeceleration) |
void |
setParameters(Parameters parameters) |
void |
setParent(GTU gtu)
Set the parent GTU.
|
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, removeAllListeners, removeAllListeners, removeListener
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getCenter, getContourPoints, getFront, getLength, getMaximumSpeed, getRear, getRelativePositions, getTacticalPlanner, getTacticalPlanner, getWidth
addListener, addListener, addListener, addListener, removeListener
protected final Historical<OperationalPlan> operationalPlan
public static boolean ALIGNED
public static int ALIGN_COUNT
public AbstractGTU(String id, GTUType gtuType, OTSSimulatorInterface simulator, PerceivableContext perceivableContext) throws GTUException
id
- String; the id of the GTUgtuType
- GTUType; the type of GTU, e.g. TruckType, CarType, BusTypesimulator
- OTSSimulatorInterface; the simulator to schedule plan changes onperceivableContext
- PerceivableContext; the perceivable context in which this GTU will be registeredGTUException
- when the preconditions of the constructor are not metpublic AbstractGTU(IdGenerator idGenerator, GTUType gtuType, OTSSimulatorInterface simulator, PerceivableContext perceivableContext) throws GTUException
idGenerator
- IdGenerator; the generator that will produce a unique id of the GTUgtuType
- GTUType; the type of GTU, e.g. TruckType, CarType, BusTypesimulator
- OTSSimulatorInterface; the simulator to schedule plan changes onperceivableContext
- PerceivableContext; the perceivable context in which this GTU will be registeredGTUException
- when the preconditions of the constructor are not metpublic void init(StrategicalPlanner strategicalPlanner, DirectedPoint initialLocation, Speed initialSpeed) throws SimRuntimeException, GTUException
strategicalPlanner
- StrategicalPlanner; the strategical planner responsible for the overall 'mission' of the GTU,
usually indicating where it needs to go. It operates by instantiating tactical planners to do the work.initialLocation
- DirectedPoint; the initial location (and direction) of the GTUinitialSpeed
- Speed; the initial speed of the GTUSimRuntimeException
- when scheduling after the first move failsGTUException
- when the preconditions of the parameters are not met or when the construction of the original
waiting path failspublic void destroy()
protected void move(DirectedPoint fromLocation) throws SimRuntimeException, OperationalPlanException, GTUException, NetworkException, ParameterException
fromLocation
- DirectedPoint; the last known location (initial location, or end location of the previous operational
plan)SimRuntimeException
- when scheduling of the next move failsOperationalPlanException
- when there is a problem creating a good path for the GTUGTUException
- when there is a problem with the state of the GTU when planning a pathNetworkException
- in case of a problem with the network, e.g., a dead end where it is not expectedParameterException
- in there is a parameter problemprotected void interruptMove() throws SimRuntimeException, OperationalPlanException, GTUException, NetworkException, ParameterException
OperationalPlanException
- when there was a problem retrieving the location from the running planSimRuntimeException
- when scheduling of the next move failsOperationalPlanException
- when there is a problem creating a good path for the GTUGTUException
- when there is a problem with the state of the GTU when planning a pathNetworkException
- in case of a problem with the network, e.g., unreachability of a certain pointParameterException
- when there is a problem with a parameterpublic final String getId()
getId
in interface Identifiable
getId
in interface GTU
public GTUType getGTUType()
getGTUType
in interface GTU
public final RelativePosition getReference()
getReference
in interface GTU
public final OTSSimulatorInterface getSimulator()
getSimulator
in interface GTU
public final Parameters getParameters()
getParameters
in interface GTU
public final void setParameters(Parameters parameters)
setParameters
in interface GTU
parameters
- Parameters; parameterspublic StrategicalPlanner getStrategicalPlanner()
getStrategicalPlanner
in interface GTU
public StrategicalPlanner getStrategicalPlanner(Time time)
getStrategicalPlanner
in interface GTU
time
- Time; time to obtain the strategical planner atpublic final OperationalPlan getOperationalPlan()
getOperationalPlan
in interface GTU
public final OperationalPlan getOperationalPlan(Time time)
getOperationalPlan
in interface GTU
time
- Time; time to obtain the operational plan atpublic final Length getOdometer()
getOdometer
in interface GTU
public final Length getOdometer(Time time)
getOdometer
in interface GTU
time
- Time; time to obtain the odometer atpublic final Speed getSpeed()
public final Acceleration getAcceleration()
getAcceleration
in interface GTU
public final Acceleration getAcceleration(Time time)
getAcceleration
in interface GTU
time
- Time; time at which to obtain the accelerationpublic final Acceleration getMaximumAcceleration()
getMaximumAcceleration
in interface GTU
public final void setMaximumAcceleration(Acceleration maximumAcceleration)
maximumAcceleration
- Acceleration; set maximumAccelerationpublic final Acceleration getMaximumDeceleration()
getMaximumDeceleration
in interface GTU
public final void setMaximumDeceleration(Acceleration maximumDeceleration)
maximumDeceleration
- Acceleration; set maximumDeceleration, stored as a negative numberpublic DirectedPoint getLocation()
getLocation
in interface Locatable
public final boolean isDestroyed()
GTU
isDestroyed
in interface GTU
public final PerceivableContext getPerceivableContext()
public void addGtu(GTU gtu) throws GTUException
addGtu
in interface GTU
gtu
- GTU; gtu to enter this GTUGTUException
- if the gtu already has a parentpublic void removeGtu(GTU gtu)
public void setParent(GTU gtu) throws GTUException
setParent
in interface GTU
gtu
- GTU; parent GTU, may be null
GTUException
- if the gtu already has a parentpublic GTU getParent()
null
if this GTU has no parent.public Set<GTU> getChildren()
getChildren
in interface GTU
public final SimEvent<SimTimeDoubleUnit> getNextMoveEvent()
Copyright © 2014–2019 Delft University of Technology. All rights reserved.