# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: blickfeld/percept_processing/data/data_type.proto, blickfeld/percept_processing/data/health.proto, blickfeld/percept_processing/data/state.proto, blickfeld/percept_processing/data/states.proto, blickfeld/percept_processing/data/volume_map.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import (
    Dict,
    List,
)

import blickfeld_qb2.betterproto as betterproto
import blickfeld_qb2.betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
import numpy as np

from ...base import (
    data as __base_data__,
    geometry as __base_geometry__,
)
from ...percept_pipeline import data as __percept_pipeline_data__


class DataType(betterproto.Enum):
    """The type of data that the stream contains"""

    DATA_TYPE_UNSPECIFIED = 0
    """The zero value should not be used"""

    DATA_TYPE_HEALTH = 1
    """
    Health data type: this contains information about the health of the
    pipeline and of the module
    """

    DATA_TYPE_POINT_CLOUD = 2
    """Point cloud data type: a complete point cloud message is streamed"""

    DATA_TYPE_STATES = 5
    """
    States data type: a map of states generated by the system as configured in
    the pipeline
    """

    DATA_TYPE_VOLUME_MAP = 6
    """
    Volume map data type: a volume map generated by one volume zone configured
    in the pipeline
    """


@dataclass(eq=False, repr=False)
class State(betterproto.Message):
    """
    A state transmits high-level information about the scene or setup. The
    information it contains depends on the configuration. States will get
    calculated on every frame of measurement.
    """

    generator_name: str = betterproto.string_field(8)
    """The name of the entity generating this state"""

    security: "StateSecurity" = betterproto.message_field(5, group="state_type")
    """The security state contains intrusion information of a zone"""

    volume: "StateVolume" = betterproto.message_field(7, group="state_type")
    """Current volume measured in the selected zone"""


@dataclass(eq=False, repr=False)
class StateSecurity(betterproto.Message):
    """A message containing an alarm state of a zone."""

    alarm: bool = betterproto.bool_field(1)
    """If there is an alarm or not in the zone"""

    num_detected_points: int = betterproto.uint32_field(2)
    """The current number of lidar points detected in the zone"""


@dataclass(eq=False, repr=False)
class StateVolume(betterproto.Message):
    """
    A message containing the volume state of a zone. This is based on one
    volume zone.
    """

    volume: float = betterproto.float_field(1)
    """The current numerical volume of the zone."""

    coverage: float = betterproto.float_field(5)
    """The current zone volume surface coverage"""


@dataclass(eq=False, repr=False)
class States(betterproto.Message):
    """
    A message that contains a map of states. A state is an information
    generated by the system based on the select zone type or device. For
    example, a state can contain information about the volume or the intrusion
    in the zone.
    """

    timestamp: int = betterproto.uint64_field(1)
    """The timestamp of the measurement(s) used to compute the states."""

    states: Dict[str, "State"] = betterproto.map_field(
        2, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
    )
    """Map of states where the key is the generator UUID of the state."""


@dataclass(eq=False, repr=False)
class VolumeMap(betterproto.Message):
    """A message containing the volume map of one volume zone."""

    timestamp: int = betterproto.uint64_field(1)
    """Timestamp of the lidar frame in which the volume map was calculated"""

    generator_uuid: str = betterproto.string_field(2)
    """The uuid of the entity generating this state"""

    generator_name: str = betterproto.string_field(3)
    """The name of the entity generating this state"""

    shape: "__base_geometry__.Shape" = betterproto.message_field(4)
    """
    The shape of the volume map, defining the pose and the dimension of the
    volume map in world frame. The shape is similar to the shape of the input
    zone with the following difference: - shape.pose.position:
    (x=zone.pose.position.x, y=zone.pose.position.y, z=0) -
    shape.pose.rotation: (roll=0, pitch=0, yaw=zone.pose.rotation.yaw) -
    shape.box.dimension: (x=zone.box.dimension.x, y=zone.box.dimension.y,z=0)
    """

    tiles: "VolumeMapTiles" = betterproto.message_field(5)
    """
    Volume map 'tiles' as defined in Tiles, providing information for each tile
    in the volume map.
    """

    tile_size: float = betterproto.float_field(6)
    """
    The tile size of the volume map (dimension of one tile in x and y
    direction)
    """

    volume: float = betterproto.float_field(7)
    """The current volume of the zone"""


@dataclass(eq=False, repr=False)
class VolumeMapTiles(betterproto.Message):
    """Tiles of the volume map"""

    length: int = betterproto.uint32_field(1)
    """Number of tiles"""

    index: np.ndarray = betterproto.bytes_field(2, numpy_dtype="(2,)<i2")
    """
    Volume Map Tile Index X (Int16) and Y (Int16) (can be negative and
    positive) The indices of Volume Tiles are expressed w.r.t the Volume Map
    coordinate system. The tile with index (0,0) will contain the points from
    [0, tile_size), [0, tile_size). That means that (0,0,0) of the Volume Map
    frame does not coincide with the center of the tile with index (0,0) but
    with the crossing of the 4 tiles [(0,0), (0, -1,), (-1,-1), (-1,0)]. Type:
    (Int16, Int16)
    """

    height: np.ndarray = betterproto.bytes_field(3, numpy_dtype="<f4")
    """Height per tile, ordered ascending Type: Float32"""

    std_deviation: np.ndarray = betterproto.bytes_field(4, numpy_dtype="<f4")
    """Standard Deviation per tile Type: Float32"""

    number_points: np.ndarray = betterproto.bytes_field(5, numpy_dtype="<u2")
    """Number Points per tile Type: UInt16"""


@dataclass(eq=False, repr=False)
class Health(betterproto.Message):
    """
    A health message that contains information about the pipeline status and
    the module itself.
    """

    state: "__base_data__.HealthState" = betterproto.enum_field(1)
    """High-level state of module."""

    state_reason: str = betterproto.string_field(2)
    """Reason for the given state. It is not set if state is STATE_OK."""

    pipeline_state: "__percept_pipeline_data__.State" = betterproto.enum_field(4)
    """
    Current state of the pipeline. It indicates if the pipeline is stable,
    unstable or broken, based on the frequency of the data that is processed
    and published.
    """

    clients: List["HealthClient"] = betterproto.message_field(5)
    """Health information of all connected clients"""


@dataclass(eq=False, repr=False)
class HealthClient(betterproto.Message):
    """Health information of connected clients"""

    uuid: str = betterproto.string_field(1)
    """Identifier of the client"""

    peer_uri: str = betterproto.string_field(2)
    """The client peer uri"""

    connection_timestamp: int = betterproto.uint64_field(3)
    """The timestamp of the moment the client connected to processing"""

    lost_frames: int = betterproto.uint64_field(4)
    """The number of total lost frames since the start of the stream"""

    point_cloud: "HealthClientPointCloud" = betterproto.message_field(
        5, group="stream_type"
    )
    """The client receives point cloud stream data"""

    states: "HealthClientStates" = betterproto.message_field(6, group="stream_type")
    """The client receives states stream data"""

    volume_map: "HealthClientVolumeMap" = betterproto.message_field(
        7, group="stream_type"
    )
    """The client receives volume map stream data"""


@dataclass(eq=False, repr=False)
class HealthClientPointCloud(betterproto.Message):
    """Point Cloud specific information"""

    point_cloud_type: "__percept_pipeline_data__.PointCloudType" = (
        betterproto.enum_field(1)
    )
    """The point cloud type the client is receiving"""


@dataclass(eq=False, repr=False)
class HealthClientStates(betterproto.Message):
    """States specific information"""

    pass


@dataclass(eq=False, repr=False)
class HealthClientVolumeMap(betterproto.Message):
    """Volume Map specific information"""

    pass
