public class TIMImpl<C extends IComponent<C>> extends Utility<C> implements TIM
Modifier and Type | Method and Description |
---|---|
long |
advance_time(long microseconds)
Advance the system clock by the specified number of microseconds.
|
Date |
create_date(int day,
int hour,
int minute,
int month,
int second,
int year)
Create a new
Date object from
the input parameters. |
long |
current_clock()
Get the current system time in microseconds since the epoch.
|
Date |
current_date()
Get the current date.
|
int |
current_seconds()
Get the current time in seconds since the epoch.
|
int |
get_day(Date date)
Get the day of the month from a date object.
|
int |
get_hour(Date date)
Get hour of the day from a date object.
|
int |
get_minute(Date date)
Get minute of the hour from a date object.
|
int |
get_month(Date date)
Get the month of the year from a date object.
|
int |
get_second(Date date)
Get second of the minute from a date object.
|
int |
get_year(Date date)
Get year from a date object.
|
void |
set_epoch(int day,
int month,
int year)
Set the instant in time from which the system clock counts.
|
long |
set_time(int year,
int month,
int day,
int hour,
int minute,
int second,
int microsecond)
Set the system clock time.
|
long |
time_of_day(long timeval)
Get the number of microseconds since the beginning of the current day.
|
boolean |
timer_add_time(int microseconds,
TimerHandle timer_inst_ref)
Add time to a running timer.
|
boolean |
timer_cancel(TimerHandle timer_inst_ref)
Cancel a running timer.
|
int |
timer_remaining_time(TimerHandle timer_inst_ref)
Get the remaining time of a running timer in microseconds.
|
boolean |
timer_reset_time(int microseconds,
TimerHandle timer_inst_ref)
Reset the timer and set a new duration from the current system time.
|
TimerHandle |
timer_start_recurring(EventHandle event_inst,
int microseconds)
Start a new recurring timer to wake in
microseconds microseconds
from the current system time. |
TimerHandle |
timer_start(EventHandle event_inst,
int microseconds)
Start a new timer to wake in
microseconds microseconds from the
current system time. |
String |
timestamp_format(long timestamp,
String format)
Format a timestamp according to a format string.
|
String |
timestamp_to_string(long timestamp)
Format a timestamp as a string representing the number of microseconds
since the current epoch.
|
context, getRunContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
warn
public TIMImpl(C context)
public long advance_time(long microseconds)
TIM
advance_time
in interface TIM
microseconds
- number of microseconds to advance the clockpublic Date create_date(int day, int hour, int minute, int month, int second, int year)
TIM
Date
object from
the input parameters.create_date
in interface TIM
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 minuteDate
object from
the input parameterspublic long current_clock()
TIM
current_clock
in interface TIM
public Date current_date()
TIM
current_date
in interface TIM
public int current_seconds()
TIM
current_seconds
in interface TIM
public int get_day(Date date)
TIM
public int get_month(Date date)
TIM
public int get_year(Date date)
TIM
public int get_hour(Date date)
TIM
public int get_minute(Date date)
TIM
get_minute
in interface TIM
date
- the input datepublic int get_second(Date date)
TIM
get_second
in interface TIM
date
- the input datepublic void set_epoch(int day, int month, int year)
TIM
set_epoch
is 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 to month
, day
, year
00:00:00 UTC.
Note: this call may result in unexpected timer behavior as the
expiration times will shift by the difference in epoch.public long set_time(int year, int month, int day, int hour, int minute, int second, int microsecond)
TIM
set_time
in interface TIM
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 secondpublic long time_of_day(long timeval)
TIM
time_of_day
in interface TIM
timeval
- timestamp valuepublic boolean timer_add_time(int microseconds, TimerHandle timer_inst_ref)
TIM
timer_add_time
in interface TIM
microseconds
- the time to add in microsecondstimer_inst_ref
- the timer handle to add time topublic boolean timer_cancel(TimerHandle timer_inst_ref)
TIM
timer_cancel
in interface TIM
timer_inst_ref
- the timer handle to cancelpublic int timer_remaining_time(TimerHandle timer_inst_ref)
TIM
timer_remaining_time
in interface TIM
timer_inst_ref
- the timer handle to inspectpublic boolean timer_reset_time(int microseconds, TimerHandle timer_inst_ref)
TIM
timer_reset_time
in interface TIM
microseconds
- the new duration from the current system time to set
in microsecondstimer_inst_ref
- the timer handle to resetpublic TimerHandle timer_start(EventHandle event_inst, int microseconds)
TIM
microseconds
microseconds from the
current system time. The architecture does not guarantee the timer will
wake in exactly microseconds
microseconds, however it does
guarantee that it will be at least that long. When the timer wakes, the
event_inst
will be added to the system event queue.timer_start
in interface TIM
event_inst
- the event to generate when the timer wakesmicroseconds
- the duration from the current system time to set in
microsecondspublic TimerHandle timer_start_recurring(EventHandle event_inst, int microseconds)
TIM
microseconds
microseconds
from the current system time. The architecture does not guarantee the
timer will wake in exactly microseconds
microseconds, however it
does guarantee that it will be at least that long. When the timer wakes,
the event_inst
will be added to the system event queue. The timer
will then be reset to wake again at microseconds
after the system
time when the timer event was last generated.timer_start_recurring
in interface TIM
event_inst
- the event to generate when the timer wakesmicroseconds
- the duration from the current system time to set in
microsecondspublic String timestamp_format(long timestamp, String format)
TIM
DateTimeFormatter
.timestamp_format
in interface TIM
timestamp
- the timestamp to formatformat
- the format stringpublic String timestamp_to_string(long timestamp)
TIM
timestamp_to_string
in interface TIM
timestamp
- the timestamp to formatCopyright © 2021. All rights reserved.