Package jsl.modeling.elements.spatial
Class AbstractMover
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.spatial.SpatialModelElement
-
- jsl.modeling.elements.spatial.AbstractMover
-
- All Implemented Interfaces:
MoverIfc,PositionIfc,SpatialElementIfc,VelocityIfc,ObservableIfc,GetNameIfc,IdentityIfc
- Direct Known Subclasses:
AbstractRG2DMover,Mover,RandomMover,Transporter
public abstract class AbstractMover extends SpatialModelElement implements MoverIfc, VelocityIfc
An AbstractMover implements the MoverIfc and is a model element (SpatialModelElement). It represents an object that can move through a spatial model. It can begin a trip and make movements towards the destination associated with the trip. Each trip can be broken up into a series of movements. Each movement can have a different length and velocity as long as the object eventually completes the trip. It has default behaviors that can be modified by some helper classes. A MovementControllerIfc can be supplied to control the movement within a trip. If a movement controller is supplied, it is responsible for setting the velocity associated with movements. A CollisionDetectorIfc can be supplied to detect collisions while moving. A CollisionHandlerIfc can be supplied to handle (react) to collisions detected while moving A OutsideSpatialModelHandlerIfc can be supplied to handle the situation if the the object attempts to go outside the valid frame of reference associated with its spatial model.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
Fields Modifier and Type Field Description static intMOVE_ENDEDIndicates that a AbstractMover ended a movementstatic intMOVE_STARTEDIndicates that a AbstractMover started a movementprotected CollisionDetectorIfcmyCollisionDetectorDetects the occurrence of collisionsprotected CollisionHandlerIfcmyCollisionHandlerHandles the occurs of collisionsprotected MovementControllerIfcmyMovementControllerControls the movement of this elementprotected OutsideSpatialModelHandlerIfcmyOSMHandlerDetects the occurrence of collisionsprotected SpatialElementIfcmySEDestinationHolds the spatial element of the destination for the current trip (movement) if givenprotected ResponseVariablemyTotalTripDistUsed to record the total distance of all tripsprotected CountermyTripCounterUsed to count the number of trips completed by the moverprotected ResponseVariablemyTripDistUsed to record the distance of each trip madestatic intTRIP_CANCELEDIndicates that a AbstractMover had its trip canceledstatic intTRIP_ENDEDIndicates that a AbstractMover ended a tripstatic intTRIP_STARTEDIndicates that a AbstractMover started a trip-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description AbstractMover(ModelElement parent)Creates a AbstractMover with the default position within its spatial model.AbstractMover(ModelElement parent, java.lang.String name)Creates a AbstractMover with the default position within its spatial model.AbstractMover(ModelElement parent, java.lang.String name, SpatialModel spatialModel)Creates a AbstractMover with the default position within the given spatial model.AbstractMover(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)Creates a AbstractMover at the supplied coordinates within the given spatial model.AbstractMover(ModelElement parent, CoordinateIfc coordinate)Creates a AbstractMover at the supplied coordinate within its spatial model.AbstractMover(ModelElement parent, SpatialElementIfc element)Creates a AbstractMover at the same coordinates as the supplied SpatialElementIfc within its spatial model.AbstractMover(ModelElement parent, SpatialElementIfc element, java.lang.String name)Creates a AbstractMover at the same coordinates as the supplied SpatialElementIfc within its spatial model.AbstractMover(ModelElement parent, SpatialModel spatialModel)Creates a AbstractMover with the default position within the given spatial model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterMovementEnds()Can be used by subclasses to invoke logic after a movement endsprotected voidafterTripEnds()Can be used by subclasses to invoke logic after a trip endsjava.lang.StringasString()Allows sub-classes to provide more detail than toString() to represent the ModelElement as a Stringprotected voidbeforeMovementStarts()Can be used by subclasses to invoke logic prior to the start of a movementprotected voidbeforeTripStarts()Can be used by subclasses to invoke logic prior to the start of a tripvoidcancelTrip()If the mover is on a trip then the movement along the trip is canceled and the mover stays at the position where it is when this method is called.protected booleancheckForCollision()This method can be overridden by subclasses to provide collision detection.protected voidcollectTripStats()A method that can be overridden to collect statistics after a trip is completed, called right before afterTripEnds().protected voidcomputeMovement()This method can be overridden by subclasses to compute the characteristics of a movement.CollisionDetectorIfcgetCollisionDetector()CollisionHandlerIfcgetCollisionHandler()CoordinateIfcgetDestination()Gets a reference to the CoordinateIfc representing the destination of the moverCoordinateIfcgetFuturePosition(double time)Returns a CoordinateIfc that represents the future position of the spatial element at the given time.longgetMaxNumTrips()Gets the number of trips that will trigger the end of the replicationMovementControllerIfcgetMovementController()doublegetMovementDistance()Gets the distance associated with the current movementdoublegetMovementStartTime()Get the time that the current movement starteddoublegetMovementTime()Gets the time length for the current movementdoublegetMovementVelocity()Gets the velocity of the movement that is in progressdoublegetNumTripsCompleted()OutsideSpatialModelHandlerIfcgetOSMHandler()Get the object the handles when the movement takes the element outside the boundaries of the current spatial modeldoublegetVelocity()doublegetVelocityChangeFactor()The addFactor will be used to increase or decrease the velocity returned by getVelocity()RandomIfcgetVelocityInitialRandomSource()RandomIfcgetVelocityRandomSource()protected voidhandleCollision()This method can be overridden by subclasses to provide collision handling.booleanhasNextTrip()A method to determine if another trip should be started This result controls whether or not startNextTrip() is called.protected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.booleanisDefaultNextTripOptionOn()Controls whether or not to automatically start a new trip via startNextTrip()booleanisMoving()Indicates whether or not the element is currently movingbooleanisOnTrip()Indicates whether or not the element is currently on a tripbooleanisTripStatOptionOn()protected voidmoveDeltaX1(double dx)Relative to the current position this method causes the mover to start a trip delta in the x1 directionprotected voidmoveDeltaX1X2(double dx, double dy)Relative to the current position this method causes the mover to start a trip to a position that is delta in the x1 direction and delta in the x2 direction.protected voidmoveDeltaX2(double dy)Relative to the current position this method causes the mover to start a trip delta in the x2 directionprotected voidmoveTo(CoordinateIfc destination)Causes the element to start a trip from its current position to the coordinates specified.protected voidmoveTo(SpatialElementIfc destination)Causes the element to start a trip to the coordinates of the specified SpatialElementIfcprotected voidoutsideSpatialModelHandler(CoordinateIfc coordinate)This method is called if the destination is outside of the element's current spatial model.protected voidreplicationEnded()This method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication() .voidsetCollisionDetector(CollisionDetectorIfc collisionDetector)Sets the collision detector.voidsetCollisionHandler(CollisionHandlerIfc collisionHandler)Sets the collision handler, if null then no collision handling is performedvoidsetDefaultNextTripOption(boolean defaultNextTripFlag)Controls whether or not to automatically start a new trip via startNextTrip()voidsetMaxNumTrips(int maxTrips)Sets the number of trips that will trigger the end of the replicationvoidsetMovement(double velocity, CoordinateIfc position)Sets up the movement before it gets processed.voidsetMovementController(MovementControllerIfc movementController)Set the movement controller.voidsetOSMHandler(OutsideSpatialModelHandlerIfc OSMHandler)Set the handler for taking care of when the element goes outside the boundaries of its spatial model.voidsetVelocityChangeFactor(double factor)The addFactor will be used to increase or decrease the velocity returned by getVelocity()voidsetVelocityInitialRandomSource(RandomIfc source)Sets the random source associated with the velocity used at the beginning of each replicationvoidsetVelocityRandomSource(RandomIfc source)Sets the random source associated with the velocity.protected voidstartNextTrip()Should be used by subclasses to initiate (schedule) the next trip after ending the current trip.protected voidtripCanceled()Can be used by subclasses to invoke logic when a trip is canceledvoidturnOnTripStatistics()Turns on trip statistical collection.protected voidupdatePosition()This method is called at the end of a movement to update the position.-
Methods inherited from class jsl.modeling.elements.spatial.SpatialModelElement
attachPositionObserver, changeSpatialModel, distanceTo, distanceTo, getInitialPosition, getInitialSpatialModel, getModelElement, getPosition, getPreviousPosition, getSpatialElement, initializeSpatialElement, isPositionEqualTo, isPositionEqualTo, removePositionObserver, setCurrentPosition, setInitialPosition, setModelElement, setSpatialElement
-
Methods inherited from class jsl.simulation.SchedulingElement
cancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication, afterReplication_, beforeExperiment, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.GetNameIfc
getName
-
Methods inherited from interface jsl.utilities.IdentityIfc
getId
-
Methods inherited from interface jsl.modeling.elements.spatial.SpatialElementIfc
attachPositionObserver, changeSpatialModel, distanceTo, distanceTo, getInitialPosition, getInitialSpatialModel, getModelElement, getObserverState, getPosition, getPreviousPosition, getSpatialModel, initializeSpatialElement, isPositionEqualTo, isPositionEqualTo, removePositionObserver, setInitialPosition
-
-
-
-
Field Detail
-
TRIP_STARTED
public static final int TRIP_STARTED
Indicates that a AbstractMover started a trip
-
TRIP_ENDED
public static final int TRIP_ENDED
Indicates that a AbstractMover ended a trip
-
TRIP_CANCELED
public static final int TRIP_CANCELED
Indicates that a AbstractMover had its trip canceled
-
MOVE_STARTED
public static final int MOVE_STARTED
Indicates that a AbstractMover started a movement
-
MOVE_ENDED
public static final int MOVE_ENDED
Indicates that a AbstractMover ended a movement
-
myMovementController
protected MovementControllerIfc myMovementController
Controls the movement of this element
-
myCollisionHandler
protected CollisionHandlerIfc myCollisionHandler
Handles the occurs of collisions
-
myCollisionDetector
protected CollisionDetectorIfc myCollisionDetector
Detects the occurrence of collisions
-
myOSMHandler
protected OutsideSpatialModelHandlerIfc myOSMHandler
Detects the occurrence of collisions
-
mySEDestination
protected SpatialElementIfc mySEDestination
Holds the spatial element of the destination for the current trip (movement) if given
-
myTripCounter
protected Counter myTripCounter
Used to count the number of trips completed by the mover
-
myTripDist
protected ResponseVariable myTripDist
Used to record the distance of each trip made
-
myTotalTripDist
protected ResponseVariable myTotalTripDist
Used to record the total distance of all trips
-
-
Constructor Detail
-
AbstractMover
public AbstractMover(ModelElement parent)
Creates a AbstractMover with the default position within its spatial model. The spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-
-
AbstractMover
public AbstractMover(ModelElement parent, java.lang.String name)
Creates a AbstractMover with the default position within its spatial model. The spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-name-
-
AbstractMover
public AbstractMover(ModelElement parent, CoordinateIfc coordinate)
Creates a AbstractMover at the supplied coordinate within its spatial model. The spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-coordinate-
-
AbstractMover
public AbstractMover(ModelElement parent, SpatialElementIfc element)
Creates a AbstractMover at the same coordinates as the supplied SpatialElementIfc within its spatial model. The spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-element-
-
AbstractMover
public AbstractMover(ModelElement parent, SpatialElementIfc element, java.lang.String name)
Creates a AbstractMover at the same coordinates as the supplied SpatialElementIfc within its spatial model. The spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-element-name-
-
AbstractMover
public AbstractMover(ModelElement parent, java.lang.String name, SpatialModel spatialModel)
Creates a AbstractMover with the default position within the given spatial model. If the supplied spatial model is null the spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-name-spatialModel-
-
AbstractMover
public AbstractMover(ModelElement parent, SpatialModel spatialModel)
Creates a AbstractMover with the default position within the given spatial model. If the supplied spatial model is null the spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-spatialModel-
-
AbstractMover
public AbstractMover(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a AbstractMover at the supplied coordinates within the given spatial model. If the supplied spatial model is null the spatial model of the parent is used as the spatial model of this object. If the parent does not have a spatial model (i.e. getSpatialModel() == null), then an IllegalArgumentException is thrown- Parameters:
parent-name-spatialModel-coordinate- Must be valid for the spatial model
-
-
Method Detail
-
turnOnTripStatistics
public void turnOnTripStatistics()
Turns on trip statistical collection. Once it is on. It is on.
-
isTripStatOptionOn
public final boolean isTripStatOptionOn()
- Returns:
- true means on, false means off
-
initialize
protected void initialize()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called- Overrides:
initializein classSpatialModelElement
-
replicationEnded
protected void replicationEnded()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication() . It is called when each replication ends and can be used to collect data from the the model element, etc.- Overrides:
replicationEndedin classModelElement
-
setMaxNumTrips
public final void setMaxNumTrips(int maxTrips)
Sets the number of trips that will trigger the end of the replication- Parameters:
maxTrips- the desired limit
-
getMaxNumTrips
public long getMaxNumTrips()
Gets the number of trips that will trigger the end of the replication- Returns:
- the limit
-
getNumTripsCompleted
public double getNumTripsCompleted()
- Returns:
- the number of trips completed by the mover
-
isDefaultNextTripOptionOn
public final boolean isDefaultNextTripOptionOn()
Controls whether or not to automatically start a new trip via startNextTrip()- Returns:
- true if the option is on
-
setDefaultNextTripOption
public final void setDefaultNextTripOption(boolean defaultNextTripFlag)
Controls whether or not to automatically start a new trip via startNextTrip()- Parameters:
defaultNextTripFlag- true means on
-
cancelTrip
public final void cancelTrip()
If the mover is on a trip then the movement along the trip is canceled and the mover stays at the position where it is when this method is called. This method cancels movement. If the mover is not moving or on a trip nothing happens.- Specified by:
cancelTripin interfaceMoverIfc
-
getFuturePosition
public final CoordinateIfc getFuturePosition(double time)
Description copied from interface:MoverIfcReturns a CoordinateIfc that represents the future position of the spatial element at the given time.- Specified by:
getFuturePositionin interfaceMoverIfc- Parameters:
time- Must be greater than or equal to zero- Returns:
- the coordinate of the future position
-
isMoving
public final boolean isMoving()
Description copied from interface:MoverIfcIndicates whether or not the element is currently moving
-
isOnTrip
public final boolean isOnTrip()
Description copied from interface:MoverIfcIndicates whether or not the element is currently on a trip
-
getMovementDistance
public final double getMovementDistance()
Description copied from interface:MoverIfcGets the distance associated with the current movement- Specified by:
getMovementDistancein interfaceMoverIfc- Returns:
- Returns the movementDistance.
-
getMovementTime
public final double getMovementTime()
Description copied from interface:MoverIfcGets the time length for the current movement- Specified by:
getMovementTimein interfaceMoverIfc- Returns:
- Returns the movementTime
-
getMovementStartTime
public final double getMovementStartTime()
Description copied from interface:MoverIfcGet the time that the current movement started- Specified by:
getMovementStartTimein interfaceMoverIfc- Returns:
- Returns the movementStartTime.
-
getMovementVelocity
public final double getMovementVelocity()
Description copied from interface:MoverIfcGets the velocity of the movement that is in progress- Specified by:
getMovementVelocityin interfaceMoverIfc- Returns:
- Returns the movementVelocity.
-
getCollisionDetector
public final CollisionDetectorIfc getCollisionDetector()
- Specified by:
getCollisionDetectorin interfaceMoverIfc- Returns:
- Returns the collisionDetector.
-
setCollisionDetector
public final void setCollisionDetector(CollisionDetectorIfc collisionDetector)
Description copied from interface:MoverIfcSets the collision detector. If null no detection is used- Specified by:
setCollisionDetectorin interfaceMoverIfc- Parameters:
collisionDetector- The collisionDetector to set.
-
getCollisionHandler
public final CollisionHandlerIfc getCollisionHandler()
- Specified by:
getCollisionHandlerin interfaceMoverIfc- Returns:
- Returns the collisionHandler.
-
setCollisionHandler
public final void setCollisionHandler(CollisionHandlerIfc collisionHandler)
Description copied from interface:MoverIfcSets the collision handler, if null then no collision handling is performed- Specified by:
setCollisionHandlerin interfaceMoverIfc- Parameters:
collisionHandler- The collisionHandler to set.
-
getMovementController
public final MovementControllerIfc getMovementController()
- Specified by:
getMovementControllerin interfaceMoverIfc- Returns:
- Returns the movementController.
-
setMovementController
public final void setMovementController(MovementControllerIfc movementController)
Description copied from interface:MoverIfcSet the movement controller. If null, then the default movement uses the point to point distance at velocity 1.- Specified by:
setMovementControllerin interfaceMoverIfc- Parameters:
movementController- The movementController to set.
-
setVelocityChangeFactor
public final void setVelocityChangeFactor(double factor)
Description copied from interface:VelocityIfcThe addFactor will be used to increase or decrease the velocity returned by getVelocity()- Specified by:
setVelocityChangeFactorin interfaceVelocityIfc- Parameters:
factor- must be greater than zero
-
getVelocityChangeFactor
public final double getVelocityChangeFactor()
Description copied from interface:VelocityIfcThe addFactor will be used to increase or decrease the velocity returned by getVelocity()- Specified by:
getVelocityChangeFactorin interfaceVelocityIfc- Returns:
- the addFactor
-
getVelocity
public double getVelocity()
- Specified by:
getVelocityin interfaceMoverIfc- Specified by:
getVelocityin interfaceVelocityIfc- Returns:
- a value from the velocity random source
-
getVelocityInitialRandomSource
public final RandomIfc getVelocityInitialRandomSource()
- Specified by:
getVelocityInitialRandomSourcein interfaceVelocityIfc- Returns:
- Returns the velocity.
-
setVelocityInitialRandomSource
public final void setVelocityInitialRandomSource(RandomIfc source)
Description copied from interface:MoverIfcSets the random source associated with the velocity used at the beginning of each replication- Specified by:
setVelocityInitialRandomSourcein interfaceMoverIfc- Specified by:
setVelocityInitialRandomSourcein interfaceVelocityIfc- Parameters:
source- the source of the randomness
-
getVelocityRandomSource
public final RandomIfc getVelocityRandomSource()
- Specified by:
getVelocityRandomSourcein interfaceVelocityIfc- Returns:
- Returns the velocity.
-
setVelocityRandomSource
public void setVelocityRandomSource(RandomIfc source)
Description copied from interface:MoverIfcSets the random source associated with the velocity. This is reset at the beginning of each replication to the value set with setVelocityInitialRandomSource()- Specified by:
setVelocityRandomSourcein interfaceMoverIfc- Specified by:
setVelocityRandomSourcein interfaceVelocityIfc- Parameters:
source- the source of the randomness
-
getOSMHandler
public final OutsideSpatialModelHandlerIfc getOSMHandler()
Description copied from interface:MoverIfcGet the object the handles when the movement takes the element outside the boundaries of the current spatial model- Specified by:
getOSMHandlerin interfaceMoverIfc- Returns:
- Returns the OSMHandler.
-
setOSMHandler
public final void setOSMHandler(OutsideSpatialModelHandlerIfc OSMHandler)
Description copied from interface:MoverIfcSet the handler for taking care of when the element goes outside the boundaries of its spatial model. If null, then an exception will be thrown if the element tries to go outside its spatial element.- Specified by:
setOSMHandlerin interfaceMoverIfc- Parameters:
OSMHandler- The OSMHandler to set.
-
setMovement
public final void setMovement(double velocity, CoordinateIfc position)Description copied from interface:MoverIfcSets up the movement before it gets processed. Takes in a velocity for the movement (which must be > 0) and the coordinate where the movement should end. This method should be used by MovementControllers to set the movement characteristics prior to the move. This method sets: 1) the velocity of the move 2) the distance of the move 3) the direction of the move 4) the time the move starts 5) the total time to move to the position at the given velocity- Specified by:
setMovementin interfaceMoverIfc- Parameters:
velocity- Must be > 0position- Must not be null
-
asString
public java.lang.String asString()
Description copied from class:ModelElementAllows sub-classes to provide more detail than toString() to represent the ModelElement as a String- Overrides:
asStringin classModelElement- Returns:
- a detailed String representation
-
getDestination
public CoordinateIfc getDestination()
Description copied from interface:MoverIfcGets a reference to the CoordinateIfc representing the destination of the mover- Specified by:
getDestinationin interfaceMoverIfc- Returns:
- the CoordinateIfcIfc for this element
-
moveTo
protected final void moveTo(CoordinateIfc destination)
Causes the element to start a trip from its current position to the coordinates specified. This starts a trip. A trip is a series of movements to move from the current position to the specified coordinates. At the beginning of a trip, trip start observers are notified. If the trip is broken down into movements, then each movement can have its own velocity, distance, and direction (as long as the final movement ends at the destination). If the destination is the same as the current position of the element then no trip is started and no movement occurs, i.e. nothing occurs If the specified coordinates are not in the element's associated spatial model then outsideSpatialModelHandler() is called. The default action is to throw an exception but this can be overridden in outsideSpatialModelHandler().- Parameters:
destination- the coordinate of the destination
-
moveTo
protected final void moveTo(SpatialElementIfc destination)
Causes the element to start a trip to the coordinates of the specified SpatialElementIfc- Parameters:
destination- the coordinate of the destination
-
moveDeltaX1
protected final void moveDeltaX1(double dx)
Relative to the current position this method causes the mover to start a trip delta in the x1 direction- Parameters:
dx- the amount of the move
-
moveDeltaX2
protected final void moveDeltaX2(double dy)
Relative to the current position this method causes the mover to start a trip delta in the x2 direction- Parameters:
dy- the amount of the move
-
moveDeltaX1X2
protected final void moveDeltaX1X2(double dx, double dy)Relative to the current position this method causes the mover to start a trip to a position that is delta in the x1 direction and delta in the x2 direction.- Parameters:
dx- amount of change in the X1 directiondy- amount of change in the X2 direction
-
beforeTripStarts
protected void beforeTripStarts()
Can be used by subclasses to invoke logic prior to the start of a trip
-
afterTripEnds
protected void afterTripEnds()
Can be used by subclasses to invoke logic after a trip ends
-
hasNextTrip
public boolean hasNextTrip()
A method to determine if another trip should be started This result controls whether or not startNextTrip() is called. By default, it returns false. Implementors can override to provide trips via startNextTrip()- Returns:
- true if another trip should be started, false otherwise
-
startNextTrip
protected void startNextTrip()
Should be used by subclasses to initiate (schedule) the next trip after ending the current trip. This is called immediately after afterTripEnds() if and only if hasNextTrip() returns true
-
beforeMovementStarts
protected void beforeMovementStarts()
Can be used by subclasses to invoke logic prior to the start of a movement
-
afterMovementEnds
protected void afterMovementEnds()
Can be used by subclasses to invoke logic after a movement ends
-
tripCanceled
protected void tripCanceled()
Can be used by subclasses to invoke logic when a trip is canceled
-
collectTripStats
protected void collectTripStats()
A method that can be overridden to collect statistics after a trip is completed, called right before afterTripEnds(). The statistical collection must be turned on via turnOnTripStatistics() for this method to be called.
-
outsideSpatialModelHandler
protected void outsideSpatialModelHandler(CoordinateIfc coordinate)
This method is called if the destination is outside of the element's current spatial model. By default it throws an IllegalArgumentException unless the user supplies an object that implements the OutsideSpatialModelHandlerIfc. Alternatively subclasses can override this method and provide the behavior directly- Parameters:
coordinate- the coordinate
-
updatePosition
protected void updatePosition()
This method is called at the end of a movement to update the position. The setCurrentPosition() method is used to set the current position to the next position attribute Overriding methods can specify other ways to set the position as long as they are consistent with the process implemented for the movements.
-
computeMovement
protected void computeMovement()
This method can be overridden by subclasses to compute the characteristics of a movement. Alternatively the user can supply an object that implements the MovementControllerIfc By default the movement goes directly to the destination at the default mover velocity. It is important that subclasses utilize the setMovement() method to properly set the characteristics of the movement.
-
checkForCollision
protected boolean checkForCollision()
This method can be overridden by subclasses to provide collision detection. Alternatively the user can supply an object that implements the CollisionDetectorIfc By default there is no collision detection. When there is no collision detector this method always returns false.- Returns:
- False if no collision, true if collided
-
handleCollision
protected void handleCollision()
This method can be overridden by subclasses to provide collision handling. Alternatively the user can supply an object that implements the CollisionHandlerIfc By default there is no collision handling.
-
-