Interface TIM

  • All Known Implementing Classes:
    TIMImpl

    public interface TIM
    Time manipulaiton utilities and utilites for setting and modifiying timers.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long advance_time​(long microseconds)
      Advance the system clock by the specified number of microseconds.
      Date create_date​(int year, int month, int day, int hour, int minute, int second)
      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​(EventHandle event_inst, int microseconds)
      Start a new timer to wake in microseconds microseconds 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.
      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.
    • Method Detail

      • advance_time

        long advance_time​(long microseconds)
        Advance the system clock by the specified number of microseconds. All timers that have expiration times earlier than the resulting time will immediately be fired.
        Parameters:
        microseconds - number of microseconds to advance the clock
        Returns:
        the system clock time after it has been advanced
      • create_date

        Date create_date​(int year,
                         int month,
                         int day,
                         int hour,
                         int minute,
                         int second)
        Create a new Date object from the input parameters.
        Parameters:
        year - the year A.D.
        month - the month of the year
        day - the day of the month
        hour - the hour of the day
        minute - the minute of the hour
        second - the second of the minute
        Returns:
        a new Date object from the input parameters
      • current_clock

        long current_clock()
        Get the current system time in microseconds since the epoch.
        Returns:
        the current time
      • current_date

        Date current_date()
        Get the current date.
        Returns:
        the current date
      • current_seconds

        int current_seconds()
        Get the current time in seconds since the epoch.
        Returns:
        the current seconds
      • get_day

        int get_day​(Date date)
        Get the day of the month from a date object.
        Parameters:
        date - the input date
        Returns:
        the day of the month for the input date
      • get_month

        int get_month​(Date date)
        Get the month of the year from a date object.
        Parameters:
        date - the input date
        Returns:
        the month of the year for the input date
      • get_year

        int get_year​(Date date)
        Get year from a date object.
        Parameters:
        date - the input date
        Returns:
        the year for the input date
      • get_hour

        int get_hour​(Date date)
        Get hour of the day from a date object.
        Parameters:
        date - the input date
        Returns:
        the hour of the day for the input date
      • get_minute

        int get_minute​(Date date)
        Get minute of the hour from a date object.
        Parameters:
        date - the input date
        Returns:
        the minute of the hour for the input date
      • get_second

        int get_second​(Date date)
        Get second of the minute from a date object.
        Parameters:
        date - the input date
        Returns:
        the second of the minute for the input date
      • set_epoch

        void set_epoch​(int day,
                       int month,
                       int year)
        Set the instant in time from which the system clock counts. If 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.
        Parameters:
        day - the day of the month of the new epoch
        month - the month of the year of the new epoch
        year - the year of the new epoch
      • set_time

        long set_time​(int year,
                      int month,
                      int day,
                      int hour,
                      int minute,
                      int second,
                      int microsecond)
        Set the system clock time. All timers that have expiration times earlier than the resulting time will immediately be fired.
        Parameters:
        year - the new system time year
        month - the new system time month of the year
        day - the new system time day of the month
        hour - the new system time hour of the day
        minute - the new system time minute of the hour
        second - the new system time second of the minute
        microsecond - the new system time microsecond of the second
        Returns:
        the new system time in microseconds since the current epoch
      • time_of_day

        long time_of_day​(long timeval)
        Get the number of microseconds since the beginning of the current day.
        Parameters:
        timeval - timestamp value
        Returns:
        the number of microseconds since 00:00:00 UTC of the current day
      • timer_add_time

        boolean timer_add_time​(int microseconds,
                               TimerHandle timer_inst_ref)
        Add time to a running timer.
        Parameters:
        microseconds - the time to add in microseconds
        timer_inst_ref - the timer handle to add time to
        Returns:
        true if successful, false otherwise
      • timer_cancel

        boolean timer_cancel​(TimerHandle timer_inst_ref)
        Cancel a running timer.
        Parameters:
        timer_inst_ref - the timer handle to cancel
        Returns:
        true if successful, false otherwise
      • timer_remaining_time

        int timer_remaining_time​(TimerHandle timer_inst_ref)
        Get the remaining time of a running timer in microseconds.
        Parameters:
        timer_inst_ref - the timer handle to inspect
        Returns:
        the remaining time of the timer in microseconds
      • timer_reset_time

        boolean timer_reset_time​(int microseconds,
                                 TimerHandle timer_inst_ref)
        Reset the timer and set a new duration from the current system time.
        Parameters:
        microseconds - the new duration from the current system time to set in microseconds
        timer_inst_ref - the timer handle to reset
        Returns:
        true if successful, false otherwise
      • timer_start

        TimerHandle timer_start​(EventHandle event_inst,
                                int microseconds)
        Start a new timer to wake in 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.
        Parameters:
        event_inst - the event to generate when the timer wakes
        microseconds - the duration from the current system time to set in microseconds
        Returns:
        a handle to the newly created timer
      • timer_start_recurring

        TimerHandle timer_start_recurring​(EventHandle event_inst,
                                          int microseconds)
        Start a new recurring timer to wake in 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.
        Parameters:
        event_inst - the event to generate when the timer wakes
        microseconds - the duration from the current system time to set in microseconds
        Returns:
        a handle to the newly created timer
      • timestamp_format

        String timestamp_format​(long timestamp,
                                String format)
        Format a timestamp according to a format string. This implementation follows the format documented in DateTimeFormatter.
        Parameters:
        timestamp - the timestamp to format
        format - the format string
        Returns:
        a formatted string representing the timestamp
      • timestamp_to_string

        String timestamp_to_string​(long timestamp)
        Format a timestamp as a string representing the number of microseconds since the current epoch.
        Parameters:
        timestamp - the timestamp to format
        Returns:
        the string representation of microseconds