sunflare.model
#
- class sunflare.model.ModelProtocol(name, model_info)#
Minimal required protocol for a recognizable device in Redsun.
Exposes the following Bluesky protocols:
- Parameters:
name (
str
) – Name of the model. Serves as a unique identifier for the object created from it.model_info (
ModelInfoProtocol
) – Object implementingModelInfoProtocol
.
- abstract read_configuration()#
Read the model configuration.
Provides a dictionary with the current values of the model configuration.
The method can be normal or async.
- Returns:
A dictionary with the current values of the model configuration.
- Return type:
dict[
str
,Reading
]
- abstract describe_configuration()#
Describe the model configuration.
Provides a description of each field of the model configuration.
The method can be normal or async.
- Returns:
A dictionary with the description of each field of the model configuration.
- Return type:
dict[
str
,Descriptor
]
- abstract property name: str#
Model identifier.
Used to populate object_keys in
DataKey
.See the following link for more information: https://blueskyproject.io/event-model/main/explanations/event-descriptors.html
- abstract property parent: Any | None#
None
, or a reference to a parent device.Used by the RE to stop duplicate stages. In Redsun (for now) should always return
None
.
- class sunflare.model.Model(name, model_info)#
A boilerplate base class for quick model development.
Users may subclass from this model and provide their custom
ModelInfo
implementation.Example usage:
from sunflare.model import Model from sunflare.config import ModelInfo from attrs import define @define class MyModelInfo(ModelInfo): str_param: str bool_param: bool # any other parameters... class MyModel(Model[MyModelInfo]): def __init__(self, name: str, model_info: MyModelInfo) -> None: super().__init__(name, model_info) # any other initialization code...
- Parameters:
name (
str
) – Name of the model. Serves as a unique identifier for the object created from it.model_info (
MI
) – Instance ofModelInfo
. subclass.
- describe_configuration(*, source='model_info')#
Provide a description of the model configuration.
Inspects the local
model_info
object and returns a descriptor dictionary compatible with the Bluesky event model.- Parameters:
source (
str
, optional) – Source of the configuration description. Default ismodel_info
.- Returns:
A dictionary with the description of each field of the model configuration.
- Return type:
dict[
str
,DataKey
]
- read_configuration(*, timestamp=0)#
Provide a description of the model configuration.
Inspects the local
model_info
object and returns a reading dictionary compatible with the Bluesky event model.- Parameters:
timestamp (
float
, optional) – Timestamp of the reading (i.e.time.time()
). Default is0
.- Returns:
A dictionary with the description of each field of the model configuration.
- Return type:
dict[
str
,Descriptor
]
- property name: str#
Model identifier.
Used to populate object_keys in
DataKey
.See the following link for more information: https://blueskyproject.io/event-model/main/explanations/event-descriptors.html
- property parent: None#
None
, or a reference to a parent device.Used by the RE to stop duplicate stages. In Redsun (for now) should always return
None
.
- sunflare.model.check_supports(obj, protocol)#
Check that an object supports a protocol
This exists so that multiple protocol checks can be run in a mypy compatible way, e.g.:
triggerable = check_supports(obj, Triggerable) triggerable.trigger() readable = check_supports(obj, Readable) readable.read()
- Parameters:
obj (T)
protocol (type[Any])
- Return type:
T
A dictionary containing the value and timestamp of a piece of scan data |
Describes the objects in the data property of Event documents |