Package FAtiMA.Core
Class AgentSimulationTime
java.lang.Object
FAtiMA.Core.AgentSimulationTime
- All Implemented Interfaces:
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:
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdvanceTime(int seconds) Advances the agent's simulation time.static AgentSimulationTimeGets a timer responsible for updating and controlling this agent's simulation timestatic voidLoadState(ObjectInputStream stream) Loads a specific state of the AgentSimulationTimer from an open ObjectInputStream, this method does not close the streamstatic voidLoads a specific state of the AgentSimulationTimer from a previously saved filevoidResume()Resumes the agent's timer.static voidSaveState(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 objectsstatic voidSaves the state of the current AgentSimulationTimer to a file, so that it can be later restored from filevoidSets the agent simulation time to real time.voidSetSimulationTime(long simulationTime) Sets the agent simulation timevoidSlowDownTimeTo(int speed) Slows down the agent simulation time in relation to real timevoidSpeedUpTimeTo(int speed) Speeds up the agent simulation time in relation to real timevoidStop()Stops the agent's timer.voidTick()Tick Tack.longTime()Gets the agent's simulation time.
-
Method Details
-
GetInstance
Gets a timer responsible for updating and controlling this agent's simulation time- Returns:
- an AgentSimulationTime timer
-
SaveState
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
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
Loads a specific state of the AgentSimulationTimer from a previously saved file- Parameters:
fileName- - the stream to load the timer state from
-
LoadState
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
-