From b1413ca66c7949cc108982df1c09a7876bd76e83 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Mon, 20 Oct 2025 17:07:10 +0100 Subject: [PATCH] Camera metadata with basic data --- .../things/camera/__init__.py | 7 ++++++- .../things/camera/picamera.py | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/openflexure_microscope_server/things/camera/__init__.py b/src/openflexure_microscope_server/things/camera/__init__.py index a48dc2c3..82aa6f28 100644 --- a/src/openflexure_microscope_server/things/camera/__init__.py +++ b/src/openflexure_microscope_server/things/camera/__init__.py @@ -7,7 +7,7 @@ See repository root for licensing information. """ from __future__ import annotations -from typing import Literal, Optional, Tuple, Any +from typing import Literal, Optional, Tuple, Any, Mapping from types import TracebackType import json import io @@ -650,6 +650,11 @@ class BaseCamera(lt.Thing): # Manually save settings as the setter is not called. self.save_settings() + @property + def thing_state(self) -> Mapping[str, Any]: + """Summary metadata describing the current state of the Thing.""" + return {"capture_time": time.time()} + CameraDependency = lt.deps.direct_thing_client_dependency(BaseCamera, "/camera/") RawCameraDependency = lt.deps.raw_thing_dependency(BaseCamera) diff --git a/src/openflexure_microscope_server/things/camera/picamera.py b/src/openflexure_microscope_server/things/camera/picamera.py index 92902718..a6b851c9 100644 --- a/src/openflexure_microscope_server/things/camera/picamera.py +++ b/src/openflexure_microscope_server/things/camera/picamera.py @@ -1093,3 +1093,9 @@ class StreamingPiCamera2(BaseCamera): to be static (except "reset") """ return tf_utils.lst_is_static(self.tuning) + + def get_thing_state(self) -> Mapping[str, Any]: + """Update generic camera metadata with Picamera-specific data.""" + state = super().get_thing_state() + state["camera_board"] = self._camera_board + return state