File: /home/oboss/Users/gec/sources/PUS_Services/Event_Scheduler/event_scheduler.ads

1     --% Compilation Unit:	Event_Scheduler
2     --
3     --% Category: Generic Package Declaration
4     --
5     --% Release:  $Name:  $
6     --
7     --% Version:  $Revision: 2.0 $
8     --
9     --% Author:   $Author: gec $
10     --
11     --% Revision Log:
12     --    $Log: event_scheduler.ads,v $
13     --    Revision 2.0  2003/04/04 08:51:03  gec
14     --    Initial release of source files serving as baseline for OBOSS-III project.
15     --
16     --    Revision 1.1.1.1  2003/04/04 08:13:12  gec
17     --    Imported using TkCVS
18     --
19     --
20     --
21     --% Project: OBOSS
22     --
23     --% Copyright (C) 2003 by Terma A/S
24     --  Proprietary and intellectual rights of Terma A/S, Denmark,
25     --  are involved in the subject-matter of this material and
26     --  all manufacturing, reproduction, use, disclosure, and
27     --  sales rights pertaining to such subject-matter are
28     --  expressly reserved. This material is submitted for a
29     --  specific purpose as agreed, and the recipient by
30     --  accepting this material agrees that this material will
31     --  not be used, copied, or reproduced in whole or in part
32     --  nor its contents revealed in any manner or to any person,
33     --  except to meet the purpose for which it was submitted and
34     --  subject to the terms of the agreement.
35     --
36     --% Target Dependencies:
37     --    None
38     --% Compiler Dependencies:
39     --    None
40     
41     --~-----------------------------------------------------------------------------
42     
43     with Task_Priority_Control;
44     generic
45     
46        --% Generic Parameter Constraints:
47        -->   Protected_Task_Priority  - Shall be higher than the ceiling of
48        --+    priorities of all tasks using services from the event scheduler
49        -->   Max_Number_Of_Events_Due - Shall be sufficiently large to cater for
50        --+    the maximum number of events due in timespane between two consecutive
51        --+    calls to Get_Events_Due
52     
53        -- Max_Number_Of_Events indicates the maximum number of events that can be
54        --+    added to the schedule
55        Max_Number_Of_Events : in     Positive;
56     
57        -- Max_Number_Of_Events_Due indicates thet maximum number of events that may
58        --+    be due at the time Get_Events_Due is called.
59        -- This will be depending on the period of events added to the schedule and
60        --+    the period with which Get_Events_Due is polled.
61        Max_Number_Of_Events_Due : in     Positive;
62     
63        -- Identification associated to events on schedule
64        type Event_ID is (<>);
65     
66        -- Time representation used for temporal ordering
67        type Time_Rep is private;
68     
69        -- Interval representing time spans
70        type Interval is private;
71     
72        -- Temporal ordering of times.
73        -- Before(T_1, T_2) iff T_1 is preceding T_2 temporally.
74        with function Before
75              (T_1, T_2 :        Time_Rep)
76              return Boolean;
77     
78        -- Absolute time corresponding to absolute time T succeeded by interval I.
79        with function Time_After_Interval
80              (T :        Time_Rep;
81               I :        Interval)
82              return Time_Rep;
83     
84        -- Time spane from Early_Time to Late_Time.
85        -- May be negative if Before(Late_Time, Early_Time)
86        with function Interval_Between
87              (Late_Time, Early_Time :        Time_Rep)
88              return Interval;
89     
90        -- Provides current absolute time
91        with function Get_Current_Time
92              return Time_Rep;
93     
94        -- Priority assigned to task implementing critical region.
95        Protected_Task_Priority
96                                : in     Task_Priority_Control.Passive_Task_Priority;
97     
98     package Event_Scheduler is
99     
100        --% Package:
101        --    Maintains a time line of periodic events.
102        --% Active Tasks:
103        -->   None
104        --% Passive Tasks:
105        -->   Critical_Region - Ensures that operations on time line are atomic.
106     
107        -- Insertion of event failed as max number of events was exceeded
108        Schedule_Full : exception;
109     
110        -- Attempt to perform an operation on an identified event not in current
111        --+    schedule
112        No_Identified_Event : exception;
113     
114        -- Attempt to add a cyclic event with an ID already present in schedule
115        Identified_Event_Exists : exception;
116     
117        -- Implementation of variable length lists of event IDs
118        type Event_List_Range is new Natural range 0 .. Max_Number_Of_Events_Due;
119        type Event_List       is array (Event_List_Range range <>) of Event_ID;
120     
121        procedure Initialize;
122     
123        --% Subprogram:
124        --    Add a cyclic event to the set of events for which a timeline is
125        --+    maintained.
126        --% Parameter Constraints:
127        -->   None
128        --% Exceptions Raised:
129        -->   Schedule_Full  - Number of periodic events has exceeded
130        --+    Max_Number_Of_Events
131        -->   Identified_Event_Exists  - Set of periodic events already contains an
132        --+    element with ID
133        procedure Add_Cyclic_Event
134              (ID             : in     Event_ID;
135               Event_Interval : in     Interval);
136     
137        --% Subprogram:
138        --    Removes identified event from set of periodic events.
139        --% Parameter Constraints:
140        -->   None
141        --% Exceptions Raised:
142        -->   No_Identified_Event  - Set of periodic event does not contain an
143        --+    element with ID.
144        procedure Delete_Cyclic_Event
145              (ID : in     Event_ID);
146     
147        --% Subprogram:
148        --    Empty the set of periodic events, and clear the timeline.
149        --% Parameter Constraints:
150        -->   None
151        --% Exceptions Raised:
152        -->   None
153        procedure Delete_All_Events;
154     
155        --% Subprogram:
156        --    Remove all periodic events from timeline.
157        --    No events will be rescheduled until Reschedule_Time_Line is invoked.
158        --% Parameter Constraints:
159        -->   None
160        --% Exceptions Raised:
161        -->   None
162        procedure Clear_Time_Line;
163     
164        --% Subprogram:
165        --    Reschedule all periodic events in the current set on the timeline
166        --+    starting from the current time.
167        --% Parameter Constraints:
168        -->   None
169        --% Exceptions Raised:
170        -->   None
171        procedure Reschedule_Time_Line;
172     
173        --% Subprogram:
174        --    Predicate that is true iff the set of periodic events is empty.
175        --% Parameter Constraints:
176        -->   None
177        --% Exceptions Raised:
178        -->   None
179        function Schedule_Is_Empty
180              return Boolean;
181     
182        --% Subprogram:
183        --    Retrieves list of periodic events that has become due since the last
184        --+    invokation.
185        --    Same event may occur several times in the list.
186        --% Parameter Constraints:
187        -->   None
188        --% Exceptions Raised:
189        -->   None
190        function Get_Events_Due
191              return Event_List;
192     
193     end Event_Scheduler;
194     
195     --~-----------------------------------------------------------------------------
196