UI: Add new unit definition

This commit is contained in:
Vladyslav_Prykhodko 2025-04-30 13:00:48 +03:00
parent 8c3f56da25
commit 505dfb2e4d
13 changed files with 845 additions and 8 deletions

View File

@ -28,8 +28,16 @@ import frequency, { FrequencyUnits } from '@core/services/unit/definitions/frequ
import illuminance,{ IlluminanceUnits } from '@core/services/unit/definitions/illuminance';
import length, { LengthUnits } from '@core/services/unit/definitions/length';
import mass, { MassUnits } from '@core/services/unit/definitions/mass';
import partsPer, { PartsPerUnits } from '@core/services/unit/definitions/parts-per';
import power, { PowerUnits } from '@core/services/unit/definitions/power';
import pressure, { PressureUnits } from '@core/services/unit/definitions/pressure';
import speed, { SpeedUnits } from '@core/services/unit/definitions/speed';
import temperature, { TemperatureUnits } from './temperature';
import time, { TimeUnits } from './time';
import torque, { TorqueUnits } from '@core/services/unit/definitions/torque';
import voltage, { VoltageUnits } from '@core/services/unit/definitions/voltage';
import volume, { VolumeUnits } from '@core/services/unit/definitions/volume';
import volumeFlowRate, { VolumeFlowRateUnits } from '@core/services/unit/definitions/volume-flow-rate';
export type AllMeasuresUnits =
| AccelerationUnits
@ -45,8 +53,16 @@ export type AllMeasuresUnits =
| IlluminanceUnits
| LengthUnits
| MassUnits
| PartsPerUnits
| PowerUnits
| PressureUnits
| SpeedUnits
| TemperatureUnits
| TimeUnits;
| TimeUnits
| TorqueUnits
| VoltageUnits
| VolumeUnits
| VolumeFlowRateUnits;
export type AllMeasures =
| 'acceleration'
@ -62,8 +78,16 @@ export type AllMeasures =
| 'illuminance'
| 'length'
| 'mass'
| 'parts-per'
| 'power'
| 'pressure'
| 'speed'
| 'temperature'
| 'time';
| 'time'
| 'torque'
| 'voltage'
| 'volume'
| 'volume-flow-rate';
const allMeasures: Record<
AllMeasures,
@ -82,8 +106,16 @@ const allMeasures: Record<
illuminance,
length,
mass,
'parts-per': partsPer,
power,
pressure,
speed,
temperature,
time,
torque,
voltage,
volume,
'volume-flow-rate': volumeFlowRate,
};
export default allMeasures;

View File

@ -53,7 +53,7 @@ const METRIC: TbMeasureUnits<AngleMetricUnits> = {
to_anchor: 9 / (50 * Math.PI),
},
rev: {
name: 'revolution',
name: 'unit.revolution',
tags: ['angle', 'revolution', 'full circle', 'complete turn', 'rev'],
to_anchor: 360,
},

View File

@ -125,7 +125,7 @@ const IMPERIAL: TbMeasureUnits<EnergyImperialUnits> = {
to_anchor: 1000,
},
BTU: {
name: 'british-thermal-unit',
name: 'unit.british-thermal-unit',
tags: ['energy', 'heat', 'work done', 'british thermal unit', 'british thermal units', 'BTU'],
to_anchor: 252.164401,
},

View File

@ -101,7 +101,7 @@ const IMPERIAL: TbMeasureUnits<MassImperialUnits> = {
to_anchor: 28,
},
cwt: {
name: 'unit.hundredweight-countt',
name: 'unit.hundredweight-count',
tags: ['mass', 'weight', 'heaviness', 'load', 'hundredweight count', 'cwt'],
to_anchor: 100,
},

View File

@ -0,0 +1,41 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type PartsPerUnits = PartsPerMetricUnits;
export type PartsPerMetricUnits = 'ppm' | 'ppb';
const METRIC: TbMeasureUnits<PartsPerMetricUnits> = {
units: {
ppm: {
name: 'unit.ppm',
tags: ['carbon dioxide', 'co²', 'carbon monoxide', 'co', 'aqi', 'air quality', 'total volatile organic compounds', 'tvoc', 'ppm'],
to_anchor: 1,
},
ppb: {
name: 'unit.ppb',
tags: ['ozone', 'o³', 'nitrogen dioxide', 'no²', 'sulfur dioxide', 'so²', 'aqi', 'air quality', 'tvoc', 'ppb'],
to_anchor: 0.001,
}
},
};
const measure: TbMeasure<PartsPerUnits> = {
METRIC,
};
export default measure;

View File

@ -0,0 +1,96 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type PowerUnits = PowerMetricUnits | PowerImperialUnits;
export type PowerMetricUnits = 'W' | 'μW' | 'mW' | 'kW' | 'MW' | 'GW' | 'PS';
export type PowerImperialUnits = 'BTU/s' | 'ft-lb/s' | 'hp' | 'BTU/h';
const METRIC: TbMeasureUnits<PowerMetricUnits> = {
ratio: 0.737562149,
units: {
W: {
name: 'unit.watt',
tags: ['power', 'horsepower', 'performance', 'watt', 'watts', 'electricity', 'W'],
to_anchor: 1,
},
μW: {
name: 'unit.microwatt',
tags: ['power', 'horsepower', 'performance', 'microwatt', 'microwatts', 'electricity', 'μW'],
to_anchor: 0.000001,
},
mW: {
name: 'unit.milliwatt',
tags: ['power', 'horsepower', 'performance', 'milliwatt', 'milliwatts', 'electricity', 'mW'],
to_anchor: 0.001,
},
kW: {
name: 'unit.kilowatt',
tags: ['power', 'horsepower', 'performance', 'kilowatt', 'kilowatts', 'electricity', 'kW'],
to_anchor: 1000,
},
MW: {
name: 'unit.megawatt',
tags: ['power', 'horsepower', 'performance', 'megawatt', 'megawatts', 'electricity', 'MW'],
to_anchor: 1000000,
},
GW: {
name: 'unit.gigawatt',
tags: ['power', 'horsepower', 'performance', 'gigawatt', 'gigawatts', 'electricity', 'GW'],
to_anchor: 1000000000,
},
PS: {
name: 'unit.metric-horsepower',
tags: ['power', 'performance', 'metric horsepower', 'PS'],
to_anchor: 735.49875,
},
},
};
const IMPERIAL: TbMeasureUnits<PowerImperialUnits> = {
ratio: 1 / 0.737562149,
units: {
'BTU/s': {
name: 'unit.btu-per-second',
tags: ['power', 'heat transfer', 'thermal energy', 'british thermal unit per second', 'Btu/s'],
to_anchor: 778.16937,
},
'ft-lb/s': {
name: 'unit.foot-pound-per-second',
tags: ['power', 'foot-pound per second', 'foot-pounds per second', 'ft-lb/s', 'mechanical power'],
to_anchor: 1,
},
hp: {
name: 'unit.horsepower',
tags: ['power', 'horsepower', 'performance', 'electricity', 'horsepowers', 'hp'],
to_anchor: 550,
},
'BTU/h': {
name: 'unit.btu-per-hour',
tags: ['power', 'heat transfer', 'thermal energy', 'HVAC', 'BTU/h'],
to_anchor: 0.216158,
},
},
};
const measure: TbMeasure<PowerUnits> = {
METRIC,
IMPERIAL
};
export default measure;

View File

@ -0,0 +1,175 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type PressureUnits = PressureMetricUnits | PressureImperialUnits;
export type PressureMetricUnits =
| 'Pa'
| 'kPa'
| 'MPa'
| 'GPa'
| 'hPa'
| 'mb'
| 'mbar'
| 'bar'
| 'kbar'
| 'Torr'
| 'mmHg'
| 'atm'
| 'Pa/m²'
| 'N/mm²'
| 'N/m²'
| 'kN/m²'
| 'kgf/m²'
| 'Pa/cm²';
export type PressureImperialUnits = 'psi' | 'ksi' | 'inHg' | 'psi/in²' | 'tonf/in²';
const METRIC: TbMeasureUnits<PressureMetricUnits> = {
ratio: 0.00014503768078,
units: {
Pa: {
name: 'unit.pascal',
tags: ['pressure', 'force', 'compression', 'tension', 'pascal', 'pascals', 'Pa', 'atmospheric pressure', 'air pressure', 'weather', 'altitude', 'flight'],
to_anchor: 0.001, // 1 Pa = 0.001 kPa
},
kPa: {
name: 'unit.kilopascal',
tags: ['pressure', 'force', 'compression', 'tension', 'kilopascal', 'kilopascals', 'kPa'],
to_anchor: 1,
},
MPa: {
name: 'unit.megapascal',
tags: ['pressure', 'force', 'compression', 'tension', 'megapascal', 'megapascals', 'MPa'],
to_anchor: 1000,
},
GPa: {
name: 'unit.gigapascal',
tags: ['pressure', 'force', 'compression', 'tension', 'gigapascal', 'gigapascals', 'GPa'],
to_anchor: 1000000,
},
hPa: {
name: 'unit.hectopascal',
tags: ['pressure', 'force', 'compression', 'tension', 'hectopascal', 'hectopascals', 'hPa', 'atmospheric pressure'],
to_anchor: 0.1,
},
mbar: {
name: 'unit.millibar',
tags: ['pressure', 'force', 'compression', 'tension', 'millibar', 'millibars', 'mbar'],
to_anchor: 0.1,
},
mb: {
name: 'unit.millibar',
tags: ['atmospheric pressure', 'air pressure', 'weather', 'altitude', 'flight', 'mb'],
to_anchor: 0.1,
},
bar: {
name: 'unit.bar',
tags: ['pressure', 'force', 'compression', 'tension', 'bar', 'bars'],
to_anchor: 100,
},
kbar: {
name: 'unit.kilobar',
tags: ['pressure', 'force', 'compression', 'tension', 'kilobar', 'kilobars', 'kbar'],
to_anchor: 100000,
},
Torr: {
name: 'unit.torr',
tags: ['pressure', 'force', 'compression', 'tension', 'vacuum pressure', 'torr'],
to_anchor: 101325 / 760000,
},
mmHg: {
name: 'unit.millimeters-of-mercury',
tags: ['pressure', 'force', 'compression', 'tension', 'millimeter of mercury', 'millimeters of mercury', 'mmHg', 'vacuum pressure'],
to_anchor: 0.133322,
},
atm: {
name: 'unit.atmospheres',
tags: ['pressure', 'force', 'compression', 'tension', 'atmosphere', 'atmospheres', 'atmospheric pressure', 'atm'],
to_anchor: 101.325,
},
'Pa/m²': {
name: 'unit.pascal-per-square-meter',
tags: ['pressure', 'stress', 'mechanical strength', 'pascal per square meter', 'Pa/m²'],
to_anchor: 0.001,
},
'N/mm²': {
name: 'unit.newton-per-square-millimeter',
tags: ['pressure', 'stress', 'mechanical strength', 'newton per square millimeter', 'N/mm²'],
to_anchor: 1000,
},
'N/m²': {
name: 'unit.newton-per-square-meter',
tags: ['pressure', 'stress', 'mechanical strength', 'newton per square meter', 'N/m²'],
to_anchor: 0.001,
},
'kN/m²': {
name: 'unit.kilonewton-per-square-meter',
tags: ['pressure', 'stress', 'mechanical strength', 'kilonewton per square meter', 'kN/m²'],
to_anchor: 1,
},
'kgf/m²': {
name: 'unit.kilogram-force-per-square-meter',
tags: ['pressure', 'stress', 'mechanical strength', 'kilogram-force per square meter', 'kgf/m²'],
to_anchor: 0.00980665,
},
'Pa/cm²': {
name: 'unit.pascal-per-square-centimeter',
tags: ['pressure', 'stress', 'mechanical strength', 'pascal per square centimeter', 'Pa/cm²'],
to_anchor: 0.1,
},
},
};
const IMPERIAL: TbMeasureUnits<PressureImperialUnits> = {
ratio: 1 / 0.00014503768078,
units: {
psi: {
name: 'unit.pounds-per-square-inch',
tags: ['pressure', 'force', 'compression', 'tension', 'pounds per square inch', 'psi'],
to_anchor: 0.001,
},
ksi: {
name: 'unit.kilopound-per-square-inch',
tags: ['pressure', 'force', 'compression', 'tension', 'kilopound per square inch', 'kilopounds per square inch', 'ksi'],
to_anchor: 1,
},
inHg: {
name: 'unit.inch-of-mercury',
tags: ['pressure', 'force', 'compression', 'tension', 'vacuum pressure', 'inHg', 'atmospheric pressure', 'barometric pressure'],
to_anchor: 0.000491154,
},
'psi/in²': {
name: 'unit.pound-per-square-inch',
tags: ['pressure', 'stress', 'mechanical strength', 'pound per square inch', 'psi/in²'],
to_anchor: 0.001,
},
'tonf/in²': {
name: 'unit.ton-force-per-square-inch',
tags: ['pressure', 'stress', 'mechanical strength', 'ton-force per square inch', 'tonf/in²'],
to_anchor: 2,
},
},
};
const measure: TbMeasure<PressureUnits> = {
METRIC,
IMPERIAL
};
export default measure;

View File

@ -0,0 +1,81 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type SpeedUnits = SpeedMetricUnits | SpeedImperialUnits;
export type SpeedMetricUnits = 'm/s' | 'km/h' | 'mm/min';
export type SpeedImperialUnits = 'mph' | 'kt' | 'ft/s' | 'ft/min' | 'in/h';
const METRIC: TbMeasureUnits<SpeedMetricUnits> = {
ratio: 1 / 1.609344,
units: {
'm/s': {
name: 'unit.meter-per-second',
tags: ['speed', 'velocity', 'pace', 'meter per second', 'm/s', 'peak', 'peak to peak', 'root mean square (RMS)', 'vibration', 'wind speed', 'weather'],
to_anchor: 3.6,
},
'km/h': {
name: 'unit.kilometer-per-hour',
tags: ['speed', 'velocity', 'pace', 'kilometer per hour', 'km/h'],
to_anchor: 1,
},
'mm/min': {
name: 'unit.millimeters-per-minute',
tags: ['feed rate', 'cutting feed rate', 'millimeters per minute', 'mm/min'],
to_anchor: 0.06,
},
},
};
const IMPERIAL: TbMeasureUnits<SpeedImperialUnits> = {
ratio: 1.609344,
units: {
mph: {
name: 'unit.mile-per-hour',
tags: ['speed', 'velocity', 'pace', 'mile per hour', 'mph'],
to_anchor: 1,
},
kt: {
name: 'unit.knot',
tags: ['speed', 'velocity', 'pace', 'knot', 'knots', 'kt'],
to_anchor: 1.150779,
},
'ft/s': {
name: 'unit.foot-per-second',
tags: ['speed', 'velocity', 'pace', 'foot per second', 'ft/s'],
to_anchor: 0.681818, // 1 ft/s ≈ 0.681818 mph
},
'ft/min': {
name: 'unit.foot-per-minute',
tags: ['speed', 'velocity', 'pace', 'foot per minute', 'ft/min'],
to_anchor: 0.0113636,
},
'in/h': {
name: 'unit.inch-per-hour',
tags: ['speed', 'velocity', 'pace', 'inch per hour', 'in/h'],
to_anchor: 0.00001578,
},
},
};
const measure: TbMeasure<SpeedUnits> = {
METRIC,
IMPERIAL,
};
export default measure;

View File

@ -0,0 +1,56 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type TorqueUnits = TorqueMetricUnits | TorqueImperialUnits;
export type TorqueMetricUnits = 'Nm';
export type TorqueImperialUnits = 'lbf-ft' | 'in·lbf';
const METRIC: TbMeasureUnits<TorqueMetricUnits> = {
ratio: 1 / 1.355818,
units: {
Nm: {
name: 'unit.newton-meter',
tags: ['torque', 'rotational force', 'newton meter', 'Nm'],
to_anchor: 1,
},
},
};
const IMPERIAL: TbMeasureUnits<TorqueImperialUnits> = {
ratio: 1.355818,
units: {
'lbf-ft': {
name: 'unit.foot-pounds',
tags: ['torque', 'rotational force', 'foot-pound', 'foot-pounds', 'ft·lbf'],
to_anchor: 1,
},
'in·lbf': {
name: 'unit.inch-pounds',
tags: ['torque', 'rotational force', 'inch-pounds', 'inch-pound', 'in·lbf'],
to_anchor: 1 / 12,
},
},
};
const measure: TbMeasure<TorqueUnits> = {
METRIC,
IMPERIAL,
};
export default measure;

View File

@ -0,0 +1,66 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type VoltageUnits = VoltageMetricUnits;
export type VoltageMetricUnits = 'pV' | 'nV' | 'μV' | 'mV' | 'V' | 'kV' | 'MV';
const METRIC: TbMeasureUnits<VoltageMetricUnits> = {
units: {
pV: {
name: 'unit.picovolt',
tags: ['voltage', 'volts', 'picovolt', 'pV'],
to_anchor: 1e-12,
},
nV: {
name: 'unit.nanovolt',
tags: ['voltage', 'volts', 'nanovolt', 'nV'],
to_anchor: 1e-9,
},
μV: {
name: 'unit.microvolt',
tags: ['electric potential', 'electric tension', 'voltage', 'microvolt', 'microvolts', 'μV'],
to_anchor: 1e-6,
},
mV: {
name: 'unit.millivolt',
tags: ['electric potential', 'electric tension', 'voltage', 'millivolt', 'millivolts', 'mV'],
to_anchor: 0.001, // 1 mV = 1e-3 V
},
V: {
name: 'unit.volt',
tags: ['electric potential', 'electric tension', 'voltage', 'volt', 'volts', 'V', 'power source', 'battery', 'battery level'],
to_anchor: 1,
},
kV: {
name: 'unit.kilovolt',
tags: ['electric potential', 'electric tension', 'voltage', 'kilovolt', 'kilovolts', 'kV'],
to_anchor: 1000,
},
MV: {
name: 'unit.megavolt',
tags: ['electric potential', 'electric tension', 'voltage', 'megavolt', 'megavolts', 'MV'],
to_anchor: 1e6,
},
},
};
const measure: TbMeasure<VoltageUnits> = {
METRIC,
};
export default measure;

View File

@ -0,0 +1,114 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type VolumeFlowRateUnits = VolumeFlowRateMetricUnits | VolumeFlowRateImperialUnits;
export type VolumeFlowRateMetricUnits =
| 'dm³/s'
| 'mL/min'
| 'L/s'
| 'L/min'
| 'L/hr'
| 'm³/s'
| 'm³/hr';
export type VolumeFlowRateImperialUnits =
| 'fl-oz/s'
| 'ft³/s'
| 'ft³/min'
| 'gal/hr'
| 'GPM';
const METRIC: TbMeasureUnits<VolumeFlowRateMetricUnits> = {
ratio: 33.8140227,
units: {
'dm³/s': {
name: 'unit.cubic-decimeter-per-second',
tags: ['volume flow', 'cubic decimeter per second', 'dm3/s'],
to_anchor: 1,
},
'mL/min': {
name: 'unit.milliliters-per-minute',
tags: ['volume flow', 'flow rate', 'fluid dynamics', 'milliliters per minute', 'mL/min'],
to_anchor: 1 / 60000,
},
'L/s': {
name: 'unit.liter-per-second',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'liter per second', 'L/s'],
to_anchor: 1,
},
'L/min': {
name: 'unit.liter-per-minute',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'liter per minute', 'L/min'],
to_anchor: 1 / 60,
},
'L/hr': {
name: 'unit.liters-per-hour',
tags: ['volume flow', 'fuel consumption', 'liter per hour', 'L/hr'],
to_anchor: 1 / 3600,
},
'm³/s': {
name: 'unit.cubic-meters-per-second',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'cubic meters per second', 'm³/s'],
to_anchor: 1000,
},
'm³/hr': {
name: 'unit.cubic-meters-per-hour',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'cubic meters per hour', 'm³/hr'],
to_anchor: 5 / 18,
},
},
};
const IMPERIAL: TbMeasureUnits<VolumeFlowRateImperialUnits> = {
ratio: 1 / 33.8140227,
units: {
'fl-oz/s': {
name: 'unit.fluid-ounce-per-second',
tags: ['volume flow', 'fluid ounce per second', 'fl-oz/s'],
to_anchor: 1,
},
'ft³/s': {
name: 'unit.cubic-foot-per-second',
tags: ['volume flow', 'flow rate', 'fluid flow', 'cubic foot per second', 'cubic feet per second', 'ft³/s'],
to_anchor: 957.506,
},
'ft³/min': {
name: 'unit.cubic-foot-per-minute',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'CFM', 'flow rate', 'fluid flow', 'cubic foot per minute', 'ft³/min'],
to_anchor: 957.506 / 60,
},
'gal/hr': {
name: 'unit.gallons-per-hour',
tags: ['volume flow', 'fuel consumption', 'gallons per hour', 'gal/hr'],
to_anchor: 128 / 3600,
},
'GPM': {
name: 'unit.gallons-per-minute',
tags: ['volume flow', 'airflow', 'ventilation', 'HVAC', 'gas flow rate', 'gallons per minute', 'GPM'],
to_anchor: 128 / 60,
},
},
};
const measure: TbMeasure<VolumeFlowRateUnits> = {
METRIC,
IMPERIAL,
};
export default measure;

View File

@ -0,0 +1,168 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models';
export type VolumeUnits = VolumeMetricUnits | VolumeImperialUnits;
export type VolumeMetricUnits =
| 'mm³'
| 'cm³'
| 'µL'
| 'mL'
| 'L'
| 'hL'
| 'm³'
| 'km³';
export type VolumeImperialUnits =
| 'tsp'
| 'tbsp'
| 'in³'
| 'fl-oz'
| 'cup'
| 'pt'
| 'qt'
| 'gal'
| 'ft³'
| 'yd³'
| 'bbl'
| 'gi'
| 'hhd';
const METRIC: TbMeasureUnits<VolumeMetricUnits> = {
ratio: 33.8140226,
units: {
'mm³': {
name: 'unit.cubic-millimeter',
tags: ['volume', 'capacity', 'extent', 'cubic millimeter', 'mm³'],
to_anchor: 1 / 1000000,
},
'cm³': {
name: 'unit.cubic-centimeter',
tags: ['volume', 'capacity', 'extent', 'cubic centimeter', 'cubic centimeters', 'cm³'],
to_anchor: 1 / 1000,
},
µL: {
name: 'unit.microliter',
tags: ['volume', 'liquid measurement', 'microliter', 'µL'],
to_anchor: 0.000001,
},
mL: {
name: 'unit.milliliter',
tags: ['volume', 'capacity', 'extent', 'milliliter', 'milliliters', 'mL'],
to_anchor: 1 / 1000,
},
L: {
name: 'unit.liter',
tags: ['volume', 'capacity', 'extent', 'liter', 'liters', 'l'],
to_anchor: 1,
},
hL: {
name: 'unit.hectoliter',
tags: ['volume', 'capacity', 'extent', 'hectoliter', 'hectoliters', 'hl'],
to_anchor: 100,
},
'm³': {
name: 'unit.cubic-meter',
tags: ['volume', 'capacity', 'extent', 'cubic meter', 'cubic meters', 'm³'],
to_anchor: 1000,
},
'km³': {
name: 'unit.cubic-kilometer',
tags: ['volume', 'capacity', 'extent', 'cubic kilometer', 'cubic kilometers', 'km³'],
to_anchor: 1000000000000,
},
},
};
const IMPERIAL: TbMeasureUnits<VolumeImperialUnits> = {
ratio: 1 / 33.8140226,
units: {
tsp: {
name: 'unit.teaspoon',
tags: ['volume', 'cooking measurement', 'tsp'],
to_anchor: 1 / 6,
},
tbsp: {
name: 'unit.tablespoon',
tags: ['volume', 'cooking measurement', 'tbsp'],
to_anchor: 1 / 2,
},
'in³': {
name: 'unit.cubic-inch',
tags: ['volume', 'capacity', 'extent', 'cubic inch', 'cubic inches', 'in³'],
to_anchor: 0.55411,
},
'fl-oz': {
name: 'unit.fluid-ounce',
tags: ['volume', 'capacity', 'extent', 'fluid ounce', 'fluid ounces', 'fl-oz'],
to_anchor: 1,
},
cup: {
name: 'unit.cup',
tags: ['volume', 'cooking measurement', 'cup'],
to_anchor: 8,
},
pt: {
name: 'unit.pint',
tags: ['volume', 'capacity', 'extent', 'pint', 'pints', 'pt'],
to_anchor: 16,
},
qt: {
name: 'unit.quart',
tags: ['volume', 'capacity', 'extent', 'quart', 'quarts', 'qt'],
to_anchor: 32,
},
gal: {
name: 'unit.gallon',
tags: ['volume', 'capacity', 'extent', 'gallon', 'gallons', 'gal'],
to_anchor: 128,
},
'ft³': {
name: 'unit.cubic-foot',
tags: ['volume', 'capacity', 'extent', 'cubic foot', 'cubic feet', 'ft³'],
to_anchor: 957.506,
},
'yd³': {
name: 'unit.cubic-yard',
tags: ['volume', 'capacity', 'extent', 'cubic yard', 'cubic yards', 'yd³'],
to_anchor: 25852.7,
},
bbl: {
name: 'unit.oil-barrels',
tags: ['volume', 'capacity', 'extent', 'oil barrel', 'oil barrels', 'bbl'],
to_anchor: 5376,
},
gi: {
name: 'unit.gill',
tags: ['volume', 'liquid measurement', 'gi'],
to_anchor: 4,
},
hhd: {
name: 'unit.hogshead',
tags: ['volume', 'liquid measurement', 'hhd'],
to_anchor: 8064,
},
},
};
const measure: TbMeasure<VolumeUnits> = {
METRIC,
IMPERIAL,
};
export default measure;

View File

@ -5938,6 +5938,7 @@
"cubic-foot": "Cubic Foot",
"cubic-yard": "Cubic Yard",
"fluid-ounce": "Fluid Ounce",
"fluid-ounce-per-second": "Fluid Ounce per second",
"pint": "Pint",
"quart": "Quart",
"gallon": "Gallon",
@ -5956,8 +5957,10 @@
"meter-per-second": "Meter per Second",
"kilometer-per-hour": "Kilometer per Hour",
"foot-per-second": "Foot per Second",
"foot-per-minute": "Foot per Minute",
"mile-per-hour": "Mile per Hour",
"knot": "Knot",
"inch-per-hour": "Inch per Hour",
"millimeters-per-minute": "Millimeters per minute",
"kilometer-per-hour-squared": "Kilometer per hour squared",
"foot-per-second-squared": "Foot per second squared",
@ -5975,6 +5978,7 @@
"newton-per-meter": "Newton per meter",
"atmospheres": "Atmospheres",
"pounds-per-square-inch": "Pounds per Square Inch",
"kilopound-per-square-inch": "Kilopound per Square Inch",
"torr": "Torr",
"inches-of-mercury": "Inches of Mercury",
"pascal-per-square-meter": "Pascal per Square Meter",
@ -6031,6 +6035,8 @@
"kilowatt-per-square-inch": "Kilowatts per square inch",
"horsepower": "Horsepower",
"btu-per-hour": "British thermal units/hour",
"btu-per-second": "British thermal units/second",
"foot-pound-per-second": "foot-pound per second",
"coulomb": "Coulomb",
"millicoulomb": "Millicoulombs",
"microcoulomb": "Microcoulomb",
@ -6081,10 +6087,11 @@
"ampere-meter-tags": "magnetic field, current loop, ampere-meter, A·m",
"nanovolt": "Nanovolt",
"picovolt": "Picovolt",
"millivolts": "Millivolts",
"microvolts": "Microvolts",
"millivolt": "Millivolts",
"microvolt": "Microvolts",
"volt": "Volt",
"kilovolts": "Kilovolts",
"kilovolt": "Kilovolt",
"megavolt": "Megavolt",
"dbmV": "dBmV",
"dbm": "dBm",
"volt-meter": "Volt-Meter",
@ -6209,6 +6216,7 @@
"gallons-per-minute": "Gallons Per Minute",
"cubic-foot-per-second": "Cubic foot per second",
"milliliters-per-minute": "Milliliters per minute",
"cubic-decimeter-per-second": "Cubic decimeter per second",
"bit": "Bit",
"byte": "Byte",
"kilobyte": "Kilobyte",