1 19 20 package org.polepos.reporters; 21 22 import java.io.*; 23 24 import org.polepos.framework.*; 25 26 27 public class CSVReporter extends GraphReporter { 28 29 private final static String TAB = "\t"; 30 private final static String FOLDER = "doc/results"; 31 32 protected void report(Graph graph){ 33 new File(FOLDER).mkdirs(); 34 35 String fileName = FOLDER + "/" + graph.circuit().name() + "_" + graph.lap().name() + ".f1graph"; 36 new File(fileName).delete(); 37 38 PrintStream ps = null; 39 try { 40 ps = new PrintStream( new FileOutputStream( new File(fileName), false)); 41 } catch (FileNotFoundException e) { 42 e.printStackTrace(); 43 } 44 45 ps.print(graph.circuit().name()); 46 ps.print(" "); 47 ps.print(graph.lap().name()); 48 renderTableHeader(graph, ps); 49 renderTableBody(graph, ps); 50 51 ps.flush(); 52 ps.close(); 53 } 54 55 private void renderTableHeader(Graph graph, PrintStream ps) { 56 for(TurnSetup setup : graph.setups()) { 57 ps.print(TAB); 58 boolean first = true; 59 for(SetupProperty sp : setup.properties()){ 60 if(! first){ 61 ps.print(" "); 62 } 63 ps.print(sp.name()); 64 ps.print(":"); 65 ps.print(sp.value()); 66 first = false; 67 } 68 } 69 ps.println(); 70 } 71 72 private void renderTableBody(Graph graph, PrintStream ps) { 73 for(TeamCar teamCar : graph.teamCars()) { 74 ps.print(teamCar); 75 for(TurnSetup setup : graph.setups()) { 76 ps.print(TAB); 77 ps.print(graph.timeFor(teamCar,setup)); 78 } 79 ps.println(); 80 } 81 } 82 83 protected void finish() { 84 } 85 86 } 87 | Popular Tags |