core: move module handling out of dispatcher
Split module handling code from the dispatcher. The new class for managing Modules is called SecNode. * change logging to no longer need a reference to modobj * modules get a reference to the secnode obj instead of the dispatcher * intermediate usage fixes for frappy_psi/sea Change-Id: Ifee4bb47aa7a4508bb4a47c9a5873b7e2d5faf67 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32249 Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
@@ -57,11 +57,23 @@ class LoggerStub:
|
||||
logger = LoggerStub()
|
||||
|
||||
|
||||
class SecNodeStub:
|
||||
def __init__(self):
|
||||
self.modules = {}
|
||||
|
||||
def add_module(self, module, modname):
|
||||
self.modules[modname] = module
|
||||
|
||||
def get_module(self, modname):
|
||||
return self.modules[modname]
|
||||
|
||||
|
||||
class ServerStub:
|
||||
restart = None
|
||||
shutdown = None
|
||||
|
||||
def __init__(self):
|
||||
self.secnode = SecNodeStub()
|
||||
self.dispatcher = Dispatcher('dispatcher', logger, {}, self)
|
||||
|
||||
|
||||
@@ -73,6 +85,6 @@ def test_attach():
|
||||
a = Module('a', logger, {'description': ''}, srv)
|
||||
m = Mod('m', logger, {'description': '', 'att': 'a'}, srv)
|
||||
assert m.propertyValues['att'] == 'a'
|
||||
srv.dispatcher.register_module(a, 'a')
|
||||
srv.dispatcher.register_module(m, 'm')
|
||||
srv.secnode.add_module(a, 'a')
|
||||
srv.secnode.add_module(m, 'm')
|
||||
assert m.att == a
|
||||
|
||||
@@ -58,6 +58,7 @@ logger = LoggerStub()
|
||||
class ServerStub:
|
||||
def __init__(self, updates):
|
||||
self.dispatcher = DispatcherStub(updates)
|
||||
self.secnode = None
|
||||
|
||||
|
||||
class ModuleTest(Module):
|
||||
|
||||
@@ -29,11 +29,24 @@ import frappy.logging
|
||||
from frappy.logging import logger, generalConfig, HasComlog
|
||||
|
||||
|
||||
class SecNodeStub:
|
||||
def __init__(self):
|
||||
self.modules = {}
|
||||
self.name = ""
|
||||
|
||||
def add_module(self, module, modname):
|
||||
self.modules[modname] = module
|
||||
|
||||
def get_module(self, modname):
|
||||
return self.modules[modname]
|
||||
|
||||
|
||||
class ServerStub:
|
||||
restart = None
|
||||
shutdown = None
|
||||
|
||||
def __init__(self):
|
||||
self.secnode = SecNodeStub()
|
||||
self.dispatcher = Dispatcher('', logger.log.getChild('dispatcher'), {}, self)
|
||||
|
||||
|
||||
@@ -98,7 +111,7 @@ def init_(monkeypatch):
|
||||
def __init__(self, name, srv, **kwds):
|
||||
kwds['description'] = ''
|
||||
super().__init__(name or 'mod', logger.log.getChild(name), kwds, srv)
|
||||
srv.dispatcher.register_module(self, name, name)
|
||||
srv.secnode.add_module(self, name)
|
||||
self.result[:] = []
|
||||
|
||||
def earlyInit(self):
|
||||
|
||||
@@ -65,6 +65,7 @@ logger = LoggerStub()
|
||||
class ServerStub:
|
||||
def __init__(self, updates):
|
||||
self.dispatcher = DispatcherStub(updates)
|
||||
self.secnode = None
|
||||
|
||||
|
||||
class DummyMultiEvent(threading.Event):
|
||||
@@ -712,6 +713,7 @@ def test_super_call():
|
||||
class ServerStub1:
|
||||
def __init__(self, updates):
|
||||
self.dispatcher = DispatcherStub1(updates)
|
||||
self.secnode = None
|
||||
|
||||
updates = []
|
||||
srv = ServerStub1(updates)
|
||||
|
||||
@@ -30,6 +30,10 @@ from frappy.lib import generalConfig
|
||||
from frappy.persistent import PersistentParam, PersistentMixin
|
||||
|
||||
|
||||
class SecNodeStub:
|
||||
pass
|
||||
|
||||
|
||||
class DispatcherStub:
|
||||
def announce_update(self, modulename, pname, pobj):
|
||||
pass
|
||||
@@ -48,7 +52,8 @@ logger = LoggerStub()
|
||||
class ServerStub:
|
||||
def __init__(self, equipment_id):
|
||||
self.dispatcher = DispatcherStub()
|
||||
self.dispatcher.equipment_id = equipment_id
|
||||
self.secnode = SecNodeStub()
|
||||
self.secnode.equipment_id = equipment_id
|
||||
|
||||
|
||||
class Mod(PersistentMixin, Module):
|
||||
|
||||
@@ -69,6 +69,7 @@ class ServerStub:
|
||||
def __init__(self):
|
||||
generalConfig.testinit()
|
||||
self.dispatcher = DispatcherStub()
|
||||
self.secnode = None
|
||||
|
||||
|
||||
class Base(Module):
|
||||
|
||||
@@ -206,6 +206,7 @@ class DispatcherStub:
|
||||
class ServerStub:
|
||||
def __init__(self, updates):
|
||||
self.dispatcher = DispatcherStub(updates)
|
||||
self.secnode = None
|
||||
|
||||
|
||||
class Mod(HasStates, Drivable):
|
||||
|
||||
Reference in New Issue
Block a user