Class TimeModule
java.lang.Object
gaiasky.script.v2.impl.APIModule
gaiasky.script.v2.impl.TimeModule
- All Implemented Interfaces:
TimeAPI
-
Field Summary
Fields inherited from class APIModule
api, em, logger, me, nameModifier and TypeFieldDescriptionprotected final APIv2Reference to API object.protected final EventManagerReference to event manager.protected final Logger.Logprotected final APIModuleReference to self.protected final StringModule name. -
Constructor Summary
ConstructorsConstructorDescriptionTimeModule(EventManager em, APIv2 api, String name) Create a new module with the given attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoidSet the current time frame to real time.voidSet the current time frame to simulation time.longReturn the current simulation time as the number of milliseconds since 1970-01-01T00:00:00Z (UTC).int[]Return the current UTC simulation time in an array.booleanQuery whether the simulation time is on or not.voidUnset the target time bookmark from the global clock, if any.voidset_clock(int yr, int month, int day, int hour, int min, int sec, int ms) Set the time of the application to the given time, in UTC.voidset_clock(long time) Set the time of the application.voidset_max_simulation_time(long yr) Set the maximum simulation time allowed, in years.voidset_target_time(int yr, int month, int day, int hour, int min, int sec, int ms) Set a time bookmark in the global clock that, when reached, the clock automatically stops.voidset_target_time(long ms) Set a time bookmark in the global clock that, when reached, the clock automatically stops.voidset_time_warp(double warp) Set the simulation time warp factor.voidset_time_warp(long warp) Alias toset_time_warp(double).voidsetMaximumSimulationTime(double years) voidsetMaximumSimulationTime(Double years) voidsetMaximumSimulationTime(Integer years) voidsetMaximumSimulationTime(Long years) voidStart simulation time.voidStop simulation time.voidtransition(int yr, int month, int day, int hour, int min, int sec, int ms, double duration, String smooth_type, double smooth_factor, boolean sync) Create a time transition from the current time to the given time (year, month, day, hour, minute, second, millisecond).voidtransition(int year, int month, int day, int hour, int min, int sec, int milliseconds, double durationSeconds, String smoothType, double smoothFactor, boolean sync, AtomicBoolean stop)
-
Constructor Details
-
TimeModule
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:TimeAPISet 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_framein interfaceTimeAPI
-
activate_simulation_time_frame
public void activate_simulation_time_frame()Description copied from interface:TimeAPISet 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_framein interfaceTimeAPI
-
set_clock
public void set_clock(int yr, int month, int day, int hour, int min, int sec, int ms) Description copied from interface:TimeAPISet the time of the application to the given time, in UTC.- Specified by:
set_clockin interfaceTimeAPI- 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
-
set_clock
public void set_clock(long time) Description copied from interface:TimeAPISet 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. -
get_clock_array
public int[] get_clock_array()Description copied from interface:TimeAPIReturn the current UTC simulation time in an array.- Specified by:
get_clock_arrayin interfaceTimeAPI- 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:TimeAPIStart simulation time. This method causes the clock to start ticking at the current pace. You can modify the clock pace withTimeAPI.set_time_warp(double).- Specified by:
start_clockin interfaceTimeAPI
-
stop_clock
public void stop_clock()Description copied from interface:TimeAPIStop simulation time.- Specified by:
stop_clockin interfaceTimeAPI
-
is_clock_on
public boolean is_clock_on()Description copied from interface:TimeAPIQuery whether the simulation time is on or not.- Specified by:
is_clock_onin interfaceTimeAPI- Returns:
- True if the time is on, false otherwise.
-
set_time_warp
public void set_time_warp(double warp) Description copied from interface:TimeAPISet 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_warpin interfaceTimeAPI- 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) Alias toset_time_warp(double). -
set_target_time
public void set_target_time(long ms) Description copied from interface:TimeAPISet a time bookmark in the global clock that, when reached, the clock automatically stops.- Specified by:
set_target_timein interfaceTimeAPI- 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:TimeAPISet a time bookmark in the global clock that, when reached, the clock automatically stops.- Specified by:
set_target_timein interfaceTimeAPI- 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:TimeAPIUnset the target time bookmark from the global clock, if any.- Specified by:
remove_target_timein interfaceTimeAPI
-
set_max_simulation_time
public void set_max_simulation_time(long yr) Description copied from interface:TimeAPISet 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_timein interfaceTimeAPI- Parameters:
yr- The maximum year number to allow.
-
setMaximumSimulationTime
public void setMaximumSimulationTime(double years) -
setMaximumSimulationTime
-
setMaximumSimulationTime
-
setMaximumSimulationTime
-
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:TimeAPICreate 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:
transitionin interfaceTimeAPI- 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)
-