Added logging system from v2 to v1

v1
Christiaan Goossens 7 years ago
parent 3aa8a67205
commit a8f32776b4

@ -7,7 +7,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="17f368cb-44f8-4101-9a29-49a0f4ff1f92" name="Default" comment="Update workspace">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java" />
</list>
<ignored path="simulator.iws" />
<ignored path=".idea/workspace.xml" />
@ -28,7 +32,71 @@
<favorites_list name="simulator" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf>
<file leaf-file-name="AOPDataWriter.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/AOPDataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="13" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="DataWriter.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="48" column="15" selection-start-line="48" selection-start-column="15" selection-end-line="48" selection-end-column="15" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="PosDataWriter.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/PosDataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="8" column="13" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Processor.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="222">
<caret line="142" column="13" selection-start-line="142" selection-start-column="13" selection-end-line="142" selection-end-column="13" />
<folding>
<element signature="method#writePos#0;class#Processor#0" expanded="false" />
<element signature="method#objectArrayToHashMap#0;class#Processor#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="SimulatorConfig.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="404">
<caret line="48" column="43" selection-start-line="48" selection-start-column="43" selection-end-line="48" selection-end-column="43" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="21" column="34" selection-start-line="21" selection-start-column="34" selection-end-line="21" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@ -67,23 +135,23 @@
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Processor.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/ProcessingException.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Node.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/ObjectProcessor.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AOP.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="-1928" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1056" />
<option name="x" value="-9" />
<option name="y" value="-9" />
<option name="width" value="1938" />
<option name="height" value="1051" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
@ -126,6 +194,9 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -244,9 +315,6 @@
</PATH>
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
@ -558,16 +626,18 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-1928" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="false" />
<frame x="-9" y="-9" width="1938" height="1051" extended-state="7" />
<editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.26451612" sideWeight="0.48333332" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.36997885" sideWeight="0.3609375" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.36989248" sideWeight="0.36614582" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.36989248" sideWeight="0.63385415" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@ -576,18 +646,16 @@
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39852008" sideWeight="0.49791667" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Nl-Palette" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Properties" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39852008" sideWeight="0.49791667" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.26451612" sideWeight="0.48333332" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Documentation" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="FLOATING" visible="false" show_stripe_button="true" weight="0.48125" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" x="1312" y="663" width="586" height="345" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.36997885" sideWeight="0.6390625" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32980973" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
</layout>
@ -618,21 +686,6 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="66">
<caret line="4" column="24" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="836">
@ -896,14 +949,7 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/ObjectProcessor.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="19" column="35" selection-start-line="19" selection-start-column="35" selection-end-line="23" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/ObjectProcessor.java" />
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/ProcessingException.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
@ -912,25 +958,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1989">
<caret line="126" column="5" selection-start-line="126" selection-start-column="5" selection-end-line="126" selection-end-column="5" />
<folding>
<element signature="method#write#0;class#Processor#0" expanded="false" />
<element signature="method#objectArrayToHashMap#0;class#Processor#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="441">
<caret line="137" column="65" selection-start-line="137" selection-start-column="20" selection-end-line="137" selection-end-column="65" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/WritingException.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
@ -939,14 +966,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="27" column="70" selection-start-line="27" selection-start-column="70" selection-end-line="27" selection-end-column="70" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Node.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
@ -984,10 +1003,53 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/PosDataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="8" column="13" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/processor/Processor.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="222">
<caret line="142" column="13" selection-start-line="142" selection-start-column="13" selection-end-line="142" selection-end-column="13" />
<folding>
<element signature="method#writePos#0;class#Processor#0" expanded="false" />
<element signature="method#objectArrayToHashMap#0;class#Processor#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-75">
<caret line="19" column="28" selection-start-line="19" selection-start-column="28" selection-end-line="19" selection-end-column="28" />
<state relative-caret-position="404">
<caret line="48" column="43" selection-start-line="48" selection-start-column="43" selection-end-line="48" selection-end-column="43" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="21" column="34" selection-start-line="21" selection-start-column="34" selection-end-line="21" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/AOPDataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="13" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="48" column="15" selection-start-line="48" selection-start-column="15" selection-end-line="48" selection-end-column="15" />
<folding />
</state>
</provider>

@ -19,6 +19,8 @@ public class Main {
* The full license is included in the git repository as LICENSE.md
*/
public static int version = 1;
public static void main(String[] args) {
/**
* Object definitions

@ -23,7 +23,7 @@ public class SimulatorConfig {
* Time settings
*/
public static int rounds = 1051896*500; // Amount of rounds to run the simulator for // 3000000 = 250.000 jaar
public static int rounds = 1051896*50; // Amount of rounds to run the simulator for // 3000000 = 250.000 jaar
public static double time = 30; // Time steps in seconds // 2592000 = 1 month
/**

@ -0,0 +1,35 @@
package com.verictas.pos.simulator.dataWriter;
import java.util.*;
public class AOPDataWriter extends DataWriter {
public AOPDataWriter() throws WritingException {
super("arguments");
try {
/**
* Write the lines with information about the columns
*/
this.writer.write("OBJECT" + DELIMITER + "ROUND" + DELIMITER + "ARGUMENT (RAD)" + NEW_LINE);
this.counter++;
} catch (Exception e) {
e.printStackTrace();
throw new WritingException("An error occurred while writing to the file!");
}
}
public void write(String object, TreeMap<Integer, Double> arguments) throws WritingException {
try {
for (Map.Entry<Integer, Double> entry : arguments.entrySet()) {
Integer key = entry.getKey();
Double value = entry.getValue();
this.writer.append(object + DELIMITER + key + DELIMITER + decimalFormatter(value) + NEW_LINE);
this.counter++;
}
} catch (Exception e) {
e.printStackTrace();
throw new WritingException("An error occurred while writing to the file!");
}
}
}

@ -1,30 +1,24 @@
package com.verictas.pos.simulator.dataWriter;
import com.verictas.pos.simulator.Object;
import com.verictas.pos.simulator.Simulator;
import com.verictas.pos.simulator.Main;
import com.verictas.pos.simulator.SimulatorConfig;
import com.verictas.pos.simulator.mathUtils.AU;
import com.verictas.pos.simulator.processor.ObjectProcessor;
import javax.vecmath.Vector3d;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.RoundingMode;
import java.text.*;
import java.util.Date;
import java.util.Locale;
public class DataWriter {
private FileWriter writer = null;
protected FileWriter writer = null;
/**
* Set global variables, such as the delimiter and the new line character
*/
private static final String DELIMITER = "\t";
private static final String NEW_LINE = "\n";
protected static final String DELIMITER = "\t";
protected static final String NEW_LINE = "\n";
private int counter = 0;
protected int counter = 0;
/**
* Decimal formatter
@ -36,7 +30,7 @@ public class DataWriter {
* Constructor
* @throws WritingException
*/
public DataWriter() throws WritingException {
public DataWriter(String filenameAppendix) throws WritingException {
/**
* Prepare the locale
@ -49,7 +43,7 @@ public class DataWriter {
String directory = System.getProperty("user.home") + File.separator + "simulatorExports";
File directoryPath = new File(directory);
String path = directory + File.separator + getCurrentTimeStamp() + ".txt";
String path = directory + File.separator + "v" + Main.version + "-" + getCurrentTimeStamp() + "-" + filenameAppendix + ".txt";
System.out.println("WRITING DATA TO: " + path);
/**
@ -64,18 +58,6 @@ public class DataWriter {
*/
this.writer = new FileWriter(path);
/**
* Write the lines with information about the columns
*/
if (SimulatorConfig.outputUnit.equals("AU")) {
this.writer.write("Object" + DELIMITER + "X (AU)" + DELIMITER + "Y (AU)" + DELIMITER + "Z (AU)" + DELIMITER + "VX (AU/day)" + DELIMITER + "VY (AU/day)" + DELIMITER + "VZ (AU/day)" + NEW_LINE);
} else {
this.writer.write("Object" + DELIMITER + "X (m)" + DELIMITER + "Y (m)" + DELIMITER + "Z (m)" + DELIMITER + "VX (m/s)" + DELIMITER + "VY (m/s)" + DELIMITER + "VZ (m/s)" + NEW_LINE);
}
this.counter++;
/**
* Configure the decimal formatter
*/
@ -118,39 +100,7 @@ public class DataWriter {
}
}
/**
*
* @param object The object you want to write data about
* @param reference The system's star
* @throws WritingException
*/
public void write(Object object, Object reference) throws WritingException {
String id = object.name;
Vector3d position = object.position;
Vector3d speed = object.speed;
Vector3d AUposition = AU.convertFromMeter(position);
Vector3d AUspeed = AU.convertFromMetersPerSecond(speed);
if (this.writer == null) {
throw new WritingException("The writer isn't defined yet");
} else {
try {
if (this.counter % SimulatorConfig.skipLines == 0) {
if (SimulatorConfig.outputUnit.equals("AU")) {
this.writer.append(id + DELIMITER + decimalFormatter(AUposition.getX()) + DELIMITER + decimalFormatter(AUposition.getY()) + DELIMITER + decimalFormatter(AUposition.getZ()) + DELIMITER + decimalFormatter(AUspeed.getX()) + DELIMITER + decimalFormatter(AUspeed.getY()) + DELIMITER + decimalFormatter(AUspeed.getZ()) + NEW_LINE);
} else {
this.writer.append(id + DELIMITER + decimalFormatter(position.getX()) + DELIMITER + decimalFormatter(position.getY()) + DELIMITER + decimalFormatter(position.getZ()) + DELIMITER + decimalFormatter(speed.getX()) + DELIMITER + decimalFormatter(speed.getY()) + DELIMITER + decimalFormatter(speed.getZ()) + NEW_LINE);
}
}
this.counter++;
} catch (Exception e) {
e.printStackTrace();
throw new WritingException("An error occurred while writing to the file!");
}
}
}
private String decimalFormatter(double input) {
protected String decimalFormatter(double input) {
return this.formatter.format(input);
}

@ -0,0 +1,61 @@
package com.verictas.pos.simulator.dataWriter;
import com.verictas.pos.simulator.Object;
import com.verictas.pos.simulator.SimulatorConfig;
import com.verictas.pos.simulator.mathUtils.AU;
import javax.vecmath.Vector3d;
public class PosDataWriter extends DataWriter {
public PosDataWriter() throws WritingException {
super("position");
try {
/**
* Write the lines with information about the columns
*/
if (SimulatorConfig.outputUnit.equals("AU")) {
this.writer.write("Object" + DELIMITER + "X (AU)" + DELIMITER + "Y (AU)" + DELIMITER + "Z (AU)" + DELIMITER + "VX (AU/day)" + DELIMITER + "VY (AU/day)" + DELIMITER + "VZ (AU/day)" + NEW_LINE);
} else {
this.writer.write("Object" + DELIMITER + "X (m)" + DELIMITER + "Y (m)" + DELIMITER + "Z (m)" + DELIMITER + "VX (m/s)" + DELIMITER + "VY (m/s)" + DELIMITER + "VZ (m/s)" + NEW_LINE);
}
this.counter++;
} catch (Exception e) {
e.printStackTrace();
throw new WritingException("An error occurred while writing to the file!");
}
}
/**
*
* @param object The object you want to write data about
* @throws WritingException
*/
public void write(Object object) throws WritingException {
String id = object.name;
Vector3d position = object.position;
Vector3d speed = object.speed;
Vector3d AUposition = AU.convertFromMeter(position);
Vector3d AUspeed = AU.convertFromMetersPerSecond(speed);
if (this.writer == null) {
throw new WritingException("The writer isn't defined yet");
} else {
try {
if (this.counter % SimulatorConfig.skipLines == 0) {
if (SimulatorConfig.outputUnit.equals("AU")) {
this.writer.append(id + DELIMITER + decimalFormatter(AUposition.getX()) + DELIMITER + decimalFormatter(AUposition.getY()) + DELIMITER + decimalFormatter(AUposition.getZ()) + DELIMITER + decimalFormatter(AUspeed.getX()) + DELIMITER + decimalFormatter(AUspeed.getY()) + DELIMITER + decimalFormatter(AUspeed.getZ()) + NEW_LINE);
} else {
this.writer.append(id + DELIMITER + decimalFormatter(position.getX()) + DELIMITER + decimalFormatter(position.getY()) + DELIMITER + decimalFormatter(position.getZ()) + DELIMITER + decimalFormatter(speed.getX()) + DELIMITER + decimalFormatter(speed.getY()) + DELIMITER + decimalFormatter(speed.getZ()) + NEW_LINE);
}
}
this.counter++;
} catch (Exception e) {
e.printStackTrace();
throw new WritingException("An error occurred while writing to the file!");
}
}
}
}

@ -3,25 +3,30 @@ package com.verictas.pos.simulator.processor;
import com.verictas.pos.simulator.Object;
import com.verictas.pos.simulator.Simulator;
import com.verictas.pos.simulator.SimulatorConfig;
import com.verictas.pos.simulator.dataWriter.AOPDataWriter;
import com.verictas.pos.simulator.dataWriter.DataWriter;
import com.verictas.pos.simulator.dataWriter.PosDataWriter;
import com.verictas.pos.simulator.dataWriter.WritingException;
import com.verictas.pos.simulator.mathUtils.AOP;
import com.verictas.pos.simulator.mathUtils.AU;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
public class Processor {
private DataWriter writer;
private PosDataWriter writer;
private AOPDataWriter aopWriter;
public HashMap<String, Object> initialObjectValues = new HashMap<>();
public HashMap<String, ObjectProcessor> objects = new HashMap<>();
public HashMap<String, ArrayList<Double>> arguments = new HashMap<>();
public HashMap<String, TreeMap<Integer, Double>> arguments = new HashMap<>();
public Processor(Object[] objects) throws ProcessingException, WritingException {
/**
* Initialize DataWriter
*/
this.writer = new DataWriter();
this.writer = new PosDataWriter();
this.aopWriter = new AOPDataWriter();
/**
* Store the initial values of all the objects in memory (and to a file) for later use
@ -29,7 +34,7 @@ public class Processor {
this.initialObjectValues = objectArrayToHashMap(objects);
// Write initial values to file
this.write(initialObjectValues);
this.writePos(initialObjectValues);
/**
* Create the object processing array
@ -117,11 +122,12 @@ public class Processor {
// Add the node to the list
if (arguments.get(objectName) == null) {
// If not defined
ArrayList<Double> agmnts = new ArrayList<>();
TreeMap<Integer, Double> agmnts = new TreeMap<>();
arguments.put(objectName, agmnts);
}
arguments.get(objectName).add(AOP.calculate(object.ascendingNode, object.perihelion, object.aphelion));
arguments.get(objectName).put(Simulator.round, AOP.calculate(object.ascendingNode, object.perihelion, object.aphelion));
}
} else {
@ -143,17 +149,17 @@ public class Processor {
this.objects.put(objectName, object);
}
this.write(objects);
this.writePos(objects);
}
private void write(HashMap<String, Object> objects) throws ProcessingException, WritingException {
private void writePos(HashMap<String, Object> objects) throws ProcessingException, WritingException {
if (SimulatorConfig.skipUnnecessary) {
for (String name : SimulatorConfig.objectNames) {
this.writer.write(objects.get(name), objects.get(SimulatorConfig.sunName));
this.writer.write(objects.get(name));
}
} else {
for (Object object : objects.values()) {
this.writer.write(object, objects.get(SimulatorConfig.sunName));
this.writer.write(object);
}
}
}
@ -172,30 +178,37 @@ public class Processor {
public void close() throws ProcessingException {
try {
this.writer.save();
System.out.println("");
for(String objectName : SimulatorConfig.objectNames) {
TreeMap<Integer, Double> arguments = this.arguments.get(objectName);
System.out.println("TOTAL RESULTS: " + arguments);
this.aopWriter.write(objectName, arguments);
for(String objectName : SimulatorConfig.objectNames) {
ArrayList<Double> arguments = this.arguments.get(objectName);
double score = 0;
Double[] empty = new Double[arguments.size()];
Double[] agmnts = arguments.values().toArray(empty);
// Calculate score
for(int i = 1; i < arguments.size() - 1; i++) {
score = score + Math.abs(arguments.get(i-1) - arguments.get(i));
for(int i = 1; i < agmnts.length - 1; i++) {
score = score + Math.abs(agmnts[i-1] - agmnts[i]);
}
System.out.println("SCORE (" + objectName + "): " + score);
// CALCULATE AVERAGE
double sum = 0;
for (int i = 0; i < arguments.size(); i++){
sum = sum + arguments.get(i);
for (int i = 0; i < agmnts.length; i++){
sum = sum + agmnts[i];
}
// calculate average
double average = sum / arguments.size();
double average = sum / agmnts.length;
System.out.println("AVERAGE (" + objectName + ") (degrees): " + Math.toDegrees(average));
System.out.println("");
}
this.aopWriter.save();
} catch(WritingException e) {
throw new ProcessingException("An error occurred during creation of the file writer: " + e.toString());
}

Loading…
Cancel
Save