mirror of
https://github.com/davidalves04/Trabalho-Pratico-SD.git
synced 2025-12-08 20:43:32 +00:00
added bike//heavy prob & cross time
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user