CentraleSupélecDépartement informatique
Plateau de Moulon
3 rue Joliot-Curie
F-91192 Gif-sur-Yvette cedex
A light switch and a fluorescent bulb

This example shows how TESL can deal with very different time scales without needing a very large number of computed instants.

A fluorescent light bulb takes 1s to become completely lit after being switched on, and 50ms to become completely off after being switched off. When a button is pressed, the light is switched on for one minute.

Q-clock ms           // a clock to measure milliseconds
Q-clock s            // a clock to measure seconds
tag relation ms = 1000 * s + 0
Q-clock min          // a clock to measure minutes
tag relation s = 60 * min + 0

Q-clock button sporadic 500   // button is pushed at time 500
tag relation button = ms        // measured on the ms scale

unit-clock switch_on   // switch the light on
unit-clock switch_off  // switch the light off
unit-clock light_on    // the light becomes on
unit-clock light_off   // the light becomes off

button implies switch_on // pushing the button switches the light on
// The light is switched off 1 minute later
switch_on time delayed by 1.0 on min implies switch_off

// The light is on 1s after being switched on
switch_on time delayed by 1.0 on s implies light_on
// The light is off 5ms after being switched off
switch_off time delayed by 50.0 on ms implies light_off

@tagref ms  // use the ms clock as time base in the output
@dumpres

The result of this simulation is difficult to show on a picture because of the large difference in magnitude between the one minute delay before switching the light off and the 50ms delay for the light to become dark. In order to separate the ticks of the switch_off and light_off clocks, you must have a very large space between the ticks on switch_on and switch_off. We therefore give the result as shown by the @dumpres directive. As you can see, thanks to the computations on tags, this simulation has only 4 instants (we do not need a clock which ticks every 50ms):

## Simulation result:
# Tag = 500.0
  button
  switch_on
# Tag = 1500.0
  light_on
# Tag = 60500.0
  switch_off
# Tag = 60550.0
  light_off
## End