1 '''
2 Defines an L{AEEvent} indicating a timer event occurred.
3
4 @author: Peter Parente
5 @organization: IBM Corporation
6 @copyright: Copyright (c) 2005, 2007 IBM Corporation
7 @license: The BSD License
8
9 @author: Frank Zenker
10 @author: Ramona Bunk
11 @organization: IT Science Center Ruegen gGmbH, Germany
12 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
13 @license: The BSD License
14
15 All rights reserved. This program and the accompanying materials are made
16 available under the terms of the BSD license which accompanies
17 this distribution, and is available at
18 U{http://www.opensource.org/licenses/bsd-license.php}
19 '''
20
21 import AccessEngine
22 import Base
23
25 '''
26 Event that fires when a registered timer triggers a notification.
27
28 This class registers its name and whether it should be monitored by default
29 in an L{AEMonitor} using the L{Base.registerEventType} function when
30 this module is first imported. The L{AEMonitor} can use this information to
31 build its menus.
32
33 @ivar aid: Unique identifier for the application L{AETier} with which the
34 timer that fired this event is associated
35 @type aid: opaque
36 @ivar task_key: Key to the task that will handle the timer event
37 @type task_key: tuple of ('task name', 'script name')
38 @ivar interval: Interval on which the timer is triggered
39 @type interval: integer
40 '''
41 Base.registerEventType('TimerAlert', False)
42 - def __init__(self, aid, task_key, interval, **kwargs):
43 '''
44 Stores important references.
45
46 @param aid: Unique identifier for the application L{AETier} with which the
47 timer that fired this event is associated
48 @type aid: opaque
49 @param task_key: Key to the task that will handle the timer event
50 @type task_key: tuple of ('task name', 'script name')
51 @param interval: Interval on which the timer is triggered
52 @type interval: integer
53 '''
54 Base.AEEvent.__init__(self, focused=False, **kwargs)
55 self.aid = aid
56 self.task_key = task_key
57 self.interval = interval
58
60 '''
61 Returns a human readable representation of this event including its name
62 and interval.
63
64 @return: Information about this event
65 @rtype: string
66 '''
67 name = Base.AEEvent.__str__(self)
68 return '%s:\n\tinterval: %d' % (name, self.interval)
69
71 '''
72 Contacts the L{AETierManager} and asks it to manage this chooser event.
73
74 @return: True to indicate the event executed properly
75 @rtype: boolean
76 '''
77 AccessEngine.AETierManager.manageTimer(self)
78 return True
79
81 '''
82 @return: Unique application ID identifying the top most container for the
83 source of this event (i.e. the application)
84 @rtype: opaque object
85 '''
86 return self.aid
87
89 '''
90 Gets the key of the task that should handle the timer event. This
91 information is used to locate the task that should handle this event.
92
93 @return: key of the task that will handle the event
94 @rtype: tuple of ('task name', 'script name')
95 '''
96 return self.task_key
97
99 '''
100 Fetches data out of this L{TimerAlert}.
101
102 @return: Dictionary of parameters to be passed to a task function as
103 follows:
104 - interval: The interval on which the timer fires
105 @rtype: dictionary
106 '''
107 return {'interval' : self.interval}
108