38 Widget to simulate a closed loop using CANAPASS
41 widget_canapass.py [<parameters_filename>]
43 with 'parameters_filename' the path to the parameters file
46 -h --help Show this help message and exit
47 -i, --interactive keep the script interactive
53 from rich.progress
import track
56 from PyQt5
import QtWidgets
57 except ModuleNotFoundError
as e:
59 from PySide2
import QtWidgets
60 except ModuleNotFoundError
as e:
61 raise ModuleNotFoundError(
"No module named 'PyQt5' or PySide2', please install one of them\nException raised: "+e.msg)
64 from typing
import Any
65 from docopt
import docopt
76 def __init__(self, config_file: Any =
None, cacao: bool =
False,
77 expert: bool =
False) ->
None:
78 widgetAOWindow.__init__(self, config_file, cacao, hide_histograms=
True)
89 self.
uiAOuiAO.actionShow_Pyramid_Tools.toggled.connect(self.
show_pyr_toolsshow_pyr_tools)
96 WidgetBase.init_config(self)
99 widgetAOWindow.init_configFinished(self)
104 widgetAOWindow.loop_once(self)
105 if (self.
uiAOuiAO.actionShow_Pyramid_Tools.isChecked()):
106 self.
wpyrwpyr.Fe = 1 / self.
configconfig.p_loop.ittime
107 if (self.
wpyrwpyr.CBNumber == 1):
108 self.
aiai = self.compute_modal_residuals()
112 aiVect = self.compute_modal_residuals()
113 self.
aiai = aiVect[np.newaxis, :]
117 aiVect = self.compute_modal_residuals()
118 self.
aiai = np.concatenate((self.
aiai, aiVect[np.newaxis, :]))
125 def next(self, nbIters):
126 ''' Move atmos -> get_slopes -> applyControl ; One integrator step '''
127 for i
in track(range(nbIters)):
131 ADOPTPATH = os.getenv(
"ADOPTPATH")
132 sys.path.append(ADOPTPATH +
"/widgets")
133 from pyrStats
import widget_pyrStats
134 print(
"OK Pyramid Tools Widget initialized")
135 self.
wpyrwpyr = widget_pyrStats()
142 self.
wpyrwpyr.updateResiduals(ai)
144 print(
'computing phase 2 Modes basis')
149 if (self.
wpyrwpyr
is None):
151 print(
"Lauching pyramid widget...")
155 raise ValueError(
"ERROR: ADOPT not found. Cannot launch Pyramid tools")
157 if (self.
uiAOuiAO.actionShow_Pyramid_Tools.isChecked()):
163 return self.
wpyrwpyr.ai
167 from subprocess
import Popen, PIPE
168 from hraa.server.pyroServer
import PyroServer
174 p = Popen(
"whoami", shell=
True, stdout=PIPE, stderr=PIPE)
175 out, err = p.communicate()
178 raise Exception(
"ERROR CANNOT RECOGNIZE USER")
180 user = out.split(b
"\n")[0].decode(
"utf-8")
181 print(
"User is " + user)
185 coro2pyro = PyroEmptyClass()
192 names = [
"supervisor",
"supervisor_rtc",
"supervisor_wfs",
193 "supervisor_target",
"supervisor_tel",
"supervisor_basis",
"supervisor_calibration",
194 "supervisor_atmos",
"supervisor_dms",
"supervisor_config",
"supervisor_modalgains",
"supervisor_corono",
"wao_loop"]
197 nname.append(name+
"_"+user)
198 server = PyroServer(listDevices=devices, listNames=nname)
201 raise Exception(
"Error could not connect to Pyro server.\n It can be:\n - Missing dependencies? (check if Pyro4 is installed)\n - pyro server not running")
211 self.
waowao.aoLoopClicked(
True)
212 self.
waowao.uiAO.wao_run.setChecked(
True)
215 self.
waowao.aoLoopClicked(
False)
216 self.
waowao.uiAO.wao_run.setChecked(
False)
222 if __name__ ==
'__main__':
223 arguments = docopt(__doc__)
224 app = QtWidgets.QApplication(sys.argv)
225 app.setStyle(
'cleanlooks')
Initialization and execution of a CANAPASS supervisor.