traffic_events.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env python
  2. # This work is licensed under the terms of the MIT license.
  3. # For a copy, see <https://opensource.org/licenses/MIT>.
  4. """
  5. Collection of TrafficEvents
  6. """
  7. from enum import Enum
  8. class TrafficEventType(Enum):
  9. """
  10. This enum represents different traffic events that occur during driving.
  11. """
  12. NORMAL_DRIVING = 0
  13. COLLISION_STATIC = 1
  14. COLLISION_VEHICLE = 2
  15. COLLISION_PEDESTRIAN = 3
  16. ROUTE_DEVIATION = 4
  17. ROUTE_COMPLETION = 5
  18. ROUTE_COMPLETED = 6
  19. TRAFFIC_LIGHT_INFRACTION = 7
  20. WRONG_WAY_INFRACTION = 8
  21. ON_SIDEWALK_INFRACTION = 9
  22. STOP_INFRACTION = 10
  23. OUTSIDE_LANE_INFRACTION = 11
  24. OUTSIDE_ROUTE_LANES_INFRACTION = 12
  25. VEHICLE_BLOCKED = 13
  26. class TrafficEvent(object):
  27. """
  28. TrafficEvent definition
  29. """
  30. def __init__(self, event_type, message=None, dictionary=None):
  31. """
  32. Initialize object
  33. :param event_type: TrafficEventType defining the type of traffic event
  34. :param message: optional message to inform users of the event
  35. :param dictionary: optional dictionary with arbitrary keys and values
  36. """
  37. self._type = event_type
  38. self._message = message
  39. self._dict = dictionary
  40. def get_type(self):
  41. """
  42. @return type
  43. """
  44. return self._type
  45. def get_message(self):
  46. """
  47. @return message
  48. """
  49. if self._message:
  50. return self._message
  51. return ""
  52. def set_message(self, message):
  53. """
  54. Set message
  55. """
  56. self._message = message
  57. def get_dict(self):
  58. """
  59. @return dictionary
  60. """
  61. return self._dict
  62. def set_dict(self, dictionary):
  63. """
  64. Set dictionary
  65. """
  66. self._dict = dictionary