home *** CD-ROM | disk | FTP | other *** search
- --::::::::::
- --cbconstg.ada
- --::::::::::
- -- CBCONSTG.ADA
- --- This generic package sets up the record CB with the central body
- -- constants. A procedure is provided by which the user
- -- can initialize their central body constants. The user
- -- must set up the order of the values in the enumerated array C_BODIES
- -- to correspond to the correct record in the CBDATA array.
- -- In addition, this package must be instantiated for the float
- -- type used at the facility. Then, the
- -- initialization is in the form CB := CBDATA(SUN) for using
- -- the sun as the central body.
-
- -- The data record is currently configured with three entries.
- -- The first entry is a string of 8 characters long which consists
- -- of an identifier
- -- The second entry is a floating scalar which is the radius in KM
- -- The third entry is a floating scalar which is the GM
-
- -- Written 8/86 by David Kwong
-
- GENERIC
-
- TYPE FLOATG IS DIGITS <>;
-
- PACKAGE CENTRAL_BODY_CONSTANTS_GENERIC IS
-
- TYPE C_BODIES IS (SUN,EARTH,MARS);
-
- SUBTYPE CB_NAME IS STRING(1..8);
-
- TYPE CB_RECORD IS
- RECORD
- NAME:CB_NAME;
- RADIUS:FLOATG;
- GM:FLOATG;
- end RECORD;
-
- CBDATA: constant array(C_BODIES) of CB_RECORD
- :=(("SUN ",6.96E8,1.32712438E20)
- ,("EARTH ",6.37814E6,3.986004479996796E14)
- ,("MARS ",3.3884E6,4.282828044E13));
-
- CB:CB_RECORD;
-
- end CENTRAL_BODY_CONSTANTS_GENERIC;
- --::::::::::
- --runcb.ada
- --::::::::::
- -- RUN_CB.ADA
- -- This program instantiates the package CENTRAL_BODY_CONSTANTS_GENERIC
- -- and tests it to see if the array CB can be initialized and the
- -- constants read out.
-
- -- Written 8/86 by David Kwong
-
- -- The generic package is first instantiated
- with CENTRAL_BODY_CONSTANTS_GENERIC;
- PACKAGE CENTRAL_BODY_CONSTANTS IS
- NEW CENTRAL_BODY_CONSTANTS_GENERIC(FLOAT);
-
- WITH CENTRAL_BODY_CONSTANTS; USE CENTRAL_BODY_CONSTANTS;
- with TEXT_IO; use TEXT_IO;
- with FLOAT_TEXT_IO; use FLOAT_TEXT_IO;
- procedure RUN_CB is
-
- begin
-
- -- test initialization with sun constants
- CB:=CBDATA(SUN);
- put(CB.NAME);
- NEW_LINE;
- put(CB.RADIUS);
- NEW_LINE;
- put(CB.GM);
- NEW_LINE(2);
-
- -- test initialization with earth constants
- CB:=CBDATA(EARTH);
- put(CB.NAME);
- NEW_LINE;
- put(CB.RADIUS);
- NEW_LINE;
- put(CB.GM);
-
-
- end RUN_CB;
-