import socket

if ACCELERATOR == 'TARLA' :

    FIRMWARE_VER = '1.5.2-0-g48a8dc81'
    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': 10, 'fwType': 'nc260'},
                         'B2': {'slot': 9, 'fwType': 'nc1300'},
                         'SC1_1': {'slot': 8, 'fwType': 'sc1300'},
                         'SC1_2': {'slot': 7, 'fwType': 'sc1300'},
                         'SC2_1': {'slot': 6, 'fwType': 'sc1300'},
                         'SC2_2': {'slot': 5, 'fwType': 'sc1300'}}

    channels = ['FWD', 'RFL', 'PRB', 'CH3', 'CH4', 'CH5', 'REF', 'VMM']
    # A dict 'channelNames', associating channel numbers with names, is required for the start script
    channelNames = dict(zip(range(len(channels)), channels))

    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
    nMaxFlattops = 1
    ftFromTimeserver = 0
    enableStatistics = 1
    enablePhaseSetter = 0
    MAXIMUM_TRIGGER_INTERVAL = 1100
    rawAdcDecimation = 0

    enableAutomation = 1
    enableMicroDAQ = 1

    pulseLength = 16384

    FACILITY = 'TEST.DOOCS'
    TIMING_LOCATION = FACILITY + '/X2TIMER/' + socket.getfqdn().upper() + '.0'