|
1 | 1 | import '../core/quantity.dart'; |
2 | 2 | import '../core/unit.dart'; |
3 | | -import '../system/si.dart'; |
4 | | -import '../system/usc.dart'; |
| 3 | +import '../units/si.dart' as si; |
| 4 | +import '../units/usc.dart' as usc show degreeFahrenheit, zerothDegreeFahrenheit; |
5 | 5 | import 'dimensions.dart'; |
6 | 6 |
|
7 | 7 | extension type Angle._(Quantity q) implements DimensionedQuantity<Angle> { |
8 | 8 | Angle(Quantity q) : q = angle.checked(q); |
9 | | - const Angle.zero() : q = const Quantity.of(0, radian); |
| 9 | + const Angle.zero() : q = const Quantity.of(0, si.radian); |
10 | 10 | Angle.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
11 | | - Angle.degrees(num value) : this._(Quantity.of(value, degree)); |
12 | | - Angle.radians(num value) : this._(Quantity.of(value, radian)); |
| 11 | + Angle.degrees(num value) : this._(Quantity.of(value, si.degree)); |
| 12 | + Angle.radians(num value) : this._(Quantity.of(value, si.radian)); |
13 | 13 | } |
14 | 14 |
|
15 | 15 | extension type Length._(Quantity q) implements DimensionedQuantity<Length> { |
16 | 16 | Length(Quantity q) : q = length.checked(q); |
17 | | - const Length.zero() : q = const Quantity.of(0, metre); |
| 17 | + const Length.zero() : q = const Quantity.of(0, si.metre); |
18 | 18 | Length.of(num value, Unit unit) : this._(Quantity.of(value, unit)); |
19 | | - Length.metres(num value) : this._(Quantity.of(value, metre)); |
| 19 | + Length.metres(num value) : this._(Quantity.of(value, si.metre)); |
20 | 20 | } |
21 | 21 |
|
22 | 22 | extension type Mass._(Quantity q) implements DimensionedQuantity<Mass> { |
23 | 23 | Mass(Quantity q) : q = mass.checked(q); |
24 | | - const Mass.zero() : q = const Quantity.of(0, kilogram); |
| 24 | + const Mass.zero() : q = const Quantity.of(0, si.kilogram); |
25 | 25 | Mass.of(num value, Unit unit) : this._(Quantity.of(value, unit)); |
26 | | - Mass.grams(num value) : this._(Quantity.of(value, gram)); |
27 | | - Mass.kilograms(num value) : this._(Quantity.of(value, kilogram)); |
| 26 | + Mass.grams(num value) : this._(Quantity.of(value, si.gram)); |
| 27 | + Mass.kilograms(num value) : this._(Quantity.of(value, si.kilogram)); |
28 | 28 | } |
29 | 29 |
|
30 | 30 | extension type Area._(Quantity q) implements DimensionedQuantity<Area> { |
31 | 31 | Area(Quantity q) : q = area.checked(q); |
32 | | - const Area.zero() : q = const Quantity.of(0, squareMetre); |
| 32 | + const Area.zero() : q = const Quantity.of(0, si.squareMetre); |
33 | 33 | Area.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
34 | | - Area.squareMetres(num value) : this._(Quantity.of(value, squareMetre)); |
35 | | - Area.hectares(num value) : this._(Quantity.of(value, hectare)); |
| 34 | + Area.squareMetres(num value) : this._(Quantity.of(value, si.squareMetre)); |
| 35 | + Area.hectares(num value) : this._(Quantity.of(value, si.hectare)); |
36 | 36 | } |
37 | 37 |
|
38 | 38 | extension type Volume._(Quantity q) implements DimensionedQuantity<Volume> { |
39 | 39 | Volume(Quantity q) : q = volume.checked(q); |
40 | | - const Volume.zero() : q = const Quantity.of(0, cubicMetre); |
| 40 | + const Volume.zero() : q = const Quantity.of(0, si.cubicMetre); |
41 | 41 | Volume.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
42 | | - Volume.litres(num value) : this._(Quantity.of(value, litre)); |
43 | | - Volume.cubicMetres(num value) : this._(Quantity.of(value, cubicMetre)); |
| 42 | + Volume.litres(num value) : this._(Quantity.of(value, si.litre)); |
| 43 | + Volume.cubicMetres(num value) : this._(Quantity.of(value, si.cubicMetre)); |
44 | 44 | } |
45 | 45 |
|
46 | 46 | extension type MassPerVolume._(Quantity q) implements DimensionedQuantity<MassPerVolume> { |
47 | 47 | MassPerVolume(Quantity q) : q = massPerVolume.checked(q); |
48 | | - const MassPerVolume.zero() : q = const Quantity.of(0, kilogramPerCubicMetre); |
| 48 | + const MassPerVolume.zero() : q = const Quantity.of(0, si.kilogramPerCubicMetre); |
49 | 49 | MassPerVolume.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
50 | | - MassPerVolume.kilogramsPerCubicMetre(num value) : this._(Quantity.of(value, kilogram / cubicMetre)); |
51 | | - MassPerVolume.gramsPerCubicCentimetre(num value) : this._(Quantity.of(value, gram / (metre.centi ^ 3))); |
| 50 | + MassPerVolume.kilogramsPerCubicMetre(num value) : this._(Quantity.of(value, si.kilogram / si.cubicMetre)); |
| 51 | + MassPerVolume.gramsPerCubicCentimetre(num value) : this._(Quantity.of(value, si.gram / (si.metre.centi ^ 3))); |
52 | 52 | } |
53 | 53 |
|
54 | 54 | extension type VolumePerMass._(Quantity q) implements DimensionedQuantity<VolumePerMass> { |
55 | 55 | VolumePerMass(Quantity q) : q = volumePerMass.checked(q); |
56 | | - const VolumePerMass.zero() : q = const Quantity.of(0, cubicMetrePerKilogram); |
| 56 | + const VolumePerMass.zero() : q = const Quantity.of(0, si.cubicMetrePerKilogram); |
57 | 57 | VolumePerMass.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
58 | | - VolumePerMass.cubicMetresPerKilogram(num value) : this._(Quantity.of(value, cubicMetre / kilogram)); |
| 58 | + VolumePerMass.cubicMetresPerKilogram(num value) : this._(Quantity.of(value, si.cubicMetre / si.kilogram)); |
59 | 59 | } |
60 | 60 |
|
61 | 61 | extension type Time._(Quantity q) implements DimensionedQuantity<Time> { |
62 | 62 | Time(Quantity q) : q = time.checked(q); |
63 | | - const Time.zero() : q = const Quantity.of(0, second); |
| 63 | + const Time.zero() : q = const Quantity.of(0, si.second); |
64 | 64 | Time.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
65 | | - Time.microseconds(num value) : this._(Quantity.of(value, second.micro)); |
66 | | - Time.milliseconds(num value) : this._(Quantity.of(value, second.milli)); |
67 | | - Time.seconds(num value) : this._(Quantity.of(value, second)); |
68 | | - Time.minutes(num value) : this._(Quantity.of(value, minute)); |
69 | | - Time.hours(num value) : this._(Quantity.of(value, hour)); |
| 65 | + Time.microseconds(num value) : this._(Quantity.of(value, si.second.micro)); |
| 66 | + Time.milliseconds(num value) : this._(Quantity.of(value, si.second.milli)); |
| 67 | + Time.seconds(num value) : this._(Quantity.of(value, si.second)); |
| 68 | + Time.minutes(num value) : this._(Quantity.of(value, si.minute)); |
| 69 | + Time.hours(num value) : this._(Quantity.of(value, si.hour)); |
70 | 70 | Time.hms(int hours, int minutes, int seconds) |
71 | 71 | : this(Time.hours(hours) + Time.minutes(minutes) + Time.seconds(seconds)); |
72 | 72 | Time.duration(Duration duration) : this.microseconds(duration.inMicroseconds); |
73 | 73 | } |
74 | 74 |
|
75 | 75 | extension type Temperature._(QuantityPoint qp) implements QuantityPoint { |
76 | 76 | Temperature(this.qp) : assert(qp.quantity.dimensions == temperature, "${qp.quantity.dimensions} != $temperature"); |
77 | | - const Temperature.absoluteZero() : qp = const QuantityPoint(Quantity.of(0, kelvin), absoluteZeroKelvin); |
78 | | - const Temperature.icePoint() : qp = const QuantityPoint(Quantity.of(0, degreeCelsius), zerothDegreeCelsius); |
| 77 | + const Temperature.absoluteZero() : qp = const QuantityPoint(Quantity.of(0, si.kelvin), si.absoluteZeroKelvin); |
| 78 | + const Temperature.icePoint() : qp = const QuantityPoint(Quantity.of(0, si.degreeCelsius), si.zerothDegreeCelsius); |
79 | 79 | Temperature.of(num value, Unit unit, QuantityOrigin origin) : this(origin + Quantity.of(value, unit)); |
80 | | - Temperature.kelvins(num value) : this._(absoluteZeroKelvin + Quantity.of(value, kelvin)); |
81 | | - Temperature.degreesCelsius(num value) : this._(zerothDegreeCelsius + Quantity.of(value, degreeCelsius)); |
82 | | - Temperature.degreesFahrenheit(num value) : this._(zerothDegreeFahrenheit + Quantity.of(value, degreeFahrenheit)); |
| 80 | + Temperature.kelvins(num value) : this._(si.absoluteZeroKelvin + Quantity.of(value, si.kelvin)); |
| 81 | + Temperature.degreesCelsius(num value) : this._(si.zerothDegreeCelsius + Quantity.of(value, si.degreeCelsius)); |
| 82 | + Temperature.degreesFahrenheit(num value) |
| 83 | + : this._(usc.zerothDegreeFahrenheit + Quantity.of(value, usc.degreeFahrenheit)); |
83 | 84 |
|
84 | 85 | Temperature inDegreesCelsius() => Temperature( |
85 | | - qp.withOrigin(zerothDegreeCelsius).inUnits(degreeCelsius), |
| 86 | + qp.withOrigin(si.zerothDegreeCelsius).inUnits(si.degreeCelsius), |
86 | 87 | ); |
87 | 88 | Temperature inDegreesFahrenheit() => Temperature( |
88 | | - qp.withOrigin(zerothDegreeFahrenheit).inUnits(degreeFahrenheit), |
| 89 | + qp.withOrigin(usc.zerothDegreeFahrenheit).inUnits(usc.degreeFahrenheit), |
89 | 90 | ); |
90 | 91 | } |
91 | 92 |
|
92 | 93 | extension type Speed._(Quantity q) implements DimensionedQuantity<Speed> { |
93 | 94 | Speed(Quantity q) : q = speed.checked(q); |
94 | | - const Speed.zero() : q = const Quantity.of(0, metrePerSecond); |
| 95 | + const Speed.zero() : q = const Quantity.of(0, si.metrePerSecond); |
95 | 96 | Speed.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
96 | | - Speed.metresPerSecond(num value) : this._(Quantity.of(value, metrePerSecond)); |
| 97 | + Speed.metresPerSecond(num value) : this._(Quantity.of(value, si.metrePerSecond)); |
97 | 98 | } |
98 | 99 |
|
99 | 100 | extension type Acceleration._(Quantity q) implements DimensionedQuantity<Acceleration> { |
100 | 101 | Acceleration(Quantity q) : q = acceleration.checked(q); |
101 | | - const Acceleration.zero() : q = const Quantity.of(0, metrePerSecondSquared); |
| 102 | + const Acceleration.zero() : q = const Quantity.of(0, si.metrePerSecondSquared); |
102 | 103 | Acceleration.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
103 | | - Acceleration.metresPerSecondSquared(num value) : this._(Quantity.of(value, metrePerSecondSquared)); |
| 104 | + Acceleration.metresPerSecondSquared(num value) : this._(Quantity.of(value, si.metrePerSecondSquared)); |
104 | 105 | } |
105 | 106 |
|
106 | 107 | extension type Capacitance._(Quantity q) implements DimensionedQuantity<Capacitance> { |
107 | 108 | Capacitance(Quantity q) : q = capacitance.checked(q); |
108 | | - const Capacitance.zero() : q = const Quantity.of(0, farad); |
| 109 | + const Capacitance.zero() : q = const Quantity.of(0, si.farad); |
109 | 110 | Capacitance.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
110 | | - Capacitance.farads(num value) : this._(Quantity.of(value, farad)); |
| 111 | + Capacitance.farads(num value) : this._(Quantity.of(value, si.farad)); |
111 | 112 | } |
112 | 113 |
|
113 | 114 | extension type Frequency._(Quantity q) implements DimensionedQuantity<Frequency> { |
114 | 115 | Frequency(Quantity q) : q = frequency.checked(q); |
115 | | - const Frequency.zero() : q = const Quantity.of(0, hertz); |
| 116 | + const Frequency.zero() : q = const Quantity.of(0, si.hertz); |
116 | 117 | Frequency.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
117 | | - Frequency.hertz(num value) : this._(Quantity.of(value, hertz)); |
| 118 | + Frequency.hertz(num value) : this._(Quantity.of(value, si.hertz)); |
118 | 119 | } |
119 | 120 |
|
120 | 121 | extension type Voltage._(Quantity q) implements DimensionedQuantity<Voltage> { |
121 | 122 | Voltage(Quantity q) : q = voltage.checked(q); |
122 | | - const Voltage.zero() : q = const Quantity.of(0, volt); |
| 123 | + const Voltage.zero() : q = const Quantity.of(0, si.volt); |
123 | 124 | Voltage.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
124 | 125 | } |
125 | 126 |
|
126 | 127 | extension type Current._(Quantity q) implements DimensionedQuantity<Current> { |
127 | 128 | Current(Quantity q) : q = electricCurrent.checked(q); |
128 | | - const Current.zero() : q = const Quantity.of(0, ampere); |
| 129 | + const Current.zero() : q = const Quantity.of(0, si.ampere); |
129 | 130 | Current.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
130 | | - Current.amperes(num value) : this._(Quantity.of(value, ampere)); |
| 131 | + Current.amperes(num value) : this._(Quantity.of(value, si.ampere)); |
131 | 132 | } |
132 | 133 |
|
133 | 134 | extension type Resistance._(Quantity q) implements DimensionedQuantity<Resistance> { |
134 | 135 | Resistance(Quantity q) : q = resistance.checked(q); |
135 | | - const Resistance.zero() : q = const Quantity.of(0, ohm); |
| 136 | + const Resistance.zero() : q = const Quantity.of(0, si.ohm); |
136 | 137 | Resistance.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
137 | | - Resistance.ohms(num value) : this._(Quantity.of(value, ohm)); |
| 138 | + Resistance.ohms(num value) : this._(Quantity.of(value, si.ohm)); |
138 | 139 | } |
139 | 140 |
|
140 | 141 | extension type Power._(Quantity q) implements DimensionedQuantity<Power> { |
141 | 142 | Power(Quantity q) : q = power.checked(q); |
142 | | - const Power.zero() : q = const Quantity.of(0, watt); |
| 143 | + const Power.zero() : q = const Quantity.of(0, si.watt); |
143 | 144 | Power.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
144 | | - Power.watts(num value) : this._(Quantity.of(value, watt)); |
| 145 | + Power.watts(num value) : this._(Quantity.of(value, si.watt)); |
145 | 146 | } |
146 | 147 |
|
147 | 148 | extension type Energy._(Quantity q) implements DimensionedQuantity<Energy> { |
148 | 149 | Energy(Quantity q) : q = energy.checked(q); |
149 | | - const Energy.zero() : q = const Quantity.of(0, joule); |
| 150 | + const Energy.zero() : q = const Quantity.of(0, si.joule); |
150 | 151 | Energy.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
151 | | - Energy.joules(num value) : this._(Quantity.of(value, joule)); |
152 | | - Energy.wattHours(num value) : this._(Quantity.of(value, wattHour)); |
| 152 | + Energy.joules(num value) : this._(Quantity.of(value, si.joule)); |
| 153 | + Energy.wattHours(num value) : this._(Quantity.of(value, si.wattHour)); |
153 | 154 | } |
154 | 155 |
|
155 | 156 | extension type MassPerTime._(Quantity q) implements DimensionedQuantity<MassPerTime> { |
156 | 157 | MassPerTime(Quantity q) : q = massPerTime.checked(q); |
157 | | - const MassPerTime.zero() : q = const Quantity.of(0, kilogramPerSecond); |
| 158 | + const MassPerTime.zero() : q = const Quantity.of(0, si.kilogramPerSecond); |
158 | 159 | MassPerTime.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
159 | | - MassPerTime.kilogramsPerSecond(num value) : this._(Quantity.of(value, kilogramPerSecond)); |
| 160 | + MassPerTime.kilogramsPerSecond(num value) : this._(Quantity.of(value, si.kilogramPerSecond)); |
160 | 161 | } |
161 | 162 |
|
162 | 163 | extension type MassPerArea._(Quantity q) implements DimensionedQuantity<MassPerArea> { |
163 | 164 | MassPerArea(Quantity q) : q = massPerArea.checked(q); |
164 | | - const MassPerArea.zero() : q = const Quantity.of(0, kilogramPerSquareMetre); |
| 165 | + const MassPerArea.zero() : q = const Quantity.of(0, si.kilogramPerSquareMetre); |
165 | 166 | MassPerArea.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
166 | | - MassPerArea.kilogramsPerSquareMetre(num value) : this._(Quantity.of(value, kilogramPerSquareMetre)); |
| 167 | + MassPerArea.kilogramsPerSquareMetre(num value) : this._(Quantity.of(value, si.kilogramPerSquareMetre)); |
167 | 168 | } |
168 | 169 |
|
169 | 170 | extension type VolumePerTime._(Quantity q) implements DimensionedQuantity<VolumePerTime> { |
170 | 171 | VolumePerTime(Quantity q) : q = volumePerTime.checked(q); |
171 | | - const VolumePerTime.zero() : q = const Quantity.of(0, cubicMetrePerSecond); |
| 172 | + const VolumePerTime.zero() : q = const Quantity.of(0, si.cubicMetrePerSecond); |
172 | 173 | VolumePerTime.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
173 | | - VolumePerTime.cubicMetresPerSecond(num value) : this._(Quantity.of(value, cubicMetrePerSecond)); |
| 174 | + VolumePerTime.cubicMetresPerSecond(num value) : this._(Quantity.of(value, si.cubicMetrePerSecond)); |
174 | 175 | } |
175 | 176 |
|
176 | 177 | extension type VolumePerArea._(Quantity q) implements DimensionedQuantity<VolumePerArea> { |
177 | 178 | VolumePerArea(Quantity q) : q = volumePerArea.checked(q); |
178 | | - const VolumePerArea.zero() : q = const Quantity.of(0, cubicMetrePerSquareMetre); |
| 179 | + const VolumePerArea.zero() : q = const Quantity.of(0, si.cubicMetrePerSquareMetre); |
179 | 180 | VolumePerArea.of(num value, Unit unit) : this(Quantity.of(value, unit)); |
180 | | - VolumePerArea.cubicMetresPerSquareMetre(num value) : this._(Quantity.of(value, cubicMetrePerSquareMetre)); |
| 181 | + VolumePerArea.cubicMetresPerSquareMetre(num value) : this._(Quantity.of(value, si.cubicMetrePerSquareMetre)); |
181 | 182 | } |
0 commit comments