description = 'ICON shutters (HE, FS, Exp)'

group = 'lowlevel'

display_order = 10

devices = dict(
    #Main Shutter HE
    he_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'HE Shutter opening bit',
        readpv = 'SQ:ICON:b4io3:HEopen',
        writepv = 'SQ:ICON:b4io3:HEopen',
        lowlevel = True,
    ),
    he_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'HE Shutter closing bit',
        readpv = 'SQ:ICON:b4io3:HEclose',
        writepv = 'SQ:ICON:b4io3:HEclose',
        lowlevel = True,
    ),
    he_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter opened bit',
        readpv = 'SQ:ICON:b4io1:HEopenRBV',
        lowlevel = True,
    ),
    he_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter closed bit',
        readpv = 'SQ:ICON:b4io1:HEcloseRBV',
        lowlevel = True,
    ),
    he_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter enable bit',
        readpv = 'SQ:ICON:b4io1:HEenabledRBV',
        lowlevel = True,
    ),
    he_popen = device('nicos.devices.generic.Pulse',
        description = 'HE Shutter opening pulse',
        moveable = 'he_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    he_pclose = device('nicos.devices.generic.Pulse',
        description = 'HE Shutter closing pulse',
        moveable = 'he_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    he_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagShutter',
        description = 'HE shutter',
        do_open = 'he_popen',
        do_close = 'he_pclose',
        is_open = 'he_ropen',
        is_closed = 'he_rclose',
        is_enabled = 'he_renabled',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 60.0,
    ),

    #Fail save shutter FS
    fs_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'FS Shutter opening bit',
        readpv = 'SQ:ICON:b4io3:FSopen',
        writepv = 'SQ:ICON:b4io3:FSopen',
        lowlevel = True,
    ),
    fs_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'FS Shutter closing bit',
        readpv = 'SQ:ICON:b4io3:FSclose',
        writepv = 'SQ:ICON:b4io3:FSclose',
        lowlevel = True,
    ),
    fs_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter opened bit',
        readpv = 'SQ:ICON:b4io1:FSopenRBV',
        lowlevel = True,
    ),
    fs_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter closed bit',
        readpv = 'SQ:ICON:b4io1:FScloseRBV',
        lowlevel = True,
    ),
    fs_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter enabled bit',
        readpv = 'SQ:ICON:b4io1:FSenabledRBV',
        lowlevel = True,
    ),
    fs_popen = device('nicos.devices.generic.Pulse',
        description = 'FS Shutter opening pulse',
        moveable = 'fs_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    fs_pclose = device('nicos.devices.generic.Pulse',
        description = 'FS Shutter closing pulse',
        moveable = 'fs_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    fs_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagShutter',
        description = 'FS shutter',
        do_open = 'fs_popen',
        do_close = 'fs_pclose',
        is_open = 'fs_ropen',
        is_closed = 'fs_rclose',
        is_enabled = 'fs_renabled',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 10.0,
    ),

    #Experimental shutter EXP
    exp_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter opening bit',
        readpv = 'SQ:ICON:b4io4:EXPopen',
        writepv = 'SQ:ICON:b4io4:EXPopen',
        lowlevel = True,
    ),
    exp_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter closing bit',
        readpv = 'SQ:ICON:b4io4:EXPclose',
        writepv = 'SQ:ICON:b4io4:EXPclose',
        lowlevel = True,
    ),
    exp_sslow = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter set slow bit',
        readpv = 'SQ:ICON:b4io4:EXPslow',
        writepv = 'SQ:ICON:b4io4:EXPslow',
        lowlevel = True,
    ),
    exp_sfast = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter set fast bit',
        readpv = 'SQ:ICON:b4io4:EXPfast',
        writepv = 'SQ:ICON:b4io4:EXPfast',
        lowlevel = True,
    ),
    exp_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter opened bit',
        readpv = 'SQ:ICON:b4io2:EXPopenRBV',
        lowlevel = True,
    ),
    exp_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter closed bit',
        readpv = 'SQ:ICON:b4io2:EXPclosedRBV',
        lowlevel = True,
    ),
    exp_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter enabled bit',
        #readpv='SQ:ICON:b4io2:EXPenabledRBV',
        readpv = 'SQ:ICON:b4io2:EXPenabledRBV',
        lowlevel = True,
    ),
    exp_rfast = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter fast bit',
        readpv = 'SQ:ICON:b4io2:EXPfastRBV',
        lowlevel = True,
    ),
    exp_popen = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter opening pulse',
        moveable = 'exp_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pclose = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter closing pulse',
        moveable = 'exp_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pslow = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter set slow pulse',
        moveable = 'exp_sslow',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pfast = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter set fast pulse',
        moveable = 'exp_sfast',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagExpShutter',
        description = 'EXP shutter',
        do_open = 'exp_popen',
        do_close = 'exp_pclose',
        do_fast = 'exp_pfast',
        do_slow = 'exp_pslow',
        is_open = 'exp_ropen',
        is_closed = 'exp_rclose',
        is_enabled = 'exp_renabled',
        is_fast = 'exp_rfast',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 10.0,
        fast = False,
    ),
    fs_he_auto = device('nicos.devices.generic.manual.ManualSwitch',
        description =
        'Switch which decides if main shutters are managed automatically or manually',
        states = ['auto', 'manual'],
    ),
    exp_auto = device('nicos.devices.generic.manual.ManualSwitch',
        description =
        'Switch which decides if the experiment shutter is managed automatically or manually',
        states = ['auto', 'manual'],
    ),
    shuttersink = device('nicos_sinq.icon.devices.shuttersink.ShutterSink',
        description =
        'Sink which manages opening and closing shutters around scans',
        shutter1 = 'he_shutter',
        shutter2 = 'fs_shutter',
        auto = 'fs_he_auto'
    ),
)

description = 'ICON shutters (HE, FS, Exp)'

group = 'lowlevel'

display_order = 10

devices = dict(
    #Main Shutter HE
    he_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'HE Shutter opening bit',
        readpv = 'SQ:ICON:b4io3:HEopen',
        writepv = 'SQ:ICON:b4io3:HEopen',
        lowlevel = True,
    ),
    he_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'HE Shutter closing bit',
        readpv = 'SQ:ICON:b4io3:HEclose',
        writepv = 'SQ:ICON:b4io3:HEclose',
        lowlevel = True,
    ),
    he_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter opened bit',
        readpv = 'SQ:ICON:b4io1:HEopenRBV',
        lowlevel = True,
    ),
    he_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter closed bit',
        readpv = 'SQ:ICON:b4io1:HEcloseRBV',
        lowlevel = True,
    ),
    he_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'HE Shutter enable bit',
        readpv = 'SQ:ICON:b4io1:HEenabledRBV',
        lowlevel = True,
    ),
    he_popen = device('nicos.devices.generic.Pulse',
        description = 'HE Shutter opening pulse',
        moveable = 'he_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    he_pclose = device('nicos.devices.generic.Pulse',
        description = 'HE Shutter closing pulse',
        moveable = 'he_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    he_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagShutter',
        description = 'HE shutter',
        do_open = 'he_popen',
        do_close = 'he_pclose',
        is_open = 'he_ropen',
        is_closed = 'he_rclose',
        is_enabled = 'he_renabled',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 60.0,
    ),

    #Fail save shutter FS
    fs_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'FS Shutter opening bit',
        readpv = 'SQ:ICON:b4io3:FSopen',
        writepv = 'SQ:ICON:b4io3:FSopen',
        lowlevel = True,
    ),
    fs_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'FS Shutter closing bit',
        readpv = 'SQ:ICON:b4io3:FSclose',
        writepv = 'SQ:ICON:b4io3:FSclose',
        lowlevel = True,
    ),
    fs_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter opened bit',
        readpv = 'SQ:ICON:b4io1:FSopenRBV',
        lowlevel = True,
    ),
    fs_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter closed bit',
        readpv = 'SQ:ICON:b4io1:FScloseRBV',
        lowlevel = True,
    ),
    fs_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'FS Shutter enabled bit',
        readpv = 'SQ:ICON:b4io1:FSenabledRBV',
        lowlevel = True,
    ),
    fs_popen = device('nicos.devices.generic.Pulse',
        description = 'FS Shutter opening pulse',
        moveable = 'fs_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    fs_pclose = device('nicos.devices.generic.Pulse',
        description = 'FS Shutter closing pulse',
        moveable = 'fs_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    fs_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagShutter',
        description = 'FS shutter',
        do_open = 'fs_popen',
        do_close = 'fs_pclose',
        is_open = 'fs_ropen',
        is_closed = 'fs_rclose',
        is_enabled = 'fs_renabled',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 10.0,
    ),

    #Experimental shutter EXP
    exp_sopen = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter opening bit',
        readpv = 'SQ:ICON:b4io4:EXPopen',
        writepv = 'SQ:ICON:b4io4:EXPopen',
        lowlevel = True,
    ),
    exp_sclose = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter closing bit',
        readpv = 'SQ:ICON:b4io4:EXPclose',
        writepv = 'SQ:ICON:b4io4:EXPclose',
        lowlevel = True,
    ),
    exp_sslow = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter set slow bit',
        readpv = 'SQ:ICON:b4io4:EXPslow',
        writepv = 'SQ:ICON:b4io4:EXPslow',
        lowlevel = True,
    ),
    exp_sfast = device('nicos.devices.epics.EpicsDigitalMoveable',
        epicstimeout = 3.0,
        description = 'EXP Shutter set fast bit',
        readpv = 'SQ:ICON:b4io4:EXPfast',
        writepv = 'SQ:ICON:b4io4:EXPfast',
        lowlevel = True,
    ),
    exp_ropen = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter opened bit',
        readpv = 'SQ:ICON:b4io2:EXPopenRBV',
        lowlevel = True,
    ),
    exp_rclose = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter closed bit',
        readpv = 'SQ:ICON:b4io2:EXPclosedRBV',
        lowlevel = True,
    ),
    exp_renabled = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter enabled bit',
        #readpv='SQ:ICON:b4io2:EXPenabledRBV',
        readpv = 'SQ:ICON:b4io2:EXPenabledRBV',
        lowlevel = True,
    ),
    exp_rfast = device('nicos.devices.epics.EpicsReadable',
        epicstimeout = 3.0,
        description = 'EXP Shutter fast bit',
        readpv = 'SQ:ICON:b4io2:EXPfastRBV',
        lowlevel = True,
    ),
    exp_popen = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter opening pulse',
        moveable = 'exp_sopen',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pclose = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter closing pulse',
        moveable = 'exp_sclose',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pslow = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter set slow pulse',
        moveable = 'exp_sslow',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_pfast = device('nicos.devices.generic.Pulse',
        description = 'EXP Shutter set fast pulse',
        moveable = 'exp_sfast',
        onvalue = 1,
        offvalue = 0,
        ontime = 0.1,
        lowlevel = True,
    ),
    exp_shutter = device('nicos_sinq.icon.devices.niag_shutter.NiagExpShutter',
        description = 'EXP shutter',
        do_open = 'exp_popen',
        do_close = 'exp_pclose',
        do_fast = 'exp_pfast',
        do_slow = 'exp_pslow',
        is_open = 'exp_ropen',
        is_closed = 'exp_rclose',
        is_enabled = 'exp_renabled',
        is_fast = 'exp_rfast',
        mapping = {
            'open': [1, 0],
            'closed': [0, 1],
        },
        fallback = 'interstage',
        timeout = 10.0,
        fast = False,
    ),
    fs_he_auto = device('nicos.devices.generic.manual.ManualSwitch',
        description =
        'Switch which decides if main shutters are managed automatically or manually',
        states = ['auto', 'manual'],
    ),
    exp_auto = device('nicos.devices.generic.manual.ManualSwitch',
        description =
        'Switch which decides if the experiment shutter is managed automatically or manually',
        states = ['auto', 'manual'],
    ),
    shuttersink = device('nicos_sinq.icon.devices.shuttersink.ShutterSink',
        description =
        'Sink which manages opening and closing shutters around scans',
        shutter1 = 'he_shutter',
        shutter2 = 'fs_shutter',
        auto = 'fs_he_auto'
    ),
)

#Main Shutter HE #Fail save shutter FS #Experimental shutter EXP #readpv='SQ:ICON:b4io2:EXPenabledRBV',