Advertisement
smathot

Wait server

Mar 21st, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. # Generated by OpenSesame 0.27.2~pre3 (Frisky Freud)
  2. # Thu Mar 21 11:40:17 2013 (posix)
  3. # <http://www.cogsci.nl/opensesame>
  4.  
  5. set foreground "white"
  6. set subject_parity "even"
  7. set font_size "18"
  8. set description "Default description"
  9. set title "Wait server"
  10. set font_family "mono"
  11. set font_bold "no"
  12. set coordinates "relative"
  13. set height "400"
  14. set mouse_backend "xpyriment"
  15. set start "experiment"
  16. set compensation "0"
  17. set sampler_backend "legacy"
  18. set keyboard_backend "legacy"
  19. set background "black"
  20. set subject_nr "0"
  21. set canvas_backend "xpyriment"
  22. set width "400"
  23. set synth_backend "legacy"
  24. set font_italic "no"
  25.  
  26. define sketchpad done
  27. set duration "keypress"
  28. set start_response_interval "no"
  29. set description "Displays stimuli"
  30. draw textline 0.0 0.0 "Done!" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
  31.  
  32. define inline_script inline_script
  33. ___run__
  34. import socket
  35.  
  36. ip = '127.0.0.1' # The IP address of the other PC
  37. port = 40007 # An arbitrary port that matches the client
  38.  
  39. print 'Opening socket'
  40. socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  41. # Reducing the timeout will improve synchronization
  42. socket.settimeout(0.1)
  43. print 'Listening'
  44. while True:
  45. socket.sendto('1', (ip, port))
  46. print 'send 1'
  47. try:
  48. s, ip = socket.recvfrom(1)
  49. print 'recv %s' % s
  50. except: # A timeout occurred
  51. s = None
  52. if s == '1':
  53. break
  54. print 'Client says hi!'
  55. socket.close()
  56. __end__
  57. set _prepare ""
  58. set description "Executes Python code"
  59.  
  60. define sequence experiment
  61. run wait_keypress "always"
  62. run wait_connect "always"
  63. run inline_script "always"
  64. run done "always"
  65.  
  66. define sketchpad wait_connect
  67. set duration "0"
  68. set description "Displays stimuli"
  69. draw textline 0.0 0.0 "Waiting for other PC" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
  70.  
  71. define sketchpad wait_keypress
  72. set duration "keypress"
  73. set description "Displays stimuli"
  74. draw textline 0.0 0.0 "Press any key" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement