Enhance DaliGatewayCache: add support for multiple status update callbacks
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -30,15 +30,19 @@ int main() {
|
||||
});
|
||||
|
||||
int status_updates = 0;
|
||||
int observer_updates = 0;
|
||||
DaliGatewayStatusUpdate last_update;
|
||||
cache.setStatusUpdateCallback([&](const DaliGatewayStatusUpdate& update) {
|
||||
++status_updates;
|
||||
last_update = update;
|
||||
});
|
||||
cache.addStatusUpdateCallback(
|
||||
[&](const DaliGatewayStatusUpdate&) { ++observer_updates; });
|
||||
|
||||
assert(cache.setGroupMask(7, 4, 0x0001));
|
||||
assert(cache.mirrorForwardFrame(7, 0x80, 42));
|
||||
assert(status_updates == 1);
|
||||
assert(observer_updates == status_updates);
|
||||
assert(last_update.channel == 7);
|
||||
assert(last_update.target.kind == DaliGatewayTargetKind::group);
|
||||
assert(last_update.target.value == 0);
|
||||
@@ -47,6 +51,12 @@ int main() {
|
||||
assert(cache.groupStatus(7, 0).actualLevel == 42);
|
||||
assert(cache.addressState(7, 4).status.actualLevel == 42);
|
||||
|
||||
// Replacing the owning callback must not remove additive adapter observers.
|
||||
cache.setStatusUpdateCallback({});
|
||||
assert(cache.setActualLevel(7, 4, 43));
|
||||
assert(status_updates == 1);
|
||||
assert(observer_updates == 2);
|
||||
|
||||
// The command-state cache tracks DTR-dependent settings and applies a
|
||||
// broadcast command to every state known by the adapter.
|
||||
cache.mirrorForwardFrame(7, 0xA3, 12);
|
||||
|
||||
Reference in New Issue
Block a user