Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

test_cereconn2.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. '''
  2. description: test connection to NSP via cereconn
  3. author: Ioannis Vlachos
  4. date: 15.11.18
  5. Copyright (c) 2018 Ioannis Vlachos.
  6. All rights reserved.'''
  7. import time
  8. import cere_conn as cc
  9. import numpy as np
  10. ck = cc.CereConn()
  11. ck.send_open()
  12. t = time.time()
  13. while ck.get_state() != cc.ccS_Idle:
  14. time.sleep(0.005)
  15. print("It took {:5.3f}s to open CereConn\n".format(time.time() - t))
  16. ck.send_record()
  17. t = time.time()
  18. while ck.get_state() != cc.ccS_Recording:
  19. time.sleep(0.02)
  20. print("It took {:5.3f}s to start CereConn recording\n".format(time.time() - t))
  21. cb_time = ck.get_cb_time()
  22. # print(cb_time)
  23. n_comments = 2
  24. start_time = time.time()
  25. round_trip_times = []
  26. round_trip_times_abs = []
  27. events = []
  28. info = []
  29. data2 = np.empty((0, 10))
  30. data = ck.get_cont_data()
  31. for i in range(n_comments):
  32. cb_time = ck.get_cb_time()
  33. ck.send_comment("Baseline yes")
  34. # time.sleep(0.001)
  35. # cb_time = ck.get_cb_time()
  36. # ck.send_comment("Baseline no ".format(i+1, cb_time), cb_time)
  37. time.sleep(0.05)
  38. # ck.print_buffer_state()
  39. comments = ck.get_comment_data()
  40. data = ck.get_cont_data()
  41. # aa
  42. # print(data)
  43. for ii in range(len(comments['comments'])):
  44. events.append((comments['comments'][ii]['ts'], comments['comments'][ii]['text']))
  45. info.append((data['ts'],data['sample_groups'][5]['data'].shape[0]))
  46. data2 = np.concatenate((data2, data['sample_groups'][5]['data']))
  47. aa = np.arange(info[0][0]-info[0][1], info[1][0])
  48. # print(aa.shape)
  49. data = ck.get_cont_data()
  50. print(ck.get_cb_time())
  51. for ii in range(10):
  52. time.sleep(.1)
  53. data = ck.get_cont_data()
  54. data2 = data['sample_groups'][5]['data']
  55. print(ck.get_cb_time())
  56. print(ii, data2.shape)
  57. # print(cd)
  58. ck.send_close()
  59. t = time.time()
  60. while ck.get_state() != cc.ccS_Closed:
  61. time.sleep(0.05)
  62. print("It took {:5.3f}s to close connection to NSP\n".format(time.time() - t))
  63. # SAVING EVENTS
  64. # print(events)
  65. # cnt = 0
  66. # cnt = sum([(8 + len(ev[1])) for ev in events])
  67. # print(cnt)
  68. # with open('events.bin', 'wb') as fh:
  69. # fh.write(np.int64(cnt).tobytes())
  70. # for ev in events:
  71. # # print(ev)
  72. # fh.write(np.int64(ev[0]).tobytes())
  73. # fh.write(ev[1])
  74. # with open('events.bin', 'rb') as fh:
  75. # ev_cnt = int(np.frombuffer(fh.read(8), dtype=np.int64)[0]/20)
  76. # for ev in range(ev_cnt):
  77. # ts = np.frombuffer(fh.read(8), dtype=np.int64)[0]
  78. # comments = fh.read(12)
  79. # print(ts, comments)