Skip to content
Snippets Groups Projects
Commit 606b07e0 authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-287: Create entrypoint wrapper and remove duplicate code

parent 3cabe7a8
No related branches found
No related tags found
1 merge request!146L2SS-287: implement python packaging
Showing
with 56 additions and 54 deletions
import sys
from tango.server import run
from tangostationcontrol.common.lofar_logging import configure_logger
def entry(Device, **kwargs):
"""General device entrypoint"""
# Remove first argument which is filename
args = sys.argv[1:]
# Setup logging
configure_logger()
# Start the device server
if type(Device) is tuple:
return run(Device, args=args, **kwargs)
else:
return run((Device,), args=args, **kwargs)
......@@ -23,6 +23,7 @@ import numpy
from device_decorators import *
from tangostationcontrol.common.entry import entry
from tangostationcontrol.devices.hardware_device import hardware_device
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
......@@ -276,10 +277,6 @@ class Boot(hardware_device):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the Boot module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((Boot,), args=args, **kwargs)
return entry(Boot, **kwargs)
......@@ -22,11 +22,11 @@ import asyncio
from device_decorators import *
# Additional import
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.clients.docker_client import DockerClient
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.hardware_device import hardware_device
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.common.lofar_version import get_version
__all__ = ["Docker", "main"]
......@@ -122,10 +122,6 @@ class Docker(hardware_device):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the Docker module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((Docker,), args=args, **kwargs)
return entry(Docker, **kwargs)
......@@ -11,9 +11,10 @@ from tango.server import Device, run, command, attribute
import numpy
from time import time
from tangostationcontrol.devices.device_decorators import *
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.common.lofar_version import get_version
from tangostationcontrol.devices.device_decorators import *
from json import loads
......@@ -110,6 +111,6 @@ class Observation(Device):
# ----------
# Run server
# ----------
def main(args = None, **kwargs):
def main(**kwargs):
"""Main function of the ObservationControl module."""
return run((Observation,), args = args, **kwargs)
return entry(Observation, **kwargs)
......@@ -14,6 +14,7 @@ import numpy
import time
from json import loads
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.common.lofar_version import get_version
from tangostationcontrol.devices.device_decorators import *
......@@ -437,6 +438,6 @@ class ObservationControl(Device):
# ----------
# Run server
# ----------
def main(args = None, **kwargs):
def main(**kwargs):
"""Main function of the ObservationControl module."""
return run((ObservationControl, Observation), verbose = True, args = args, **kwargs)
return entry((ObservationControl, Observation), verbose=True, **kwargs)
......@@ -25,11 +25,10 @@ import numpy
import asyncio
# Additional import
from devices.device_decorators import *
from clients.opcua_client import OPCUAConnection
from devices.hardware_device import hardware_device
from common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.clients.opcua_client import OPCUAConnection
from tangostationcontrol.devices.device_decorators import *
from tangostationcontrol.devices.hardware_device import hardware_device
__all__ = ["opcua_device", "main"]
......
......@@ -19,8 +19,9 @@ from tango import AttrWriteType
import numpy
# Additional import
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.device_decorators import *
from tangostationcontrol.devices.opcua_device import opcua_device
......@@ -257,10 +258,6 @@ class RECV(opcua_device):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the RECV module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((RECV,), args=args, **kwargs)
return entry(RECV, **kwargs)
......@@ -19,12 +19,14 @@ from tango import AttrWriteType
# Additional import
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.opcua_device import opcua_device
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
import numpy
__all__ = ["SDP", "main"]
@device_logging_to_python()
class SDP(opcua_device):
# -----------------
......@@ -69,7 +71,7 @@ class SDP(opcua_device):
mandatory=False,
default_value=[[0.0] * 12] * 16
)
FPGA_sdp_info_station_id_RW_default = device_property(
dtype='DevVarULongArray',
mandatory=True
......@@ -171,10 +173,6 @@ class SDP(opcua_device):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the SDP module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((SDP,), args=args, **kwargs)
return entry(SDP, **kwargs)
......@@ -17,6 +17,7 @@ from tango.server import device_property, attribute
from tango import AttrWriteType
# Additional import
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.clients.opcua_client import OPCUAConnection
from tangostationcontrol.clients.statistics_client import StatisticsClient
......@@ -27,6 +28,7 @@ import numpy
__all__ = ["SST", "main"]
class SST(Statistics):
STATISTICS_COLLECTOR_CLASS = SSTCollector
......@@ -113,10 +115,6 @@ class SST(Statistics):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the SST Device module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((SST,), args=args, **kwargs)
return entry(SST, **kwargs)
......@@ -17,6 +17,7 @@ from tango.server import device_property, attribute
from tango import AttrWriteType
# Additional import
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.clients.opcua_client import OPCUAConnection
from tangostationcontrol.clients.statistics_client import StatisticsClient
......@@ -151,10 +152,6 @@ class XST(Statistics):
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
def main(**kwargs):
"""Main function of the XST Device module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((XST,), args=args, **kwargs)
return entry(XST, **kwargs)
......@@ -17,6 +17,7 @@ from tango.server import device_property, attribute
from tango import AttrWriteType
# Additional import
from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.opcua_device import opcua_device
from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
......@@ -146,8 +147,4 @@ class UNB2(opcua_device):
# ----------
def main(args=None, **kwargs):
"""Main function of the UNB2 module."""
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((UNB2,), args=args, **kwargs)
return entry(UNB2, **kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment