Skip to content
Snippets Groups Projects
Commit 1e24f45d authored by Taya Snijder's avatar Taya Snijder
Browse files

merged master

parents 18fda380 d38353a7
No related branches found
No related tags found
1 merge request!27Resolve #2021 "04 16 branched from master apsctl device"
...@@ -16,14 +16,14 @@ from tango.server import Device, command ...@@ -16,14 +16,14 @@ from tango.server import Device, command
from tango import DevState, DebugIt from tango import DevState, DebugIt
# Additional import # Additional import
from src.attribute_wrapper import * from util.attribute_wrapper import attribute_wrapper
from util.lofar_logging import log_exceptions
__all__ = ["hardware_device"] __all__ = ["hardware_device"]
from src.wrappers import only_in_states from util.wrappers import only_in_states, fault_on_error
#@log_exceptions()
class hardware_device(Device): class hardware_device(Device):
""" """
...@@ -74,6 +74,8 @@ class hardware_device(Device): ...@@ -74,6 +74,8 @@ class hardware_device(Device):
@command() @command()
@only_in_states([DevState.FAULT, DevState.OFF]) @only_in_states([DevState.FAULT, DevState.OFF])
@DebugIt() @DebugIt()
@fault_on_error()
@log_exceptions()
def Initialise(self): def Initialise(self):
""" """
Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. Command to ask for initialisation of this device. Can only be called in FAULT or OFF state.
...@@ -87,20 +89,11 @@ class hardware_device(Device): ...@@ -87,20 +89,11 @@ class hardware_device(Device):
self.set_state(DevState.STANDBY) self.set_state(DevState.STANDBY)
# @only_in_states([DevState.INIT])
# def Standby(self):
# """
# Command to ask for initialisation of this device. Can only be called in FAULT or OFF state.
#
# :return:None
# """
#
# self.standby()
# self.set_state(DevState.STANDBY)
@command() @command()
@only_in_states([DevState.STANDBY]) @only_in_states([DevState.STANDBY])
@DebugIt() @DebugIt()
@fault_on_error()
@log_exceptions()
def On(self): def On(self):
""" """
Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. Command to ask for initialisation of this device. Can only be called in FAULT or OFF state.
...@@ -112,6 +105,7 @@ class hardware_device(Device): ...@@ -112,6 +105,7 @@ class hardware_device(Device):
@command() @command()
@DebugIt() @DebugIt()
@log_exceptions()
def Off(self): def Off(self):
""" """
Command to ask for shutdown of this device. Command to ask for shutdown of this device.
...@@ -133,6 +127,7 @@ class hardware_device(Device): ...@@ -133,6 +127,7 @@ class hardware_device(Device):
@command() @command()
@only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY]) @only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY])
@DebugIt() @DebugIt()
@log_exceptions()
def Fault(self): def Fault(self):
""" """
FAULT state is used to indicate our connection with the OPC-UA server is down. FAULT state is used to indicate our connection with the OPC-UA server is down.
...@@ -154,8 +149,6 @@ class hardware_device(Device): ...@@ -154,8 +149,6 @@ class hardware_device(Device):
pass pass
def on(self): def on(self):
pass pass
def standby(self):
pass
def initialise(self): def initialise(self):
pass pass
......
File moved
File moved
File moved
...@@ -22,12 +22,13 @@ def only_in_states(allowed_states): ...@@ -22,12 +22,13 @@ def only_in_states(allowed_states):
return wrapper return wrapper
def only_when_on(func): def only_when_on():
""" """
Wrapper to call and return the wrapped function if the device is Wrapper to call and return the wrapped function if the device is
in the ON state. Otherwise None is returned and nothing in the ON state. Otherwise None is returned and nothing
will be called. will be called.
""" """
def inner(func):
@wraps(func) @wraps(func)
def when_on_wrapper(self, *args, **kwargs): def when_on_wrapper(self, *args, **kwargs):
if self.get_state() == DevState.ON: if self.get_state() == DevState.ON:
...@@ -37,10 +38,13 @@ def only_when_on(func): ...@@ -37,10 +38,13 @@ def only_when_on(func):
return when_on_wrapper return when_on_wrapper
def fault_on_error(func): return inner
def fault_on_error():
""" """
Wrapper to catch exceptions. Sets the device in a FAULT state if any occurs. Wrapper to catch exceptions. Sets the device in a FAULT state if any occurs.
""" """
def inner(func):
@wraps(func) @wraps(func)
def error_wrapper(self, *args, **kwargs): def error_wrapper(self, *args, **kwargs):
try: try:
...@@ -51,3 +55,5 @@ def fault_on_error(func): ...@@ -51,3 +55,5 @@ def fault_on_error(func):
return None return None
return error_wrapper return error_wrapper
return inner
This diff is collapsed.
version: '2' version: '2'
services: services:
maria-db: archiver-maria-db:
image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/mariadb_hdbpp:latest image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/mariadb_hdbpp:latest
container_name: archiver-maria-db container_name: archiver-maria-db
network_mode: ${NETWORK_MODE} network_mode: ${NETWORK_MODE}
...@@ -23,7 +23,7 @@ services: ...@@ -23,7 +23,7 @@ services:
depends_on: depends_on:
- databaseds - databaseds
- dsconfig - dsconfig
- maria-db - archiver-maria-db
environment: environment:
- TANGO_HOST=${TANGO_HOST} - TANGO_HOST=${TANGO_HOST}
- HdbManager=archiving/hdbpp/confmanager01 - HdbManager=archiving/hdbpp/confmanager01
...@@ -40,7 +40,7 @@ services: ...@@ -40,7 +40,7 @@ services:
depends_on: depends_on:
- databaseds - databaseds
- dsconfig - dsconfig
- maria-db - archiver-maria-db
environment: environment:
- TANGO_HOST=${TANGO_HOST} - TANGO_HOST=${TANGO_HOST}
- HdbManager=archiving/hdbpp/confmanager01 - HdbManager=archiving/hdbpp/confmanager01
......
...@@ -16,7 +16,7 @@ services: ...@@ -16,7 +16,7 @@ services:
depends_on: depends_on:
- databaseds - databaseds
- dsconfig - dsconfig
- maria-db - archiver-maria-db
- hdbpp-es - hdbpp-es
- hdbpp-cm - hdbpp-cm
volumes: volumes:
......
...@@ -25,3 +25,7 @@ ENV TINI_VERSION v0.6.0 ...@@ -25,3 +25,7 @@ ENV TINI_VERSION v0.6.0
ENV JUPYTER_RUNTIME_DIR=/tmp ENV JUPYTER_RUNTIME_DIR=/tmp
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN sudo chmod +x /usr/bin/tini RUN sudo chmod +x /usr/bin/tini
# Make sure Jupyter can write to the home directory
ENV HOME=/home/tango
RUN chmod a+rwx /home/tango
#! /usr/bin/env python3
import logging
def configure_logging():
# Always also log the hostname because it makes the origin of the log clear.
import socket
hostname = socket.gethostname()
# Set up logging in a way that it can be understood by a human reader, be
# easily grep'ed, be parsed with a couple of shell commands and
# easily fed into an Kibana/Elastic search system.
logging.basicConfig(format = '%(asctime)s.%(msecs)d %(levelname)s - HOST="{}" PID="%(process)d" TNAME="%(threadName)s" TID="%(thread)d" FILE="%(pathname)s" LINE="%(lineno)d" FUNC="%(funcName)s" MSG="%(message)s"'.format(hostname), datefmt = '%Y-%m-%dT%H:%M:%S', level = logging.INFO, Force = True)
#! /usr/bin/env python3
def startup(device: str, force_restart: bool):
'''
Start a LOFAR Tango device:
pcc = startup(device = 'LTS/PCC/1', force_restart = False)
'''
import tango
proxy = tango.DeviceProxy(device)
state = proxy.state()
if force_restart is True:
print("Forcing device {} restart.".format(device))
proxy.off()
state = proxy.state()
if state is not tango._tango.DevState.OFF:
print("Device {} cannot perform off although restart has been enforced, state = {}. Please investigate.".format(device, state))
return proxy
if state is not tango._tango.DevState.OFF:
print("Device {} is not in OFF state, cannot start it. state = {}".format(device, state))
return proxy
print("Device {} is in OFF, performing initialisation.".format(device))
proxy.initialise()
state = proxy.state()
if state is not tango._tango.DevState.STANDBY:
print("Device {} cannot perform initialise, state = {}. Please investigate.".format(device, state))
return proxy
print("Device {} is in STANDBY, performing on.".format(device))
proxy.on()
state = proxy.state()
if state is not tango._tango.DevState.ON:
print("Device {} cannot perform on, state = {}. Please investigate.".format(device, state))
else:
print("Device {} has successfully reached ON state.".format(device))
return proxy
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment