Bases: KPFFunction
Returns True if SoCal enclosure is closed and tracker is parked.
ARGS:
None
Source code in kpf/socal/IsSoCalShutDown.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
46
47
48
49
50
51
52
53
54
55 | class IsSoCalShutDown(KPFFunction):
'''Returns True if SoCal enclosure is closed and tracker is parked.
ARGS:
=====
None
'''
@classmethod
def pre_condition(cls, args):
pass
@classmethod
def perform(cls, args):
# Enclosure
timeout = cfg.getfloat('SoCal', 'enclosure_status_time', fallback=10)
ENCSTA = ktl.cache('kpfsocal', 'ENCSTA')
is_closed = ENCSTA.waitFor("==1", timeout=timeout)
EKOHOME = ktl.cache('kpfsocal', 'EKOHOME')
is_home = EKOHOME.waitFor("==1", timeout=timeout)
closedstr = {True: '', False: 'NOT '}[is_closed]
parkedstr = {True: '', False: 'NOT '}[is_home]
msg = f'SoCal is {closedstr}closed and {parkedstr}parked'
print(msg)
shutdown = is_closed and is_home
if not shutdown and args.get('email', False) is True:
try:
SendEmail.execute({'Subject': f'KPF SoCal is not shut down properly',
'Message': msg})
except Exception as email_err:
log.error(f'Sending email failed')
log.error(email_err)
return shutdown
@classmethod
def post_condition(cls, args):
pass
@classmethod
def add_cmdline_args(cls, parser):
parser.add_argument('--email', dest="email",
default=False, action="store_true",
help='Send email if SoCal is not shut down?')
return super().add_cmdline_args(parser)
|