UnitDatabase

baja. UnitDatabase

new UnitDatabase()

Description:
  • Queries the unit database from the station.

    There is no reason to call this constructor directly; rather use the
    static accessor functions.

Source:

Methods

convertUnit(unitConversion, unit) → {baja.Unit|null}

Description:
  • Convert a unit from metric to English or vice versa.

Source:
Parameters:
Name Type Description
unitConversion String | number | baja.FrozenEnum

metric to convert
from English to metric; english to convert from metric to English. Also
accepts baja:UnitConversion instances or ordinals.

unit baja.Unit

the unit to convert

Returns:

the converted unit. If the unit cannot be
converted, the same unit will be returned directly. If no unit given,
returns null.

Type
baja.Unit | null

getQuantities() → {Array.<baja.UnitDatabase.Quantity>}

Description:
  • Get all quantities contained in the unit database.

Source:
Returns:
Type
Array.<baja.UnitDatabase.Quantity>

getQuantity(unit) → {baja.UnitDatabase.Quantity|undefined}

Description:
  • Get the Quantity which contains the specified unit or return undefined if the unit is not
    contained by the database.

Source:
Since:
  • Niagara 4.14
Parameters:
Name Type Description
unit baja.Unit

the unit we want the quantity for

Returns:
Type
baja.UnitDatabase.Quantity | undefined

getUnit(name) → {baja.Unit|null}

Description:
  • Retrieve the unit instance with the given name.

Source:
Parameters:
Name Type Description
name String | baja.Unit

the desired unit name. If a baja.Unit is
passed, it will just be returned back directly.

Returns:

the unit, or null if not found

Type
baja.Unit | null

(static) get(callbacksopt) → {Promise.<baja.UnitDatabase>}

Description:
  • Asynchronously retrieve the unit database from the station. The network
    call to the station will only happen once: the same database instance will
    be resolved no matter how many times this function is called.

Source:
Parameters:
Name Type Attributes Description
callbacks Object <optional>
Properties
Name Type Attributes Description
ok function <optional>

(Deprecated: use Promise) ok callback,
will receive a UnitDatabase instance populated with data retrieved from
the station

fail function <optional>

(Deprecated: use Promise) fail callback

batch baja.comm.Batch <optional>

batch to use for the network
request

Returns:
Type
Promise.<baja.UnitDatabase>