Source code for ddf.message

from abc import ABC
from dataclasses import dataclass
from enum import Enum
from uuid import UUID

import numpy as np

from .ant_link.loss_channel import LossChannel
from .ddf import NodeId, ObjectId
from .information import ExchangeVector


[docs] class ControlCommand(Enum): FZB = 0 UUI = 1 GetNodeInfo = 2 GetNodeContext = 3
[docs] @dataclass class Message(ABC): sender: NodeId recipient: NodeId
[docs] @dataclass class InfoMessage(Message): object_id: ObjectId state: ExchangeVector message_counter: int
[docs] @dataclass class GradientMessage(Message): object_id: ObjectId gradient: np.ndarray loss_channel: LossChannel
[docs] @dataclass class ControlMessage(Message): request_id: UUID command: ControlCommand
[docs] @dataclass class NodeInfoMessage(Message): available: list[str] exchange: list[str] alias: str req_id: UUID
[docs] @dataclass class NodeContextMessage(Message): # context from manufacturer for example: about the machine fixed_context: str # context set by the user user_context: str req_id: UUID
[docs] @dataclass class ProbeResponseMessage(Message): reference: ObjectId gradient: np.ndarray loss_channel: LossChannel
[docs] @dataclass class AddNeighborMessage(Message): neighbor: NodeId req_id: UUID