Skip to content
Snippets Groups Projects
FACILITY.TARLA.py 3.88 KiB
Newer Older
Patrick Nonn's avatar
Patrick Nonn committed
import socket


class ChannelAttr:
    """Container class to hold attributes of a single channel"""
    def __init__(self, ch_number: int, ch_name: str=None, **kwargs):
        """
        :param ch_number: Channel number as assigned by the firmware, usually starting with 0.
        :param ch_name: How the channel should be referenced in the PV. Defaults to 'CH{ch_number}', if omitted.
        :param kwargs: List of key=value pairs. The keys will be accessible as object members, holding the value.
        """
        self.number = ch_number
        if ch_name is None:
            self.name = f'CH{ch_number}'
        else:
            self.name = ch_name
        for key, val in kwargs.items():
            setattr(self, key, val)


Patrick Nonn's avatar
Patrick Nonn committed
if ACCELERATOR == 'TARLA' :

Patrick Nonn's avatar
Patrick Nonn committed
    FIRMWARE_VER_CONTROLLER = FIRMWARE_VER

    singleCavityStation().useLOGM()

    gradientUnit = 'kV' if STATION in ['B1', 'B2'] else 'MV'
    powerUnit = 'W' if STATION in ['B1', 'B2'] else 'kW'
    timeUnit = 'us'
    config_by_station = {'B1': {'slot': 11, 'fwType': 'nc260'},
                         'B2': {'slot': 10, 'fwType': 'nc1300'},
                         'SC1_1': {'slot': 9, 'fwType': 'sc1300'},
                         'SC1_2': {'slot': 8, 'fwType': 'sc1300'},
                         'SC2_1': {'slot': 7, 'fwType': 'sc1300'},
                         'SC2_2': {'slot': 6, 'fwType': 'sc1300'}}
Patrick Nonn's avatar
Patrick Nonn committed

    channels = [ChannelAttr(0, 'FWD', unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(1, 'RFL', unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(2, 'PRB', unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(3, unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(4, unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(5, unit_ampl=gradientUnit, unit_power=powerUnit),
                ChannelAttr(6, 'REF', unit_ampl='V', unit_power='mW'),
                ChannelAttr(7, 'VMM', unit_ampl='V', unit_power='mW')]
    
    channelNames = [ch.name for ch in channels]
    #channels_no = range(len(channels))
    ## A dict 'channelNames', associating channel numbers with names, is required for the start script
    #channelNames = dict(zip(channels_no, channels))
    ## Dicts to change the units of specific channels (e.g. VMM, REF)
    #channelAmpUnit = dict(zip(channels_no, [gradientUnit] * (channels_no - 2) + ['mV', 'mV']))
    #channelPowerUnit = dict(zip(channels_no, [powerUnit] * (channels_no - 2) + ['mW', 'mW']))
Patrick Nonn's avatar
Patrick Nonn committed

    if STATION == 'B1':
        rfFrequency = 260
        clockFrequency = 78.0
        IQdetectionLength = 12
        nSinCosTableSize = 3
        phaseStep = 120
        sinSign = -1
        boardDS8VM1(slot=config_by_station[STATION]['slot'],
                    firmwareType=config_by_station[STATION]['fwType'],
                    firmwareProject='llrf_scav_sis8300l_tarla',
                    channelNames=channelNames,
                    pllConfig='260MHz_to_78MHz_clock')
    else:
        rfFrequency = 1300
        clockFrequency = 65.0
        IQdetectionLength = 36
        nSinCosTableSize = 6
        phaseStep = 60
        sinSign = -1
        boardDWC8VM1(slot=config_by_station[STATION]['slot'],
                     firmwareType=config_by_station[STATION]['fwType'],
                     firmwareProject='llrf_scav_sis8300l_tarla',
                     channelNames=channelNames)


    SYSTEM_UID = 'doocsadm'
    SYSTEM_GID = 'doocsadm'

    provideLimiterEnable = 1
Patrick Nonn's avatar
Patrick Nonn committed
    enablePerBunchSetpoints = False
Patrick Nonn's avatar
Patrick Nonn committed
    nMaxFlattops = 1
    ftFromTimeserver = 0
    enableStatistics = 1
    enablePhaseSetter = 0
    MAXIMUM_TRIGGER_INTERVAL = 1100
    rawAdcDecimation = 0

    enableAutomation = 1
    enableMicroDAQ = 0
    enableMicroDAQdetails = 0
    enableDynamicOVC = 0
Patrick Nonn's avatar
Patrick Nonn committed

    pulseLength = 16384

Patrick Nonn's avatar
Patrick Nonn committed
    FACILITY = 'TARLA'
    TIMING_LOCATION = f'{FACILITY}.RF/TIMER/{HOSTNAME.upper()}.0'