Skip to content

Commit cd9cb33

Browse files
authored
Neues COM Messwert (#1042)
addresses #994 Neues COM Messwert ergänzt, wie im Workshop vom 11.11.2025 beschlossen
1 parent 7b47c83 commit cd9cb33

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

src/bo4e/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"Messart",
150150
"Messgroesse",
151151
"Messpreistyp",
152+
"Messwert",
152153
"Messwerterfassung",
153154
"Messwertstatus",
154155
"Messwertstatuszusatz",
@@ -277,6 +278,7 @@
277278
from .com.lastprofil import Lastprofil
278279
from .com.marktgebietinfo import MarktgebietInfo
279280
from .com.menge import Menge
281+
from .com.messwert import Messwert
280282
from .com.positionsaufabschlag import PositionsAufAbschlag
281283
from .com.preis import Preis
282284
from .com.preisgarantie import Preisgarantie

src/bo4e/com/messwert.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Contains Messwert class
3+
"""
4+
5+
from typing import TYPE_CHECKING, Annotated, Literal, Optional
6+
7+
import pydantic
8+
from pydantic import Field
9+
10+
from ..enum.comtyp import ComTyp
11+
from ..utils import postprocess_docstring
12+
from .com import COM
13+
14+
if TYPE_CHECKING:
15+
from ..com.menge import Menge
16+
from ..enum.messwertstatus import Messwertstatus
17+
from ..enum.messwertstatuszusatz import Messwertstatuszusatz
18+
19+
20+
@postprocess_docstring
21+
class Messwert(COM):
22+
"""
23+
Abbildung eines Messwertes mit Stati, Zeitpunkt und Wert.
24+
25+
.. raw:: html
26+
27+
<object data="../_static/images/bo4e/com/Messwert.svg" type="image/svg+xml"></object>
28+
29+
.. HINT::
30+
`Messwert JSON Schema <https://json-schema.app/view/%23?url=https://raw.githubusercontent.com/BO4E/BO4E-Schemas/{__gh_version__}/src/bo4e_schemas/com/Messwert.json>`_
31+
32+
"""
33+
34+
typ: Annotated[Literal[ComTyp.MESSWERT], Field(alias="_typ")] = ComTyp.MESSWERT
35+
36+
messwertstatus: Optional["Messwertstatus"] = None
37+
"""Gibt den Status des Messwerts an."""
38+
messwertstatuszusatz: Optional["Messwertstatuszusatz"] = None
39+
"""Gibt den Status Zusatz des Messwerts an."""
40+
zeitpunkt: Optional[pydantic.AwareDatetime] = None
41+
"""Gibt den Zeitpunkt des Messwerts an."""
42+
wert: Optional["Menge"] = None
43+
"""Gibt die gemessene Menge an."""

src/bo4e/enum/comtyp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ComTyp(StrEnum):
3838
LASTPROFIL = "LASTPROFIL"
3939
MARKTGEBIETINFO = "MARKTGEBIETINFO"
4040
MENGE = "MENGE"
41+
MESSWERT = "MESSWERT"
4142
POSITIONSAUFABSCHLAG = "POSITIONSAUFABSCHLAG"
4243
PREIS = "PREIS"
4344
PREISGARANTIE = "PREISGARANTIE"

tests/test_messwert.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from datetime import datetime, timezone
2+
3+
import pytest
4+
5+
from bo4e import Menge, Messwert, Messwertstatus, Messwertstatuszusatz
6+
from tests.serialization_helper import assert_serialization_roundtrip
7+
8+
9+
class TestMesswert:
10+
@pytest.mark.parametrize(
11+
"messwert",
12+
[
13+
pytest.param(
14+
Messwert(
15+
messwertstatus=Messwertstatus.ABGELESEN,
16+
messwertstatuszusatz=Messwertstatuszusatz.Z84_LEERSTAND,
17+
zeitpunkt=datetime(2022, 2, 1, 0, 0, 0, tzinfo=timezone.utc),
18+
wert=Menge(),
19+
),
20+
id="all attributes at first level",
21+
),
22+
],
23+
)
24+
def test_serialization_roundtrip(self, messwert: Messwert) -> None:
25+
"""
26+
Test de-/serialisation roundtrip.
27+
"""
28+
assert_serialization_roundtrip(messwert)

0 commit comments

Comments
 (0)