From eb6e25106ed2f6a931f9cfcf73759f4b0c5abcda Mon Sep 17 00:00:00 2001 From: Wilhelm Date: Thu, 12 Apr 2018 21:38:52 +0200 Subject: [PATCH] Limit the SerialPlotter to max 20 graphs --- app/src/processing/app/SerialPlotter.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/processing/app/SerialPlotter.java b/app/src/processing/app/SerialPlotter.java index 035005ac362..2ac976c083e 100644 --- a/app/src/processing/app/SerialPlotter.java +++ b/app/src/processing/app/SerialPlotter.java @@ -51,6 +51,7 @@ public class SerialPlotter extends AbstractMonitor { private ArrayList graphs; private final static int BUFFER_CAPACITY = 500; + private final static int MAX_GRAPH_COUNT = 20; private static class Graph { public CircularBuffer buffer; @@ -412,18 +413,18 @@ public void message(final String s) { int validParts = 0; int validLabels = 0; - for(int i = 0; i < parts.length; ++i) { + for(int i = 0; i < parts.length && validParts < MAX_GRAPH_COUNT; ++i) { Double value = null; String label = null; - + // column formated name value pair if(parts[i].contains(":")) { // get label String[] subString = parts[i].split("[:]+"); - + if(subString.length > 0) { int labelLength = subString[0].length(); - + if(labelLength > 32) { labelLength = 32; } @@ -431,7 +432,7 @@ public void message(final String s) { } else { label = ""; } - + if(subString.length > 1) { parts[i] = subString[1]; } else { @@ -448,7 +449,7 @@ public void message(final String s) { if(label == null && value == null) { label = parts[i]; } - + if(value != null) { if(validParts >= graphs.size()) { graphs.add(new Graph(validParts));