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 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: true on a TM Data Link (this is implemented in AbstractTmDataLink) 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 Details

    • SimulationTimeService

      public SimulationTimeService(String yamcsInstance, YConfiguration config)
    • SimulationTimeService

      public SimulationTimeService(String yamcsInstance)
  • 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 with setSimSpeed(double) and javaTime are the values set with setSimElapsedTime(long, long).

      Specified by:
      getMissionTime in interface TimeService
      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 by getMissionTime()
      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: TimeService
      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.
      Specified by:
      getSpeed in interface TimeService
      Returns:
      the relation between the mission time and the wall clock time