From c336e1b0562c44f454c7b1e1033eb12dc3534de3 Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Wed, 16 Nov 2016 23:51:55 -0200 Subject: [PATCH] =?UTF-8?q?organizando=20o=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/repo.py b/repo.py index ed499c7..a7ab4f8 100755 --- a/repo.py +++ b/repo.py @@ -4,7 +4,7 @@ ############################################################################################### #Marca - 1 Byte Marca inicio de transmissao, inicio de msg fim de msg -#Tipo - 0 Token, 1 - Msg, 2 - ACK, 3 - NACK +#Tipo - 0 Token, 1 - Msg, #Destino - pode variar de 1 a 4 #Origem - pode variar de 1 a 4 #Prioridade - pode variar de 0 a 7 @@ -34,13 +34,11 @@ import time import Queue global TOKEN -global StartTime global HighPriority global RECEBIDA global PRIORITY_TOKEN PRIORITY_TOKEN = 8 RECEBIDA = 1 -StartTime = 0 HighPriority = 10 TOKEN = 0 SEND_PORT = 3131 # Porta que o Servidor envia @@ -118,6 +116,7 @@ def token (): tokenMessage = Protocol() msgProtocol = Protocol() dest = (HOST, SEND_PORT) + time.sleep(2) if (TOKEN == 2): TOKEN = 0 tokenMessage.type = str(0) @@ -143,7 +142,6 @@ def client (): global TOKEN protocolMessage = Protocol() global queue - queue = Queue.PriorityQueue() while True: protocolMessage.setDestiny() protocolMessage.setPriority() @@ -160,7 +158,6 @@ def client (): def server (): global TOKEN - global StartTime global RECEBIDA global queue global PRIORITY_TOKEN @@ -211,7 +208,6 @@ def server (): aux1.setDesempacota(msg) aux1.priority = str(HighPriorat) msg = aux1.getEmpacotar() - print msg udp.sendto (msg, dest) udp.close() @@ -222,13 +218,11 @@ if len(sys.argv) > 1: TOKEN = 2 print 'COMECEI COM O TOKEN' PRIORITY_TOKEN = 7 - StartTime = time.time() print 'ID Dessa maquina, escolha entre 1 e 4' MACHINE_ID = raw_input () print "Ip da proxima maquina" HOST = raw_input() -if TOKEN == 1: - StartTime = time.time() +queue = Queue.PriorityQueue() threadServer = threading.Thread(target=server) threadClient = threading.Thread(target=client) threadServer.start() -- GitLab