1 '''
2 Defines a L{Task} to execute when the state of an accesible or item changes.
3
4 @author: Peter Parente
5 @organization: IBM Corporation
6 @copyright: Copyright (c) 2005, 2007 IBM Corporation
7 @license: The BSD License
8
9 All rights reserved. This program and the accompanying materials are made
10 available under the terms of the BSD license which accompanies
11 this distribution, and is available at
12 U{http://www.opensource.org/licenses/bsd-license.php}
13 '''
14
15 import Base, EventTask
16 import AEEvent
17
19 '''
20 Executed when the state of an accesible or item changes.
21
22 This class registers its name and whether it should be monitored by default
23 in an L{AEMonitor} using the L{Base.registerTaskType} function when this
24 module is first imported. The L{AEMonitor} can use this information to build
25 its menus.
26 '''
27 Base.registerTaskType('StateTask', False)
28
30 '''
31 @return: Type of L{AEEvent} this L{Task} wants to handle
32 @rtype: class
33 '''
34 return AEEvent.StateChange
35
36 - def update(self, por, name, value, layer, **kwargs):
37 '''
38 Updates this L{Task} in response to a consumed state change event. Called by
39 L{Tier.Tier._executeTask}.
40
41 @param por: Point of regard for the related accessible/item
42 @type por: L{POR}
43 @param name: Name of the state that changed
44 @type name: string
45 @param value: True if the state is now set, False if not
46 @type value: boolean
47 @param layer: Layer on which the event occurred
48 @type layer: integer
49 '''
50 pass
51
52 - def execute(self, por, name, value, layer, **kwargs):
53 '''
54 Executes this L{Task} in response to a state change event. Called by
55 L{Tier.Tier._executeTask}.
56
57 @param por: Point of regard for the related accessible/item
58 @type por: L{POR}
59 @param name: Name of the state that changed
60 @type name: string
61 @param value: True if the state is now set, False if not
62 @type value: boolean
63 @param layer: Layer on which the event occurred
64 @type layer: integer
65 @return: True to allow other L{Task}s to process this event
66 @rtype: boolean
67 '''
68 return True
69