improve HasIodev
- automatically reuse communicators (iodevs) with the same uri - when uri and iodev is given, iodev gets the name of the auto-created communicator Change-Id: If30353c0b61104837e0f940968080c3c1e53c1c6 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23122 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
3261e5e5ff
commit
c14671204c
@ -196,20 +196,29 @@ class StringIO(Communicator):
|
||||
|
||||
|
||||
class HasIodev(Module):
|
||||
"""Mixin for modules using a communicator"""
|
||||
"""Mixin for modules using a communicator
|
||||
|
||||
not only StringIO !
|
||||
"""
|
||||
properties = {
|
||||
'iodev': Attached(),
|
||||
'uri': Property('uri for auto creation of iodev', StringType(), default=''),
|
||||
}
|
||||
|
||||
iodevDict = {}
|
||||
|
||||
def __init__(self, name, logger, opts, srv):
|
||||
iodev = opts.pop('iodev', None)
|
||||
super().__init__(name, logger, opts, srv)
|
||||
if self.uri:
|
||||
opts = {'uri': self.uri, 'description': 'communication device for %s' % name,
|
||||
'export': False}
|
||||
ioname = name + '_iodev'
|
||||
iodev = self.iodevClass(ioname, srv.log.getChild(ioname), opts, srv)
|
||||
srv.modules[ioname] = iodev
|
||||
ioname = self.iodevDict.get(self.uri)
|
||||
if not ioname:
|
||||
ioname = iodev or name + '_iodev'
|
||||
iodev = self.iodevClass(ioname, srv.log.getChild(ioname), opts, srv)
|
||||
srv.modules[ioname] = iodev
|
||||
self.iodevDict[self.uri] = ioname
|
||||
self.setProperty('iodev', ioname)
|
||||
|
||||
def initModule(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user