ChronaxisUser manual中文
On this pageMembersPresetSpecPresetSpec.from_dictSource locations

chronaxis.PresetSpec

Import this object from chronaxis. This page covers directly public members and necessary construction/context protocols. See the Chinese implementation reference for internals. Return to the public API index. Check required parameters, defaults, returns, and exceptions before calling.

Members

PresetSpec

Freeze a preset ID, type/version, role aliases, and parameters as an independent JSON snapshot. The ID is a simple identifier. Role values reference simple aliases in the current plan, not domain attribute paths. Parameters do not retain caller-owned mutable objects. build_preset validates the actual type-specific parameters.

python
PresetSpec(id: str, preset_type: str, version: str, role_bindings: collections.abc.Mapping, parameters: collections.abc.Mapping) -> None
Name Type Required Default Purpose, choices, and effect
id str Yes No default Unique preset instance name, such as hot; generated names use this prefix and must not collide with existing nodes.
preset_type str Yes No default charge_session, fault_context, command_response, or threshold_excursion. See presets for their purposes and roles.
version str Yes No default Current template version is string "1", not number 1 or the top-level config_version.
role_bindings Mapping Yes No default Map permitted roles to defined signals, for example {"signal": "temperature"}. Omitted roles require the documented semantic lookup declarations.
parameters Mapping Yes No default Type-specific parameters, such as threshold unit/enter_threshold/exit_threshold. Obtain values from business requirements and device units; do not mix different preset types' fields.

PresetSpec.from_dict

Build an immutable public declaration from the current configuration format.

python
PresetSpec.from_dict(value)

Class method.

Name Type Required Default Purpose, choices, and effect
value dict[str, object] Yes No default Positional or keyword. Requires name, preset_type, and parameters. Omitted version is string "1"; omitted role_bindings is an empty mapping. See role requirements.

Returns PresetSpec. Raises PlanValidationError for unknown keys, missing fields, or construction-protocol errors.

python
from chronaxis import PresetSpec

# Full role and threshold semantics are checked when the plan is assembled.
spec = PresetSpec.from_dict({
    "name": "heat_alarm",
    "preset_type": "threshold_excursion",
    "version": "1",
    "role_bindings": {"signal": "temperature"},
    "parameters": {"unit": "degC", "enter_threshold": 80, "exit_threshold": 75},
})
print(spec.id, spec.preset_type)

Source locations

Chronaxis user manual · Offline edition