From d41973d27fdf286985bad0f460a351b4f8da1a30 Mon Sep 17 00:00:00 2001 From: Leandro Afonso Date: Tue, 21 Oct 2025 11:19:40 +0100 Subject: [PATCH] added bike//heavy prob & cross time --- .../main/java/sd/config/SimulationConfig.java | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/main/src/main/java/sd/config/SimulationConfig.java b/main/src/main/java/sd/config/SimulationConfig.java index b2100b1..153f9e4 100644 --- a/main/src/main/java/sd/config/SimulationConfig.java +++ b/main/src/main/java/sd/config/SimulationConfig.java @@ -11,90 +11,102 @@ import java.util.Properties; */ public class SimulationConfig { private final Properties properties; - + public SimulationConfig(String filePath) throws IOException { properties = new Properties(); try (InputStream input = new FileInputStream(filePath)) { properties.load(input); } } - + // Network configurations public String getIntersectionHost(String intersectionId) { return properties.getProperty("intersection." + intersectionId + ".host", "localhost"); } - + public int getIntersectionPort(String intersectionId) { return Integer.parseInt(properties.getProperty("intersection." + intersectionId + ".port", "0")); } - + public String getDashboardHost() { return properties.getProperty("dashboard.host", "localhost"); } - + public int getDashboardPort() { return Integer.parseInt(properties.getProperty("dashboard.port", "9000")); } - + public String getExitHost() { return properties.getProperty("exit.host", "localhost"); } - + public int getExitPort() { return Integer.parseInt(properties.getProperty("exit.port", "9001")); } - + // Simulation configurations public double getSimulationDuration() { return Double.parseDouble(properties.getProperty("simulation.duration", "3600.0")); } - + public String getArrivalModel() { return properties.getProperty("simulation.arrival.model", "POISSON"); } - + public double getArrivalRate() { return Double.parseDouble(properties.getProperty("simulation.arrival.rate", "0.5")); } - + public double getFixedArrivalInterval() { return Double.parseDouble(properties.getProperty("simulation.arrival.fixed.interval", "2.0")); } - + // Traffic light configurations public double getTrafficLightGreenTime(String intersectionId, String direction) { String key = "trafficlight." + intersectionId + "." + direction + ".green"; return Double.parseDouble(properties.getProperty(key, "30.0")); } - + public double getTrafficLightRedTime(String intersectionId, String direction) { String key = "trafficlight." + intersectionId + "." + direction + ".red"; return Double.parseDouble(properties.getProperty(key, "30.0")); } - + // Vehicle configurations public double getLightVehicleProbability() { return Double.parseDouble(properties.getProperty("vehicle.probability.light", "0.7")); } - + public double getLightVehicleCrossingTime() { return Double.parseDouble(properties.getProperty("vehicle.crossing.time.light", "2.0")); } - + + public double getBikeVehicleProbability() { + return Double.parseDouble(properties.getProperty("vehicle.probability.bike", "0.0")); + } + + public double getBikeVehicleCrossingTime() { + return Double.parseDouble(properties.getProperty("vehicle.crossing.time.bike", "1.5")); + } + + public double getHeavyVehicleProbability() { + return Double.parseDouble(properties.getProperty("vehicle.probability.heavy", "0.0")); + } + public double getHeavyVehicleCrossingTime() { return Double.parseDouble(properties.getProperty("vehicle.crossing.time.heavy", "4.0")); } - + // Statistics public double getStatisticsUpdateInterval() { return Double.parseDouble(properties.getProperty("statistics.update.interval", "10.0")); } - + // Generic method to get any property public String getProperty(String key, String defaultValue) { return properties.getProperty(key, defaultValue); } - + public String getProperty(String key) { return properties.getProperty(key); }