diff --git a/ui-ngx/src/app/core/services/unit/definitions/all.ts b/ui-ngx/src/app/core/services/unit/definitions/all.ts index 275f9c4c6f..9be86f61e5 100644 --- a/ui-ngx/src/app/core/services/unit/definitions/all.ts +++ b/ui-ngx/src/app/core/services/unit/definitions/all.ts @@ -19,6 +19,9 @@ import acceleration, { AccelerationUnits } from '@core/services/unit/definitions import angle, { AngleUnits } from '@core/services/unit/definitions/angle'; import angularAcceleration, { AngularAccelerationUnits } from '@core/services/unit/definitions/angular-acceleration'; import area, { AreaUnits } from '@core/services/unit/definitions/area'; +import charge, { ChargeUnits } from '@core/services/unit/definitions/charge'; +import digital, { DigitalUnits } from '@core/services/unit/definitions/digital'; +import electricCurrent, { ElectricCurrentUnits } from '@core/services/unit/definitions/electric-current'; import temperature, { TemperatureUnits } from './temperature'; import time, { TimeUnits } from './time'; @@ -27,6 +30,9 @@ export type AllMeasuresUnits = | AngleUnits | AngularAccelerationUnits | AreaUnits + | ChargeUnits + | DigitalUnits + | ElectricCurrentUnits | TemperatureUnits | TimeUnits; @@ -35,6 +41,9 @@ export type AllMeasures = | 'angle' | 'angular-acceleration' | 'area' + | 'charge' + | 'digital' + | 'electric-current' | 'temperature' | 'time'; @@ -46,6 +55,9 @@ const allMeasures: Record< angle, 'angular-acceleration': angularAcceleration, area, + charge, + digital, + 'electric-current': electricCurrent, temperature, time, }; diff --git a/ui-ngx/src/app/core/services/unit/definitions/angle.ts b/ui-ngx/src/app/core/services/unit/definitions/angle.ts index 2be1cc9a97..05a7593b03 100644 --- a/ui-ngx/src/app/core/services/unit/definitions/angle.ts +++ b/ui-ngx/src/app/core/services/unit/definitions/angle.ts @@ -16,11 +16,11 @@ import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models'; -export type AngleUnits = AngleSIUnits; +export type AngleUnits = AngleMetricUnits; -export type AngleSIUnits = 'rad' | 'deg' | 'grad' | 'arcmin' | 'arcsec' | 'mil' | 'rev'; +export type AngleMetricUnits = 'rad' | 'deg' | 'grad' | 'arcmin' | 'arcsec' | 'mil' | 'rev'; -const METRIC: TbMeasureUnits = { +const METRIC: TbMeasureUnits = { units: { rad: { name: 'unit.rad', diff --git a/ui-ngx/src/app/core/services/unit/definitions/charge.ts b/ui-ngx/src/app/core/services/unit/definitions/charge.ts new file mode 100644 index 0000000000..933e821a6a --- /dev/null +++ b/ui-ngx/src/app/core/services/unit/definitions/charge.ts @@ -0,0 +1,57 @@ +/// +/// 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 ChargeUnits = ChargeMetricUnits; + +export type ChargeMetricUnits = 'c' | 'mC' | 'μC' | 'nC' | 'pC'; + +const METRIC: TbMeasureUnits = { + units: { + c: { + name: 'unit.coulomb', + tags: ['charge', 'electricity', 'electrostatics', 'Coulomb', 'C'], + to_anchor: 1, + }, + mC: { + name: 'unit.millicoulomb', + tags: ['charge', 'electricity', 'electrostatics', 'millicoulombs', 'mC'], + to_anchor: 1 / 1000, + }, + μC: { + name: 'unit.microcoulomb', + tags: ['charge', 'electricity', 'electrostatics', 'microcoulomb', 'µC'], + to_anchor: 1 / 1000000, + }, + nC: { + name: 'unit.nanocoulomb', + tags: ['charge', 'electricity', 'electrostatics', 'nanocoulomb', 'nC'], + to_anchor: 1e-9, + }, + pC: { + name: 'unit.picocoulomb', + tags: ['charge', 'electricity', 'electrostatics', 'picocoulomb', 'pC'], + to_anchor: 1e-12, + }, + } +}; + +const measure: TbMeasure = { + METRIC, +}; + +export default measure; diff --git a/ui-ngx/src/app/core/services/unit/definitions/digital.ts b/ui-ngx/src/app/core/services/unit/definitions/digital.ts new file mode 100644 index 0000000000..54bcceea2f --- /dev/null +++ b/ui-ngx/src/app/core/services/unit/definitions/digital.ts @@ -0,0 +1,82 @@ +/// +/// 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 DigitalUnits = DigitalMetricUnits; + +export type DigitalMetricUnits = 'bit' | 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'ZB' | 'YB'; + +const METRIC: TbMeasureUnits = { + units: { + bit: { + name: 'unit.bit', + tags: ['data', 'binary digit', 'information', 'bit'], + to_anchor: 1.25e-1, + }, + B: { + name: 'unit.byte', + tags: ['data', 'byte', 'information', 'storage', 'memory', 'B'], + to_anchor: 1 + }, + KB: { + name: 'unit.kilobyte', + tags: ['data', 'kilobyte', 'KB'], + to_anchor: 1024, + }, + MB: { + name: 'unit.megabyte', + tags: ['data', 'megabyte', 'MB'], + to_anchor: 1024 ** 2, + }, + GB: { + name: 'unit.gigabyte', + tags: ['data', 'gigabyte', 'GB'], + to_anchor: 1024 ** 3, + }, + TB: { + name: 'unit.terabyte', + tags: ['data', 'terabyte', 'TB'], + to_anchor: 1024 ** 4, + }, + PB: { + name: 'unit.petabyte', + tags: ['data', 'petabyte', 'PB'], + to_anchor: 1024 ** 5, + }, + EB: { + name: 'unit.exabyte', + tags: ['data', 'exabyte', 'EB'], + to_anchor: 1024 ** 6, + }, + ZB: { + name: 'unit.zettabyte', + tags: ['data', 'zettabyte', 'EB'], + to_anchor: 1024 ** 7, + }, + YB: { + name: 'unit.yottabyte', + tags: ['data', 'yottabyte', 'EB'], + to_anchor: 1024 ** 8, + }, + } +}; + +const measure: TbMeasure = { + METRIC, +}; + +export default measure; diff --git a/ui-ngx/src/app/core/services/unit/definitions/electric-current.ts b/ui-ngx/src/app/core/services/unit/definitions/electric-current.ts new file mode 100644 index 0000000000..72a21ccf7f --- /dev/null +++ b/ui-ngx/src/app/core/services/unit/definitions/electric-current.ts @@ -0,0 +1,67 @@ +/// +/// 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 ElectricCurrentUnits = ElectricCurrentMetricalUnits; + +export type ElectricCurrentMetricalUnits = 'A' | 'nA' | 'μA' | 'mA' | 'kA' | 'MA' | 'GA'; + +const METRIC: TbMeasureUnits = { + units: { + A: { + name: 'unit.ampere', + tags: ['electric current', 'current flow', 'flow of electricity', 'electrical flow', 'ampere', 'amperes', 'amperage', 'A'], + to_anchor: 1, + }, + nA: { + name: 'unit.nanoampere', + tags: ['electric current', 'nanoampere', 'nanoamperes', 'nA'], + to_anchor: 1e-9, + }, + μA: { + name: 'unit.microampere', + tags: ['electric current', 'microampere', 'microamperes', 'μA'], + to_anchor: 1e-6, + }, + mA: { + name: 'unit.milliampere', + tags: ['electric current', 'milliampere', 'milliamperes', 'mA'], + to_anchor: 0.001, + }, + kA: { + name: 'unit.kiloampere', + tags: ['electric current', 'kiloampere', 'kiloamperes', 'kA'], + to_anchor: 1000, + }, + MA: { + name: 'unit.megaampere', + tags: ['electric current', 'megaampere', 'megaamperes', 'MA'], + to_anchor: 1e6, + }, + GA: { + name: 'unit.gigaampere', + tags: ['electric current', 'gigaampere', 'gigaamperes', 'GA'], + to_anchor: 1e9, + }, + } +}; + +const measure: TbMeasure = { + METRIC, +}; + +export default measure; diff --git a/ui-ngx/src/app/core/services/unit/definitions/time.ts b/ui-ngx/src/app/core/services/unit/definitions/time.ts index a78a9450fb..944bfafbe7 100644 --- a/ui-ngx/src/app/core/services/unit/definitions/time.ts +++ b/ui-ngx/src/app/core/services/unit/definitions/time.ts @@ -16,9 +16,9 @@ import { TbMeasure, TbMeasureUnits } from '@shared/models/unit.models'; -export type TimeUnits = TimeSIUnits; +export type TimeUnits = TimeMetricUnits; -export type TimeSIUnits = +export type TimeMetricUnits = | 'ns' | 'μs' | 'ms' @@ -32,7 +32,7 @@ export type TimeSIUnits = const daysInYear = 365.25; -const METRIC: TbMeasureUnits = { +const METRIC: TbMeasureUnits = { units: { ns: { name: 'unit.nanosecond', diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 560f85dfe6..78cc2d6e2e 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -5859,6 +5859,9 @@ "angle": "Angle", "angular-acceleration": "Angular acceleration", "area": "Area", + "charge": "Charge", + "digital": "Digital", + "electric-current": "Electric current", "temperature": "Temperature", "time": "Time" }, @@ -6009,6 +6012,7 @@ "coulomb": "Coulomb", "millicoulomb": "Millicoulombs", "microcoulomb": "Microcoulomb", + "nanocoulomb": "Nanocoulomb", "picocoulomb": "Picocoulomb", "coulomb-per-meter": "Coulomb per meter", "coulomb-per-cubic-meter": "Coulomb per Cubic Meter", @@ -6033,17 +6037,12 @@ "kiloampere-hours": "Kiloampere-hours", "kiloampere-hours-tags": "electric current, current flow, electric charge, current capacity, flow of electricity, electrical flow, kiloampere-hours, kiloampere-hour, kAh", "nanoampere": "Nanoampere", - "nanoampere-tags": "current, amperes, nanoampere, nA", - "picoampere": "Picoampere", - "picoampere-tags": "current, amperes, picoampere, pA", "microampere": "Microampere", - "microampere-tags": "electric current, microampere, microamperes, μA", "milliampere": "Milliampere", - "milliampere-tags": "electric current, milliampere, milliamperes, mA", "ampere": "Ampere", - "ampere-tags": "electric current, current flow, flow of electricity, electrical flow, ampere, amperes, amperage, A", - "kiloamperes": "Kiloamperes", - "kiloamperes-tags": "electric current, current flow, kiloamperes, kA", + "kiloampere": "Kiloampere", + "megaampere": "Megaampere", + "gigaampere": "Gigaampere", "microampere-per-square-centimeter": "Microampere per square centimeter", "microampere-per-square-centimeter-tags": "Current density, microampere per square centimeter, µA/cm²", "ampere-per-square-meter": "Ampere per Square Meter",