3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that a protected object can have discriminants
30 -- Use a subset of the simulation of the freeway on-ramp described in
31 -- c940005. In this case an array of access types is built with pointers
32 -- to successive ramps. Each ramp has its Ramp_Number specified by
33 -- discriminant and this corresponds to the index in the array. The test
34 -- checks that the ramp numbers are assigned as expected then uses calls
35 -- to procedures within the objects (ramps) to verify external calls to
36 -- ensure the structures are valid. The external references within the
37 -- protected objects are made via the index into the array. Routines
38 -- which refer to the "previous" ramp and the "next" ramp are exercised.
39 -- (Note: The first and last ramps are assumed to be dummies and no
40 -- first/last condition code is included)
44 -- 06 Dec 94 SAIC ACVC 2.0
54 type Ramp_Index
is range 1..4;
57 type a_Ramp
is access Ramp
;
59 Ramp_Array
: array (Ramp_Index
) of a_Ramp
;
61 -- Weighted load given to each potential problem area and accumulated
62 type Load_Factor
is range 0..8;
63 Clear_Level
: constant Load_Factor
:= 0;
64 Moderate_Level
: constant Load_Factor
:= 3;
66 --================================================================
67 -- Only the Routines that are used in this test are shown
69 protected type Ramp
(Ramp_In
: Ramp_Index
) is
71 function Ramp_Number
return Ramp_Index
;
72 function Local_Overload
return Load_Factor
;
73 function Next_Ramp_Overload
return Load_Factor
;
74 procedure Set_Local_Overload
(Sensor_Level
: Load_Factor
);
79 Next_Ramp_Alert
: Boolean := false; -- Next Ramp is in trouble?
81 -- Current state of the various Sample Points
82 Local_State
: Load_Factor
:= Clear_Level
;
85 --================================================================
86 protected body Ramp
is
88 function Ramp_Number
return Ramp_Index
is
93 -- These Set/Clear routines are triggered by real-time sensors that
94 -- reflect traffic state
95 procedure Set_Local_Overload
(Sensor_Level
: Load_Factor
) is
97 if Local_State
= Clear_Level
then
98 -- Notify "previous" ramp to check this one for current state.
99 -- Subsequent changes in state will not send an alert
100 -- When the situation clears another routine performs the
101 -- all_clear notification. (not shown)
102 Ramp_Array
(Ramp_In
- 1).Notify
; -- index to previous ramp
104 Local_State
:= Sensor_Level
;
105 null; --::::: Start local meter if not already started
108 function Local_Overload
return Load_Factor
is
113 -- This is notification from the next ramp that it is in
114 -- overload. With this provision we only need to sample the next
115 -- ramp during adverse conditions.
118 Next_Ramp_Alert
:= true;
121 function Next_Ramp_Overload
return Load_Factor
is
123 if Next_Ramp_Alert
then
124 -- Get next ramp's current state
125 return Ramp_Array
(Ramp_In
+ 1).Local_Overload
;
129 end Next_Ramp_Overload
;
131 --================================================================
136 Report
.Test
("C940012", "Check that a protected object " &
137 "can have discriminants");
139 -- Build the ramps and populate the ramp array
140 for i
in Ramp_Index
loop
141 Ramp_Array
(i
) := new Ramp
(i
);
144 -- Test driver. This is ALL test control code
146 -- Check the assignment of the index
147 for i
in Ramp_Index
loop
148 if Ramp_Array
(i
).Ramp_Number
/= i
then
149 Report
.Failed
("Ramp_Number assignment incorrect");
153 -- Simulate calls to the protected functions and procedures
154 -- external calls. (do not call the "dummy" end ramps)
157 if Ramp_Array
(2).Next_Ramp_Overload
/= Clear_level
then
158 Report
.Failed
("Primary call incorrect");
161 -- Call which results in an external procedure call via the array
162 -- index from within the protected object
163 Ramp_Array
(3).Set_Local_Overload
(Moderate_Level
);
165 -- Call which results in an external function call via the array
166 -- index from within the protected object
167 if Ramp_Array
(2).Next_Ramp_Overload
/= Moderate_level
then
168 Report
.Failed
("Secondary call incorrect");