caproto.ioc_examples.random_walk.RandomWalkIOC

Inheritance diagram of RandomWalkIOC
class caproto.ioc_examples.random_walk.RandomWalkIOC(prefix, *, macros=None, parent=None, name=None)[source]

This example contains a PV x that takes random steps at an update rate controlled by a second PV, dt.

RandomWalkIOC pvproperties

Attribute

Suffix

Docs

Type

Notes

Alarm Group

dt

dt

Delta time [sec]

float

x

x

The random float value

float

Startup

Methods

group_read(instance)

Generic read called for channels without get defined

group_write(instance, value)

Generic write called for channels without put defined

Attributes

default_values

type_map

type_map_read_only

pvproperty methods

x.startup(self, instance, async_lib)

This is a startup hook which periodically updates the value.

Source code: x.startup
16@x.startup
17async def x(self, instance, async_lib):
18    """This is a startup hook which periodically updates the value."""
19    while True:
20        # Grab the current value from `self.x` and compute the next value:
21        x = self.x.value + 2. * random.random() - 1.0
22
23        # Update the ChannelData instance and notify any subscribers:
24        await instance.write(value=x)
25
26        # Let the async library wait for the next iteration
27        await async_lib.sleep(self.dt.value)