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_cereconn1.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ck = cc.CereConn()
  10. ck.send_open()
  11. t = time.time()
  12. while ck.get_state() != cc.ccS_Idle:
  13. time.sleep(0.005)
  14. print("It took {:5.3f}s to open CereConn\n".format(time.time() - t))
  15. ck.send_record()
  16. t = time.time()
  17. while ck.get_state() != cc.ccS_Recording:
  18. time.sleep(0.02)
  19. print("It took {:5.3f}s to start CereConn recording\n".format(time.time() - t))
  20. cb_time = ck.get_cb_time()
  21. print(cb_time)
  22. t = time.time()
  23. while (time.time()-t < 1):
  24. print(ck.get_cb_time()['ts']/1000.)
  25. time.sleep(0.1)
  26. n_comments = 1
  27. start_time = time.time()
  28. round_trip_times = []
  29. round_trip_times_abs = []
  30. ck.get_comment_data()
  31. for i in range(n_comments):
  32. cb_time = ck.get_cb_time()
  33. ck.send_comment("Test {} at tick {}".format(i+1, cb_time), cb_time)
  34. cd = ck.get_comment_data()
  35. while cb_time not in [c['data'] for c in cd['comments'] ]:
  36. time.sleep(0.001)
  37. cd = ck.get_comment_data()
  38. com = [com for com in cd['comments'] if com['data'] == cb_time]
  39. round_trip_times.append(com[0]['ts'] - com[0]['data'])
  40. round_trip_times_abs.append(cd['ts'] - com[0]['data'])
  41. print("Average round trip times for {} comments: {} ticks, or {:5.1f}ms (min {:5.1f}, max {:5.1f})".format(n_comments, sum(round_trip_times)/len(round_trip_times), sum(round_trip_times)/len(round_trip_times) / 30.0, min(round_trip_times)/30.0, max(round_trip_times)/30.0 ))
  42. print("Average round trip times for {} comments until processed here: {} ticks, or {:5.1f}ms (min {:5.1f}, max {:5.1f})".format(n_comments, sum(round_trip_times_abs)/len(round_trip_times_abs), sum(round_trip_times_abs)/len(round_trip_times_abs) / 30.0, min(round_trip_times_abs)/30.0, max(round_trip_times_abs)/30.0 ))
  43. ck.send_close()
  44. t = time.time()
  45. while ck.get_state() != cc.ccS_Closed:
  46. time.sleep(0.05)
  47. print("It took {:5.3f}s to close connection to NSP\n".format(time.time() - t))