pyAirwaves is an ADS-B and AIS processing, storage, and display application with Leaflets integration.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.2 KiB

  1. #!/usr/bin/env python
  2. from real_datas_test import fake_planes
  3. from libPyAirwaves.structs import AdsbType
  4. import time
  5. import config as cfg
  6. import redis
  7. import json
  8. DELAY_MESSAGES = 2 # second
  9. redis = redis.from_url(cfg.REDIS_URL)
  10. pubsub = redis.pubsub()
  11. pubsub.subscribe("room:vehicles")
  12. print("Sending messages...")
  13. try:
  14. sample = "MSG,3,1,1,field_4,1,2019/02/25,20:49:58.331,2019/02/25,20:49:58.361,,field_11,,,field_14,field_15,,field_17,0,,0,0"
  15. foo = sample.split(",")
  16. # "addr": "000000", "idInfo": "LOLK293", "alt": 23000, "aSquawk": "1337"
  17. for coords in fake_planes["planeA"]["path"]:
  18. msg = foo
  19. msg[4] = fake_planes["planeA"]["idInfo"]
  20. msg[11] = str(fake_planes["planeA"]["alt"])
  21. msg[14] = str(coords[1])
  22. msg[15] = str(coords[0])
  23. msg[17] = fake_planes["planeA"]["aSquawk"]
  24. adsb_msg = AdsbType()
  25. adsb_msg.populate_from_list(msg)
  26. adsb_msg.entryPoint = "simulator"
  27. adsb_msg.ourName = cfg.PYAW_HOSTNAME
  28. adsb_msg.srcName = cfg.ADSB_SOURCE["name"]
  29. adsb_msg.srcLat = cfg.ADSB_SOURCE["lat"]
  30. adsb_msg.srcLon = cfg.ADSB_SOURCE["lon"]
  31. adsb_msg.srcPosMode = cfg.ADSB_SOURCE["posMode"]
  32. adsb_msg.clientName = "sim_host"
  33. adsb_msg.dataOrigin = "dump1090"
  34. redis.publish("room:vehicles", json.dumps(adsb_msg.to_dict()))
  35. time.sleep(DELAY_MESSAGES)
  36. # "addr": "ffffff", "idInfo": "WEE2162", "alt": 45000, "aSquawk": "7007"
  37. for coords in fake_planes["planeB"]["path"]:
  38. msg = foo
  39. msg[4] = fake_planes["planeB"]["idInfo"]
  40. msg[11] = str(fake_planes["planeB"]["alt"])
  41. msg[14] = str(coords[1])
  42. msg[15] = str(coords[0])
  43. msg[17] = fake_planes["planeB"]["aSquawk"]
  44. adsb_msg = AdsbType()
  45. adsb_msg.populate_from_list(msg)
  46. adsb_msg.entryPoint = "simulator"
  47. adsb_msg.ourName = cfg.PYAW_HOSTNAME
  48. adsb_msg.srcName = cfg.ADSB_SOURCE["name"]
  49. adsb_msg.srcLat = cfg.ADSB_SOURCE["lat"]
  50. adsb_msg.srcLon = cfg.ADSB_SOURCE["lon"]
  51. adsb_msg.srcPosMode = cfg.ADSB_SOURCE["posMode"]
  52. adsb_msg.clientName = "sim_host"
  53. adsb_msg.dataOrigin = "dump1090"
  54. redis.publish("room:vehicles", json.dumps(adsb_msg.to_dict()))
  55. time.sleep(DELAY_MESSAGES)
  56. # "addr": "111111", "idInfo": "NOPE", "alt": 40000, "aSquawk": "0666"
  57. for coords in fake_planes["planeC"]["path"]:
  58. msg = foo
  59. msg[4] = fake_planes["planeC"]["idInfo"]
  60. msg[11] = str(fake_planes["planeC"]["alt"])
  61. msg[14] = str(coords[1])
  62. msg[15] = str(coords[0])
  63. msg[17] = fake_planes["planeC"]["aSquawk"]
  64. adsb_msg = AdsbType()
  65. adsb_msg.populate_from_list(msg)
  66. adsb_msg.entryPoint = "simulator"
  67. adsb_msg.ourName = cfg.PYAW_HOSTNAME
  68. adsb_msg.srcName = cfg.ADSB_SOURCE["name"]
  69. adsb_msg.srcLat = cfg.ADSB_SOURCE["lat"]
  70. adsb_msg.srcLon = cfg.ADSB_SOURCE["lon"]
  71. adsb_msg.srcPosMode = cfg.ADSB_SOURCE["posMode"]
  72. adsb_msg.clientName = "sim_host"
  73. adsb_msg.dataOrigin = "dump1090"
  74. redis.publish("room:vehicles", json.dumps(adsb_msg.to_dict()))
  75. time.sleep(DELAY_MESSAGES)
  76. except KeyboardInterrupt:
  77. print("Stopping.")