-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.py
42 lines (35 loc) · 1.26 KB
/
event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Esta classe representa um evento
# type: tipo do evento de um job
# tipos:
# Chegada de job, Fim de job
# Requisição de memória, liberaçào de memória
# Encerramento
#
# duration: duração do evento
# elapsed: tempo decorrido de execução
# value: se for evento de alocação de memória, esse é o valor alocado
class Event:
eventType = ""
duration = 0
elapsed = 0
value = 0
job = 0
# Inicializa o evento
def __init__(self, eventType, duration, value, job):
self.eventType = eventType
self.duration = duration
self.elapsed = 0
self.value = value
self.job = job
# Realiza uma iteração de relógio no evento
def iterate(self):
self.elapsed += 1
# Verifica se o evento acabou
def isOver(self):
if self.elapsed >= self.duration:
return True
else:
return False
def __str__(self):
return str(f"Job name: {self.job.__str__()} ({self.job.index}), type: {self.eventType}, duration: {self.duration}, elapsed: {self.elapsed}, value: {self.value}")
return str("Job name: "+self.job.__str__()+", type: "+self.eventType+", duration: "+str(self.duration)+", elapsed: "+str(self.elapsed)+", value: "+str(self.value))