1------------------------------------------------------------------------------ 2-- -- 3-- GNAT RUN-TIME COMPONENTS -- 4-- -- 5-- S Y S T E M . D I M . M K S -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 2011-2018, Free Software Foundation, Inc. -- 10-- -- 11-- GNAT is free software; you can redistribute it and/or modify it under -- 12-- terms of the GNU General Public License as published by the Free Soft- -- 13-- ware Foundation; either version 3, or (at your option) any later ver- -- 14-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 15-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- 16-- or FITNESS FOR A PARTICULAR PURPOSE. -- 17-- -- 18-- As a special exception under Section 7 of GPL version 3, you are granted -- 19-- additional permissions described in the GCC Runtime Library Exception, -- 20-- version 3.1, as published by the Free Software Foundation. -- 21-- -- 22-- You should have received a copy of the GNU General Public License and -- 23-- a copy of the GCC Runtime Library Exception along with this program; -- 24-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 25-- <http://www.gnu.org/licenses/>. -- 26-- -- 27-- GNAT was originally developed by the GNAT team at New York University. -- 28-- Extensive contributions were provided by Ada Core Technologies Inc. -- 29-- -- 30------------------------------------------------------------------------------ 31 32-- Defines the MKS dimension system which is the SI system of units 33 34-- Some other prefixes of this system are defined in a child package (see 35-- System.Dim_Mks.Other_Prefixes) in order to avoid too many constant 36-- declarations in this package. 37 38-- The dimension terminology is defined in System.Dim_IO package 39 40with Ada.Numerics; 41 42package System.Dim.Mks is 43 44 e : constant := Ada.Numerics.e; 45 Pi : constant := Ada.Numerics.Pi; 46 47 -- Dimensioned type Mks_Type 48 49 type Mks_Type is new Long_Long_Float 50 with 51 Dimension_System => ( 52 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'), 53 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'), 54 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'), 55 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'), 56 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@'), 57 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'), 58 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J')); 59 60 -- SI Base dimensioned subtypes 61 62 subtype Length is Mks_Type 63 with 64 Dimension => (Symbol => 'm', 65 Meter => 1, 66 others => 0); 67 68 subtype Mass is Mks_Type 69 with 70 Dimension => (Symbol => "kg", 71 Kilogram => 1, 72 others => 0); 73 74 subtype Time is Mks_Type 75 with 76 Dimension => (Symbol => 's', 77 Second => 1, 78 others => 0); 79 80 subtype Electric_Current is Mks_Type 81 with 82 Dimension => (Symbol => 'A', 83 Ampere => 1, 84 others => 0); 85 86 subtype Thermodynamic_Temperature is Mks_Type 87 with 88 Dimension => (Symbol => 'K', 89 Kelvin => 1, 90 others => 0); 91 92 subtype Amount_Of_Substance is Mks_Type 93 with 94 Dimension => (Symbol => "mol", 95 Mole => 1, 96 others => 0); 97 98 subtype Luminous_Intensity is Mks_Type 99 with 100 Dimension => (Symbol => "cd", 101 Candela => 1, 102 others => 0); 103 104 -- Initialize SI Base unit values 105 106 -- Turn off the all the dimension warnings for these basic assignments 107 -- since otherwise we would get complaints about assigning dimensionless 108 -- values to dimensioned subtypes (we can't assign 1.0*m to m). 109 110 pragma Warnings (Off, "*assumed to be*"); 111 112 m : constant Length := 1.0; 113 kg : constant Mass := 1.0; 114 s : constant Time := 1.0; 115 A : constant Electric_Current := 1.0; 116 K : constant Thermodynamic_Temperature := 1.0; 117 mol : constant Amount_Of_Substance := 1.0; 118 cd : constant Luminous_Intensity := 1.0; 119 120 pragma Warnings (On, "*assumed to be*"); 121 122 -- SI Derived dimensioned subtypes 123 124 subtype Absorbed_Dose is Mks_Type 125 with 126 Dimension => (Symbol => "Gy", 127 Meter => 2, 128 Second => -2, 129 others => 0); 130 131 subtype Angle is Mks_Type 132 with 133 Dimension => (Symbol => "rad", 134 others => 0); 135 136 subtype Area is Mks_Type 137 with 138 Dimension => ( 139 Meter => 2, 140 others => 0); 141 142 subtype Catalytic_Activity is Mks_Type 143 with 144 Dimension => (Symbol => "kat", 145 Second => -1, 146 Mole => 1, 147 others => 0); 148 149 subtype Celsius_Temperature is Mks_Type 150 with 151 Dimension => (Symbol => "°C", 152 Kelvin => 1, 153 others => 0); 154 155 subtype Electric_Capacitance is Mks_Type 156 with 157 Dimension => (Symbol => 'F', 158 Meter => -2, 159 Kilogram => -1, 160 Second => 4, 161 Ampere => 2, 162 others => 0); 163 164 subtype Electric_Charge is Mks_Type 165 with 166 Dimension => (Symbol => 'C', 167 Second => 1, 168 Ampere => 1, 169 others => 0); 170 171 subtype Electric_Conductance is Mks_Type 172 with 173 Dimension => (Symbol => 'S', 174 Meter => -2, 175 Kilogram => -1, 176 Second => 3, 177 Ampere => 2, 178 others => 0); 179 180 subtype Electric_Potential_Difference is Mks_Type 181 with 182 Dimension => (Symbol => 'V', 183 Meter => 2, 184 Kilogram => 1, 185 Second => -3, 186 Ampere => -1, 187 others => 0); 188 189 -- Note the type punning below. The Symbol is a single "ohm" character 190 -- encoded in UTF-8 (ce a9 in hexadecimal), but this file is not compiled 191 -- with -gnatW8, so we're treating the string literal as a two-character 192 -- String. 193 194 subtype Electric_Resistance is Mks_Type 195 with 196 Dimension => (Symbol => "Ω", 197 Meter => 2, 198 Kilogram => 1, 199 Second => -3, 200 Ampere => -2, 201 others => 0); 202 203 subtype Energy is Mks_Type 204 with 205 Dimension => (Symbol => 'J', 206 Meter => 2, 207 Kilogram => 1, 208 Second => -2, 209 others => 0); 210 211 subtype Equivalent_Dose is Mks_Type 212 with 213 Dimension => (Symbol => "Sv", 214 Meter => 2, 215 Second => -2, 216 others => 0); 217 218 subtype Force is Mks_Type 219 with 220 Dimension => (Symbol => 'N', 221 Meter => 1, 222 Kilogram => 1, 223 Second => -2, 224 others => 0); 225 226 subtype Frequency is Mks_Type 227 with 228 Dimension => (Symbol => "Hz", 229 Second => -1, 230 others => 0); 231 232 subtype Illuminance is Mks_Type 233 with 234 Dimension => (Symbol => "lx", 235 Meter => -2, 236 Candela => 1, 237 others => 0); 238 239 subtype Inductance is Mks_Type 240 with 241 Dimension => (Symbol => 'H', 242 Meter => 2, 243 Kilogram => 1, 244 Second => -2, 245 Ampere => -2, 246 others => 0); 247 248 subtype Luminous_Flux is Mks_Type 249 with 250 Dimension => (Symbol => "lm", 251 Candela => 1, 252 others => 0); 253 254 subtype Magnetic_Flux is Mks_Type 255 with 256 Dimension => (Symbol => "Wb", 257 Meter => 2, 258 Kilogram => 1, 259 Second => -2, 260 Ampere => -1, 261 others => 0); 262 263 subtype Magnetic_Flux_Density is Mks_Type 264 with 265 Dimension => (Symbol => 'T', 266 Kilogram => 1, 267 Second => -2, 268 Ampere => -1, 269 others => 0); 270 271 subtype Power is Mks_Type 272 with 273 Dimension => (Symbol => 'W', 274 Meter => 2, 275 Kilogram => 1, 276 Second => -3, 277 others => 0); 278 279 subtype Pressure is Mks_Type 280 with 281 Dimension => (Symbol => "Pa", 282 Meter => -1, 283 Kilogram => 1, 284 Second => -2, 285 others => 0); 286 287 subtype Radioactivity is Mks_Type 288 with 289 Dimension => (Symbol => "Bq", 290 Second => -1, 291 others => 0); 292 293 subtype Solid_Angle is Mks_Type 294 with 295 Dimension => (Symbol => "sr", 296 others => 0); 297 298 subtype Speed is Mks_Type 299 with 300 Dimension => ( 301 Meter => 1, 302 Second => -1, 303 others => 0); 304 305 subtype Volume is Mks_Type 306 with 307 Dimension => ( 308 Meter => 3, 309 others => 0); 310 311 -- Initialize derived dimension values 312 313 -- Turn off the all the dimension warnings for these basic assignments 314 -- since otherwise we would get complaints about assigning dimensionless 315 -- values to dimensioned subtypes. 316 317 pragma Warnings (Off, "*assumed to be*"); 318 319 rad : constant Angle := 1.0; 320 sr : constant Solid_Angle := 1.0; 321 Hz : constant Frequency := 1.0; 322 N : constant Force := 1.0; 323 Pa : constant Pressure := 1.0; 324 J : constant Energy := 1.0; 325 W : constant Power := 1.0; 326 C : constant Electric_Charge := 1.0; 327 V : constant Electric_Potential_Difference := 1.0; 328 F : constant Electric_Capacitance := 1.0; 329 Ohm : constant Electric_Resistance := 1.0; 330 Si : constant Electric_Conductance := 1.0; 331 Wb : constant Magnetic_Flux := 1.0; 332 T : constant Magnetic_Flux_Density := 1.0; 333 H : constant Inductance := 1.0; 334 dC : constant Celsius_Temperature := 273.15; 335 lm : constant Luminous_Flux := 1.0; 336 lx : constant Illuminance := 1.0; 337 Bq : constant Radioactivity := 1.0; 338 Gy : constant Absorbed_Dose := 1.0; 339 Sv : constant Equivalent_Dose := 1.0; 340 kat : constant Catalytic_Activity := 1.0; 341 342 -- SI prefixes for Meter 343 344 um : constant Length := 1.0E-06; -- micro (u) 345 mm : constant Length := 1.0E-03; -- milli 346 cm : constant Length := 1.0E-02; -- centi 347 dm : constant Length := 1.0E-01; -- deci 348 dam : constant Length := 1.0E+01; -- deka 349 hm : constant Length := 1.0E+02; -- hecto 350 km : constant Length := 1.0E+03; -- kilo 351 Mem : constant Length := 1.0E+06; -- mega 352 353 -- SI prefixes for Kilogram 354 355 ug : constant Mass := 1.0E-09; -- micro (u) 356 mg : constant Mass := 1.0E-06; -- milli 357 cg : constant Mass := 1.0E-05; -- centi 358 dg : constant Mass := 1.0E-04; -- deci 359 g : constant Mass := 1.0E-03; -- gram 360 dag : constant Mass := 1.0E-02; -- deka 361 hg : constant Mass := 1.0E-01; -- hecto 362 Meg : constant Mass := 1.0E+03; -- mega 363 364 -- SI prefixes for Second 365 366 us : constant Time := 1.0E-06; -- micro (u) 367 ms : constant Time := 1.0E-03; -- milli 368 cs : constant Time := 1.0E-02; -- centi 369 ds : constant Time := 1.0E-01; -- deci 370 das : constant Time := 1.0E+01; -- deka 371 hs : constant Time := 1.0E+02; -- hecto 372 ks : constant Time := 1.0E+03; -- kilo 373 Mes : constant Time := 1.0E+06; -- mega 374 375 -- Other constants for Second 376 377 min : constant Time := 60.0 * s; 378 hour : constant Time := 60.0 * min; 379 day : constant Time := 24.0 * hour; 380 year : constant Time := 365.25 * day; 381 382 -- SI prefixes for Ampere 383 384 mA : constant Electric_Current := 1.0E-03; -- milli 385 cA : constant Electric_Current := 1.0E-02; -- centi 386 dA : constant Electric_Current := 1.0E-01; -- deci 387 daA : constant Electric_Current := 1.0E+01; -- deka 388 hA : constant Electric_Current := 1.0E+02; -- hecto 389 kA : constant Electric_Current := 1.0E+03; -- kilo 390 MeA : constant Electric_Current := 1.0E+06; -- mega 391 392 pragma Warnings (On, "*assumed to be*"); 393end System.Dim.Mks; 394