Project 'desp/hdl' was moved to 'rtsd/hdl'. Please update any links and bookmarks that may still have the old path.
Select Git revision
image_set.cc
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
startup.py 1.68 KiB
#! /usr/bin/env python3
import tango
import logging
logger = logging.getLogger()
def startup(device: str, force_restart: bool) -> tango.DeviceProxy:
'''
Start a LOFAR Tango device:
pcc = startup(device = 'LTS/PCC/1', force_restart = False)
'''
proxy = tango.DeviceProxy(device)
state = proxy.state()
# go to OFF, but only if force_restart is True
if force_restart is True:
logger.warning(f"Forcing device {device} restart.")
proxy.off()
state = proxy.state()
if state is not tango._tango.DevState.OFF:
logger.error(f"Device {device} cannot perform off although restart has been enforced, state = {state}. Please investigate.")
return proxy
if state is not tango._tango.DevState.OFF:
logger.error(f"Device {device} is not in OFF state, cannot start it. state = {state}")
return proxy
# Initialise device
logger.info(f"Device {device} is in OFF, performing initialisation.")
proxy.initialise()
state = proxy.state()
if state is not tango._tango.DevState.STANDBY:
logger.error(f"Device {device} cannot perform initialise, state = {state}. Please investigate.")
return proxy
# Set default values
logger.info(f"Device {device} is in STANDBY, setting default values.")
proxy.set_defaults()
# Turn on device
logger.info(f"Device {device} is in STANDBY, performing on.")
proxy.on()
state = proxy.state()
if state is not tango._tango.DevState.ON:
logger.error(f"Device {device} cannot perform on, state = {state}. Please investigate.")
else:
logger.info(f"Device {device} has successfully reached ON state.")
return proxy