Class TIMImpl<C extends IComponent<C>>

    • Constructor Detail

      • TIMImpl

        public TIMImpl​(C context)
    • Method Detail

      • advance_time

        public long advance_time​(long microseconds)
        Description copied from interface: TIM
        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.
        Specified by:
        advance_time in interface TIM
        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: TIM
        Create a new Date object from the input parameters.
        Specified by:
        create_date in interface TIM
        Parameters:
        day - the year A.D.
        hour - the month of the year
        minute - the day of the month
        month - the hour of the day
        second - the minute of the hour
        year - the second of the minute
        Returns:
        a new Date object from the input parameters
      • current_clock

        public long current_clock()
        Description copied from interface: TIM
        Get the current system time in microseconds since the epoch.
        Specified by:
        current_clock in interface TIM
        Returns:
        the current time
      • current_date

        public Date current_date()
        Description copied from interface: TIM
        Get the current date.
        Specified by:
        current_date in interface TIM
        Returns:
        the current date
      • current_seconds

        public int current_seconds()
        Description copied from interface: TIM
        Get the current time in seconds since the epoch.
        Specified by:
        current_seconds in interface TIM
        Returns:
        the current seconds
      • get_day

        public int get_day​(Date date)
        Description copied from interface: TIM
        Get the day of the month from a date object.
        Specified by:
        get_day in interface TIM
        Parameters:
        date - the input date
        Returns:
        the day of the month for the input date
      • get_month

        public int get_month​(Date date)
        Description copied from interface: TIM
        Get the month of the year from a date object.
        Specified by:
        get_month in interface TIM
        Parameters:
        date - the input date
        Returns:
        the month of the year for the input date
      • get_year

        public int get_year​(Date date)
        Description copied from interface: TIM
        Get year from a date object.
        Specified by:
        get_year in interface TIM
        Parameters:
        date - the input date
        Returns:
        the year for the input date
      • get_hour

        public int get_hour​(Date date)
        Description copied from interface: TIM
        Get hour of the day from a date object.
        Specified by:
        get_hour in interface TIM
        Parameters:
        date - the input date
        Returns:
        the hour of the day for the input date
      • get_minute

        public int get_minute​(Date date)
        Description copied from interface: TIM
        Get minute of the hour from a date object.
        Specified by:
        get_minute in interface TIM
        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: TIM
        Get second of the minute from a date object.
        Specified by:
        get_second in interface TIM
        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: TIM
        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.
        Specified by:
        set_epoch in interface TIM
        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

        public long set_time​(int year,
                             int month,
                             int day,
                             int hour,
                             int minute,
                             int second,
                             int microsecond)
        Description copied from interface: TIM
        Set the system clock time. All timers that have expiration times earlier than the resulting time will immediately be fired.
        Specified by:
        set_time in interface TIM
        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

        public long time_of_day​(long timeval)
        Description copied from interface: TIM
        Get the number of microseconds since the beginning of the current day.
        Specified by:
        time_of_day in interface TIM
        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: TIM
        Add time to a running timer.
        Specified by:
        timer_add_time in interface TIM
        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

        public boolean timer_cancel​(TimerHandle timer_inst_ref)
        Description copied from interface: TIM
        Cancel a running timer.
        Specified by:
        timer_cancel in interface TIM
        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: TIM
        Get the remaining time of a running timer in microseconds.
        Specified by:
        timer_remaining_time in interface TIM
        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: TIM
        Reset the timer and set a new duration from the current system time.
        Specified by:
        timer_reset_time in interface TIM
        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

        public TimerHandle timer_start​(EventHandle event_inst,
                                       int microseconds)
        Description copied from interface: TIM
        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.
        Specified by:
        timer_start in interface TIM
        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

        public TimerHandle timer_start_recurring​(EventHandle event_inst,
                                                 int microseconds)
        Description copied from interface: TIM
        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.
        Specified by:
        timer_start_recurring in interface TIM
        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

        public String timestamp_format​(long timestamp,
                                       String format)
        Description copied from interface: TIM
        Format a timestamp according to a format string. This implementation follows the format documented in DateTimeFormatter.
        Specified by:
        timestamp_format in interface TIM
        Parameters:
        timestamp - the timestamp to format
        format - the format string
        Returns:
        a formatted string representing the timestamp
      • timestamp_to_string

        public String timestamp_to_string​(long timestamp)
        Description copied from interface: TIM
        Format a timestamp as a string representing the number of microseconds since the current epoch.
        Specified by:
        timestamp_to_string in interface TIM
        Parameters:
        timestamp - the timestamp to format
        Returns:
        the string representation of microseconds