send udp message to feeder
inform the history feeder in case of a SECoP server without UDP mechanism
This commit is contained in:
21
devices.py
21
devices.py
@ -27,6 +27,8 @@ connected to a SEC node
|
||||
"""
|
||||
|
||||
import threading
|
||||
import socket
|
||||
import json
|
||||
from nicos import config, session
|
||||
from nicos.core import Override, Param, Moveable, status, POLLER, SIMULATION, DeviceAlias, \
|
||||
Device, anytype, listof, MASTER
|
||||
@ -38,6 +40,8 @@ from nicos.commands.basic import AddSetup, CreateAllDevices, CreateDevice
|
||||
from nicos.utils import loggers
|
||||
from servicemanager import FrappyManager, SeaManager, Reconnect, Keep
|
||||
|
||||
|
||||
SECOP_UDP_PORT = 10767
|
||||
SERVICES = FrappyManager.services
|
||||
|
||||
|
||||
@ -113,6 +117,21 @@ def get_frappy_config():
|
||||
return None
|
||||
|
||||
|
||||
def send_other_udp(uri, instrument, device=None):
|
||||
"""inform the feeder about the start of a frappy server"""
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
msg = {
|
||||
'SECoP': 'for_other_node',
|
||||
'uri': uri,
|
||||
'instrument': instrument,
|
||||
}
|
||||
if device:
|
||||
msg['device'] = device
|
||||
msg = json.dumps(msg, ensure_ascii=False, separators=(',', ':')).encode('utf-8')
|
||||
sock.sendto(msg, ('255.255.255.255', SECOP_UDP_PORT))
|
||||
|
||||
|
||||
class FrappyConfig(Device):
|
||||
# respect the order: e.g. temperature_regulation must be after temperature
|
||||
# because it will not be added to envlist when temperature is the same device
|
||||
@ -830,8 +849,10 @@ class FrappyNode(SecNodeDevice, Moveable):
|
||||
if available_cfg is not None:
|
||||
raise ValueError('use "frappy_list()" to get a list of valid frappy configurations')
|
||||
uri = 'localhost:%d' % info[self.service]
|
||||
send_other_udp(uri, config.instrument, device=cfg)
|
||||
else:
|
||||
uri = cfg
|
||||
send_other_udp(uri, config.instrument)
|
||||
if uri != self.uri:
|
||||
self._disconnect(keeptarget=True)
|
||||
if uri:
|
||||
|
Reference in New Issue
Block a user