Class SimulationTimeService
- java.lang.Object
-
- org.yamcs.time.SimulationTimeService
-
- All Implemented Interfaces:
TimeService
public class SimulationTimeService extends Object implements TimeService
Simulation time model. Can be used by configuring in the yamcs.instance.yaml: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 mantains 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 from other place (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: true
on 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
Constructors Constructor Description SimulationTimeService(String yamcsInstance)
SimulationTimeService(String yamcsInstance, YConfiguration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getMissionTime()
The mission time returned is:void
setSimElapsedTime(long simElapsedTime)
void
setSimSpeed(double simSpeed)
Set the simulation speed.void
setTime0(long time0)
Set the time0-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.yamcs.time.TimeService
getHresMissionTime
-
-
-
-
Constructor Detail
-
SimulationTimeService
public SimulationTimeService(String yamcsInstance, YConfiguration config)
-
SimulationTimeService
public SimulationTimeService(String yamcsInstance)
-
-
Method Detail
-
getMissionTime
public long getMissionTime()
The mission time returned is:time0 + simElapsedTime + speed * (System.currentTimeMillis() - javaTime)
where time0 is the value set with
setTime0(long)
, simElapsedTime is the value set withsetSimElapsedTime(long)
and the javaTime is the value returned bySystem.currentTimeMillis()
last time whensetSimElapsedTime(long)
has been called.- Specified by:
getMissionTime
in interfaceTimeService
-
setSimElapsedTime
public void setSimElapsedTime(long 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
-
-
-