Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
package com.neuronrobotics.graphing;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import com.neuronrobotics.sdk.common.SDKInfo;
public class CSVWriter {
private CSVWriter() {
}
public static void WriteToCSV(ArrayList<GraphDataElement> dataTable, String filename) {
String out = "";
synchronized(dataTable){
for(int j =0;j< dataTable.size();j++) {
out+=dataTable.get(j).getTimestamp();
for (int i=0;i<dataTable.get(j).getData().length;i++) {
out+=","+dataTable.get(j).getData()[i];
}
out+="\r\n";
}
}
try{
// Create file
FileWriter fstream = new FileWriter(filename);
BufferedWriter outPut = new BufferedWriter(fstream);
outPut.write(out);
//Close the output stream
outPut.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
File dir1 = new File (".");
try {
String dir;
if(SDKInfo.isWindows)
dir=dir1.getCanonicalPath()+"\\";
else
dir=dir1.getCanonicalPath()+"/";
JOptionPane.showMessageDialog(null, "Saved data to file: "+dir+filename, "PID Save", JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
}
}
}