ControlAction#

module wntr.network.controls

class ControlAction[source]#

Bases: BaseControlAction

A general class for specifying a control action that simply modifies the attribute of an object (target).

Parameters:
  • target_obj (object) – The object whose attribute will be changed when the control runs.

  • attribute (string) – The attribute that will be changed on the target_obj when the control runs.

  • value (any) – The new value for target_obj.attribute when the control runs.


__init__(target_obj, attribute, value)[source]#
notify()#

Call the update method for all observers of this subject.

requires()[source]#

Returns a set of objects used to evaluate the control

Returns:

req – The objects required to run the control action.

Return type:

OrderedSet

run_control_action()[source]#

This method is called to run the corresponding control action.

subscribe(observer)#

Subscribe observer to this subject. The update method of any observers of this subject will be called when notify is called on this subject.

Parameters:

observer (Observer)

target()[source]#

Returns a tuple (object, attribute) containing the object and attribute that the control action may change

Returns:

target – A tuple containing the target object and the attribute to be changed (target, attr).

Return type:

tuple

unsubscribe(observer)#

Unsubscribe observer from this subject.

Parameters:

observer (Observer)