replace last references to device by module
Change-Id: I2b7099715c356054aad21895f11b13547f104a88 Reviewed-on: https://forge.frm2.tum.de/review/17126 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
parent
8538659b22
commit
8e7908f9b7
@ -101,7 +101,7 @@ import mlzlog
|
||||
|
||||
from secop.protocol.encoding import ENCODERS
|
||||
from secop.protocol.framing import FRAMERS
|
||||
from secop.protocol.messages import *
|
||||
from secop.protocol.messages import EventMessage, DescribeRequest
|
||||
|
||||
|
||||
class TCPConnection(object):
|
||||
@ -146,20 +146,20 @@ class TCPConnection(object):
|
||||
self.handle(msg)
|
||||
|
||||
def handle(self, msg):
|
||||
if isinstance(msg, AsyncDataUnit):
|
||||
if isinstance(msg, EventMessage):
|
||||
self.log.info("got Async: %r" % msg)
|
||||
for cb in self.callbacks:
|
||||
try:
|
||||
cb(msg)
|
||||
except Exception as e:
|
||||
self.log.debug(
|
||||
"handle_async: got exception %r" % e, exception=true)
|
||||
"handle_async: got exception %r" % e, exception=True)
|
||||
else:
|
||||
self.queue.append(msg)
|
||||
|
||||
def read(self):
|
||||
while not len(self.queue):
|
||||
pass
|
||||
while not self.queue:
|
||||
pass # XXX: remove BUSY polling
|
||||
return self.queue.popleft()
|
||||
|
||||
def register_callback(self, callback):
|
||||
@ -181,15 +181,15 @@ class Client(object):
|
||||
|
||||
def handle_async(self, msg):
|
||||
self.log.info("Got async update %r" % msg)
|
||||
device = msg.device
|
||||
module = msg.module
|
||||
param = msg.param
|
||||
value = msg.value
|
||||
self._cache.getdefault(device, {})[param] = value
|
||||
self._cache.getdefault(module, {})[param] = value
|
||||
# XXX: further notification-callbacks needed ???
|
||||
|
||||
def populateNamespace(self, namespace):
|
||||
self.connection.send(ListModulesRequest())
|
||||
self.connection.send(DescribeRequest())
|
||||
# reply = self.connection.read()
|
||||
# self.log.info("found devices %r" % reply)
|
||||
# self.log.info("found modules %r" % reply)
|
||||
# create proxies, populate cache....
|
||||
namespace.setconst('connection', self.connection)
|
||||
|
@ -181,9 +181,9 @@ class Client(object):
|
||||
exception = info
|
||||
self.log = logStub()
|
||||
self._cache = dict()
|
||||
if 'device' in opts:
|
||||
if 'module' in opts:
|
||||
# serial port
|
||||
devport = opts.pop('device')
|
||||
devport = opts.pop('module')
|
||||
baudrate = int(opts.pop('baudrate', 115200))
|
||||
self.contactPoint = "serial://%s:%s" % (devport, baudrate)
|
||||
self.connection = serial.Serial(
|
||||
|
@ -21,7 +21,7 @@
|
||||
#
|
||||
# *****************************************************************************
|
||||
|
||||
"""Utilities for devices that require sequenced actions on value change."""
|
||||
"""Utilities for modules that require sequenced actions on value change."""
|
||||
|
||||
from time import sleep
|
||||
|
||||
@ -98,11 +98,11 @@ class SequencerMixin(object):
|
||||
**Error handling**
|
||||
|
||||
If *fault_on_error* in ``init_sequencer`` is true and an exception is
|
||||
raised during an atomic step, the device goes into an ERROR state
|
||||
raised during an atomic step, the module goes into an ERROR state
|
||||
because it cannot be ensured that further actions will be safe to
|
||||
execute. A manual reset is required.
|
||||
|
||||
Otherwise, the device goes into the WARN state and can be started
|
||||
Otherwise, the module goes into the WARN state and can be started
|
||||
again normally.
|
||||
|
||||
**Stop handling**
|
||||
@ -111,7 +111,7 @@ class SequencerMixin(object):
|
||||
which is set by the mixin's ``Stop`` method.
|
||||
|
||||
The *fault_on_stop* argument in ``init_sequencer`` controls which state
|
||||
the device enters when the sequence is interrupted by a stop. Here,
|
||||
the module enters when the sequence is interrupted by a stop. Here,
|
||||
the default is to only go into ALARM.
|
||||
"""
|
||||
if self.seq_is_alive():
|
||||
|
@ -24,7 +24,6 @@
|
||||
import os
|
||||
import ast
|
||||
import time
|
||||
import psutil
|
||||
import threading
|
||||
import ConfigParser
|
||||
|
||||
@ -105,15 +104,15 @@ class Server(object):
|
||||
|
||||
self._interfaces = []
|
||||
|
||||
deviceopts = []
|
||||
moduleopts = []
|
||||
interfaceopts = []
|
||||
equipment_id = None
|
||||
nodeopts = []
|
||||
for section in parser.sections():
|
||||
if section.lower().startswith('device '):
|
||||
# device section
|
||||
# omit leading 'device ' string
|
||||
devname = section[len('device '):]
|
||||
if section.lower().startswith('module '):
|
||||
# module section
|
||||
# omit leading 'module ' string
|
||||
devname = section[len('module '):]
|
||||
devopts = dict(item for item in parser.items(section))
|
||||
if 'class' not in devopts:
|
||||
self.log.error('Module %s needs a class option!')
|
||||
@ -123,7 +122,7 @@ class Server(object):
|
||||
# try to import the class, raise if this fails
|
||||
devopts['class'] = get_class(devopts['class'])
|
||||
# all went well so far
|
||||
deviceopts.append([devname, devopts])
|
||||
moduleopts.append([devname, devopts])
|
||||
if section.lower().startswith('interface '):
|
||||
# interface section
|
||||
# omit leading 'interface ' string
|
||||
@ -161,14 +160,14 @@ class Server(object):
|
||||
self._dispatcher = self._buildObject(
|
||||
'Dispatcher', Dispatcher, nodeopts)
|
||||
self._processInterfaceOptions(interfaceopts)
|
||||
self._processModuleOptions(deviceopts)
|
||||
self._processModuleOptions(moduleopts)
|
||||
|
||||
def _processModuleOptions(self, deviceopts):
|
||||
# check devices opts by creating them
|
||||
def _processModuleOptions(self, moduleopts):
|
||||
# check modules opts by creating them
|
||||
devs = []
|
||||
for devname, devopts in deviceopts:
|
||||
for devname, devopts in moduleopts:
|
||||
devclass = devopts.pop('class')
|
||||
# create device
|
||||
# create module
|
||||
self.log.debug('Creating Module %r' % devname)
|
||||
export = devopts.pop('export', '1')
|
||||
export = export.lower() in ('1', 'on', 'true', 'yes')
|
||||
@ -184,13 +183,13 @@ class Server(object):
|
||||
self.log.getChild(devname), devopts, devname, self._dispatcher)
|
||||
devs.append([devname, devobj, export])
|
||||
|
||||
# connect devices with dispatcher
|
||||
# connect modules with dispatcher
|
||||
for devname, devobj, export in devs:
|
||||
self.log.info('registering device %r' % devname)
|
||||
self.log.info('registering module %r' % devname)
|
||||
self._dispatcher.register_module(devobj, devname, export)
|
||||
# also call init on the devices
|
||||
# also call init on the modules
|
||||
devobj.init()
|
||||
# call a possibly empty postinit on each device after registering all
|
||||
# call a possibly empty postinit on each module after registering all
|
||||
for _devname, devobj, _export in devs:
|
||||
postinit = getattr(devobj, 'postinit', None)
|
||||
if postinit:
|
||||
|
Loading…
x
Reference in New Issue
Block a user