Skip to content

Commit

Permalink
Merge branch 'development' into experimental
Browse files Browse the repository at this point in the history
* development:
  More details in report file saved
  • Loading branch information
pgleeson committed Jun 13, 2019
2 parents 5c6e123 + 1268c45 commit 5dd6991
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/org/lemsml/jlems/core/sim/Sim.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Sim extends LemsProcess {

EventManager eventManager;

public long initTime = -1;
public long simulationStartTime = -1;
public long simulationEndTime = -1;
public long simulationSaveTime = -1;
Expand All @@ -59,6 +60,7 @@ public class Sim extends LemsProcess {

public Sim(String srcStr) {
super(srcStr);
initTime = System.currentTimeMillis();
}

public Map<String, DataViewer> getDvHM() {
Expand Down Expand Up @@ -267,7 +269,6 @@ public void run(RunConfig rc, boolean flatten) throws ConnectionError, ContentEr
int nstep = (int) Math.round(rc.getRuntime() / dt);


simulationStartTime = System.currentTimeMillis();

double t = 0;
times = new double[nstep+1];
Expand All @@ -278,6 +279,7 @@ public void run(RunConfig rc, boolean flatten) throws ConnectionError, ContentEr
long realTimeStart = System.currentTimeMillis();
int nsDone = 0;

simulationStartTime = System.currentTimeMillis();
try{

for (int istep = 0; istep <= nstep; istep++) {
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/lemsml/jlems/io/IOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;

import org.lemsml.jlems.core.logging.E;
import org.lemsml.jlems.core.run.RuntimeError;
Expand All @@ -17,7 +18,7 @@
public class IOUtil {


public static void saveReportAndTimesFile(Sim sim) throws ContentError, RuntimeError
public static void saveReportAndTimesFile(Sim sim, File lemsFile) throws ContentError, RuntimeError
{

File reportFile = null;
Expand Down Expand Up @@ -46,12 +47,17 @@ public static void saveReportAndTimesFile(Sim sim) throws ContentError, RuntimeE
for(double time: sim.times) {
times.append((float)time+"\n");
}

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {

info.append("Simulator=jLEMS\n");
info.append("SimulatorVersion=" + org.lemsml.jlems.io.Main.VERSION + "\n");
info.append("SimulationFile=" + lemsFile.getAbsolutePath() + "\n");

info.append("StartTime=" + format.format(sim.initTime) + "\n");
info.append("SetupTime=" + ((sim.simulationStartTime - sim.initTime) / 1000.0) + "\n");
info.append("RealSimulationTime=" + ((sim.simulationEndTime - sim.simulationStartTime) / 1000.0) + "\n");
info.append("SimulationSaveTime=" + ((sim.simulationSaveTime - sim.simulationEndTime) / 1000.0) + "\n");
info.append("SimulatorVersion=" + org.lemsml.jlems.io.Main.VERSION + "\n");

if (reportFile != null) {
FileUtil.writeStringToFile(info.toString(), reportFile);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/lemsml/jlems/io/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void main(String[] argv) throws ConnectionError, ContentError, Run
E.info("Finished reading, building, running and displaying the LEMS model");
}

IOUtil.saveReportAndTimesFile(sim);
IOUtil.saveReportAndTimesFile(sim, simFile);

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/lemsml/jlems/viz/VizMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ public Sim importFile(File simFile) throws LEMSException {
E.info("Finished reading, building, running and displaying the LEMS model");
}

IOUtil.saveReportAndTimesFile(sim);
IOUtil.saveReportAndTimesFile(sim, simFile);
}
}

0 comments on commit 5dd6991

Please sign in to comment.