Skip to content

Commit

Permalink
added epics limits to DataKey
Browse files Browse the repository at this point in the history
Also made `Dtype` accessible from `event_model`
  • Loading branch information
evalott100 committed Sep 23, 2024
1 parent 1e3f44a commit 1dcac84
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import numpy
from typing_extensions import Literal

from .documents import Dtype
from .documents.datum import Datum
from .documents.datum_page import DatumPage
from .documents.event import Event
Expand Down Expand Up @@ -61,6 +62,7 @@


__all__ = [
"Dtype",
"DocumentNames",
"schemas",
"schema_validators",
Expand Down
4 changes: 3 additions & 1 deletion event_model/documents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from event_model.documents.datum import Datum
from event_model.documents.datum_page import DatumPage
from event_model.documents.event import Event
from event_model.documents.event_descriptor import EventDescriptor
from event_model.documents.event_descriptor import Dtype, EventDescriptor, Limits
from event_model.documents.event_page import EventPage
from event_model.documents.resource import Resource
from event_model.documents.run_start import RunStart
Expand Down Expand Up @@ -42,9 +42,11 @@
__all__ = [
"Datum",
"DatumPage",
"Dtype",
"Event",
"EventDescriptor",
"EventPage",
"Limits",
"Resource",
"RunStart",
"RunStop",
Expand Down
18 changes: 18 additions & 0 deletions event_model/documents/event_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,27 @@
Dtype = Literal["string", "number", "array", "boolean", "integer"]


class LimitsRange(TypedDict):
low: float
high: float


class Limits(TypedDict):
"""
Epics limits:
see 3.4.1 https://epics.anl.gov/base/R3-14/12-docs/AppDevGuide/node4.html
"""

control: NotRequired[Annotated[LimitsRange, Field(description="Control limits.")]]
display: NotRequired[Annotated[LimitsRange, Field(description="Display limits.")]]
warning: NotRequired[Annotated[LimitsRange, Field(description="Warning limits.")]]
alarm: NotRequired[Annotated[LimitsRange, Field(description="Alarm limits.")]]


class DataKey(TypedDict):
"""Describes the objects in the data property of Event documents"""

limits: NotRequired[Annotated[Limits, Field(description="Epics limits.")]]
dims: NotRequired[
Annotated[
List[str],
Expand Down
45 changes: 45 additions & 0 deletions event_model/schemas/event_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"type": "string",
"pattern": "^[A-Z]+:?"
},
"limits": {
"description": "Epics limits.",
"$ref": "#/$defs/Limits"
},
"object_name": {
"title": "Object Name",
"description": "The name of the object this key was pulled from.",
Expand Down Expand Up @@ -93,6 +97,47 @@
"source"
]
},
"Limits": {
"title": "Limits",
"description": "Epics limits - see 3.4.1 https://epics.anl.gov/base/R3-14/12-docs/AppDevGuide/node4.html",
"type": "object",
"properties": {
"alarm": {
"description": "Alarm limits.",
"$ref": "#/$defs/LimitsRange"
},
"control": {
"description": "Control limits.",
"$ref": "#/$defs/LimitsRange"
},
"display": {
"description": "Display limits.",
"$ref": "#/$defs/LimitsRange"
},
"warning": {
"description": "Warning limits.",
"$ref": "#/$defs/LimitsRange"
}
}
},
"LimitsRange": {
"title": "LimitsRange",
"type": "object",
"properties": {
"high": {
"title": "High",
"type": "number"
},
"low": {
"title": "Low",
"type": "number"
}
},
"required": [
"high",
"low"
]
},
"PerObjectHint": {
"title": "PerObjectHint",
"description": "The 'interesting' data keys for this device.",
Expand Down

0 comments on commit 1dcac84

Please sign in to comment.