Fix PSC causing lag via selective update broadcasting (#28)

* Fix PSC causing lag via selective update broadcasting

* add logging, update key

* Fix current pipeline setting selective send

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
Banks T
2020-07-17 01:37:18 -04:00
committed by GitHub
parent 53783d88d7
commit bac09bf430
3 changed files with 19 additions and 5 deletions

View File

@@ -30,8 +30,11 @@ public class OutgoingUIEvent<T> extends DataChangeEvent<T> {
this.updateType = updateType;
}
@SuppressWarnings("unchecked")
public OutgoingUIEvent(UIUpdateType updateType, String dataKey, HashMap<String, Object> data) {
this(updateType, dataKey, (T) data.get(dataKey));
public static OutgoingUIEvent<HashMap<String, Object>> wrappedOf(
UIUpdateType uiUpdateType, String commandName, String propertyName, Object value) {
HashMap<String, Object> data = new HashMap<>();
data.put(propertyName, value);
return new OutgoingUIEvent<>(uiUpdateType, commandName, data);
}
}

View File

@@ -284,8 +284,8 @@ public class VisionModule {
logger.error("Unknown exception when setting PSC prop!");
e.printStackTrace();
}
saveAndBroadcast(propName, newPropValue);
}
saveAndBroadcast();
}
}
}
@@ -320,6 +320,17 @@ public class VisionModule {
ConfigManager.getInstance().getConfig().toHashMap()));
}
private void saveAndBroadcast(String propertyName, Object value) {
logger.trace("Broadcasting PSC mutation - " + propertyName + ": " + value);
ConfigManager.getInstance()
.saveModule(
getStateAsCameraConfig(), visionSource.getSettables().getConfiguration().uniqueName);
DataChangeService.getInstance()
.publishEvent(
OutgoingUIEvent.wrappedOf(
UIUpdateType.BROADCAST, "mutatePipeline", propertyName, value));
}
private void setCameraNickname(String newName) {
visionSource.getSettables().getConfiguration().nickname = newName;
ntConsumer.updateCameraNickname(newName);