forked from M-Labs/artiq
qui/models: add LocalModelManager
This commit is contained in:
parent
826d529756
commit
4edfd6caa4
|
@ -3,9 +3,8 @@ from PyQt5 import QtCore
|
|||
from artiq.protocols.sync_struct import Subscriber
|
||||
|
||||
|
||||
class ModelSubscriber(Subscriber):
|
||||
def __init__(self, notifier_name, model_factory):
|
||||
Subscriber.__init__(self, notifier_name, self._create_model)
|
||||
class ModelManager:
|
||||
def __init__(self, model_factory):
|
||||
self.model = None
|
||||
self._model_factory = model_factory
|
||||
self._setmodel_callbacks = []
|
||||
|
@ -22,6 +21,24 @@ class ModelSubscriber(Subscriber):
|
|||
cb(self.model)
|
||||
|
||||
|
||||
class ModelSubscriber(ModelManager, Subscriber):
|
||||
def __init__(self, notifier_name, model_factory):
|
||||
ModelManager.__init__(self, model_factory)
|
||||
Subscriber.__init__(self, notifier_name, self._create_model)
|
||||
|
||||
|
||||
class LocalModelManager(ModelManager):
|
||||
def __init__(self, model_factory):
|
||||
ModelManager.__init__(self, model_factory)
|
||||
self.notify_cbs = []
|
||||
|
||||
def init(self, struct):
|
||||
self._create_model(struct)
|
||||
mod = {"action": "init", "struct": struct}
|
||||
for notify_cb in self.notify_cbs:
|
||||
notify_cb(mod)
|
||||
|
||||
|
||||
class _SyncSubstruct:
|
||||
def __init__(self, update_cb, ref):
|
||||
self.update_cb = update_cb
|
||||
|
|
Loading…
Reference in New Issue