lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.TimeValue Class Reference

Represents an amount of time (a duration). More...

Inherits Comparable< TimeValue >.

Public Member Functions

TimeValue add (TimeValue b)
 Return the sum of this duration and the one represented by b.
int compareTo (TimeValue o)
boolean equals (Object t1)
long getMagnitude ()
 Return the magnitude of this value, as expressed in the unit of this value.
TimeUnit getUnit ()
 Units associated with this time value.
int hashCode ()
boolean isEarlierThan (TimeValue other)
 Returns whether this time value is earlier than another.
TimeValue subtract (TimeValue b)
 Return this time value minus the specified time value but no less than 0.
 TimeValue (long time, TimeUnit unit)
 Create a new time value.
 TimeValue (Time time)
 Create a new time value.
long toNanoSeconds ()
 Get this time value in number of nanoseconds.
String toString ()
 Return a string representation of this time value.

Static Public Member Functions

static int compare (TimeValue t1, TimeValue t2)
static TimeValue fromNanoSeconds (long ns)
 Return a TimeValue based on a nanosecond value.
static TimeValue max (TimeValue t1, TimeValue t2)
 Return the latest of both values.
static TimeValue min (TimeValue t1, TimeValue t2)
 Return the earliest of both values.

Public Attributes

final long time
 Primitive numerical representation of this time value, to be interpreted in terms the associated time unit.
final TimeUnit unit
 Units associated with this time value.

Static Public Attributes

static final TimeValue FOREVER = new TimeValue(Long.MAX_VALUE, TimeUnit.NANO)
 A time value representing FOREVER which is greater than any other time value.
static final long MAX_LONG_DEADLINE = Long.decode("0x7FFFFFFFFFFF")
 Maximum size of a deadline in primitive representation.
static final TimeValue MAX_VALUE = new TimeValue(Long.MAX_VALUE, TimeUnit.NANO)
 The maximum value of this type.
static final TimeValue MIN_VALUE = new TimeValue(Long.MIN_VALUE, TimeUnit.NANO)
 The minimum value of this type.
static final TimeValue NEVER = new TimeValue(Long.MIN_VALUE, TimeUnit.NANO)
 A time value representing NEVER, which is less than any other time value.
static final TimeValue ZERO = new TimeValue(0, null)
 A time value equal to zero.

Detailed Description

Represents an amount of time (a duration).

Author
Marten Lohstroh
Clément Fournier - TU Dresden, INSA Rennes

Constructor & Destructor Documentation

◆ TimeValue() [1/2]

org.lflang.TimeValue.TimeValue ( long time,
TimeUnit unit )

Create a new time value.

Parameters
timeThe time value.
unitThe unit of the time value.
Exceptions
IllegalArgumentExceptionIf time is non-zero and the unit is null.

◆ TimeValue() [2/2]

org.lflang.TimeValue.TimeValue ( Time time)

Create a new time value.

Parameters
timeThe time AST node..
Exceptions
IllegalArgumentExceptionIf time is non-zero and the unit is null.

Member Function Documentation

◆ add()

TimeValue org.lflang.TimeValue.add ( TimeValue b)

Return the sum of this duration and the one represented by b.

The unit of the returned TimeValue will be the minimum of the units of both operands except if only one of the units is TimeUnit.NONE. In that case, the unit of the other input is used.

Parameters
bThe right operand
Returns
A new TimeValue (the current value will not be affected)

◆ compare()

int org.lflang.TimeValue.compare ( TimeValue t1,
TimeValue t2 )
static

◆ compareTo()

int org.lflang.TimeValue.compareTo ( TimeValue o)

◆ equals()

boolean org.lflang.TimeValue.equals ( Object t1)

◆ fromNanoSeconds()

TimeValue org.lflang.TimeValue.fromNanoSeconds ( long ns)
static

Return a TimeValue based on a nanosecond value.

◆ getMagnitude()

long org.lflang.TimeValue.getMagnitude ( )

Return the magnitude of this value, as expressed in the unit of this value.

◆ getUnit()

TimeUnit org.lflang.TimeValue.getUnit ( )

Units associated with this time value.

May be null, but only if the magnitude is zero.

◆ hashCode()

int org.lflang.TimeValue.hashCode ( )

◆ isEarlierThan()

boolean org.lflang.TimeValue.isEarlierThan ( TimeValue other)

Returns whether this time value is earlier than another.

◆ max()

TimeValue org.lflang.TimeValue.max ( TimeValue t1,
TimeValue t2 )
static

Return the latest of both values.

◆ min()

TimeValue org.lflang.TimeValue.min ( TimeValue t1,
TimeValue t2 )
static

Return the earliest of both values.

◆ subtract()

TimeValue org.lflang.TimeValue.subtract ( TimeValue b)

Return this time value minus the specified time value but no less than 0.

The unit of the returned TimeValue will be the minimum of the units of both operands except if only one of the units is TimeUnit.NONE. In that case, the unit of the other input is used.

Parameters
bThe right operand
Returns
A new TimeValue (the current value will not be affected)

◆ toNanoSeconds()

long org.lflang.TimeValue.toNanoSeconds ( )

Get this time value in number of nanoseconds.

◆ toString()

String org.lflang.TimeValue.toString ( )

Return a string representation of this time value.

Member Data Documentation

◆ FOREVER

final TimeValue org.lflang.TimeValue.FOREVER = new TimeValue(Long.MAX_VALUE, TimeUnit.NANO)
static

A time value representing FOREVER which is greater than any other time value.

◆ MAX_LONG_DEADLINE

final long org.lflang.TimeValue.MAX_LONG_DEADLINE = Long.decode("0x7FFFFFFFFFFF")
static

Maximum size of a deadline in primitive representation.

NOTE: if we were to use an unsigned data type this would be 0xFFFFFFFFFFFF

◆ MAX_VALUE

final TimeValue org.lflang.TimeValue.MAX_VALUE = new TimeValue(Long.MAX_VALUE, TimeUnit.NANO)
static

The maximum value of this type.

This is approximately equal to 292 years.

◆ MIN_VALUE

final TimeValue org.lflang.TimeValue.MIN_VALUE = new TimeValue(Long.MIN_VALUE, TimeUnit.NANO)
static

The minimum value of this type.

◆ NEVER

final TimeValue org.lflang.TimeValue.NEVER = new TimeValue(Long.MIN_VALUE, TimeUnit.NANO)
static

A time value representing NEVER, which is less than any other time value.

◆ time

final long org.lflang.TimeValue.time

Primitive numerical representation of this time value, to be interpreted in terms the associated time unit.

◆ unit

final TimeUnit org.lflang.TimeValue.unit

Units associated with this time value.

May be null.

◆ ZERO

final TimeValue org.lflang.TimeValue.ZERO = new TimeValue(0, null)
static

A time value equal to zero.


The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/TimeValue.java