Utils

n2k.utils.millis() int[source]
Return type:

int

class n2k.utils.IntRef(value: int = 0) None[source]

Bases: object

A reference to an integer value.

This class is useful for creating a mutable integer object that can be passed around and modified in place.

Implements basic arithmetic operations to allow for easy manipulation of the integer value.

__init__(value: int = 0) None[source]
value: int
n2k.utils.clamp_int(min_val: int, val: int, max_val: int) int[source]
Return type:

int

n2k.utils.n2k_double_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_float_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_uint8_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_int8_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_uint16_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_int16_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_uint32_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_int32_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_uint64_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.n2k_int64_is_na(v: float) bool[source]
Return type:

bool

n2k.utils.rad_to_deg(v: float) float[source]
Return type:

float

n2k.utils.deg_to_rad(v: float) float[source]
Return type:

float

n2k.utils.c_to_kelvin(v: float) float[source]
Return type:

float

n2k.utils.kelvin_to_c(v: float) float[source]
Return type:

float

n2k.utils.f_to_kelvin(v: float) float[source]
Return type:

float

n2k.utils.kelvin_to_f(v: float) float[source]
Return type:

float

n2k.utils.mbar_to_pascal(v: float) float[source]
Return type:

float

n2k.utils.pascal_to_mbar(v: float) float[source]
Return type:

float

n2k.utils.hpa_to_pascal(v: float) float[source]
Return type:

float

n2k.utils.pascal_to_hpa(v: float) float[source]
Return type:

float

n2k.utils.ah_to_coulomb(v: float) float[source]
Return type:

float

n2k.utils.coulomb_to_ah(v: float) float[source]
Return type:

float

n2k.utils.hours_to_seconds(v: float) float[source]
Return type:

float

n2k.utils.seconds_to_hours(v: float) float[source]
Return type:

float

n2k.utils.meters_per_second_to_knots(v: float) float[source]
Return type:

float

n2k.utils.knots_to_meters_per_second(v: float) float[source]
Return type:

float

n2k.utils.n2k_reset_binary_status() int[source]

Reset all single binary status values to not available

This helper function returns a new fully reset 64bit bank status. For each individual item the status will be 3 (0b11 - Unavailable N2kOnOff)

Return type:

int

n2k.utils.n2k_get_status_on_binary_status(bank_status: int, item_index: int = 1) N2kOnOff[source]

Get single status of full binary bank status returned by n2k.messages.parse_n2k_binary_status_report().

Parameters:
Return type:

N2kOnOff

Returns:

single status of full binary bank status

n2k.utils.n2k_set_status_binary_on_status(bank_status: int, item_status: N2kOnOff, item_index: int = 1) int[source]

Set single status to full binary bank status.

Parameters:
  • bank_status (int) – Existing Bank Status

  • item_status (N2kOnOff) – New Item Status

  • item_index (int, default: 1) – Index of Item to be changed

Return type:

int

Returns:

New Bank Status

n2k.utils.with_fallback(v: T | None, fallback: T) T[source]
Return type:

TypeVar(T)