Skip to content

Commit

Permalink
fix configure(full=True)
Browse files Browse the repository at this point in the history
  • Loading branch information
yupinghuang committed Feb 7, 2024
1 parent f01db67 commit da44f65
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions mnc/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import yaml
import logging
from typing import Union, Callable, List
import glob
import warnings
import numpy as np
import glob
from dsautils import dsa_store
from lwautils import lwa_arx # arx
from lwa_antpos import mapping
Expand Down Expand Up @@ -222,13 +221,17 @@ def status_fengine(self):

return timestamp, stats

def configure_xengine(self, recorders=None, calibratebeams=False, full=False, timeout=300, force=False):
""" Restart xengine. Configure pipelines to send data to recorders.
Recorders is list of recorders to configure output to. Defaults to those in config file.
Supported recorders are "drvs" (slow vis), "drvf" (fast vis), "dr[n]" (power beams), "drt1" (teng)
Option "full" will stop/start/clear pipelines/beamformer controllers.
force will apply beam calibration, even if already applied in x-engines.
timeout is for x-engine start_pipelines method.
def configure_xengine(self, recorders=None, calibratebeams=False, full=False, force=False):
"""
Configure the xengines for beamforming.
TODO we should really rearlly really lump this into control_bf.
Args:
recorders (list or None): List of recorders (drN) to configure.
calibratebeams (bool): whether to use calibration for the beams
full (bool): Stop and restart the xengines before configuring.
force (bool): Force loading of calibration to beam.
"""

dconf = self.conf['dr']
Expand All @@ -238,13 +241,15 @@ def configure_xengine(self, recorders=None, calibratebeams=False, full=False, ti
recorders = [recorders,]

if full:
logger.info("Stopping/starting pipelines with 20s sleep")
# stop before starting
self.pcontroller.stop_pipelines()
warnings.warn(
'full argument in configure_xengine to be deprecated. '
'Use stop_xengine and start_xengine instead if you want to restart x engine. '
'Usually it is not needed.',
DeprecationWarning, 2)
self.stop_xengine()
self.start_xengine(timeout=timeout)
# Clear the beamformer state
self.bfc.clear()
self.start_xengine()

logger.info(f'pipelines up? {self.pcontroller.pipelines_are_up()}')
if not self.pcontroller.pipelines_are_up():
Expand Down

0 comments on commit da44f65

Please sign in to comment.