Package FAtiMA.Core

Class AgentSimulationTime

  • All Implemented Interfaces:
    java.io.Serializable

    public class AgentSimulationTime
    extends java.lang.Object
    implements java.io.Serializable
    Author:
    Joao Dias Class that implements the simulation time experienced by the agent. It allows the agent to freeze its time, to advance time, and to speed up time. You cannot create an AgentSimulationTime since there is one and only instance for the agent. If you want to access it use AgentSimulationTime.GetInstance() method.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void AdvanceTime​(int seconds)
      Advances the agent's simulation time.
      static AgentSimulationTime GetInstance()
      Gets a timer responsible for updating and controlling this agent's simulation time
      static void LoadState​(java.io.ObjectInputStream stream)
      Loads a specific state of the AgentSimulationTimer from an open ObjectInputStream, this method does not close the stream
      static void LoadState​(java.lang.String fileName)
      Loads a specific state of the AgentSimulationTimer from a previously saved file
      void Resume()
      Resumes the agent's timer.
      static void SaveState​(java.io.ObjectOutputStream stream)
      Saves the state of the current AgentSimulationTimer to a currently opened ObjectOutputStream, the method does not close the stream and is intended for embedding the timer state into an output stream containing other objects
      static void SaveState​(java.lang.String fileName)
      Saves the state of the current AgentSimulationTimer to a file, so that it can be later restored from file
      void SetNormalTime()
      Sets the agent simulation time to real time.
      void SetSimulationTime​(long simulationTime)
      Sets the agent simulation time
      void SlowDownTimeTo​(int speed)
      Slows down the agent simulation time in relation to real time
      void SpeedUpTimeTo​(int speed)
      Speeds up the agent simulation time in relation to real time
      void Stop()
      Stops the agent's timer.
      void Tick()
      Tick Tack.
      long Time()
      Gets the agent's simulation time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • GetInstance

        public static AgentSimulationTime GetInstance()
        Gets a timer responsible for updating and controlling this agent's simulation time
        Returns:
        an AgentSimulationTime timer
      • SaveState

        public static void SaveState​(java.lang.String fileName)
        Saves the state of the current AgentSimulationTimer to a file, so that it can be later restored from file
        Parameters:
        fileName - - the name of the file where we must write the state of the timer
      • SaveState

        public static void SaveState​(java.io.ObjectOutputStream stream)
        Saves the state of the current AgentSimulationTimer to a currently opened ObjectOutputStream, the method does not close the stream and is intended for embedding the timer state into an output stream containing other objects
        Parameters:
        stream - - the open object output stream to save the timer to
      • LoadState

        public static void LoadState​(java.lang.String fileName)
        Loads a specific state of the AgentSimulationTimer from a previously saved file
        Parameters:
        fileName - - the stream to load the timer state from
      • LoadState

        public static void LoadState​(java.io.ObjectInputStream stream)
        Loads a specific state of the AgentSimulationTimer from an open ObjectInputStream, this method does not close the stream
        Parameters:
        stream - - the name of the file that contains the stored timer
      • Stop

        public void Stop()
        Stops the agent's timer. While the timer is stopped, no time elapses for the agent, even though real time is elapsing
      • Resume

        public void Resume()
        Resumes the agent's timer. Time will now elapse for the agent
      • Tick

        public void Tick()
        Tick Tack. Updates the agent's timer according to the current system's time. You should to call this method in each simulation round so that time is properly updated.
      • AdvanceTime

        public void AdvanceTime​(int seconds)
        Advances the agent's simulation time. Very useful if you want to skip time.
        Parameters:
        seconds - - the number of seconds you want to advance in time
      • SpeedUpTimeTo

        public void SpeedUpTimeTo​(int speed)
        Speeds up the agent simulation time in relation to real time
        Parameters:
        speed - - how many times faster should the simulation time run in relation to real time. For instance, if speed is 7, one second of real time will seem like 7 seconds to the agent The value provided must be greater than 1
      • SlowDownTimeTo

        public void SlowDownTimeTo​(int speed)
        Slows down the agent simulation time in relation to real time
        Parameters:
        speed - - how many times slower should the simulation time run in relation to real time. For instance, if speed is 5, 10 second of real time will correspond to only 2 for the agent. The value provided must be greater than 1
      • SetNormalTime

        public void SetNormalTime()
        Sets the agent simulation time to real time. One second of real time, will correspond to exactly one second for the agent
      • Time

        public long Time()
        Gets the agent's simulation time.
        Returns:
        the agent's simulation time
      • SetSimulationTime

        public void SetSimulationTime​(long simulationTime)
        Sets the agent simulation time
        Parameters:
        simulationTime - agent simulation time