Reset network tables on camera rename

This commit is contained in:
Matt
2019-11-30 11:02:10 -08:00
parent 806c8d6968
commit 60721cac36
2 changed files with 9 additions and 1 deletions

View File

@@ -91,6 +91,13 @@ public class VisionProcess {
initNT(newTable);
}
public void setCameraName(String newName) {
var newTable = NetworkTableInstance.getDefault().getTable("/chameleon-vision/" + newName);
resetNT(newTable);
pipelineManager.renameCurrentPipeline(newName);
pipelineManager.ntIndexEntry = ntPipelineEntry;
}
private void initNT(NetworkTable newTable) {
ntPipelineEntry = newTable.getEntry("pipeline");
ntDriverModeEntry = newTable.getEntry("driver_mode");

View File

@@ -10,6 +10,7 @@ import com.chameleonvision.vision.pipeline.CVPipelineSettings;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.wpi.first.networktables.NetworkTable;
import io.javalin.websocket.WsBinaryMessageContext;
import io.javalin.websocket.WsCloseContext;
import io.javalin.websocket.WsConnectContext;
@@ -71,7 +72,7 @@ public class SocketHandler {
break;
}
case "changePipelineName": {
currentProcess.pipelineManager.renameCurrentPipeline((String) entry.getValue());
currentProcess.setCameraName((String) entry.getValue());
sendFullSettings();
VisionManager.saveCurrentCameraPipelines();
break;