Module enrgdaq.daq.template.message

DAQ Job message template generator.

Uses msgspec's built-in JSON schema generation for DAQ job messages.

Functions

def get_message_templates() ‑> dict[str, dict]
Expand source code
def get_message_templates() -> dict[str, dict]:
    """
    Generate DAQ job message templates using msgspec's JSON schema generation.

    Returns a dictionary of JSON schemas for each message type that can be
    sent to DAQ jobs via CNC.
    """
    # List of message types that can be sent to DAQ jobs
    # These are the types that the send_message handler can decode and route
    templates: dict[str, dict] = {}

    for message_cls in all_subclasses(DAQJobMessage):
        message_name = message_cls.__name__

        # Generate JSON schema using msgspec
        try:
            schema = msgspec.json.schema(message_cls)
        except TypeError:
            # Skip messages with unsupported types
            continue

        # Add our custom metadata
        schema["type_key"] = message_name
        schema["label"] = _get_message_label(message_name)
        schema["description"] = _parse_class_docstring(message_cls)

        templates[message_name] = schema

    return templates

Generate DAQ job message templates using msgspec's JSON schema generation.

Returns a dictionary of JSON schemas for each message type that can be sent to DAQ jobs via CNC.