BF-PHYSICS-UNITCONVERTER - Unit Converters

../../../../../../../_images/MLPro-BF-Physics-UnitConverter_class_diagram.drawio.png

Ver. 1.0.4 (2023-03-07)

This module provides models for unit conversions.

class mlpro.bf.physics.unitconverter.UnitConverter(p_name: str, p_id: int = None, p_type: int = None, p_unit_in: str = None, p_unit_out: str = None, p_logging=True, **p_args)

Bases: TransferFunction

This class serves as a base class of unit converters, which inherits the main attributes from a transfer function. By default, there are several ready-to-use unit converters available, such as, Length, Temperature, Pressure, Electric Current, Force, Power, Mass, and Time.

Parameters:
  • p_name (str) – name of the unit converter.

  • p_id (int) – unique id of the unit converter. Default: None.

  • p_type (int) – type of the unit converter. Default: None.

  • p_unit_in (str) – unit of the unit converter’s input. Default: None.

  • p_unit_out (str) – unit of the unit converter’s output. Default: None.

  • p_logging – Log level (see constants of class Log). Default: Log.C_LOG_ALL.

C_TYPE

type of the base class. Default: ‘UnitConverter’.

Type:

str

C_NAME

name of the unit converter. Default: ‘’.

Type:

str

C_UNIT_CONV_LENGTH

unit converter for length. Default: 0.

Type:

int

C_UNIT_CONV_PRESSURE

unit converter for pressure. Default: 1.

Type:

int

C_UNIT_CONV_CURRENT

unit converter for electric current. Default: 2.

Type:

int

C_UNIT_CONV_FORCE

unit converter for force. Default: 3.

Type:

int

C_UNIT_CONV_POWER

unit converter for power. Default: 4.

Type:

int

C_UNIT_CONV_MASS

unit converter for mass. Default: 5.

Type:

int

C_UNIT_CONV_TIME

unit converter for time. Default: 6.

Type:

int

C_UNIT_CONV_TEMPERATURE

unit converter for temperature. Default: 7.

Type:

int

C_TYPE = 'UnitConverter'
C_NAME = ''
C_UNIT_CONV_LENGTH = 0
C_UNIT_CONV_PRESSURE = 1
C_UNIT_CONV_CURRENT = 2
C_UNIT_CONV_FORCE = 3
C_UNIT_CONV_POWER = 4
C_UNIT_CONV_MASS = 5
C_UNIT_CONV_TIME = 6
C_UNIT_CONV_TEMPERATURE = 7
_set_function_parameters(p_args=None) bool

This method provides a functionality to set the parameters of the unit converter.

Parameters:

p_args – not necessary for a unit converter. Default: None.

Returns:

true means initialization is successful.

Return type:

bool

_scalar_conversion(p_input: float) float

This method provides a scalar conversion functionality.

Parameters:

p_input (float) – input value.

Returns:

output value.

Return type:

float

_temperature(p_input: float) float

This method provides a temperature conversion functionality.

Parameters:

p_input (float) – input value.

Returns:

output value.

Return type:

float