import xml.etree.ElementTree as ET
CONST_MAXSIZE = None
CONST_MINSIZE = None
CONST_STOP_SPEED = None
CONST_SEARCH_DISTANCE = None
CONST_MIN_PLATOON_DISTANCE = None
CONST_EXIT_PLATOON_BUFFER = None
CONST_SPLIT_DISTANCE = None
CONST_LANE_CHANGE_DURATION = None
CONST_PROPORTION_CONNECTED_VEHICLES = None
CONST_TAU_UNCONNECTED = None
CONST_TAU_CONNECTED_NO_PLATOON = None
CONST_TAU_CONNECTED_PLATOON = None
CONST_ENABLE_PLATOONING = None
CONST_CURR_MAP = None
CONST_MEASURE_ALL_JUNCTIONS = None
CONST_MEASUREMENT_INTERVAL = None
CONST_FLOW_FILE_NAME = None
CONST_FLOW_SIMULATION_TIME = None
CONST_FLOW_CUT_OFF = None
CONST_JUNCTIONS_TO_MEASURE = None
CONST_EXPERIMENT_NAME = None
#CONST_GUI = None

def UpdateParameters(SettingsName):
	tree = ET.parse(SettingsName)
	root = tree.getroot()
	global CONST_MAXSIZE, CONST_MINSIZE, CONST_STOP_SPEED, CONST_SEARCH_DISTANCE, CONST_MIN_PLATOON_DISTANCE, CONST_EXIT_PLATOON_BUFFER, CONST_SPLIT_DISTANCE, CONST_LANE_CHANGE_DURATION, CONST_PROPORTION_CONNECTED_VEHICLES, CONST_TAU_UNCONNECTED,CONST_TAU_CONNECTED_NO_PLATOON
	global CONST_TAU_CONNECTED_PLATOON, CONST_ENABLE_PLATOONING, CONST_CURR_MAP, CONST_MEASURE_ALL_JUNCTIONS, CONST_MEASUREMENT_INTERVAL, CONST_FLOW_FILE_NAME, CONST_FLOW_SIMULATION_TIME, CONST_FLOW_CUT_OFF, CONST_JUNCTIONS_TO_MEASURE, CONST_EXPERIMENT_NAME, CONST_GUI
	CONST_MAXSIZE = int(root.find('CONST_MAXSIZE').text)
	CONST_MINSIZE = int(root.find('CONST_MINSIZE').text)
	CONST_STOP_SPEED = int(root.find('CONST_STOP_SPEED').text)
	CONST_SEARCH_DISTANCE = int(root.find('CONST_SEARCH_DISTANCE').text)
	CONST_MIN_PLATOON_DISTANCE = int(root.find('CONST_MIN_PLATOON_DISTANCE').text)
	CONST_EXIT_PLATOON_BUFFER = int(root.find('CONST_EXIT_PLATOON_BUFFER').text)
	CONST_SPLIT_DISTANCE = int(root.find('CONST_SPLIT_DISTANCE').text)
	CONST_LANE_CHANGE_DURATION = int(root.find('CONST_LANE_CHANGE_DURATION').text)
	CONST_PROPORTION_CONNECTED_VEHICLES = float(root.find('CONST_PROPORTION_CONNECTED_VEHICLES').text)
	CONST_TAU_UNCONNECTED = float(root.find('CONST_TAU_UNCONNECTED').text)
	CONST_TAU_CONNECTED_NO_PLATOON = float(root.find('CONST_TAU_CONNECTED_NO_PLATOON').text)
	CONST_TAU_CONNECTED_PLATOON = float(root.find('CONST_TAU_CONNECTED_PLATOON').text)
	CONST_ENABLE_PLATOONING = True if (root.find('CONST_ENABLE_PLATOONING').text.lower() == 'true') else False
	CONST_CURR_MAP = root.find('CONST_CURR_MAP').text
	CONST_MEASURE_ALL_JUNCTIONS = True if (root.find('CONST_MEASURE_ALL_JUNCTIONS').text.lower() == 'true') else False
	CONST_MEASUREMENT_INTERVAL = int(root.find('CONST_MEASUREMENT_INTERVAL').text)
	CONST_FLOW_FILE_NAME = root.find('CONST_FLOW_FILE_NAME').text
	CONST_FLOW_SIMULATION_TIME = int(root.find('CONST_FLOW_SIMULATION_TIME').text)
	CONST_FLOW_CUT_OFF = True if (root.find('CONST_FLOW_CUT_OFF').text.lower() == 'true') else False
	CONST_JUNCTIONS_TO_MEASURE = []#root.find('CONST_JUNCTIONS_TO_MEASURE').text.split(",")
	CONST_EXPERIMENT_NAME = root.find('CONST_EXPERIMENT_NAME').text
	CONST_GUI = True if (root.find('CONST_GUI').text.lower() == 'true') else False
