Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1
- 4
- 6
- 3
- ..
- # TCP connection
- try:
- so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- except socket.error as err:
- print ("socket creation failed with error %s" %(err))
- # default port for socket
- port = 2000
- # default time out
- so.settimeout(1000000)
- try:
- host_ip = socket.gethostbyname('localhost')
- except socket.gaierror:
- # this means could not resolve the host
- print ("there was an error resolving the host")
- sys.exit()
- # connecting to the server
- so.connect((host_ip,port))
- # MATLAB INFORMATION FOR OFFLINE EXPERIMENT
- Nepoch = 10 #nr de epochs por trial
- Nwords = 7 #nr de palavras (SIM, NAO, FOME, SEDE, URINAR, AR, POSICAO)
- SeqTrain = [1, 3, 5, 7, 2, 4, 6, 1, 3, 5, 7, 2, 4, 6] #sequencia offline de treino
- # read the TCP sequence received
- def sequencia():
- num = 0
- for i in range(0,999):
- s = so.recv(port) + b'n' #since the sequence received is : 1n 2n 5n etc
- i = int(s)
- #feedbak offline (for the user to know which are the words)
- if (num in (0, Nepoch*Nwords+1, Nepoch*Nwords*2+2, Nepoch*Nwords*3+3, Nepoch*Nwords*4+4, Nepoch*Nwords*5+5,
- Nepoch*Nwords*6+6)):
- labels1[i-1].configure(foreground="white")
- root.update()
- elif (num in (Nepoch*Nwords*7+7, Nepoch*Nwords*8+8, Nepoch*Nwords*9+9, Nepoch*Nwords*10+10,
- Nepoch*Nwords*11+11, Nepoch*Nwords*12+12, Nepoch*Nwords*13+13)):
- labels2[i-1].configure(foreground="white")
- root.update()
- else:
- labels[i-1].configure(background="green",foreground="red")
- root.update()
- winsound.PlaySound(sounds[i-1], winsound.SND_FILENAME)
- labels[i-1].configure(background="gray",foreground="white")
- root.update()
- num = num + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement