Commit f54c4059 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

application no longer crash if the commithash.txt is not placed in...

application no longer crash if the commithash.txt is not placed in VadereSimulator/resources, add test that checks if the commithash is placed in VadereSimulator/resources, add missing output folder in testResources, add git hooks to the Documentation folder
parent cc7e34d7
Copy files "post-checkout", "post-merge", "post-applypatch" and "post-commit" to .git/hooks/
The file "current_commit_hash.txt" will be created after a change to the current commit status. To create this file without changes to the current commit, you can choose "Switch/Checkout..." on the Repository folder.
\ No newline at end of file
#!/bin/sh
exec git log -1 --format=format:"%H" > VadereSimulatio/resources/current_commit_hash.txt
\ No newline at end of file
#!/bin/sh
exec version-control/git-hook-vadere-software
\ No newline at end of file
#!/bin/sh
exec version-control/git-hook-vadere-software
\ No newline at end of file
#!/bin/sh
exec version-control/git-hook-vadere-software
\ No newline at end of file
#!/bin/sh
exec version-control/git-hook-vadere-software
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.vadere.state.scenario.Topography;
import org.vadere.util.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
......@@ -38,17 +39,61 @@ public class HashGenerator {
return hash;
}
public static boolean isCommitHashAvailable() {
InputStream in = HashGenerator.class.getResourceAsStream("/current_commit_hash.txt");
boolean result = in != null;
if(result) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public static String commitHash() {
Scanner scanner = new Scanner(HashGenerator.class.getResourceAsStream("/current_commit_hash.txt"));
String commithash = scanner.next();
scanner.close();
InputStream in = HashGenerator.class.getResourceAsStream("/current_commit_hash.txt");
String commithash = "";
if(in != null) {
Scanner scanner = new Scanner(HashGenerator.class.getResourceAsStream("/current_commit_hash.txt"));
if(scanner.hasNext()) {
commithash = scanner.next();
}
else {
logger.warn("no commit hash in resource.");
}
scanner.close();
}
else {
commithash = "warning: no commit hash";
logger.warn("no commit hash. This will cause the scenario output file to be not uniquely assignable to a software version.");
}
return commithash;
}
public static String releaseNumber() {
Scanner scanner = new Scanner(HashGenerator.class.getResourceAsStream("/current_release_number.txt"));
String releaseNumber = scanner.next();
scanner.close();
InputStream in = HashGenerator.class.getResourceAsStream("/current_release_number.txt");
String releaseNumber = "";
if(in != null) {
Scanner scanner = new Scanner(HashGenerator.class.getResourceAsStream("/current_release_number.txt"));
releaseNumber = scanner.next();
if(scanner.hasNext()) {
releaseNumber = scanner.next();
}
else {
logger.warn("no release number in resource.");
}
scanner.close();
}
else {
releaseNumber = "warning: no release number";
logger.warn("no release number. This will cause the project files to be not uniquely assignable to a software release version.");
}
return releaseNumber;
}
......
{
"topographyhash": "4cd0fdc685fc51e4ae57d0514b3d325d4f2e1340",
"name": "Test1",
"processWriters": [],
"attributeshash": "af732ad440af7f01cd0cc12608657058fd55f8a8",
"vadere": {
"attributesModel": {
"OPTIMAL_STEPS_MODEL": {
"stepCircleResolution": 18.0,
"numberOfCircles": 1.0,
"varyStepDirection": false,
"stepLengthIntercept": 0.4625,
"stepLengthSlopeSpeed": 0.2345,
"stepLengthSD": 0.036,
"movementThreshold": 0.0,
"optimizationType": "DISCRETE",
"movementType": "ARBITRARY",
"dynamicStepLength": false,
"updateType": "EVENT_DRIVEN",
"seeSmallWalls": false
},
"FLOORFIELD": {
"createMethod": "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution": 0.1,
"obstacleGridPenalty": 0.1,
"targetAttractionStrength": 1.0,
"timeCostAttributes": {
"standardDerivation": 0.7,
"pedestrianTorso": 0.4,
"meanSpeed": 1.34,
"type": "UNIT",
"obstacleDensityWeight": 3.5,
"pedestrianSameTargetDensityWeight": 3.5,
"pedestrianOtherTargetDensityWeight": 3.5,
"pedestrianWeight": 3.5,
"queueWidthLoading": 1.0,
"pedestrianDynamicWeight": 6.0,
"loadingType": "CONSTANT"
}
},
"POTENTIAL_COMPACT_SUPPORT": {
"pedPotentialWidth": 0.5,
"pedPotentialHeight": 12.6,
"obstPotentialWidth": 0.25,
"obstPotentialHeight": 20.1,
"visionFieldAngle": 1.8849555921538759,
"visionFieldRadius": 5.0,
"numPedConsidered": 5.0
}
},
"attributesPedestrian": {
"radius": 0.195,
"densityDependentSpeed": false,
"speedDistributionMean": 1.34,
"speedDistributionStandardDeviation": 0.0,
"minimumSpeed": 0.3,
"maximumSpeed": 3.0,
"acceleration": 2.0,
"id": -1
},
"attributesSimulation": {
"simTimeStepLength": 0.4,
"realTimeSimTimeRatio": 0.1,
"writeSimulationData": true,
"visualizationEnabled": true,
"printFPS": false,
"needsBoundary": false,
"digitsPerCoordinate": 2,
"useRandomSeed": true,
"randomSeed": 1
},
"topography": {
"attributes": {
"finishTime": 60.0,
"bounds": {
"x": 0.0,
"y": 0.0,
"width": 10.0,
"height": 10.0
},
"boundingBoxWidth": 0.5,
"bounded": true
},
"obstacles": [
{
"shape": {
"x": 3.9,
"y": 8.0,
"width": 2.2,
"height": 1.1,
"type": "RECTANGLE"
},
"id": -1
},
{
"shape": {
"type": "POLYGON",
"points": [
{
"x": -1.0E-4,
"y": 0.5001
},
{
"x": -1.0E-4,
"y": -1.0E-4
},
{
"x": 10.0001,
"y": -1.0E-4
},
{
"x": 10.0001,
"y": 0.5001
}
]
},
"id": -1
},
{
"shape": {
"type": "POLYGON",
"points": [
{
"x": 9.4999,
"y": -1.0E-4
},
{
"x": 10.0001,
"y": -1.0E-4
},
{
"x": 10.0001,
"y": 10.0001
},
{
"x": 9.4999,
"y": 10.0001
}
]
},
"id": -1
},
{
"shape": {
"type": "POLYGON",
"points": [
{
"x": 10.0001,
"y": 9.4999
},
{
"x": 10.0001,
"y": 10.0001
},
{
"x": -1.0E-4,
"y": 10.0001
},
{
"x": -1.0E-4,
"y": 9.4999
}
]
},
"id": -1
},
{
"shape": {
"type": "POLYGON",
"points": [
{
"x": 0.5001,
"y": 10.0001
},
{
"x": -1.0E-4,
"y": 10.0001
},
{
"x": -1.0E-4,
"y": -1.0E-4
},
{
"x": 0.5001,
"y": -1.0E-4
}
]
},
"id": -1
}
],
"stairs": [],
"targets": [
{
"id": 1,
"absorbing": true,
"shape": {
"x": 8.0,
"y": 1.0,
"width": 1.0,
"height": 1.0,
"type": "RECTANGLE"
},
"waitingTime": 0.0,
"parallelWaiters": 0
}
],
"sources": [
{
"id": 2,
"shape": {
"x": 1.0,
"y": 8.0,
"width": 1.0,
"height": 1.0,
"type": "RECTANGLE"
},
"spawnDelay": 1.0,
"spawnNumber": 1,
"startTime": 0.0,
"endTime": 40.0,
"spawnAtRandomPositions": false,
"useFreeSpaceOnly": false,
"targetIds": [
1
]
}
],
"dynamicElements": [],
"pedestrians": []
}
},
"commithash": "c45f1d26328baaec22418c15e6351a059e910f5f"
}
package org.vadere.simulator.io;
import org.junit.Test;
import org.vadere.simulator.projects.io.HashGenerator;
import static org.junit.Assert.assertTrue;
public class TestHashGenerator {
@Test
public void testIsCommitHashFileInstalled() {
assertTrue("missing commit hash file", HashGenerator.isCommitHashAvailable());
}
}
......@@ -3,6 +3,7 @@ package org.vadere.simulator.io;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.simulator.projects.io.JsonSerializerTopography;
import org.vadere.state.attributes.scenario.AttributesObstacle;
import org.vadere.state.attributes.scenario.AttributesTeleporter;
......@@ -13,13 +14,15 @@ import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.io.IOUtils;
import com.google.gson.JsonElement;
import com.fasterxml.jackson.core.JsonProcessingException;
public class TestScenarioToJson {
private static final AttributesTopography attributesTopography = new AttributesTopography();
private static final String scenarioJson = "{\"attributes\":{\"finishTime\":500.0"
+ ",\"bounds\":{"
private static final String scenarioJson = "{\"attributes\":{\"bounds\":{"
+ "\"x\":" + attributesTopography.getBounds().getX()
+ ",\"y\":" + attributesTopography.getBounds().getY()
+ ",\"width\":" + attributesTopography.getBounds().getWidth()
......@@ -48,12 +51,11 @@ public class TestScenarioToJson {
}
@Test
public void testScenarioToJson() {
/*
* JsonElement jsonElement = JsonSerializerTopography.topographyToJson(scenario);
* String actualJson = IOUtils.toJson(jsonElement);
* Assert.assertEquals("Scenario json is not correct.", scenarioJson, actualJson);
*/
public void testScenarioToJson() throws JsonProcessingException {
/* String jsonString = JsonConverter.serializeTopography(scenario);
Assert.assertEquals("Scenario json is not correct.", scenarioJson, jsonString);
*/
}
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment