Source code for ska_oso_scripting.functions.pdm_transforms.common

"""
The pdm_transforms module contains code to transform Project Data Model (PDM)
entities to Configuration Data Model (CDM) entities. The pdm_transforms code
is called by observing scripts to convert the PDM Scheduling Block to the
equivalent CDM configurations, which are then sent to TMC devices to control
the telescope.
"""
import logging

from ska_oso_pdm.entities.common.scan_definition import ScanDefinition
from ska_tmc_cdm.messages.subarray_node.configure.tmc import (
    TMCConfiguration as cdm_TMCConfiguration,
)

LOG = logging.getLogger(__name__)
FORMAT = "%(asctime)-15s %(message)s"

logging.basicConfig(level=logging.INFO, format=FORMAT)

# Not every function in this module should be called externally
__all__ = [
    "convert_tmcconfiguration",
]


[docs]def convert_tmcconfiguration( scan_definition: ScanDefinition, ) -> cdm_TMCConfiguration: """ Convert a PDM ScanDefinition to the equivalent TMC configuration """ if isinstance(scan_definition, ScanDefinition): return cdm_TMCConfiguration(scan_duration=scan_definition.scan_duration) raise TypeError(f"Expected PDM ScanDefinition, got {type(scan_definition)}")