Different sampling strategies as well as reactor for coordinating sampling of multiple sensors each with different strategies.
Bases: katcp.sampling.SampleStrategy
Strategy which sends updates whenever the sensor itself is updated.
Methods
| SampleAuto.attach() | |
| SampleAuto.detach() | Detach strategy from its sensor. |
| SampleAuto.get_sampling() | |
| SampleAuto.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleAuto.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SampleAuto.inform() | Inform strategy creator of the sensor status. |
| SampleAuto.periodic(timestamp) | This method is called when a period strategy is being configured or periodically after that. |
| SampleAuto.update(sensor) |
Bases: katcp.sampling.SampleStrategy
Differential sampling strategy for integer and float sensors.
Sends updates only when the value has changed by more than some specified threshold, or the status changes.
Methods
| SampleDifferential.attach() | |
| SampleDifferential.detach() | Detach strategy from its sensor. |
| SampleDifferential.get_sampling() | |
| SampleDifferential.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleDifferential.get_strategy(...) | Factory method to create a strategy object. |
| SampleDifferential.inform() | Inform strategy creator of the sensor status. |
| SampleDifferential.periodic(timestamp) | This method is called when a period strategy is being configured or periodically after that. |
| SampleDifferential.update(sensor) |
Bases: katcp.sampling.SampleEventRate
Strategy which sends updates when the sensor value or status changes.
This implementation of the event strategy extends the KATCP guidelines to allow an optional minimum time between updates (in millseconds) to be specified as a parameter. If further sensor updates occur before this time has elapsed, no additional events are sent out.
Methods
| SampleEvent.attach() | |
| SampleEvent.detach() | Detach strategy from its sensor. |
| SampleEvent.get_sampling() | |
| SampleEvent.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleEvent.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SampleEvent.inform() | Inform strategy creator of the sensor status. |
| SampleEvent.periodic(timestamp) | |
| SampleEvent.update(sensor[, now]) |
Bases: katcp.sampling.SampleStrategy
Event rate sampling strategy.
Report the sensor value whenever it changes or if more than longest_period milliseconds have passed since the last reported update. However, do not report the value if less than shortest_period milliseconds have passed since the last reported update.
Methods
| SampleEventRate.attach() | |
| SampleEventRate.detach() | Detach strategy from its sensor. |
| SampleEventRate.get_sampling() | |
| SampleEventRate.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleEventRate.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SampleEventRate.inform() | Inform strategy creator of the sensor status. |
| SampleEventRate.periodic(timestamp) | |
| SampleEventRate.update(sensor[, now]) |
Bases: katcp.sampling.SampleStrategy
Sampling strategy which never sends any updates.
Methods
| SampleNone.attach() | Attach strategy to its sensor. |
| SampleNone.detach() | Detach strategy from its sensor. |
| SampleNone.get_sampling() | |
| SampleNone.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleNone.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SampleNone.inform() | Inform strategy creator of the sensor status. |
| SampleNone.periodic(timestamp) | This method is called when a period strategy is being configured or periodically after that. |
| SampleNone.update(sensor) | Callback used by the sensor’s notify method. |
Bases: katcp.sampling.SampleStrategy
Periodic sampling strategy.
For periodic sampling of any sensor.
Methods
| SamplePeriod.attach() | Attach strategy to its sensor. |
| SamplePeriod.detach() | Detach strategy from its sensor. |
| SamplePeriod.get_sampling() | |
| SamplePeriod.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SamplePeriod.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SamplePeriod.inform() | Inform strategy creator of the sensor status. |
| SamplePeriod.periodic(timestamp) | |
| SamplePeriod.update(sensor) | Callback used by the sensor’s notify method. |
Bases: katcp.core.ExcepthookThread
SampleReactor manages sampling strategies.
This class keeps track of all the sensors and what strategy is currently used to sample each one. It also provides a thread that calls periodic sampling strategies as needed.
| Parameters : | logger : logging.Logger object
|
|---|
Methods
| SampleReactor.add_strategy(strategy) | Add a sensor strategy to the reactor. |
| SampleReactor.getName() | |
| SampleReactor.isAlive() | |
| SampleReactor.isDaemon() | |
| SampleReactor.is_alive() | |
| SampleReactor.join([timeout]) | |
| SampleReactor.remove_strategy(strategy) | Remove a strategy from the reactor. |
| SampleReactor.run() | Run the sample reactor. |
| SampleReactor.setDaemon(daemonic) | |
| SampleReactor.setName(name) | |
| SampleReactor.start() | |
| SampleReactor.stop() | Send event to processing thread and wait for it to stop. |
Add a sensor strategy to the reactor.
Strategies should be removed using remove_strategy().
The new strategy is then attached to the sensor for updates and a periodic sample is triggered to schedule the next one.
| Parameters : | strategy : SampleStrategy object
|
|---|
Remove a strategy from the reactor.
Strategies are added with add_strategy().
| Parameters : | strategy : SampleStrategy object
|
|---|
Run the sample reactor.
Send event to processing thread and wait for it to stop.
Bases: object
Base class for strategies for sampling sensors.
| Parameters : | inform_callback : callable
sensor : Sensor object
params : list of objects
|
|---|
Methods
| SampleStrategy.attach() | Attach strategy to its sensor. |
| SampleStrategy.detach() | Detach strategy from its sensor. |
| SampleStrategy.get_sampling() | Return the Strategy constant for this sampling strategy. |
| SampleStrategy.get_sampling_formatted() | Return the current sampling strategy and parameters. |
| SampleStrategy.get_strategy(strategyName, ...) | Factory method to create a strategy object. |
| SampleStrategy.inform() | Inform strategy creator of the sensor status. |
| SampleStrategy.periodic(timestamp) | This method is called when a period strategy is being configured or periodically after that. |
| SampleStrategy.update(sensor) | Callback used by the sensor’s notify method. |
Attach strategy to its sensor.
Detach strategy from its sensor.
Return the Strategy constant for this sampling strategy.
Sub-classes should implement this method and return the appropriate constant.
| Returns : | strategy : Strategy constant
|
|---|
Return the current sampling strategy and parameters.
The strategy is returned as a string and the values in the parameter list are formatted as strings using the formatter for this sensor type.
| Returns : | strategy_name : string
params : list of strings
|
|---|
Factory method to create a strategy object.
| Parameters : | inform_callback : callable
sensor : Sensor object
params : list of objects
|
|---|---|
| Returns : | strategy : SampleStrategy object
|
Inform strategy creator of the sensor status.
This method is called when a period strategy is being configured or periodically after that.
Sub-classes should override this method or update() to provide the necessary sampling strategy.
| Parameters : | timestamp : float in seconds
|
|---|---|
| Returns : | next_timestamp : float in seconds
|
Callback used by the sensor’s notify method.
This update method is called whenever the sensor value is set so sensor will contain the right info. Note that the strategy does not really need to be passed sensor because it already has a handle to it but receives it due to the generic observer mechanism.
Sub-classes should override this method or periodic() to provide the necessary sampling strategy.
| Parameters : | sensor : Sensor object
|
|---|