camacq.plugins.sample package

Handle sample state.

class camacq.plugins.sample.Image(path: str, values: dict[str, Any] | None = None, **kwargs: Any)[source]

Bases: ImageContainer

An image with path and position info.

property change_event: type[SampleImageSetEvent]

Event: Return an event class to fire on container change.

property images: dict[str, Image]

dict: Return a dict with all images for the container.

property name: str

str: Return an identifying name for the container.

property path: str

str: Return the path of the image.

property values: dict[str, Any]

dict: Return a dict with the values set for the container.

class camacq.plugins.sample.ImageContainer[source]

Bases: ABC

A container for images.

abstract property change_event: type[SampleEvent]

Event: Return an event class to fire on container change.

abstract property images: dict[str, Image]

dict: Return a dict with all images for the container.

abstract property name: str

str: Return an identifying name for the container.

abstract property values: dict[str, Any]

dict: Return a dict with the values set for the container.

class camacq.plugins.sample.Sample[source]

Bases: ImageContainer, ABC

Representation of the state of the sample.

center: Center | None = None
data: dict[str, ImageContainer] | None = None
get_sample(name: str, **kwargs: Any) ImageContainer | None[source]

Get an image container of the sample.

Parameters:
  • name (str) – The name of the container type.

  • **kwargs – Arbitrary keyword arguments. These will be used to create the id string of the container.

Returns:

Return the found ImageContainer instance.

Return type:

ImageContainer instance

abstract property image_event_type: str

str: Return the image event type to listen to for the sample.

abstract property name: str

str: Return the name of the sample.

abstractmethod async on_image(center: Center, event: Event) None[source]

Handle image event for this sample.

async set_sample(name: str, values: dict[str, Any] | None = None, **kwargs: Any) ImageContainer[source]

Set an image container of the sample.

Parameters:
  • name (str) – The name of the container type.

  • values (dict) – The optional values to set on the container.

  • **kwargs – Arbitrary keyword arguments. These will be used to create the id string of the container.

Returns:

Return the ImageContainer instance that was updated.

Return type:

ImageContainer instance

abstract property set_sample_schema: Schema | Any

Return the validation schema of the set_sample method.

class camacq.plugins.sample.SampleEvent(data: dict[str, Any] | None = None)[source]

Bases: Event

An event produced by a sample change event.

property container: ImageContainer | None

ImageContainer instance: Return the container instance of the event.

property container_name: str

str: Return the container name of the event.

event_type: ClassVar[str] = 'sample_event'
property images: dict[str, Image]

dict: Return the container images of the event.

property values: dict[str, Any]

dict: Return the container values of the event.

class camacq.plugins.sample.SampleImageSetEvent(data: dict[str, Any] | None = None)[source]

Bases: SampleEvent

An event produced by a new image on the sample.

event_type: ClassVar[str] = 'sample_image_set_event'
class camacq.plugins.sample.Samples[source]

Bases: dotdict

Hold all samples.

camacq.plugins.sample.get_matched_samples(sample: Sample, name: str, attrs: dict[str, Any] | None = None, values: dict[str, Any] | None = None) list[ImageContainer][source]

Return the sample items that match.

camacq.plugins.sample.register_sample(center: Center, sample: Sample) None[source]

Register sample.

async camacq.plugins.sample.setup_module(center: Center, config: dict[str, Any]) None[source]

Set up sample module.

Parameters:
  • center (Center instance) – The Center instance.

  • config (dict) – The config dict.