from mxcubecore.model.nstate import NStateOption
from pydantic import (
BaseModel,
ConfigDict,
Field,
)
[docs]class HOModel(BaseModel):
name: str = Field("", description="name of the hardware object")
state: str = Field("", description="hardware object state")
msg: str = Field("", description="additional message to display")
type: str = Field("", description="type of data the object contains")
available: bool = Field(True, description="True if the object avilable/enabled")
readonly: bool = Field(
True,
description="True if the object can only be read (not manipluated)",
)
attributes: dict = Field({}, description="Data attributes")
commands: dict | list = Field({}, description="Available methods")
model_config = ConfigDict(extra="forbid")
[docs]class HOActuatorModel(HOModel):
value: float = Field(0, description="Value of actuator (position)")
limits: tuple[float | None, float | None] = Field(
(-1, -1), description="Limits (min max)"
)
[docs]class NStateModel(HOActuatorModel):
value: str = Field("", description="Value of nstate object")
[docs]class HOMachineInfoModel(HOModel):
limits: tuple[float | None, float | None] = Field(
(-1, -1), description="Limits (min max)"
)
value: dict = Field(description="Value of machine info")
[docs]class HOActuatorValueChangeModel(BaseModel):
name: str = Field("", description="Name of the hardware object to change")
value: float | str = Field("", description="New value of actuator (position)")
[docs]class HOBeamValueModel(BaseModel):
apertureList: list[str | int | NStateOption] = Field(
[0],
description="List of available beam sizes",
)
currentAperture: str = Field(0, description="Current beam size label")
position: tuple[float, float] = Field((0, 0), description="Beam position on OAV")
shape: str = Field("ellipse", description="Beam shape")
size_x: float = Field(
0.01,
description="Current beam x size (width) in millimieters",
)
size_y: float = Field(
0.01,
description="Current beam y size (height) in millimieters",
)
model_config = ConfigDict(extra="forbid")
[docs]class HOBeamModel(HOActuatorModel):
value: HOBeamValueModel
[docs]class FloatValueModel(BaseModel):
value: float = Field(0, description="Value of actuator (position)")
[docs]class StrValueModel(BaseModel):
value: str = Field("", description="Value of actuator (position)")
[docs]class FrontEndStackTraceModel(BaseModel):
stack: str
state: dict
[docs]class ListOfShapesModel(BaseModel):
shapes: list[dict] = Field([], description="List of dictionaries")
[docs]class Base64StrModel(BaseModel):
value: str = Field("", description="Base64 encoded string")