mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
More table support
This commit is contained in:
@@ -38,6 +38,8 @@ public class Robot extends TimedRobot {
|
||||
desmosServer = new DesmosServer(8000);
|
||||
desmosServer.start();
|
||||
DesmosServer.putInteger("Active", 1);
|
||||
|
||||
DesmosServer.putTable("test", "x1", new double[] {1, 2}, "y1", new double[] {1, 2});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,8 +49,12 @@
|
||||
break;
|
||||
case 'table':
|
||||
let cols = [];
|
||||
for(let col of variable['value'].split('\t')) {
|
||||
let latex = latexName(col[0]);
|
||||
for(let col of variable['value'].split('\s')) {
|
||||
col = col.split(',');
|
||||
let latexStr = latexName(col[0]);
|
||||
let valuesArr = col.slice(1, col.length);
|
||||
|
||||
cols.push({ latex: latexStr, values: valuesArr });
|
||||
}
|
||||
|
||||
calculator.setExpression({ type: 'table', id: variable['name'], columns: cols});
|
||||
|
||||
@@ -199,6 +199,28 @@ public class DesmosServer extends Thread {
|
||||
desmosVariables.put(name, new String[] {"array", Arrays.toString(arr).replace(" ", "")});
|
||||
}
|
||||
|
||||
public static void putTable(String name, Object... table) {
|
||||
// Check parameters
|
||||
for(int i = 0; i < table.length; i += 2)
|
||||
if(!(table[i] instanceof String)) { return; }
|
||||
|
||||
for(int i = 1; i < table.length; i += 2)
|
||||
if(!(table[i] instanceof double[])) { return; }
|
||||
|
||||
String tableStr = "";
|
||||
|
||||
for(int i = 0; i < table.length; i += 2) {
|
||||
tableStr += table[i] + ",";
|
||||
String values = Arrays.toString((double[]) table[i+1]).replace(" ", "");
|
||||
tableStr += values.substring(1, values.length() - 1);
|
||||
tableStr += " ";
|
||||
}
|
||||
|
||||
tableStr = tableStr.substring(0, tableStr.length()-1); // remove tab at the end
|
||||
|
||||
desmosVariables.put(name, new String[] {"table", tableStr});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
public static int readInteger(String name) {
|
||||
|
||||
Reference in New Issue
Block a user