ControlHatch

Bases: KPFTranslatorFunction

Open or close the FIU hatch

Parameters:
  • destination (str) –

    The desired FIU hatch position name. Allowed values: closed, open

KTL Keywords Used:

  • kpffiu.HATCH
Source code in kpf/fiu/ControlHatch.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class ControlHatch(KPFTranslatorFunction):
    '''Open or close the FIU hatch

    Args:
        destination (str): The desired FIU hatch position name. Allowed
            values: closed, open

    KTL Keywords Used:

    - `kpffiu.HATCH`
    '''
    @classmethod
    def pre_condition(cls, args, logger, cfg):
        check_input(args, 'destination', allowed_values=['closed', 'open'])

    @classmethod
    def perform(cls, args, logger, cfg):
        destination = args.get('destination', '').strip()
        kpffiu = ktl.cache('kpffiu')
        kpffiu['HATCH'].write(destination)

    @classmethod
    def post_condition(cls, args, logger, cfg):
        destination = args.get('destination', '').strip()
        timeout = cfg.getfloat('times', 'fiu_hatch_move_time', fallback=1)
        success = ktl.waitFor(f'($kpffiu.hatch == {destination})', timeout=timeout)
        if success is not True:
            hatch = ktl.cache('kpffiu', 'HATCH')
            raise FailedToReachDestination(hatch.read(), destination)

    @classmethod
    def add_cmdline_args(cls, parser, cfg=None):
        parser.add_argument('destination', type=str,
                            choices=['open', 'closed'],
                            help='Desired hatch position')
        return super().add_cmdline_args(parser, cfg)