AutoApi.UnitType (auto_api v13.2.0) View Source

Handles unit types

Link to this section Summary

Functions

Returns all measurement types

Returns the ID of a measurement type given the name.

Returns the name of a measurement type given its ID

Returns the ID of an unit of measurement.

Returns the name of an unit of measurement.

Returns all possible units for the given measurement type.

Link to this section Types

Specs

acceleration() :: %{
  value: float() | integer(),
  unit: :meters_per_second_squared | :gravity
}

Specs

angle() :: %{
  value: float() | integer(),
  unit: :degrees | :radians | :revolutions
}

Specs

angular_velocity() :: %{
  value: float() | integer(),
  unit: :revolutions_per_minute | :degrees_per_second | :radians_per_second
}

Specs

duration() :: %{
  value: float() | integer(),
  unit: :seconds | :minutes | :hours | :days | :weeks | :months | :milliseconds
}

Specs

electric_current() :: %{
  value: float() | integer(),
  unit: :amperes | :milliamperes | :kiloamperes
}
Link to this type

electric_potential_difference()

View Source

Specs

electric_potential_difference() :: %{
  value: float() | integer(),
  unit: :volts | :millivolts | :kilovolts
}

Specs

energy() :: %{
  value: float() | integer(),
  unit: :joules | :kilojoules | :watt_hours | :kilowatt_hours | :ampere_hours
}

Specs

energy_efficiency() :: %{
  value: float() | integer(),
  unit: :kwh_per_100_kilometers | :miles_per_kwh
}

Specs

frequency() :: %{
  value: float() | integer(),
  unit:
    :hertz
    | :millihertz
    | :kilohertz
    | :megahertz
    | :gigahertz
    | :times_per_minute
    | :times_per_hour
    | :times_per_day
}

Specs

fuel_efficiency() :: %{
  value: float() | integer(),
  unit:
    :liters_per_100_kilometers | :miles_per_imperial_gallon | :miles_per_gallon
}

Specs

id() :: 1..255

Specs

illuminance() :: %{value: float() | integer(), unit: :lux}

Specs

length() :: %{
  value: float() | integer(),
  unit:
    :meters
    | :millimeters
    | :centimeters
    | :decimeters
    | :kilometers
    | :megameters
    | :inches
    | :feet
    | :yards
    | :miles
    | :scandinavian_miles
    | :nautical_miles
}

Specs

mass() :: %{
  value: float() | integer(),
  unit:
    :kilograms
    | :grams
    | :decigrams
    | :centigrams
    | :milligrams
    | :micrograms
    | :nanograms
    | :picograms
    | :ounces
    | :pounds
    | :stones
    | :metric_tons
    | :short_tons
    | :carats
    | :ounces_troy
    | :slugs
}

Specs

power() :: %{
  value: float() | integer(),
  unit: :watts | :milliwatts | :kilowatts | :megawatts | :horsepower
}

Specs

pressure() :: %{
  value: float() | integer(),
  unit:
    :pascals
    | :kilopascals
    | :inches_of_mercury
    | :bars
    | :millibars
    | :millimeters_of_mercury
    | :pounds_force_per_square_inch
}

Specs

speed() :: %{
  value: float() | integer(),
  unit: :meters_per_second | :kilometers_per_hour | :miles_per_hour | :knots
}

Specs

t(unit_type) :: %{value: float() | integer(), unit: unit_type}

Specs

temperature() :: %{
  value: float() | integer(),
  unit: :kelvin | :celsius | :fahrenheit
}

Specs

torque() :: %{
  value: float() | integer(),
  unit: :newton_meters | :newton_millimeters | :pound_feet
}

Specs

volume() :: %{
  value: float() | integer(),
  unit:
    :liters
    | :milliliters
    | :centiliters
    | :deciliters
    | :cubic_millimeters
    | :cubic_centimeters
    | :cubic_decimeters
    | :cubic_meters
    | :cubic_inches
    | :cubic_feet
    | :fluid_ounces
    | :gallons
    | :imperial_fluid_ounces
    | :imperial_gallons
}

Link to this section Functions

Specs

all() :: [atom()]

Returns all measurement types

Example

iex> types = AutoApi.UnitType.all()
iex> length(types)
19
iex> List.first(types)
:acceleration

Specs

id(String.t() | atom()) :: id()

Returns the ID of a measurement type given the name.

The name can be expressed as a string or atom.

Examples

iex> AutoApi.UnitType.id(:length)
0x12
iex> AutoApi.UnitType.id("power")
0x14

Specs

name(id()) :: atom()

Returns the name of a measurement type given its ID

Example

iex> AutoApi.UnitType.name(0x18)
:torque
Link to this function

unit_id(type_name, unit_name)

View Source

Specs

unit_id(String.t() | atom(), atom()) :: id() | nil

Returns the ID of an unit of measurement.

The measurement name can be passed either as string or atom, but the unit name is only accepted in atom format.

Examples

iex> AutoApi.UnitType.unit_id(:volume, :liters)
0x02
iex> AutoApi.UnitType.unit_id("power", :megawatts)
0x03
iex> AutoApi.UnitType.unit_id("power", :foobar)
nil
Link to this function

unit_name(type_id, unit_id)

View Source

Specs

unit_name(id(), id()) :: atom()

Returns the name of an unit of measurement.

Both the type and unit must be specified by their IDs.

Example

iex> AutoApi.UnitType.unit_name(0x16, 0x02)
:miles_per_hour

Specs

units(atom() | String.t() | id()) :: [atom()]

Returns all possible units for the given measurement type.

The type can be specified either by ID or name (string or atom).

Examples

iex> AutoApi.UnitType.units(:speed) |> List.first()
:meters_per_second
iex> AutoApi.UnitType.units("torque") |> List.first()
:newton_meters
iex> AutoApi.UnitType.units(0x11) |> List.first()
:lux