Simulation Time Overview

From SIMboxWiki
Jump to navigation Jump to search


Why do we need a timer? Theoretically, a simulation may be designed without any user-accessible timer and run on a frame-based manner.
But there are many cases where timer functionality is very useful or even required. Some examples are:

  • Motion models that use exact time deltas for high fidelity calculation of a current position.
  • Cockpit elements that may show current day time or mission time.
  • Simulation playback that gives an ability to jump to specified position within the session timeline.
  • Events that are saved with timestamp indicating when they were occurred during the session.
  • Virtual Instructor logic, that use a timer for time bounded operations.
  • Graphics engine uses time of day, provided by timer, for creating appropriate lighting conditions.

These are only few examples. The actual use is much wider. The SimBox user, who develops new components by utilizing SimBox SDK, can use a timer to control simulation time.
One of the simplest examples for using a timer: implementing timeout for something. For example, some logic should be performed X milliseconds and then stopped. X millisecond may be measured by using timer’s function, which provides a simulation time.

The question that may be asked here; why not to use timer function of the operating system or why not just count frames? The operating system’s timer does not pause when the simulation pauses and it has a different time resolution (more about that later), therefore it is not convenient and near impossible to use it for orientation in time within the simulated world. Counting frames is not a good way either.

The SimBox simulation is not real-time, therefore it does not promise exact frame duration, because it depends on simulation and system load.

The timer, provided by SimBox simulation, is an only accurate and correct way to work with time in simulation components. It provides a control over simulation time, time of day and playback position. For more information about timer’s functionality see Timer API.

Simulation Time Principles

A simulation can represent time either as a continuum or as a series of discrete events. However, these two approaches differ greatly:

  • A continuum representation of time is similar to the way time is conceived in the real world. Each calculation is done with different time values, and object graphic representation is done in discrete events (frames). Hence, inconsistency between the display and the simulation occurs.
  • A discrete representation of time is different from the way time is conceived in the real world, but is more similar to the method in which computer programs operate. Programs that involve time consideration (including real-time programs) often find it convenient to assume that a certain calculation takes zero time to calculate. Although it is never true, such an assumption simplifies many problems.

KnowBook simulation works in a discrete representation of time. Utilizing this principle, time is sampled from every discrete time event and a time stamp is established. This time stamp is used for all time dependent calculations, until the next discrete time event sample. The gap between two discrete time events is the smallest time resolution. A single frame is defined as the smallest relevant time resolution.

In practice, a time stamp is sampled for every frame. All calculations are done with the time stamp as if they take zero time to compute. Then the frame is drawn and time stamp is advanced.

Types of Timers

Simulation Time

This timer is the time passed since the scenario started. The simulation timer starts from 0 and advances as the scenario advance. When the scenario is paused the simulation time also pauses and does not advance.

Time of Day

This timer represents the current day time in which the simulation scenario operates. Using the SIMbox Scenario Editor you can specify the scenario start time. The Time of Day timer is calculated as follows: Time Of Day = The Initial Scenario Start Time + Simulation Time.

Admin Time

Admin Time is Simulation Time which does not pause when the simulation pauses.

[[Category::Development Articles]]