SHARE
TWEET

Untitled

a guest Jun 26th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1
  2. 4
  3. 6
  4. 3
  5. ..
  6.      
  7. # TCP connection
  8. try:
  9.     so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  10. except socket.error as err:
  11.     print ("socket creation failed with error %s" %(err))
  12.  
  13. # default port for socket
  14. port = 2000
  15.  
  16. # default time out
  17. so.settimeout(1000000)
  18.  
  19. try:
  20.     host_ip = socket.gethostbyname('localhost')
  21. except socket.gaierror:
  22.     # this means could not resolve the host
  23.     print ("there was an error resolving the host")
  24.     sys.exit()
  25.  
  26. # connecting to the server
  27. so.connect((host_ip,port))
  28.  
  29. # MATLAB INFORMATION FOR OFFLINE EXPERIMENT
  30. Nepoch = 10  #nr de epochs por trial
  31. Nwords = 7   #nr de palavras (SIM, NAO, FOME, SEDE, URINAR, AR, POSICAO)
  32. SeqTrain = [1, 3, 5, 7, 2, 4, 6, 1, 3, 5, 7, 2, 4, 6] #sequencia offline de treino
  33.  
  34. # read the TCP sequence received
  35. def sequencia():
  36.     num = 0
  37.     for i in range(0,999):
  38.         s = so.recv(port) + b'n' #since the sequence received is : 1n 2n 5n etc
  39.         i = int(s)
  40.         #feedbak offline (for the user to know which are the words)
  41.         if (num in (0, Nepoch*Nwords+1, Nepoch*Nwords*2+2, Nepoch*Nwords*3+3, Nepoch*Nwords*4+4, Nepoch*Nwords*5+5,
  42.                     Nepoch*Nwords*6+6)):
  43.             labels1[i-1].configure(foreground="white")
  44.             root.update()
  45.         elif (num in (Nepoch*Nwords*7+7, Nepoch*Nwords*8+8, Nepoch*Nwords*9+9, Nepoch*Nwords*10+10,
  46.                      Nepoch*Nwords*11+11, Nepoch*Nwords*12+12, Nepoch*Nwords*13+13)):
  47.             labels2[i-1].configure(foreground="white")
  48.             root.update()
  49.         else:
  50.             labels[i-1].configure(background="green",foreground="red")
  51.             root.update()
  52.             winsound.PlaySound(sounds[i-1], winsound.SND_FILENAME)
  53.             labels[i-1].configure(background="gray",foreground="white")
  54.             root.update()
  55.         num = num + 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top