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-2012, 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 subtype
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   --  SI Base units
105
106   pragma Warnings (Off);
107   --  Turn off the all the dimension warnings
108
109   m   : constant Length                    := 1.0;
110   kg  : constant Mass                      := 1.0;
111   s   : constant Time                      := 1.0;
112   A   : constant Electric_Current          := 1.0;
113   K   : constant Thermodynamic_Temperature := 1.0;
114   mol : constant Amount_Of_Substance       := 1.0;
115   cd  : constant Luminous_Intensity        := 1.0;
116
117   pragma Warnings (On);
118
119   --  SI Derived dimensioned subtypes
120
121   subtype Absorbed_Dose is Mks_Type
122     with
123      Dimension => (Symbol => "Gy",
124        Meter =>  2,
125        Second => -2,
126        others => 0);
127
128   subtype Angle is Mks_Type
129     with
130      Dimension => (Symbol => "rad",
131        others => 0);
132
133   subtype Area is Mks_Type
134     with
135      Dimension => (
136        Meter =>  2,
137        others => 0);
138
139   subtype Catalytic_Activity is Mks_Type
140     with
141      Dimension => (Symbol => "kat",
142        Second => -1,
143        Mole =>   1,
144        others => 0);
145
146   subtype Celsius_Temperature is Mks_Type
147     with
148      Dimension => (Symbol => "°C",
149        Kelvin => 1,
150        others => 0);
151
152   subtype Electric_Capacitance is Mks_Type
153     with
154      Dimension => (Symbol => 'F',
155        Meter =>    -2,
156        Kilogram => -1,
157        Second =>   4,
158        Ampere =>   2,
159        others =>   0);
160
161   subtype Electric_Charge is Mks_Type
162     with
163      Dimension => (Symbol => 'C',
164        Second => 1,
165        Ampere => 1,
166        others => 0);
167
168   subtype Electric_Conductance is Mks_Type
169     with
170      Dimension => (Symbol => 'S',
171        Meter =>    -2,
172        Kilogram => -1,
173        Second =>   3,
174        Ampere =>   2,
175        others =>   0);
176
177   subtype Electric_Potential_Difference is Mks_Type
178     with
179      Dimension => (Symbol => 'V',
180        Meter =>    2,
181        Kilogram => 1,
182        Second =>   -3,
183        Ampere =>   -1,
184        others =>   0);
185
186   subtype Electric_Resistance is Mks_Type
187     with
188      Dimension => (Symbol => "Ω",
189        Meter =>    2,
190        Kilogram => 1,
191        Second =>   -3,
192        Ampere =>   -2,
193        others =>   0);
194
195   subtype Energy is Mks_Type
196     with
197      Dimension => (Symbol => 'J',
198        Meter =>    2,
199        Kilogram => 1,
200        Second =>   -2,
201        others =>   0);
202
203   subtype Equivalent_Dose is Mks_Type
204     with
205      Dimension => (Symbol => "Sv",
206        Meter =>  2,
207        Second => -2,
208        others => 0);
209
210   subtype Force is Mks_Type
211     with
212      Dimension => (Symbol => 'N',
213        Meter =>    1,
214        Kilogram => 1,
215        Second =>  -2,
216        others =>   0);
217
218   subtype Frequency is Mks_Type
219     with
220      Dimension => (Symbol => "Hz",
221        Second => -1,
222        others => 0);
223
224   subtype Illuminance is Mks_Type
225     with
226      Dimension => (Symbol => "lx",
227        Meter =>   -2,
228        Candela => 1,
229        others =>  0);
230
231   subtype Inductance is Mks_Type
232     with
233      Dimension => (Symbol => 'H',
234        Meter =>    2,
235        Kilogram => 1,
236        Second =>   -2,
237        Ampere =>   -2,
238        others =>   0);
239
240   subtype Luminous_Flux is Mks_Type
241     with
242      Dimension => (Symbol => "lm",
243        Candela => 1,
244        others =>  0);
245
246   subtype Magnetic_Flux is Mks_Type
247     with
248      Dimension => (Symbol => "Wb",
249        Meter =>    2,
250        Kilogram => 1,
251        Second =>   -2,
252        Ampere =>   -1,
253        others =>   0);
254
255   subtype Magnetic_Flux_Density is Mks_Type
256     with
257      Dimension => (Symbol => 'T',
258        Kilogram => 1,
259        Second =>   -2,
260        Ampere =>   -1,
261        others =>   0);
262
263   subtype Power is Mks_Type
264     with
265      Dimension => (Symbol => 'W',
266        Meter =>    2,
267        Kilogram => 1,
268        Second =>   -3,
269        others =>   0);
270
271   subtype Pressure is Mks_Type
272     with
273      Dimension => (Symbol => "Pa",
274        Meter =>    -1,
275        Kilogram => 1,
276        Second =>   -2,
277        others =>   0);
278
279   subtype Radioactivity is Mks_Type
280     with
281      Dimension => (Symbol => "Bq",
282        Second => -1,
283        others => 0);
284
285   subtype Solid_Angle is Mks_Type
286     with
287      Dimension => (Symbol => "sr",
288        others => 0);
289
290   subtype Speed is Mks_Type
291     with
292      Dimension => (
293        Meter =>  1,
294        Second => -1,
295        others => 0);
296
297   subtype Volume is Mks_Type
298     with
299      Dimension => (
300        Meter =>  3,
301        others => 0);
302
303   pragma Warnings (Off);
304   --  Turn off the all the dimension warnings
305
306   rad : constant Angle                         := 1.0;
307   sr  : constant Solid_Angle                   := 1.0;
308   Hz  : constant Frequency                     := 1.0;
309   N   : constant Force                         := 1.0;
310   Pa  : constant Pressure                      := 1.0;
311   J   : constant Energy                        := 1.0;
312   W   : constant Power                         := 1.0;
313   C   : constant Electric_Charge               := 1.0;
314   V   : constant Electric_Potential_Difference := 1.0;
315   F   : constant Electric_Capacitance          := 1.0;
316   Ohm : constant Electric_Resistance           := 1.0;
317   Si  : constant Electric_Conductance          := 1.0;
318   Wb  : constant Magnetic_Flux                 := 1.0;
319   T   : constant Magnetic_Flux_Density         := 1.0;
320   H   : constant Inductance                    := 1.0;
321   dC  : constant Celsius_Temperature           := 273.15;
322   lm  : constant Luminous_Flux                 := 1.0;
323   lx  : constant Illuminance                   := 1.0;
324   Bq  : constant Radioactivity                 := 1.0;
325   Gy  : constant Absorbed_Dose                 := 1.0;
326   Sv  : constant Equivalent_Dose               := 1.0;
327   kat : constant Catalytic_Activity            := 1.0;
328
329   --  SI prefixes for Meter
330
331   um  : constant Length := 1.0E-06;  -- micro (u)
332   mm  : constant Length := 1.0E-03;  -- milli
333   cm  : constant Length := 1.0E-02;  -- centi
334   dm  : constant Length := 1.0E-01;  -- deci
335   dam : constant Length := 1.0E+01;  -- deka
336   hm  : constant Length := 1.0E+02;  -- hecto
337   km  : constant Length := 1.0E+03;  -- kilo
338   Mem : constant Length := 1.0E+06;  -- mega
339
340   --  SI prefixes for Kilogram
341
342   ug  : constant Mass := 1.0E-09;  -- micro (u)
343   mg  : constant Mass := 1.0E-06;  -- milli
344   cg  : constant Mass := 1.0E-05;  -- centi
345   dg  : constant Mass := 1.0E-04;  -- deci
346   g   : constant Mass := 1.0E-03;  -- gram
347   dag : constant Mass := 1.0E-02;  -- deka
348   hg  : constant Mass := 1.0E-01;  -- hecto
349   Meg : constant Mass := 1.0E+03;  -- mega
350
351   --  SI prefixes for Second
352
353   us  : constant Time := 1.0E-06;  -- micro (u)
354   ms  : constant Time := 1.0E-03;  -- milli
355   cs  : constant Time := 1.0E-02;  -- centi
356   ds  : constant Time := 1.0E-01;  -- deci
357   das : constant Time := 1.0E+01;  -- deka
358   hs  : constant Time := 1.0E+02;  -- hecto
359   ks  : constant Time := 1.0E+03;  -- kilo
360   Mes : constant Time := 1.0E+06;  -- mega
361
362   --  Other constants for Second
363
364   min  : constant Time := 60.0 * s;
365   hour : constant Time := 60.0 * min;
366   day  : constant Time := 24.0 * hour;
367   year : constant Time := 365.25 * day;
368
369   --  SI prefixes for Ampere
370
371   mA  : constant Electric_Current := 1.0E-03;  -- milli
372   cA  : constant Electric_Current := 1.0E-02;  -- centi
373   dA  : constant Electric_Current := 1.0E-01;  -- deci
374   daA : constant Electric_Current := 1.0E+01;  -- deka
375   hA  : constant Electric_Current := 1.0E+02;  -- hecto
376   kA  : constant Electric_Current := 1.0E+03;  -- kilo
377   MeA : constant Electric_Current := 1.0E+06;  -- mega
378
379   pragma Warnings (On);
380end System.Dim.Mks;
381