Class Clock
Represents virtual time.
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public class Clock : object
Constructors
View SourceClock(DateTime, Single)
Initializes a new instance of the Clock class.
Declaration
public Clock(DateTime virtualNow, float replaySpeedFactor = null)
Parameters
Type | Name | Description |
---|---|---|
DateTime | virtualNow | The desired current virtual time. |
Single | replaySpeedFactor | if set to a value greater than 1, virtual time passes faster than real time by this factor. |
Clock(TimeSpan, Single)
Initializes a new instance of the Clock class.
Declaration
public Clock(TimeSpan virtualTimeOffset = null, float timeDilationFactor = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | virtualTimeOffset | The delta between virtual time and real time. A negative value will result in times in the past, a positive value will result in times in the future. |
Single | timeDilationFactor | if set to a value greater than 1, virtual time passes faster than real time by this factor. |
Properties
View SourceOrigin
Gets the offset origin in real time.
Declaration
public DateTime Origin { get; }
Property Value
Type | Description |
---|---|
DateTime |
RealTimeOrigin
Gets the origin in real time.
Declaration
public DateTime RealTimeOrigin { get; }
Property Value
Type | Description |
---|---|
DateTime |
Methods
View SourceGetCurrentTime()
Returns the virtual time with high resolution (1us), in the virtual time frame of reference.
Declaration
public DateTime GetCurrentTime()
Returns
Type | Description |
---|---|
DateTime | The current time in the adjusted frame of reference. |
GetTimeFromElapsedTicks(Int64)
Returns the absolute time represented by the number of 100ns ticks from system boot.
Declaration
public DateTime GetTimeFromElapsedTicks(long ticksFromSystemBoot)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | ticksFromSystemBoot | The number of 100ns ticks since system boot. |
Returns
Type | Description |
---|---|
DateTime | The absolute time. |
ToRealTime(DateTime)
Returns the real time corresponding to the virtual time, given the current time mapping.
Declaration
public DateTime ToRealTime(DateTime virtualTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | virtualTime | A time in the virtual time frame. |
Returns
Type | Description |
---|---|
DateTime | The corresponding time in the real time frame of reference. |
ToRealTime(TimeSpan)
Returns the real time span, given a virtual time span.
Declaration
public TimeSpan ToRealTime(TimeSpan virtualTimeInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | virtualTimeInterval | Virtual time span. |
Returns
Type | Description |
---|---|
TimeSpan | Real time span. |
ToVirtualTime(DateTime)
Returns the virtual time, given the current time mapping.
Declaration
public DateTime ToVirtualTime(DateTime realTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | realTime | A time in the real time frame. |
Returns
Type | Description |
---|---|
DateTime | The corresponding time in the adjusted frame of reference. |
ToVirtualTime(TimeSpan)
Returns the virtual time span, given a real time span.
Declaration
public TimeSpan ToVirtualTime(TimeSpan realTimeInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | realTimeInterval | Real time span. |
Returns
Type | Description |
---|---|
TimeSpan | Virtual time span. |