Class TIMImpl<C extends IComponent<C>>
- java.lang.Object
-
- io.ciera.runtime.summit.util.Utility<C>
-
- io.ciera.runtime.summit.util.impl.TIMImpl<C>
-
- All Implemented Interfaces:
IActionHome<C>,TIM
public class TIMImpl<C extends IComponent<C>> extends Utility<C> implements TIM
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longadvance_time(long microseconds)Advance the system clock by the specified number of microseconds.Datecreate_date(int day, int hour, int minute, int month, int second, int year)Create a newDateobject from the input parameters.longcurrent_clock()Get the current system time in microseconds since the epoch.Datecurrent_date()Get the current date.intcurrent_seconds()Get the current time in seconds since the epoch.intget_day(Date date)Get the day of the month from a date object.intget_hour(Date date)Get hour of the day from a date object.intget_minute(Date date)Get minute of the hour from a date object.intget_month(Date date)Get the month of the year from a date object.intget_second(Date date)Get second of the minute from a date object.intget_year(Date date)Get year from a date object.voidset_epoch(int day, int month, int year)Set the instant in time from which the system clock counts.longset_time(int year, int month, int day, int hour, int minute, int second, int microsecond)Set the system clock time.longtime_of_day(long timeval)Get the number of microseconds since the beginning of the current day.booleantimer_add_time(int microseconds, TimerHandle timer_inst_ref)Add time to a running timer.booleantimer_cancel(TimerHandle timer_inst_ref)Cancel a running timer.inttimer_remaining_time(TimerHandle timer_inst_ref)Get the remaining time of a running timer in microseconds.booleantimer_reset_time(int microseconds, TimerHandle timer_inst_ref)Reset the timer and set a new duration from the current system time.TimerHandletimer_start(EventHandle event_inst, int microseconds)Start a new timer to wake inmicrosecondsmicroseconds from the current system time.TimerHandletimer_start_recurring(EventHandle event_inst, int microseconds)Start a new recurring timer to wake inmicrosecondsmicroseconds from the current system time.Stringtimestamp_format(long timestamp, String format)Format a timestamp according to a format string.Stringtimestamp_to_string(long timestamp)Format a timestamp as a string representing the number of microseconds since the current epoch.-
Methods inherited from class io.ciera.runtime.summit.util.Utility
context, getRunContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.ciera.runtime.summit.application.IActionHome
warn
-
-
-
-
Constructor Detail
-
TIMImpl
public TIMImpl(C context)
-
-
Method Detail
-
advance_time
public long advance_time(long microseconds)
Description copied from interface:TIMAdvance the system clock by the specified number of microseconds. All timers that have expiration times earlier than the resulting time will immediately be fired.- Specified by:
advance_timein interfaceTIM- Parameters:
microseconds- number of microseconds to advance the clock- Returns:
- the system clock time after it has been advanced
-
create_date
public Date create_date(int day, int hour, int minute, int month, int second, int year)
Description copied from interface:TIMCreate a newDateobject from the input parameters.- Specified by:
create_datein interfaceTIM- Parameters:
day- the year A.D.hour- the month of the yearminute- the day of the monthmonth- the hour of the daysecond- the minute of the houryear- the second of the minute- Returns:
- a new
Dateobject from the input parameters
-
current_clock
public long current_clock()
Description copied from interface:TIMGet the current system time in microseconds since the epoch.- Specified by:
current_clockin interfaceTIM- Returns:
- the current time
-
current_date
public Date current_date()
Description copied from interface:TIMGet the current date.- Specified by:
current_datein interfaceTIM- Returns:
- the current date
-
current_seconds
public int current_seconds()
Description copied from interface:TIMGet the current time in seconds since the epoch.- Specified by:
current_secondsin interfaceTIM- Returns:
- the current seconds
-
get_day
public int get_day(Date date)
Description copied from interface:TIMGet the day of the month from a date object.
-
get_month
public int get_month(Date date)
Description copied from interface:TIMGet the month of the year from a date object.
-
get_year
public int get_year(Date date)
Description copied from interface:TIMGet year from a date object.
-
get_hour
public int get_hour(Date date)
Description copied from interface:TIMGet hour of the day from a date object.
-
get_minute
public int get_minute(Date date)
Description copied from interface:TIMGet minute of the hour from a date object.- Specified by:
get_minutein interfaceTIM- Parameters:
date- the input date- Returns:
- the minute of the hour for the input date
-
get_second
public int get_second(Date date)
Description copied from interface:TIMGet second of the minute from a date object.- Specified by:
get_secondin interfaceTIM- Parameters:
date- the input date- Returns:
- the second of the minute for the input date
-
set_epoch
public void set_epoch(int day, int month, int year)Description copied from interface:TIMSet the instant in time from which the system clock counts. Ifset_epochis not called, the system clock will initialize at the current number of microseconds from the January 1, 1970 00:00:00 UTC and count up. Setting the epoch will change this reference instant tomonth,day,year00:00:00 UTC. Note: this call may result in unexpected timer behavior as the expiration times will shift by the difference in epoch.
-
set_time
public long set_time(int year, int month, int day, int hour, int minute, int second, int microsecond)Description copied from interface:TIMSet the system clock time. All timers that have expiration times earlier than the resulting time will immediately be fired.- Specified by:
set_timein interfaceTIM- Parameters:
year- the new system time yearmonth- the new system time month of the yearday- the new system time day of the monthhour- the new system time hour of the dayminute- the new system time minute of the hoursecond- the new system time second of the minutemicrosecond- the new system time microsecond of the second- Returns:
- the new system time in microseconds since the current epoch
-
time_of_day
public long time_of_day(long timeval)
Description copied from interface:TIMGet the number of microseconds since the beginning of the current day.- Specified by:
time_of_dayin interfaceTIM- Parameters:
timeval- timestamp value- Returns:
- the number of microseconds since 00:00:00 UTC of the current day
-
timer_add_time
public boolean timer_add_time(int microseconds, TimerHandle timer_inst_ref)Description copied from interface:TIMAdd time to a running timer.- Specified by:
timer_add_timein interfaceTIM- Parameters:
microseconds- the time to add in microsecondstimer_inst_ref- the timer handle to add time to- Returns:
- true if successful, false otherwise
-
timer_cancel
public boolean timer_cancel(TimerHandle timer_inst_ref)
Description copied from interface:TIMCancel a running timer.- Specified by:
timer_cancelin interfaceTIM- Parameters:
timer_inst_ref- the timer handle to cancel- Returns:
- true if successful, false otherwise
-
timer_remaining_time
public int timer_remaining_time(TimerHandle timer_inst_ref)
Description copied from interface:TIMGet the remaining time of a running timer in microseconds.- Specified by:
timer_remaining_timein interfaceTIM- Parameters:
timer_inst_ref- the timer handle to inspect- Returns:
- the remaining time of the timer in microseconds
-
timer_reset_time
public boolean timer_reset_time(int microseconds, TimerHandle timer_inst_ref)Description copied from interface:TIMReset the timer and set a new duration from the current system time.- Specified by:
timer_reset_timein interfaceTIM- Parameters:
microseconds- the new duration from the current system time to set in microsecondstimer_inst_ref- the timer handle to reset- Returns:
- true if successful, false otherwise
-
timer_start
public TimerHandle timer_start(EventHandle event_inst, int microseconds)
Description copied from interface:TIMStart a new timer to wake inmicrosecondsmicroseconds from the current system time. The architecture does not guarantee the timer will wake in exactlymicrosecondsmicroseconds, however it does guarantee that it will be at least that long. When the timer wakes, theevent_instwill be added to the system event queue.- Specified by:
timer_startin interfaceTIM- Parameters:
event_inst- the event to generate when the timer wakesmicroseconds- the duration from the current system time to set in microseconds- Returns:
- a handle to the newly created timer
-
timer_start_recurring
public TimerHandle timer_start_recurring(EventHandle event_inst, int microseconds)
Description copied from interface:TIMStart a new recurring timer to wake inmicrosecondsmicroseconds from the current system time. The architecture does not guarantee the timer will wake in exactlymicrosecondsmicroseconds, however it does guarantee that it will be at least that long. When the timer wakes, theevent_instwill be added to the system event queue. The timer will then be reset to wake again atmicrosecondsafter the system time when the timer event was last generated.- Specified by:
timer_start_recurringin interfaceTIM- Parameters:
event_inst- the event to generate when the timer wakesmicroseconds- the duration from the current system time to set in microseconds- Returns:
- a handle to the newly created timer
-
timestamp_format
public String timestamp_format(long timestamp, String format)
Description copied from interface:TIMFormat a timestamp according to a format string. This implementation follows the format documented inDateTimeFormatter.- Specified by:
timestamp_formatin interfaceTIM- Parameters:
timestamp- the timestamp to formatformat- the format string- Returns:
- a formatted string representing the timestamp
-
timestamp_to_string
public String timestamp_to_string(long timestamp)
Description copied from interface:TIMFormat a timestamp as a string representing the number of microseconds since the current epoch.- Specified by:
timestamp_to_stringin interfaceTIM- Parameters:
timestamp- the timestamp to format- Returns:
- the string representation of microseconds
-
-