Browse Source

function layout added

master
caliskanbi 1 year ago
parent
commit
14fea73572

+ 72
- 1
software/backend/data_handling_functions.py View File

@@ -3,4 +3,75 @@ created by caliskan at 19.04.2023

This file contains all functions, which handle the different cases.
Every function should return json format with the wanted data from the database
"""
"""
import paho.mqtt.client as mqtt


def data_handler(client: mqtt.Client, message) -> dict:
"""
main entrypoint for a message handling method
:param client:
:param message:
:return:
"""
if message.topic.startwith('BackEnd'):

if message.topic == "BackEnd/Action/All":
action_all(client, message)
elif message.topic == "BackEnd/Action/GetPosition":
action_get_position(client, message)
elif message.topic == "BackEnd/Action/GetBattery":
action_get_battery(client, message)
elif message.topic == "BackEnd/Action/GetAllData":
action_get_all_data(client, message)

elif message.topic.startwith('Robot'):

if message.topic == "Robot/Data/SensorData":
data_sensordata(client, message)
elif message.topic == "Robot/Data/Position":
data_position(client, message)
elif message.topic == "Robot/Data/Battery":
data_battery(client, message)
elif message.topic == "Robot/Data/Picture":
data_picture(client, message)


# START ACTION FUNCTION DEFINITIONS

def action_all(client, message):
pass


def action_get_position(client, message):
pass


def action_get_battery(client, message):
pass


def action_get_all_data(client, message):
pass


# END ACTION FUNCTION DEFINITIONS

# START ROBOT FUNCTION DEFINITIONS

def data_sensordata(client, message):
pass


def data_position(client, message):
pass


def data_battery(client, message):
pass


def data_picture(client, message):
pass

# END ROBOT FUNCTION DEFINITIONS

+ 3
- 1
software/backend/defines.py View File

@@ -4,5 +4,7 @@ created by caliskan at 19.04.2023
contains all constants for the backend architecture of the smart garden project
"""

MQTT_BROKER_LOCAL = ""
MQTT_BROKER_LOCAL = "lorem ipsum"
MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io"
RASPI_CLIENT_ID = "lorem ipsum"
BACKEND_CLIENT_ID = "lorem ipsum"

+ 7
- 5
software/backend/main.py View File

@@ -11,9 +11,12 @@ Used protocol for interaction: mqtt (paho-mqtt module)
import paho.mqtt.client as mqtt
from defines import MQTT_BROKER_LOCAL, MQTT_BROKER_GLOBAL
from plantdatabase import PlantDataBase
from data_handling_functions import data_handler


def on_message(client, userdata, message):
print(f'message received! {message.topic}')
data_handler(client, message)


def on_connect(client, userdata, flags, rc):
@@ -29,11 +32,10 @@ def on_connect(client, userdata, flags, rc):
client.subscribe("Robot/Data/Picture")

# FrontEnd topics
client.subscribe("BackEnd/Data/SensorData")
client.subscribe("BackEnd/Data/SensorDataAll")
client.subscribe("BackEnd/Data/Position")
client.subscribe("BackEnd/Data/Battery")
client.subscribe("BackEnd/Data/Picture")
client.subscribe("BackEnd/Action/All")
client.subscribe("BackEnd/Action/GetPosition")
client.subscribe("BackEnd/Action/GetBattery")
client.subscribe("BackEnd/Action/GetAllData")

# END TOPIC SUBSCRIPTIONS
else:

Loading…
Cancel
Save