Detect

This is a long line of text.

Classes

class detect.DetectionMonitor
algorithm
parameter
obj
prop
filter
__init__(algorithm, parameter, obj, prop, filter=None)

This is a long line of text.

property_change(old_value, new_value)

This is a long line of text.

class detect.DetectionAlgorithm
_monitors

This private attribute is a list of DetectionMonitor objects that associate this algorithm instance with objects and properties.

_triggered

This private attribute is True when there is a change in a parameter which causes the algorithm to schedule itself to execute. More than one parameter may change between the times that the algorithm can execute.

__init__()

Initialize a detection algorithm, which simply initializes the instance attributes.

bind(**kwargs)
Parameters:kwargs (tuple) – parameter to property mapping

Create a DetectionMonitor instance for each of the keyword arguments and point it back to this algorithm instance. The algorithm parameter matches the keyword parameter name and the parameter value is an (object, property_name) tuple.

unbind()

Delete the DetectionMonitor objects associated with this algorithm and remove them from the property changed call list(s).

execute()

This function is provided by a derived class which checks to see if something should happen when its parameters have changed. For example, maybe a change-of-value or event notification should be generated.

_execute()

This method is a special wrapper around the execute() function that sets the internal trigger flag. When the flag is set then the execute() function is already scheduled to run (via deferred()) and doesn’t need to be scheduled again.

Decorators

detect.monitor_filter(parameter)
Parameters:parameter (string) – name of parameter to filter

This decorator is used with class methods of an algorithm to determine if the new value for a propert of an object is significant enough to consider the associated parameter value changed. For example:

class SomeAlgorithm(DetectionAlgorithm):

    @monitor_filter('pValue')
    def value_changed(self, old_value, new_value):
        return new_value > old_value + 10

Assume that an instance of this algorithm is bound to the presentValue of an AnalogValueObject:

some_algorithm = SomeAlgorithm()
some_algorithm.bind(pValue = (avo, 'presentValue'))

The algorithm parameter pValue will only be considered changed when the present value of the analog value object has increased by more than 10 at once. If it slowly climbs by something less than 10, or declines at all, the algorithm will not execute.