Class SimulationTimeService
- All Implemented Interfaces:
TimeService
timeService:
class: org.yamcs.time.SimulationTimeService
args:
time0: "2020-10-02T18:10:00.000Z"
speed: 1.0
By default the time0 is initialised with the time at the instance startup and the speed is 1.
The service maintains a simulated time which is running based on the computer clock according to speed (e.g. speed = 2 means it runs two times realtime speed). If the speed is 0, the simulated time never advances and it has to be advanced externally (see below).
The simulation time service (as well as the speed) can be updated by various means:
- Using the http time API; see https://docs.yamcs.org/yamcs-http-api/time/ for details.
- Setting the option
updateSimulationTime: trueon a TM Data Link (this is implemented inAbstractTmDataLink) and will cause the simulation time to be updated with the packet generation time each time a packet is received on the corresponding link. - By a custom service.
Note: using a time0 configured with a fixed value will cause the Yamcs to start always with the same simulation time and that might cause undesired effects such as packets overwriting eachother in the archive.
Such an option is better to be used in a template which can then be used to create always new Yamcs instances (corresponding to test sessions) such that the data is separated. See the instance and templates API .
-
Constructor Summary
ConstructorsConstructorDescriptionSimulationTimeService(String yamcsInstance) SimulationTimeService(String yamcsInstance, YConfiguration config) -
Method Summary
Modifier and TypeMethodDescriptionlongThe mission time returned is:doublegetSpeed()If the time service is a simulated time, this gives the relation between the (simulated) mission time and the wall clock time: 1.0 = realtime speed. >1.0 = faster than realtime <1.0 = slower than realtime.voidsetSimElapsedTime(long simElapsedTime) Same as setSimElapsedTime(System.currentTimeMillis(), simElapsedTime).voidsetSimElapsedTime(long javaTime, long simElapsedTime) Sets the javaTime and simElapsedTime used to compute the mission time bygetMissionTime()voidsetSimSpeed(double simSpeed) Set the simulation speed.voidsetTime0(long time0) Set the time0Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.yamcs.time.TimeService
getHresMissionTime
-
Constructor Details
-
SimulationTimeService
-
SimulationTimeService
-
-
Method Details
-
getMissionTime
public long getMissionTime()The mission time returned is:time0 + simElapsedTime + speed * (System.currentTimeMillis() - javaTime)where time0 is the value set with
setTime0(long), speed is the value set withsetSimSpeed(double)and javaTime are the values set withsetSimElapsedTime(long, long).- Specified by:
getMissionTimein interfaceTimeService- Returns:
- the mission time in Yamcs millisecond resolution
-
setSimElapsedTime
public void setSimElapsedTime(long javaTime, long simElapsedTime) Sets the javaTime and simElapsedTime used to compute the mission time bygetMissionTime()- Parameters:
javaTime-simElapsedTime-
-
setSimElapsedTime
public void setSimElapsedTime(long simElapsedTime) Same as setSimElapsedTime(System.currentTimeMillis(), simElapsedTime).- Parameters:
simElapsedTime-
-
setTime0
public void setTime0(long time0) Set the time0- Parameters:
time0-
-
setSimSpeed
public void setSimSpeed(double simSpeed) Set the simulation speed. If greater than 0, the time passes even without the update of the simElapsedTime.- Parameters:
simSpeed-
-
getSpeed
public double getSpeed()Description copied from interface:TimeServiceIf the time service is a simulated time, this gives the relation between the (simulated) mission time and the wall clock time:- 1.0 = realtime speed.
- >1.0 = faster than realtime
- <1.0 = slower than realtime.
- Specified by:
getSpeedin interfaceTimeService- Returns:
- the relation between the mission time and the wall clock time
-