ControlFoldMirror

Bases: KPFFunction

Insert or remove the FIU Cal Fold Mirror from the beam.

Parameters:
  • destination (str) –

    The desired FIU fold mirror position name. Allowed values: in, out

  • wait (bool) –

    Wait for move to complete before returning? (default: True)

KTL Keywords Used:

  • kpffiu.FOLDNAM
Source code in kpf/fiu/ControlFoldMirror.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
44
45
class ControlFoldMirror(KPFFunction):
    '''Insert or remove the FIU Cal Fold Mirror from the beam.

    Args:
        destination (str): The desired FIU fold mirror position name. Allowed
            values: in, out
        wait (bool): Wait for move to complete before returning? (default: True)

    KTL Keywords Used:

    - `kpffiu.FOLDNAM`
    '''
    @classmethod
    def pre_condition(cls, args):
        destination = args.get('destination', '').strip()
        if destination.lower() not in ['in', 'out']:
            raise FailedPreCondition(f"Requested state {destination} is invalid")

    @classmethod
    def perform(cls, args):
        destination = args.get('destination', '').strip()
        FOLDNAM = ktl.cache('kpffiu', 'FOLDNAM')
        FOLDNAM.write(destination)

    @classmethod
    def post_condition(cls, args):
        destination = args.get('destination', '').strip()
        timeout = cfg.getfloat('times', 'fiu_fold_mirror_move_time', fallback=5)
        FOLDNAM = ktl.cache('kpffiu', 'FOLDNAM')
        if FOLDNAM.waitFor(f'== "{destination}"', timeout=timeout) is not True:
            raise FailedToReachDestination(FOLDNAM.read(), destination)

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument('destination', type=str,
                            choices=['in', 'out'],
                            help='Desired fold mirror position')
        return super().add_cmdline_args(parser)