API
efcControl.py
Go to the documentation of this file.
1 import sys
2 import logging
3 from enum import Enum
4 import time
5 import numpy as np
6 
7 import xconf
8 
9 from magaox.indi.device import XDevice, BaseConfig
10 from magaox.camera import XCam
11 from magaox.deformable_mirror import XDeformableMirror, XFourierMirror, XPokeMirror
12 from magaox.constants import StateCodes
13 
14 from purepyindi2 import device, properties, constants
15 from purepyindi2.messages import DefNumber, DefSwitch, DefLight, DefText
16 
17 from utils import *
18 
19 @xconf.config
21  """
22  """
23  shmim : str = xconf.field(help="Name of the camera device (specifically, the associated shmim, if different)")
24  dark_shmim : str = xconf.field(help="Name of the dark frame shmim associated with this camera device")
25 
26 @xconf.config
27 class efcControlConfig(BaseConfig):
28  """Automatic coronagraph alignment assistant
29  """
30  camera : CameraConfig = xconf.field(help="Camera to use")
31  sleep_interval_sec : float = xconf.field(default=0.25, help="Sleep interval between loop() calls")
32 
33 class States(Enum):
34  IDLE = 0
35 
36 class efcControl(XDevice):
37  config : efcControlConfig
38 
39  def setup(self):
40  self.log.debug(f"I was configured! See? {self.config=}")
41  fsm = properties.TextVector(name='fsm')
42  fsm.add_element(DefText(name='state', _value=StateCodes.INITIALIZED.name))
43  self.add_property(fsm)
44 
45  self.log.info("Found camera: {:s}".format(self.config.camera.shmim))
46  self.cameracamera = XCam(self.config.camera.shmim, use_hcipy=True)
47  self._state_state = States.IDLE
48 
49  self.properties['fsm']['state'] = StateCodes.READY.name
50  self.update_property(self.properties['fsm'])
51 
52  def loop(self):
53  pass
54  # Basic EFC loop
55  # Acquire sequence of images
56  # Need to trigger based on start of exposure?
57  # Send DM command
58  # Get