Source code for ska.cdm.schemas.central_node.mccs

"""
The schemas.central_node module defines Marshmallow schemas that map TMC
Central Node message classes to/from a JSON representation.
"""
from marshmallow import Schema, fields, post_load

from ska.cdm.messages.central_node.mccs import MCCSAllocate
from ska.cdm.schemas import CODEC

__all__ = ["MCCSAllocateSchema"]


[docs]@CODEC.register_mapping(MCCSAllocate) class MCCSAllocateSchema(Schema): """ Marshmallow schema for the MCCSAllocate class. """ station_ids = fields.List(fields.Tuple((fields.Integer, fields.Integer)), data_key="station_ids", required=True) channel_blocks = fields.List(fields.Integer, data_key="channel_blocks", required=True) subarray_beam_ids = fields.List( fields.Integer, data_key="subarray_beam_ids", required=True )
[docs] @post_load def create_mccs_allocate(self, data, **_): """ Convert parsed JSON back into a MCCSAllocate object. :param data: Marshmallow-provided dict containing parsed JSON values :param _: kwargs passed by Marshmallow :return: MCCSAllocate object populated from data """ station_ids = data["station_ids"] channel_blocks = data["channel_blocks"] subarray_beam_ids = data["subarray_beam_ids"] return MCCSAllocate(station_ids, channel_blocks, subarray_beam_ids)