UniSet 2.45.1
Пространство имен st2js.mapping

Классы

class  SensorEntry
class  MappingOptions
class  FileMapping
class  SensorMapping

Функции

IECType _parse_iec_type (str type_name, str st_name, str section)
float _parse_scale (scale_value, str st_name, str section)
list[SensorEntry_parse_entries (dict|None raw_section, str section_name)
MappingOptions _parse_options (dict|None raw_options)
list[str] _parse_loads (raw_value, str section_name)
list[str] _dedup_append (list[str] base, list[str] extra)
SensorMapping load_mapping_from_string (str content)
SensorMapping load_mapping (str path)

Подробное описание

YAML sensor mapping loader for the st2js converter.

Loads and validates YAML mapping configuration that maps ST variable names
to UniSet sensor names, with optional IEC type and scale factor information.

Функции

◆ _dedup_append()

list[str] st2js.mapping._dedup_append ( list[str] base,
list[str] extra )
protected
Append items from `extra` to `base`, skipping items already present.

Membership is tested by exact string equality (no path normalization);
`"sim.js"` and `"./sim.js"` are treated as distinct. First occurrence
wins; ordering of the original sequences is preserved.

◆ _parse_entries()

list[SensorEntry] st2js.mapping._parse_entries ( dict | None raw_section,
str section_name )
protected
Parse a section (inputs or outputs) into a list of SensorEntry.

Args:
    raw_section: The raw dict from YAML for this section.
    section_name: 'inputs' or 'outputs' (for error messages).

Returns:
    List of SensorEntry objects.

Raises:
    MappingError: If any entry is missing required fields or has invalid values.

◆ _parse_iec_type()

IECType st2js.mapping._parse_iec_type ( str type_name,
str st_name,
str section )
protected
Parse and validate an IEC type name string.

Args:
    type_name: The type name string from YAML.
    st_name: The ST variable name (for error messages).
    section: 'inputs' or 'outputs' (for error messages).

Returns:
    The corresponding IECType enum value.

Raises:
    MappingError: If the type name is not a valid IEC type.

◆ _parse_loads()

list[str] st2js.mapping._parse_loads ( raw_value,
str section_name )
protected
Parse a load_head / load_on_start list from YAML.

Args:
    raw_value: The raw value for the section (list or None).
    section_name: Section key name (for error messages).

Returns:
    List of validated path strings.

Raises:
    MappingError: If the value is not a list, or any element is not
        a non-empty string.

◆ _parse_options()

MappingOptions st2js.mapping._parse_options ( dict | None raw_options)
protected
Parse the options section into MappingOptions.

Args:
    raw_options: The raw dict from YAML for the options section.

Returns:
    MappingOptions with values from YAML or defaults.

◆ _parse_scale()

float st2js.mapping._parse_scale ( scale_value,
str st_name,
str section )
protected
Parse and validate a scale factor value.

Args:
    scale_value: The raw scale value from YAML.
    st_name: The ST variable name (for error messages).
    section: 'inputs' or 'outputs' (for error messages).

Returns:
    The validated scale factor as a float.

Raises:
    MappingError: If the scale is not a positive number.

◆ load_mapping()

SensorMapping st2js.mapping.load_mapping ( str path)
Load and validate a sensor mapping from a YAML file.

Args:
    path: Path to the YAML mapping file.

Returns:
    A validated SensorMapping object.

Raises:
    MappingError: If the file cannot be read or the YAML is invalid.

◆ load_mapping_from_string()

SensorMapping st2js.mapping.load_mapping_from_string ( str content)
Load and validate a sensor mapping from a YAML string.

Args:
    content: The YAML content as a string.

Returns:
    A validated SensorMapping object.

Raises:
    MappingError: If the YAML is invalid or fails validation.