Class TimeModule

java.lang.Object
gaiasky.script.v2.impl.APIModule
gaiasky.script.v2.impl.TimeModule
All Implemented Interfaces:
TimeAPI

public class TimeModule extends APIModule implements TimeAPI
The time module contains methods and calls to access, modify, and query the time subsystem.
  • Constructor Details

    • TimeModule

      public TimeModule(EventManager em, APIv2 api, String name)
      Create a new module with the given attributes.
      Parameters:
      em - Reference to the event manager.
      api - Reference to the API class.
      name - Name of the module.
  • Method Details

    • activate_real_time_frame

      public void activate_real_time_frame()
      Description copied from interface: TimeAPI
      Set the current time frame to real time. All the commands executed after this command becomes active will be in the real time frame (real clock ticks).
      Specified by:
      activate_real_time_frame in interface TimeAPI
    • activate_simulation_time_frame

      public void activate_simulation_time_frame()
      Description copied from interface: TimeAPI
      Set the current time frame to simulation time. All the commands executed after this command becomes active will be in the simulation time frame (simulation clock ticks).
      Specified by:
      activate_simulation_time_frame in interface TimeAPI
    • set_clock

      public void set_clock(int yr, int month, int day, int hour, int min, int sec, int ms)
      Description copied from interface: TimeAPI
      Set the time of the application to the given time, in UTC.
      Specified by:
      set_clock in interface TimeAPI
      Parameters:
      yr - The year to represent.
      month - The month-of-year to represent, from 1 (January) to 12 (December).
      day - The day-of-month to represent, from 1 to 31.
      hour - The hour-of-day to represent, from 0 to 23.
      min - The minute-of-hour to represent, from 0 to 59.
      sec - The second-of-minute to represent, from 0 to 59.
      ms - The millisecond-of-second, from 0 to 999.
    • get_clock

      public long get_clock()
      Description copied from interface: TimeAPI
      Return the current simulation time as the number of milliseconds since 1970-01-01T00:00:00Z (UTC).
      Specified by:
      get_clock in interface TimeAPI
      Returns:
      Number of milliseconds since the epoch (Jan 1, 1970 00:00:00 UTC).
    • set_clock

      public void set_clock(long time)
      Description copied from interface: TimeAPI
      Set the time of the application. The long value represents specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
      Specified by:
      set_clock in interface TimeAPI
      Parameters:
      time - Number of milliseconds since the epoch (Jan 1, 1970).
    • get_clock_array

      public int[] get_clock_array()
      Description copied from interface: TimeAPI
      Return the current UTC simulation time in an array.
      Specified by:
      get_clock_array in interface TimeAPI
      Returns:
      The current simulation time in an array with the given indices.
      • 0 - The year.
      • 1 - The month, from 1 (January) to 12 (December).
      • 2 - The day-of-month, from 1 to 31.
      • 3 - The hour-of-day, from 0 to 23.
      • 4 - The minute-of-hour, from 0 to 59.
      • 5 - The second-of-minute, from 0 to 59.
      • 6 - The millisecond-of-second, from 0 to 999.
    • start_clock

      public void start_clock()
      Description copied from interface: TimeAPI
      Start simulation time. This method causes the clock to start ticking at the current pace. You can modify the clock pace with TimeAPI.set_time_warp(double).
      Specified by:
      start_clock in interface TimeAPI
    • stop_clock

      public void stop_clock()
      Description copied from interface: TimeAPI
      Stop simulation time.
      Specified by:
      stop_clock in interface TimeAPI
    • is_clock_on

      public boolean is_clock_on()
      Description copied from interface: TimeAPI
      Query whether the simulation time is on or not.
      Specified by:
      is_clock_on in interface TimeAPI
      Returns:
      True if the time is on, false otherwise.
    • set_time_warp

      public void set_time_warp(double warp)
      Description copied from interface: TimeAPI
      Set the simulation time warp factor. Positive values make time advance forward, while negative values make time run backwards. A warp factor of 1 sets a real time pace to the simulation time.
      Specified by:
      set_time_warp in interface TimeAPI
      Parameters:
      warp - The warp as a factor. A value of 2.0 sets the Gaia Sky time to be twice as fast as real world time.
    • set_time_warp

      public void set_time_warp(long warp)
    • set_target_time

      public void set_target_time(long ms)
      Description copied from interface: TimeAPI
      Set a time bookmark in the global clock that, when reached, the clock automatically stops.
      Specified by:
      set_target_time in interface TimeAPI
      Parameters:
      ms - The time as the number of milliseconds since the epoch (Jan 1, 1970).
    • set_target_time

      public void set_target_time(int yr, int month, int day, int hour, int min, int sec, int ms)
      Description copied from interface: TimeAPI
      Set a time bookmark in the global clock that, when reached, the clock automatically stops.
      Specified by:
      set_target_time in interface TimeAPI
      Parameters:
      yr - The year to represent.
      month - The month-of-year to represent, from 1 (January) to 12 (December).
      day - The day-of-month to represent, from 1 to 31.
      hour - The hour-of-day to represent, from 0 to 23.
      min - The minute-of-hour to represent, from 0 to 59.
      sec - The second-of-minute to represent, from 0 to 59.
      ms - The millisecond-of-second, from 0 to 999.
    • remove_target_time

      public void remove_target_time()
      Description copied from interface: TimeAPI
      Unset the target time bookmark from the global clock, if any.
      Specified by:
      remove_target_time in interface TimeAPI
    • set_max_simulation_time

      public void set_max_simulation_time(long yr)
      Description copied from interface: TimeAPI
      Set the maximum simulation time allowed, in years. This sets the maximum time in the future (years) and in the past (-years). This setting is not saved to the configuration and resets to 5 Myr after restart.
      Specified by:
      set_max_simulation_time in interface TimeAPI
      Parameters:
      yr - The maximum year number to allow.
    • setMaximumSimulationTime

      public void setMaximumSimulationTime(double years)
    • setMaximumSimulationTime

      public void setMaximumSimulationTime(Long years)
    • setMaximumSimulationTime

      public void setMaximumSimulationTime(Double years)
    • setMaximumSimulationTime

      public void setMaximumSimulationTime(Integer years)
    • transition

      public void transition(int yr, int month, int day, int hour, int min, int sec, int ms, double duration, String smooth_type, double smooth_factor, boolean sync)
      Description copied from interface: TimeAPI
      Create a time transition from the current time to the given time (year, month, day, hour, minute, second, millisecond). The time is given in UTC.
      Specified by:
      transition in interface TimeAPI
      Parameters:
      yr - The year to represent.
      month - The month-of-year to represent, from 1 (January) to 12 (December).
      day - The day-of-month to represent, from 1 to 31.
      hour - The hour-of-day to represent, from 0 to 23.
      min - The minute-of-hour to represent, from 0 to 59.
      sec - The second-of-minute to represent, from 0 to 59.
      ms - The millisecond-of-second, from 0 to 999.
      duration - The duration of the transition, in seconds.
      smooth_type - The function type to use for smoothing. Either "logit", "logisticsigmoid" or "none".
      • "logisticsigmoid": starts slow and ends slow. The smooth factor must be over 12 to produce an effect, otherwise, linear interpolation is used.
      • "logit": starts fast and ends fast. The smooth factor must be between 0.09 and 0.01.
      • "none": no smoothing is applied.
      smooth_factor - Smoothing factor (depends on type, see #smoothType).
      sync - If true, the call waits for the transition to finish before returning, otherwise it returns immediately.
    • transition

      public void transition(int year, int month, int day, int hour, int min, int sec, int milliseconds, double durationSeconds, String smoothType, double smoothFactor, boolean sync, AtomicBoolean stop)