44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
"""Diagnostics helpers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from .state import get_gauge_state
|
|
from .types import Tag
|
|
|
|
|
|
def get_gauge_debug_state(tag: Tag) -> dict[str, Any]:
|
|
"""Return renderer and state diagnostics for an existing gauge."""
|
|
state = get_gauge_state(tag)
|
|
debug = {
|
|
"tag": state.tag,
|
|
"gauge_type": state.gauge_type,
|
|
"target_value": state.target_value,
|
|
"clamped_value": state.clamped_value,
|
|
"displayed_value": state.displayed_value,
|
|
"invalid_value": state.invalid_value,
|
|
"measured_size": (state.measured_width, state.measured_height),
|
|
"last_nonzero_size": (state.last_nonzero_width, state.last_nonzero_height),
|
|
"dirty": state.dirty,
|
|
"dirty_names": [flag.name for flag in type(state.dirty) if flag in state.dirty],
|
|
"value_revision": state.value_revision,
|
|
"config_revision": state.config_revision,
|
|
"animation_active": state.animation_state.active,
|
|
"smoothing_active": state.smoothing_state.active,
|
|
"animation": {
|
|
"start_value": state.animation_state.start_value,
|
|
"target_value": state.animation_state.target_value,
|
|
"started_at": state.animation_state.started_at,
|
|
"duration": state.animation_state.duration,
|
|
"active": state.animation_state.active,
|
|
},
|
|
"smoothing": {
|
|
"value": state.smoothing_state.value,
|
|
"active": state.smoothing_state.active,
|
|
},
|
|
}
|
|
if state.renderer is not None:
|
|
debug["renderer"] = state.renderer.debug_state()
|
|
return debug
|