home *** CD-ROM | disk | FTP | other *** search
-
- -- The combinational problem of converting from every unit to every
- -- other units of the same dimension is too large to be practical.
- --
- -- The compromise solution is to provide:
- -- MKS, conversion of every metric unit to the corresponding MKS unit
- -- MKS, conversion of primary English unit to corresponding MKS unit
- -- ENGLISH, conversion of every English unit to the primary English unit
- -- ENGLISH, conversion of every MKS unit to corresponding primary English unit
- -- CONVERT, conversion from primary English unit to other English units
- -- CONVERT, conversion from MKS unit to other metric units
- --
- -- The overloaded function MKS returns the MKS value.
- --
- -- The overloaded function ENGLISH returns the primary English value.
- --
- -- The overloaded function CONVERT returns all units
- -- other than MKS or primary English
- --
- -- Note: Any of these functions may need to be called with qualification.
- -- Usually, MKS and ENGLISH will not require qualification.
- -- Almost always, CONVERT will require qualification.
- --
- -- PUT ( LENGTH_CENTIMETER' ( CONVERT ( SOME_LENGTH ) ) ) ;
- --
- -- DO NOT get the concept of units conversion confused with the
- -- Ada concept of type conversion. An Ada type conversion CAN NOT
- -- change meters to feet.
- --
-
- with PHYSICAL_UNITS_BASIC ; use PHYSICAL_UNITS_BASIC ;
- with PHYSICAL_UNITS_MECHANICAL ; use PHYSICAL_UNITS_MECHANICAL ;
- with PHYSICAL_UNITS_ELECTRICAL ; use PHYSICAL_UNITS_ELECTRICAL ;
-
- package PHYSICAL_UNITS_CONVERSION is
-
- function CONVERT ( ITEM : LENGTH_ENGLISH ) return LENGTH_INCH ;
-
- function CONVERT ( ITEM : LENGTH_MKS ) return LENGTH_CENTIMETER ;
-
- end PHYSICAL_UNITS_CONVERSION ;
-
-
- with PHYSICAL_CONVERSION_CONSTANT ; use PHYSICAL_CONVERSION_CONSTANT ;
- with PHYSICAL_REAL ; use PHYSICAL_REAL ;
-
- package body PHYSICAL_UNITS_CONVERSION is
- -- This will be filled in for all CONVERT functions
-
- function CONVERT ( ITEM : LENGTH_ENGLISH ) return LENGTH_INCH is
- begin
- return DIMENSION ( UNDIMENSION( ITEM )) * FOOT_TO_INCH ;
- end CONVERT ;
-
- function CONVERT ( ITEM : LENGTH_MKS ) return LENGTH_CENTIMETER is
- begin
- return DIMENSION ( UNDIMENSION( ITEM )) * METER_TO_CENTIMETER ;
- end CONVERT ;
-
- end PHYSICAL_UNITS_CONVERSION ;
-