Package jsl.modeling.elements.spatial
Class MobileResource
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.entity.Resource
-
- jsl.modeling.elements.spatial.MobileResource
-
- All Implemented Interfaces:
SeizeIfc
,MoverIfc
,PositionIfc
,SpatialElementIfc
,VelocityIfc
,ObservableIfc
,GetNameIfc
,IdentityIfc
public abstract class MobileResource extends Resource implements MoverIfc
-
-
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 inherited from class jsl.modeling.elements.entity.Resource
myAllocations, myResourceSets, myWaitingRequests
-
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 MobileResource(ModelElement parent)
Creates a MobileResource with capacity 1 at the default position in the spatial model.MobileResource(ModelElement parent, int capacity)
Creates a MobileResource with the given capacity at the default position in the spatial model.MobileResource(ModelElement parent, int capacity, double x, double y)
Creates a MobileResource with the given capacity and (x,y) position.MobileResource(ModelElement parent, int capacity, java.lang.String name)
Creates a MobileResource with the given capacity at the default position in the spatial model.MobileResource(ModelElement parent, int capacity, java.lang.String name, double x, double y)
Creates a MobileResource with the given capacity and (x,y) position.MobileResource(ModelElement parent, int capacity, java.lang.String name, CoordinateIfc position)
Creates a MobileResource with capacity 1 at the given coordinates.MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel)
Creates a MobileResource with the given capacity at the default coordinates in the supplied spatial model.MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel, double x, double y, double z)
Creates a MobileResource with the given capacity at the (x,y,z) coordinates in the supplied spatial model.MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a MobileResource with the given capacity at the supplied coordinates in the supplied spatial model.MobileResource(ModelElement parent, int capacity, CoordinateIfc position)
Creates a MobileResource with the given capacity at the given coordinates.MobileResource(ModelElement parent, int capacity, SpatialElementIfc position)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model.MobileResource(ModelElement parent, int capacity, SpatialModel spatialModel)
Creates a MobileResource with the given capacity at the default coordinates in the supplied spatial model.MobileResource(ModelElement parent, java.lang.String name)
Creates a MobileResource with capacity 1 at the default position in the spatial model.MobileResource(ModelElement parent, java.lang.String name, double x, double y)
Creates a MobileResource with capacity 1 and (x,y) position.MobileResource(ModelElement parent, java.lang.String name, CoordinateIfc position)
Creates a MobileResource with capacity 1 at the given coordinates.MobileResource(ModelElement parent, SpatialElementIfc position)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model.MobileResource(ModelElement parent, SpatialElementIfc position, java.lang.String name)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
attachPositionObserver(ObserverIfc observer)
Implementor of this interface should allow Observers to be attached.void
changeSpatialModel(SpatialModel spatialModel, CoordinateIfc coordinate)
Changes the spatial model for this element and places the element at the supplied coordinate within the new spatial model.double
distanceTo(CoordinateIfc coordinate)
This is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial modeldouble
distanceTo(SpatialElementIfc element)
This is a "convenience" method for getting the distance from this element to the supplied element within the underlying spatial model Requirement: The elements must be in the same spatial model.protected abstract void
emptyMoveCompleted()
Subclasses must override this method to react to the end of an empty moveCollisionDetectorIfc
getCollisionDetector()
CollisionHandlerIfc
getCollisionHandler()
CoordinateIfc
getDestination()
Gets a reference to the CoordinateIfc representing the destination of the moverCoordinateIfc
getFuturePosition(double time)
Returns a CoordinateIfc that represents the future position of the spatial element at the given time.CoordinateIfc
getInitialPosition()
SpatialModel
getInitialSpatialModel()
Returns the spatial model that should hold this element at the beginning of each replication of a simulationModelElement
getModelElement()
Gets the ModelElement associated with this spatial element May be nullMovementControllerIfc
getMovementController()
double
getMovementDistance()
Gets the distance associated with the current movementdouble
getMovementStartTime()
Get the time that the current movement starteddouble
getMovementTime()
Gets the time length for the current movementdouble
getMovementVelocity()
Gets the velocity of the movement that is in progressOutsideSpatialModelHandlerIfc
getOSMHandler()
Get the object the handles when the movement takes the element outside the boundaries of the current spatial modelCoordinateIfc
getPosition()
CoordinateIfc
getPreviousPosition()
protected Transporter
getTransporter()
Subclasses can use this to access the underlying Transporterprotected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.void
initializeSpatialElement()
This method should be called to initialize the spatial element prior to running a simulationboolean
isMoving()
Indicates whether or not the element is currently movingboolean
isOnTrip()
Indicates whether or not the element is currently on a tripboolean
isPositionEqualTo(CoordinateIfc coordinate)
Returns true if the position of this element is the same as supplied coordinate within the underlying spatial model.boolean
isPositionEqualTo(SpatialElementIfc element)
Returns true if the position of this element is the same as the position of the supplied element within the underlying spatial model.protected void
moveEmpty(CoordinateIfc coordinate)
Tells the resource to move empty to the supplied coordinatesprotected void
moveEmpty(SpatialElementIfc element)
Tells the resource to move empty to the coordinates of the supplied spatial elementvoid
removePositionObserver(ObserverIfc observer)
Remove the observer from this PositionIfcvoid
setCollisionDetector(CollisionDetectorIfc collisionDetector)
Sets the collision detector.void
setCollisionHandler(CollisionHandlerIfc collisionHandler)
Sets the collision handler, if null then no collision handling is performedvoid
setInitialPosition(CoordinateIfc coordinate)
Sets the initial position of the element.void
setMovement(double velocity, CoordinateIfc position)
Sets up the movement before it gets processed.void
setMovementController(MovementControllerIfc movementController)
Set the movement controller.void
setOSMHandler(OutsideSpatialModelHandlerIfc OSMHandler)
Set the handler for taking care of when the element goes outside the boundaries of its spatial model.void
setVelocityInitialRandomSource(RandomIfc source)
Sets the random source associated with the velocity used at the beginning of each replicationvoid
setVelocityRandomSource(RandomIfc source)
Sets the random source associated with the velocity.protected void
transport(CoordinateIfc coordinate)
Tells the resource to transport to the supplied coordinatesprotected void
transport(SpatialElementIfc element)
Tells the resource to transport to the coordinates of the supplied spatial elementprotected abstract void
transportCompleted()
Subclasses must override this method to react to the end of a transport-
Methods inherited from class jsl.modeling.elements.entity.Resource
addAllocation, addWaitingRequest, allocate, allocate, asString, attachResourceSet, attachStateChangeListener, decrementNumberBusy, detachResourceSet, detachStateChangeListener, getCapacity, getInitialCapacity, getMaximumCapacity, getNumberAvailable, hasAvailableUnits, incrementNumberBusy, isBusy, isFailed, isIdle, isInactive, notifyResourceSets, notifyStateChangeListeners, partiallyAllocate, peekNextRequest, processWaitingRequests, release, release, release, removeAllocation, removeNextRequest, removeWaitingRequest, seize, seize, seize, seize, seize, setInitialCapacity, setMaximumCapacity, setState
-
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, 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.MoverIfc
cancelTrip, getVelocity
-
Methods inherited from interface jsl.modeling.elements.spatial.SpatialElementIfc
getObserverState, getSpatialModel
-
Methods inherited from interface jsl.modeling.elements.spatial.VelocityIfc
getVelocityChangeFactor, getVelocityInitialRandomSource, getVelocityRandomSource, setVelocityChangeFactor
-
-
-
-
Constructor Detail
-
MobileResource
public MobileResource(ModelElement parent)
Creates a MobileResource with capacity 1 at the default position in the spatial model. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-
-
MobileResource
public MobileResource(ModelElement parent, java.lang.String name)
Creates a MobileResource with capacity 1 at the default position in the spatial model. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-name
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity)
Creates a MobileResource with the given capacity at the default position in the spatial model. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name)
Creates a MobileResource with the given capacity at the default position in the spatial model. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-
-
MobileResource
public MobileResource(ModelElement parent, java.lang.String name, CoordinateIfc position)
Creates a MobileResource with capacity 1 at the given coordinates. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-name
-position
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name, CoordinateIfc position)
Creates a MobileResource with capacity 1 at the given coordinates. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-position
-
-
MobileResource
public MobileResource(ModelElement parent, java.lang.String name, double x, double y)
Creates a MobileResource with capacity 1 and (x,y) position. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-name
-x
-y
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name, double x, double y)
Creates a MobileResource with the given capacity and (x,y) position. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-x
-y
-
-
MobileResource
public MobileResource(ModelElement parent, SpatialElementIfc position)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-position
-
-
MobileResource
public MobileResource(ModelElement parent, SpatialElementIfc position, java.lang.String name)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-position
-name
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, SpatialElementIfc position)
Creates a MobileResource with the given capacity at the coordinates of the given spatial element The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-position
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, CoordinateIfc position)
Creates a MobileResource with the given capacity at the given coordinates. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-position
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, double x, double y)
Creates a MobileResource with the given capacity and (x,y) position. The spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-x
-y
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, SpatialModel spatialModel)
Creates a MobileResource with the given capacity at the default coordinates in the supplied spatial model. The supplied is used unless it is null, then the spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-spatialModel
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel)
Creates a MobileResource with the given capacity at the default coordinates in the supplied spatial model. The supplied is used unless it is null, then the spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-spatialModel
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel, double x, double y, double z)
Creates a MobileResource with the given capacity at the (x,y,z) coordinates in the supplied spatial model. The supplied is used unless it is null, then the spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-spatialModel
-x
-y
-z
-
-
MobileResource
public MobileResource(ModelElement parent, int capacity, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a MobileResource with the given capacity at the supplied coordinates in the supplied spatial model. The supplied is used unless it is null, then the spatial model of the parent is used as the spatial model. If the parent does not have a spatial model, then an IllegalArgumentException is thrown- Parameters:
parent
-capacity
-name
-spatialModel
-coordinate
-
-
-
Method Detail
-
getCollisionDetector
public final CollisionDetectorIfc getCollisionDetector()
- Specified by:
getCollisionDetector
in interfaceMoverIfc
- Returns:
- Returns the collisionDetector.
-
getCollisionHandler
public final CollisionHandlerIfc getCollisionHandler()
- Specified by:
getCollisionHandler
in interfaceMoverIfc
- Returns:
- Returns the collisionHandler.
-
getDestination
public final CoordinateIfc getDestination()
Description copied from interface:MoverIfc
Gets a reference to the CoordinateIfc representing the destination of the mover- Specified by:
getDestination
in interfaceMoverIfc
- Returns:
- the CoordinateIfcIfc for this element
-
getFuturePosition
public final CoordinateIfc getFuturePosition(double time)
Description copied from interface:MoverIfc
Returns a CoordinateIfc that represents the future position of the spatial element at the given time.- Specified by:
getFuturePosition
in interfaceMoverIfc
- Parameters:
time
- Must be greater than or equal to zero- Returns:
- the coordinate of the future position
-
getMovementController
public final MovementControllerIfc getMovementController()
- Specified by:
getMovementController
in interfaceMoverIfc
- Returns:
- Returns the movementController.
-
getMovementDistance
public final double getMovementDistance()
Description copied from interface:MoverIfc
Gets the distance associated with the current movement- Specified by:
getMovementDistance
in interfaceMoverIfc
- Returns:
- Returns the movementDistance.
-
getMovementStartTime
public final double getMovementStartTime()
Description copied from interface:MoverIfc
Get the time that the current movement started- Specified by:
getMovementStartTime
in interfaceMoverIfc
- Returns:
- Returns the movementStartTime.
-
getMovementTime
public final double getMovementTime()
Description copied from interface:MoverIfc
Gets the time length for the current movement- Specified by:
getMovementTime
in interfaceMoverIfc
- Returns:
- Returns the movementTime
-
getMovementVelocity
public final double getMovementVelocity()
Description copied from interface:MoverIfc
Gets the velocity of the movement that is in progress- Specified by:
getMovementVelocity
in interfaceMoverIfc
- Returns:
- Returns the movementVelocity.
-
getOSMHandler
public final OutsideSpatialModelHandlerIfc getOSMHandler()
Description copied from interface:MoverIfc
Get the object the handles when the movement takes the element outside the boundaries of the current spatial model- Specified by:
getOSMHandler
in interfaceMoverIfc
- Returns:
- Returns the OSMHandler.
-
isMoving
public final boolean isMoving()
Description copied from interface:MoverIfc
Indicates whether or not the element is currently moving
-
isOnTrip
public final boolean isOnTrip()
Description copied from interface:MoverIfc
Indicates whether or not the element is currently on a trip
-
setCollisionDetector
public final void setCollisionDetector(CollisionDetectorIfc collisionDetector)
Description copied from interface:MoverIfc
Sets the collision detector. If null no detection is used- Specified by:
setCollisionDetector
in interfaceMoverIfc
- Parameters:
collisionDetector
- The collisionDetector to set.
-
setCollisionHandler
public final void setCollisionHandler(CollisionHandlerIfc collisionHandler)
Description copied from interface:MoverIfc
Sets the collision handler, if null then no collision handling is performed- Specified by:
setCollisionHandler
in interfaceMoverIfc
- Parameters:
collisionHandler
- The collisionHandler to set.
-
setMovement
public final void setMovement(double velocity, CoordinateIfc position)
Description copied from interface:MoverIfc
Sets 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:
setMovement
in interfaceMoverIfc
- Parameters:
velocity
- Must be > 0position
- Must not be null
-
setMovementController
public final void setMovementController(MovementControllerIfc movementController)
Description copied from interface:MoverIfc
Set the movement controller. If null, then the default movement uses the point to point distance at velocity 1.- Specified by:
setMovementController
in interfaceMoverIfc
- Parameters:
movementController
- The movementController to set.
-
setOSMHandler
public final void setOSMHandler(OutsideSpatialModelHandlerIfc OSMHandler)
Description copied from interface:MoverIfc
Set 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:
setOSMHandler
in interfaceMoverIfc
- Parameters:
OSMHandler
- The OSMHandler to set.
-
setVelocityInitialRandomSource
public final void setVelocityInitialRandomSource(RandomIfc source)
Description copied from interface:MoverIfc
Sets the random source associated with the velocity used at the beginning of each replication- Specified by:
setVelocityInitialRandomSource
in interfaceMoverIfc
- Specified by:
setVelocityInitialRandomSource
in interfaceVelocityIfc
- Parameters:
source
- the source of the randomness
-
setVelocityRandomSource
public void setVelocityRandomSource(RandomIfc source)
Description copied from interface:MoverIfc
Sets the random source associated with the velocity. This is reset at the beginning of each replication to the value set with setVelocityInitialRandomSource()- Specified by:
setVelocityRandomSource
in interfaceMoverIfc
- Specified by:
setVelocityRandomSource
in interfaceVelocityIfc
- Parameters:
source
- the source of the randomness
-
attachPositionObserver
public final void attachPositionObserver(ObserverIfc observer)
Description copied from interface:SpatialElementIfc
Implementor of this interface should allow Observers to be attached. For example, the observers should be notified when the position changes. It is the responsibility of implementers to properly notify the observers.- Specified by:
attachPositionObserver
in interfaceSpatialElementIfc
- Parameters:
observer
- the observer
-
changeSpatialModel
public final void changeSpatialModel(SpatialModel spatialModel, CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfc
Changes the spatial model for this element and places the element at the supplied coordinate within the new spatial model. Throws IllegalArgumentException if the coordinate is not valid for the supplied spatial model. This spatial element becomes a child element of the new spatial model.- Specified by:
changeSpatialModel
in interfaceSpatialElementIfc
- Parameters:
spatialModel
- the spatial modelcoordinate
- the coordinate
-
distanceTo
public final double distanceTo(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfc
This is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial model- Specified by:
distanceTo
in interfaceSpatialElementIfc
- Parameters:
coordinate
- the coordinate to check- Returns:
- the distance
-
distanceTo
public final double distanceTo(SpatialElementIfc element)
Description copied from interface:SpatialElementIfc
This is a "convenience" method for getting the distance from this element to the supplied element within the underlying spatial model Requirement: The elements must be in the same spatial model. The distance should be calculated by the spatial model. If they are not in the same spatial model this method will throw and IllegalArgumentException- Specified by:
distanceTo
in interfaceSpatialElementIfc
- Parameters:
element
- the element to check- Returns:
- the distance
-
getPosition
public final CoordinateIfc getPosition()
- Specified by:
getPosition
in interfacePositionIfc
- Specified by:
getPosition
in interfaceSpatialElementIfc
- Returns:
- Returns the current Position.
-
getInitialPosition
public final CoordinateIfc getInitialPosition()
- Specified by:
getInitialPosition
in interfaceSpatialElementIfc
- Returns:
- Returns the initialPosition.
-
setInitialPosition
public void setInitialPosition(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfc
Sets the initial position of the element. This position should be used when initializeSpatialElement() is called, typically at the beginning of a replication.- Specified by:
setInitialPosition
in interfaceSpatialElementIfc
- Parameters:
coordinate
- the coordinate
-
getInitialSpatialModel
public final SpatialModel getInitialSpatialModel()
Description copied from interface:SpatialElementIfc
Returns the spatial model that should hold this element at the beginning of each replication of a simulation- Specified by:
getInitialSpatialModel
in interfaceSpatialElementIfc
- Returns:
- the spatial model
-
getModelElement
public final ModelElement getModelElement()
Description copied from interface:SpatialElementIfc
Gets the ModelElement associated with this spatial element May be null- Specified by:
getModelElement
in interfaceSpatialElementIfc
- Returns:
- the model element
-
getPreviousPosition
public final CoordinateIfc getPreviousPosition()
- Specified by:
getPreviousPosition
in interfaceSpatialElementIfc
- Returns:
- Returns the previousPosition.
-
initializeSpatialElement
public final void initializeSpatialElement()
Description copied from interface:SpatialElementIfc
This method should be called to initialize the spatial element prior to running a simulation- Specified by:
initializeSpatialElement
in interfaceSpatialElementIfc
-
isPositionEqualTo
public final boolean isPositionEqualTo(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfc
Returns true if the position of this element is the same as supplied coordinate within the underlying spatial model. This is not necessarily object reference equality, but rather whether or not the positions within the underlying spatial model can be considered the same (equivalent).- Specified by:
isPositionEqualTo
in interfaceSpatialElementIfc
- Parameters:
coordinate
- the coordinate to check- Returns:
- true if position is equal
-
isPositionEqualTo
public final boolean isPositionEqualTo(SpatialElementIfc element)
Description copied from interface:SpatialElementIfc
Returns true if the position of this element is the same as the position of the supplied element within the underlying spatial model. This is not necessarily object reference equality, but rather whether or not the positions within the underlying spatial model can be considered the same (equivalent). Requirement: The elements must be in the same spatial model. If they are not in the same spatial model, then this method should return false.- Specified by:
isPositionEqualTo
in interfaceSpatialElementIfc
- Parameters:
element
- the element to check- Returns:
- the distance
-
removePositionObserver
public final void removePositionObserver(ObserverIfc observer)
Description copied from interface:SpatialElementIfc
Remove the observer from this PositionIfc- Specified by:
removePositionObserver
in interfaceSpatialElementIfc
- Parameters:
observer
- the observer
-
initialize
protected void initialize()
Description copied from class:ModelElement
This 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:
initialize
in classResource
-
getTransporter
protected final Transporter getTransporter()
Subclasses can use this to access the underlying Transporter- Returns:
- Returns the Transporter.
-
moveEmpty
protected void moveEmpty(CoordinateIfc coordinate)
Tells the resource to move empty to the supplied coordinates- Parameters:
coordinate
-
-
moveEmpty
protected void moveEmpty(SpatialElementIfc element)
Tells the resource to move empty to the coordinates of the supplied spatial element- Parameters:
element
-
-
transport
protected void transport(CoordinateIfc coordinate)
Tells the resource to transport to the supplied coordinates- Parameters:
coordinate
-
-
transport
protected void transport(SpatialElementIfc element)
Tells the resource to transport to the coordinates of the supplied spatial element- Parameters:
element
-
-
emptyMoveCompleted
protected abstract void emptyMoveCompleted()
Subclasses must override this method to react to the end of an empty move
-
transportCompleted
protected abstract void transportCompleted()
Subclasses must override this method to react to the end of a transport
-
-