message.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
  2. # McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """
  16. Network messages used in the distributed simulation
  17. """
  18. class NetworkMessage(object):
  19. """
  20. Network messages used in the distributed simulation, simply a data class.
  21. """
  22. def __init__(self, timestamp, content, uuid, color, destination):
  23. """
  24. Constructor
  25. :param timestamp: timestamp of the message
  26. :param content: content of the message
  27. :param uuid: UUID of the message
  28. :param color: color of the message for Mattern's algorithm
  29. :param destination: the model_id of the destination model
  30. """
  31. self.timestamp = timestamp
  32. self.content = content
  33. self.uuid = uuid
  34. self.color = color
  35. self.destination = destination
  36. def __lt__(self, other):
  37. """
  38. Comparison of different NetworkMessages, necessary for Python3
  39. """
  40. return self.timestamp < other.timestamp