SetTipTiltControl

Bases: KPFTranslatorFunction

Turn the tip tilt control software on or off.

Parameters:
  • control (str) –

    The desired state of the control. Allowed values: Active or Inactive

KTL Keywords Used:

  • kpfguide.TIPTILT_CONTROL
Source code in kpf/fiu/SetTipTiltControl.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 SetTipTiltControl(KPFTranslatorFunction):
    '''Turn the tip tilt control software on or off.

    Args:
        control (str): The desired state of the control. Allowed values: Active
            or Inactive

    KTL Keywords Used:

    - `kpfguide.TIPTILT_CONTROL`
    '''
    @classmethod
    def pre_condition(cls, args, logger, cfg):
        allowed_values = ['Active', 'Inactive', '1', '0', 1, 0]
        check_input(args, 'control', allowed_values=allowed_values)

    @classmethod
    def perform(cls, args, logger, cfg):
        control = args.get('control')
        tiptiltcontrol = ktl.cache('kpfguide', 'TIPTILT_CONTROL')
        tiptiltcontrol.write(control)

    @classmethod
    def post_condition(cls, args, logger, cfg):
        control = args.get('control')
        timeout = cfg.getfloat('times', 'tip_tilt_move_time', fallback=0.1)
        expr = f"($kpfguide.TIPTILT_CONTROL == {calculations}) "
        success = ktl.waitFor(expr, timeout=timeout)
        if success is not True:
            tiptiltcontrol = ktl.cache('kpfguide', 'TIPTILT_CONTROL')
            raise FailedToReachDestination(tiptiltcontrol.read(), control)

    @classmethod
    def add_cmdline_args(cls, parser, cfg=None):
        parser.add_argument('control', type=str,
                            choices=['Active', 'Inactive'],
                            help='Control "Active" or "Inactive"')
        return super().add_cmdline_args(parser, cfg)