mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user