Unit Converter#
Unit Converter is a static helper that converts a given value from and to internal units
.
All values in Kappa-Automate are stored in SI units.
You cannot instantiate this class directly, but you can access it in two ways:
When writing a Python script with an established connection:
unit_converter = connection.unit_converter
When working in a user task environment, use the services variable:
unit_converter = services.unit_converter
Examples#
Before writing back some data to Kappa-Automate, use the kappa_sdk.UnitConverter.convert_to_internal()
method to convert your data to SI units:
value_in_si_unit = unit_converter.convert_to_internal(ka.UnitEnum.pressure_psia, value)
Conversely, when reading data from Kappa-Automate, you may want to convert it to a specific unit using the kappa_sdk.UnitConverter.convert_from_internal()
method:
value_in_specific_unit = unit_converter.convert_from_internal(ka.UnitEnum.pressure_psia, value)
Note
Most of the time, when you are writing or reading data, there is a unit
parameter that lets you specify a kappa_sdk.UnitEnum
object and performs the conversion for you.