<commit_before>__author__ = '<NAME>'

from LEDController import LEDController
from SpeakerController import SpeakerController
from WarningLevel import WarningLevel
from RESTCommunicator import RESTCommunicator
from datetime import datetime
from time import time

class SensorDataEvaluator:
	def __init__(self):
		self.led_controller = LEDController()
		self.speaker_controller = SpeakerController()
		self.rest_communicator = RESTCommunicator()

		self.minimum_time_elapsed_between_requests = 30  # 30s should pass before sending another request
		self.last_inform_server_datetime = None

	def evaluate(self, processed_sensor_data):
		print('evaluating sensor data')

		# TODO:
		# depending on where the data comes from,
		# what time it it,
		# and how reliable the data is,
		# a warning should be given and an event sent.

		if processed_sensor_data.result:  # if there is a warning according to the ProcessedSensorData object
			self.led_controller.start_warning(WarningLevel.DANGEROUS_SITUATION_WARNING.value)
			self.speaker_controller.start_warning(WarningLevel.DANGEROUS_SITUATION_WARNING.value)
			self.inform_server()
		else:
			self.led_controller.stop_warning()
			self.speaker_controller.stop_warning()

	# TODO: use asyncio???
	def inform_server(self):
		if self.last_inform_server_datetime is None:
			datetime_diff = self.minimum_time_elapsed_between_requests + 1  # greater than minimum in any case
		else:
			datetime_diff = (datetime.now() - self.last_inform_server_datetime).seconds

		if datetime_diff >= 30:
			example_longitude = '58.33444'
			example_latitude = '19.72878'

			# create dictionary
			current_timestamp = time()
			current_datetime = datetime.fromtimestamp(timestamp).strftime('%Y-%m-%dT%H:%M:%S')
			print('sending request with timestamp:', current_datetime)

			self.rest_communicator.send_dangerous_traffic_situation_request(
				example_longitude,
				example_latitude,<commit_msg>changed variable name to not use an undefined one<commit_after>__author__ = '<NAME>'

from LEDController import LEDController
from SpeakerController import SpeakerController
from WarningLevel import WarningLevel
from RESTCommunicator import RESTCommunicator
from datetime import datetime
from time import time

class SensorDataEvaluator:
	def __init__(self):
		self.led_controller = LEDController()
		self.speaker_controller = SpeakerController()
		self.rest_communicator = RESTCommunicator()

		self.minimum_time_elapsed_between_requests = 30  # 30s should pass before sending another request
		self.last_inform_server_datetime = None

	def evaluate(self, processed_sensor_data):
		print('evaluating sensor data')

		# TODO:
		# depending on where the data comes from,
		# what time it it,
		# and how reliable the data is,
		# a warning should be given and an event sent.

		if processed_sensor_data.result:  # if there is a warning according to the ProcessedSensorData object
			self.led_controller.start_warning(WarningLevel.DANGEROUS_SITUATION_WARNING.value)
			self.speaker_controller.start_warning(WarningLevel.DANGEROUS_SITUATION_WARNING.value)
			self.inform_server()
		else:
			self.led_controller.stop_warning()
			self.speaker_controller.stop_warning()

	# TODO: use asyncio???
	def inform_server(self):
		if self.last_inform_server_datetime is None:
			datetime_diff = self.minimum_time_elapsed_between_requests + 1  # greater than minimum in any case
		else:
			datetime_diff = (datetime.now() - self.last_inform_server_datetime).seconds

		if datetime_diff >= 30:
			example_longitude = '58.33444'
			example_latitude = '19.72878'

			# create dictionary
			current_timestamp = time()
			current_datetime = datetime.fromtimestamp(current_timestamp).strftime('%Y-%m-%dT%H:%M:%S')
			print('sending request with timestamp:', current_datetime)

			self.rest_communicator.send_dangerous_traffic_situation_request(
				example_longitude,
				example_latitude,
{'fraction_non_alphanumeric': 0.07344632768361582, 'fraction_numerical': 0.01078582434514638, 'mean_word_length': 5.43801652892562, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6203134', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1126, 'n_words': 289}