Class MobileResource

    • 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

      • 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 interface MoverIfc
        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 interface MoverIfc
        Parameters:
        time - Must be greater than or equal to zero
        Returns:
        the coordinate of the future position
      • getMovementDistance

        public final double getMovementDistance()
        Description copied from interface: MoverIfc
        Gets the distance associated with the current movement
        Specified by:
        getMovementDistance in interface MoverIfc
        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 interface MoverIfc
        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 interface MoverIfc
        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 interface MoverIfc
        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 interface MoverIfc
        Returns:
        Returns the OSMHandler.
      • isMoving

        public final boolean isMoving()
        Description copied from interface: MoverIfc
        Indicates whether or not the element is currently moving
        Specified by:
        isMoving in interface MoverIfc
        Returns:
        true if moving
      • isOnTrip

        public final boolean isOnTrip()
        Description copied from interface: MoverIfc
        Indicates whether or not the element is currently on a trip
        Specified by:
        isOnTrip in interface MoverIfc
        Returns:
        true if 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 interface MoverIfc
        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 interface MoverIfc
        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 interface MoverIfc
        Parameters:
        velocity - Must be > 0
        position - 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 interface MoverIfc
        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 interface MoverIfc
        Parameters:
        OSMHandler - The OSMHandler to set.
      • 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 interface MoverIfc
        Specified by:
        setVelocityRandomSource in interface VelocityIfc
        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 interface SpatialElementIfc
        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 interface SpatialElementIfc
        Parameters:
        spatialModel - the spatial model
        coordinate - 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 interface SpatialElementIfc
        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 interface SpatialElementIfc
        Parameters:
        element - the element to check
        Returns:
        the distance
      • 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 interface SpatialElementIfc
        Parameters:
        coordinate - the coordinate
      • 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 interface SpatialElementIfc
      • 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 interface SpatialElementIfc
        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 interface SpatialElementIfc
        Parameters:
        element - the element to check
        Returns:
        the distance
      • 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 class Resource
      • 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