Commit de111bcf authored by Tobias Winchen's avatar Tobias Winchen
Browse files

Fix ioloop launch of scpi server

parent 7c4bfcf4
......@@ -3,13 +3,17 @@ import logging
from mpikat.core.scpi import ScpiAsyncDeviceServer, scpi_request, raise_or_ok, launch_server
import mpikat.effelsberg.edd.pipeline.EDDPipeline as EDDPipeline
from mpikat.effelsberg.edd.edd_server_product_controller import EddServerProductController
import coloredlogs
from tornado.gen import Return, coroutine, sleep
import tornado
import signal
log = logging.getLogger('mpikat.edd_scpi_interface')
class EddScpiInterface(ScpiAsyncDeviceServer):
def __init__(self, master_controller_ip, master_controller_port, interface, port, ioloop=None):
class EddScpiInterface(ScpiAsyncDeviceServer):
def __init__(self, interface, port, master_ip, master_port, ioloop=None):
"""
@brief A SCPI interface for a EddMasterController instance
......@@ -21,10 +25,16 @@ class EddScpiInterface(ScpiAsyncDeviceServer):
@note If no IOLoop instance is specified the current instance is used.
"""
log.info("Master ast {}:{}".format(master_ip, master_port))
super(EddScpiInterface, self).__init__(interface, port, ioloop)
self.__controller = EddServerProductController("MASTER", master_controller_ip, master_controller_port)
self.address = (master_ip, master_port)
self.__controller = EddServerProductController("MASTER", master_ip, master_port)
@scpi_request()
@raise_or_ok
@coroutine
def request_edd_configure(self, req):
"""
@brief Configure the EDD backend
......@@ -69,6 +79,8 @@ class EddScpiInterface(ScpiAsyncDeviceServer):
yield self.__controller.capture_stop()
@scpi_request(str)
@raise_or_ok
@coroutine
def request_edd_set(self, req, message):
"""
@brief Set an option for an edd backend component.
......@@ -85,7 +97,6 @@ class EddScpiInterface(ScpiAsyncDeviceServer):
d[i] = {}
d = d[i]
d[p[-1]] = o
yield self.__controller.set(g)
@scpi_request(str)
......@@ -98,6 +109,7 @@ class EddScpiInterface(ScpiAsyncDeviceServer):
if __name__ == "__main__":
parser = EDDPipeline.getArgumentParser()
parser.add_argument('--master-controller-ip', dest='master_ip', type=str, default="localhost",
help='The ip for the master controller')
......@@ -105,6 +117,30 @@ if __name__ == "__main__":
help='The port number for the master controller')
args = parser.parse_args()
server = EddScpiInterface(args.master_ip, args.master_port, args.host, args.port)
launch_server(server)
logging.getLogger().addHandler(logging.NullHandler())
log = logging.getLogger('mpikat')
log.setLevel(args.log_level.upper())
coloredlogs.install(
fmt=("[ %(levelname)s - %(asctime)s - %(name)s "
"- %(filename)s:%(lineno)s] %(message)s"),
level=args.log_level.upper(),
logger=log)
ioloop = tornado.ioloop.IOLoop.current()
log.info("Starting Pipeline instance")
server = EddScpiInterface(args.host, args.port, args.master_ip, args.master_port)
log.info("Created Pipeline instance")
signal.signal(
signal.SIGINT, lambda sig, frame: ioloop.add_callback_from_signal(
EDDPipeline.on_shutdown, ioloop, server))
def start_and_display():
log.info("Starting Pipeline server")
server.start()
log.debug("Started Pipeline server")
log.info(
"Listening at {0}, Ctrl-C to terminate server".format(
server.bind_address))
ioloop.add_callback(start_and_display)
ioloop.start()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment