Dynamic Value Generator

An implementation of a dynamic TPM simulator.

class DynamicValuesGenerator(soft_min, soft_max, window_size=20, in_range_rate=0.95)

A generator of dynamic values with the following properties.

  • We want the values to gradually walk around their range rather than randomly jumping around. i.e. we want values to be temporally correlated. We achieve this by calculating values as a sliding window sum of a sequence of independent (uncorrelated) random values.

  • The provided range is a “soft” range – we allow values to walk outside this range occasionally. The proportion of time that the values should stay within the required range is exposed as an argument. This is useful for testing the alarm conditions of TANGO attributes: we set the soft range of this generator to the attribute’s alarm range, and we specify how often the attribute should exceed that range and thus start alarming.

__init__(soft_min, soft_max, window_size=20, in_range_rate=0.95)

Create a new instance.

Parameters:
  • soft_min (float) – a “soft” minimum value. For TANGO device attributes, this should be the alarm minimum.

  • soft_max (float) – a “soft” maximum value. For TANGO device attributes, this should be the alarm maximum.

  • window_size (int) – the size of the sliding window to sum over. A value of 1 will give uncorrelated values. Increasing the value increases correlation – a graph of how the value changes over time will be smoother. The default is 20.

  • in_range_rate (float) – the proportion of time during which the value should remain within the [soft_min, soft_max] range. The default is 0.95. Don’t change this to 1.0 unless you want the variance to collapse: you’ll get the mean of the range every time.

class DynamicValuesUpdater(update_rate=1.0)

An dynamic updater of values, for use in a dynamic simulator.

__init__(update_rate=1.0)

Create a new instance.

Parameters:

update_rate (float) – how often, in seconds, the target values should be updated. Defaults to 1 second.

add_target(generator, callback)

Add a new target to be updated.

Parameters:
  • generator (Any) – the generator of values to be used as updates

  • callback (Callable) – the callback to be called with updates

Return type:

None

start()

Start the updater thread.

Return type:

None

stop()

Stop the updater thread.

Return type:

None