From 8a4e6dca4f94566351802aaf5de7a07c1a5d178e Mon Sep 17 00:00:00 2001 From: Ahp06 Date: Wed, 6 Feb 2019 15:06:41 +0100 Subject: [PATCH] Fixed some typo --- sumo_project/actions.py | 7 +++---- sumo_project/config.py | 2 +- sumo_project/runner.py | 27 +++++++++++++++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/sumo_project/actions.py b/sumo_project/actions.py index 058c3ed..0c71352 100644 --- a/sumo_project/actions.py +++ b/sumo_project/actions.py @@ -9,9 +9,8 @@ This module defines all possible actions on the simulation """ import traci -from typing import Iterable -from model import Area, Vehicle +from model import Area def compute_edge_weight(edge_id): @@ -103,7 +102,7 @@ def lock_area(area): Prohibits access to the area to a particular vehicle class NOT FIXED : Some vehicles continue to go into the area if they can not turn around and then will stay blocked there - as long as it will not be reversed + as long as "lock_area" will not be reversed :param area: The Area object :return: """ @@ -136,4 +135,4 @@ def reverse_actions(area): if area.locked: area.locked = False for lane in area._lanes: - traci.lane.setAllowed(lane.lane_id, '') # empty means all classes are allowed + traci.lane.setAllowed(lane.lane_id, []) # empty means all classes are allowed diff --git a/sumo_project/config.py b/sumo_project/config.py index 996a436..de879fa 100644 --- a/sumo_project/config.py +++ b/sumo_project/config.py @@ -39,7 +39,7 @@ class Config: :param config_file: The path to your configuration file :return: """ - with open(f'{config_file}.json', 'r') as f: + with open(f'{config_file}', 'r') as f: data = json.load(f) for option in data: diff --git a/sumo_project/runner.py b/sumo_project/runner.py index c588a1c..0c1cb19 100644 --- a/sumo_project/runner.py +++ b/sumo_project/runner.py @@ -8,10 +8,6 @@ Created on 19 janv. 2019 This module defines the entry point of the application """ -""" -Init the Traci API -""" - import argparse import csv import datetime @@ -31,6 +27,9 @@ import emissions from model import Emission +""" +Init the Traci API +""" if 'SUMO_HOME' in os.environ: tools = os.path.join(os.environ['SUMO_HOME'], 'tools') sys.path.append(tools) @@ -177,8 +176,16 @@ def create_dump(dump_name, simulation_dir, areas_number): :return: """ + #sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo') + #sumo_cmd = [sumo_binary, "-c", f'files/simulations/{simulation_dir}/osm.sumocfg'] + + for f in os.listdir(simulation_dir): + if f.endswith('.sumocfg'): + _SUMOCFG = os.path.join(simulation_dir, f) + sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo') - sumo_cmd = [sumo_binary, "-c", f'files/simulations/{simulation_dir}/osm.sumocfg'] + sumo_cmd = [sumo_binary, "-c", _SUMOCFG] + traci.start(sumo_cmd) if not os.path.isfile(f'files/dump/{dump_name}.json'): @@ -254,7 +261,7 @@ def main(args): create_dump(args.new_dump, args.simulation_dir, args.areas) if args.run is not None: - dump_path = f'files/dump/{args.run}.json' + dump_path = f'{args.run}' if os.path.isfile(dump_path): with open(dump_path, 'r') as f: data = jsonpickle.decode(f.read()) @@ -264,14 +271,14 @@ def main(args): if args.c is not None: for config in args.c: - files.append(f'files/configs/{config}') + files.append(f'{config}') if args.c_dir is not None: - path = f'files/configs/{args.c_dir}/' + path = f'{args.c_dir}' bundle_files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] for config in bundle_files: - conf_formatted = config.replace('.json','') - files.append(f'files/configs/{args.c_dir}/{conf_formatted}') + files.append(os.path.join(path, config)) + for conf in files: # Initialize all process