FVCPower

Bases: KPFFunction

Turn on or off the power for the specified FVC camera.

Parameters:
  • camera (str) –

    Which FVC camera? Allowed values: SCI, CAHK, EXT, CAL

  • power (str) –

    The desired state. Allowed values: on or off

KTL Keywords Used:

  • kpfpower.KPFFVC1
  • kpfpower.KPFFVC2
  • kpfpower.KPFFVC3
Source code in kpf/fvc/FVCPower.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class FVCPower(KPFFunction):
    '''Turn on or off the power for the specified FVC camera.

    Args:
        camera (str): Which FVC camera? Allowed values: SCI, CAHK, EXT, CAL
        power (str): The desired state. Allowed values: on or off

    KTL Keywords Used:

    - `kpfpower.KPFFVC1`
    - `kpfpower.KPFFVC2`
    - `kpfpower.KPFFVC3`
    '''
    @classmethod
    def pre_condition(cls, args):
        check_input(args, 'camera', allowed_values=['SCI', 'CAHK', 'CAL'])

    @classmethod
    def perform(cls, args):
        camera = args.get('camera')
        camnum = {'SCI': 1, 'CAHK': 2, 'CAL': 3}[camera]
        powerkw = ktl.cache('kpfpower', f'KPFFVC{camnum}')
        dest = args.get('power')
        if powerkw.read().lower() != dest.lower():
            log.info(f"Turning {dest} {camera} FVC")
            powerkw.write(args.get('power'))
            shim = cfg.getfloat('times', 'fvc_command_timeshim', fallback=2)
            time.sleep(shim)

    @classmethod
    def post_condition(cls, args):
        camera = args.get('camera')
        camnum = {'SCI': 1, 'CAHK': 2, 'CAL': 3}[camera]
        powerkw = ktl.cache('kpfpower', f'KPFFVC{camnum}')
        timeout = cfg.getfloat('times', 'fvc_command_timeout', fallback=1)
        dest = args.get('power')
        success = powerkw.waitFor(f"== '{dest}'", timeout=timeout)
        if success is False:
            raise FailedToReachDestination(powerkw.read(), dest)

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument('camera', type=str,
                            choices=['SCI', 'CAHK', 'CAL'],
                            help='The FVC camera')
        parser.add_argument('power', type=str,
                            choices=['on', 'off'],
                            help='Desired power state: "on" or "off"')
        return super().add_cmdline_args(parser)