repository to manage all files related to the makeathon farm bot project (Software + Documentation).
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.

data_handling_functions.py 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. """
  2. created by caliskan at 19.04.2023
  3. This file contains all functions, which handle the different cases.
  4. Every function should return json format with the wanted data from the database
  5. """
  6. import paho.mqtt.client as mqtt
  7. def data_handler(client: mqtt.Client, message) -> dict:
  8. """
  9. main entrypoint for a message handling method
  10. :param client:
  11. :param message:
  12. :return:
  13. """
  14. if message.topic.startwith('BackEnd'):
  15. if message.topic == "BackEnd/Action/All":
  16. action_all(client, message)
  17. elif message.topic == "BackEnd/Action/GetPosition":
  18. action_get_position(client, message)
  19. elif message.topic == "BackEnd/Action/GetBattery":
  20. action_get_battery(client, message)
  21. elif message.topic == "BackEnd/Action/GetAllData":
  22. action_get_all_data(client, message)
  23. elif message.topic.startwith('Robot'):
  24. if message.topic == "Robot/Data/SensorData":
  25. data_sensordata(client, message)
  26. elif message.topic == "Robot/Data/Position":
  27. data_position(client, message)
  28. elif message.topic == "Robot/Data/Battery":
  29. data_battery(client, message)
  30. elif message.topic == "Robot/Data/Picture":
  31. data_picture(client, message)
  32. # START ACTION FUNCTION DEFINITIONS
  33. def action_all(client, message):
  34. pass
  35. def action_get_position(client, message):
  36. pass
  37. def action_get_battery(client, message):
  38. pass
  39. def action_get_all_data(client, message):
  40. pass
  41. # END ACTION FUNCTION DEFINITIONS
  42. # START ROBOT FUNCTION DEFINITIONS
  43. def data_sensordata(client, message):
  44. pass
  45. def data_position(client, message):
  46. pass
  47. def data_battery(client, message):
  48. pass
  49. def data_picture(client, message):
  50. pass
  51. # END ROBOT FUNCTION DEFINITIONS