diff --git a/simulator/.idea/workspace.xml b/simulator/.idea/workspace.xml index c8b3271..19765a5 100644 --- a/simulator/.idea/workspace.xml +++ b/simulator/.idea/workspace.xml @@ -7,10 +7,8 @@ - - - + @@ -35,7 +33,7 @@ - + @@ -44,11 +42,11 @@ - + - - + + @@ -56,16 +54,49 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -104,8 +135,8 @@ diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class b/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class index fee996d..2e53d9e 100644 Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class differ diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class b/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class index 3a0a16f..753140b 100644 Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class differ diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class b/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class index 5a68c96..291bae4 100644 Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class differ diff --git a/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java b/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java index c312933..dae1dd5 100644 --- a/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java +++ b/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java @@ -1,6 +1,10 @@ package com.verictas.pos.simulator; public class SimulatorConfig { + // The amount of rounds and the time step public static int rounds = 525960; public static double time = 60; // in seconds + + // Set the skipLines integer to skip lines (for example: every 5th line is written) in the output file (for smaller files), if this is set to 1, it has no effect and all lines will be written. + public static int skipLines = 5; } diff --git a/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java b/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java index 07b352d..f1798dd 100644 --- a/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java +++ b/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java @@ -1,5 +1,6 @@ package com.verictas.pos.simulator.dataWriter; +import com.verictas.pos.simulator.SimulatorConfig; import com.verictas.pos.simulator.mathUtils.AU; import javax.vecmath.Vector3d; @@ -16,6 +17,8 @@ public class DataWriter { private static final String DELIMITER = "\t"; private static final String NEW_LINE = "\n"; + private int counter = 0; + public DataWriter() throws WritingException { try { // Define the save path @@ -30,11 +33,12 @@ public class DataWriter { } this.writer = new FileWriter(path); - this.writer.write("Object" + DELIMITER + "Position (m)" + DELIMITER + "Position (AU)" + DELIMITER + "Speed (m)" + DELIMITER + "Speed (AU)" + DELIMITER + "Old Acceleration" + DELIMITER + "Acceleration" + DELIMITER + "Mass" + NEW_LINE); + this.writer.write("Object" + DELIMITER + "Position (m)" + DELIMITER + "Position (AU)" + DELIMITER + "Speed (m/s)" + DELIMITER + "Speed (AU/day)" + DELIMITER + "Old Acceleration" + DELIMITER + "Acceleration" + DELIMITER + "Mass" + NEW_LINE); + this.counter++; } catch(IOException e) { - throw new WritingException("Whoop! Creation error!"); + throw new WritingException("The destination file couldn't be created."); } catch(Exception e) { - throw new WritingException("Whoop! Unknown creation error!"); + throw new WritingException("Some unknown error occurred while writing to the file!"); } } @@ -43,9 +47,13 @@ public class DataWriter { throw new WritingException("The writer isn't defined yet"); } else { try { - this.writer.append(string); + if (this.counter % SimulatorConfig.skipLines == 0) { + this.writer.append(string); + } + this.counter++; } catch (Exception e) { - throw new WritingException("Whoop! Write error!"); + e.printStackTrace(); + throw new WritingException("An error occurred while writing to the file!"); } } } @@ -55,10 +63,13 @@ public class DataWriter { throw new WritingException("The writer isn't defined yet"); } else { try { - this.writer.append(id + DELIMITER + position.toString() + DELIMITER + AU.convertFromMeter(position).toString() + DELIMITER + speed.toString() + DELIMITER + AU.convertFromMetersPerSecond(speed).toString() + DELIMITER + oldAcceleration.toString() + DELIMITER + acceleration.toString() + DELIMITER + String.valueOf(mass) + NEW_LINE); + if (this.counter % SimulatorConfig.skipLines == 0) { + this.writer.append(id + DELIMITER + position.toString() + DELIMITER + AU.convertFromMeter(position).toString() + DELIMITER + speed.toString() + DELIMITER + AU.convertFromMetersPerSecond(speed).toString() + DELIMITER + oldAcceleration.toString() + DELIMITER + acceleration.toString() + DELIMITER + String.valueOf(mass) + NEW_LINE); + } + this.counter++; } catch (Exception e) { e.printStackTrace(); - throw new WritingException("Whoop! Write error!"); + throw new WritingException("An error occurred while writing to the file!"); } } } @@ -76,6 +87,10 @@ public class DataWriter { } } + public int getLines() { + return this.counter; + } + public String getCurrentTimeStamp() { return new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date()); }