Browse Source

Minor Changes in mainProg, defines synchronized

master
Luis Waldhauser 1 year ago
parent
commit
a368637346

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

@@ -14,6 +14,7 @@ DATABASE_NAME = 'backend_database.db'
# Topics:
Topics = {
"ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE",
"ROBOT_ACTION_DRIVEALL": "ROBOT/ACTION/DRIVEALL",
"ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION",
"ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY",

@@ -23,6 +24,8 @@ Topics = {
"ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE",
"ROBOT_DATA_ERROR": "ROBOT/DATA/ERROR",
"ROBOT_DATA_ROBOTREADY": "ROBOT/DATA/ROBOTREADY",
"ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE",
"ROBOT_DATA_ALL": "ROBOT/DATA/ALL",

"BACKEND_ACTION_DRIVE": "BACKEND/ACTION/DRIVE",
"BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL",
@@ -54,7 +57,12 @@ SENSORDATA = {
"SoilMoisture": 0.0,
"Brightness": 0,
"PlantID": 0,
"ActionID": 0
"ActionID": ""
}

ALLSENSORDATA = {
"SensorData": [],
"ActionID": ""
}

# TODO When sensor is available

+ 8
- 6
software/roboter/raspy/defines.py View File

@@ -8,6 +8,8 @@ MQTT_BROKER_LOCAL = "192.168.0.199"
MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io"
RASPI_CLIENT_ID = "smart_farming_raspi"
BACKEND_CLIENT_ID = "smart_farming_server"
MAX_PLANT_COUNT = 6
DATABASE_NAME = 'backend_database.db'

# Topics:
Topics = {
@@ -26,7 +28,7 @@ Topics = {
"ROBOT_DATA_ALL": "ROBOT/DATA/ALL",

"BACKEND_ACTION_DRIVE": "BACKEND/ACTION/DRIVE",
"BACKEND_ACTION_DRIVEPALL": "BACKEND/ACTION/DRIVEALL",
"BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL",
"BACKEND_ACTION_GETPOSITION": "BACKEND/ACTION/GETPOSITION",
"BACKEND_ACTION_GETBATTERY": "BACKEND/ACTION/GETBATTERY",
"BACKEND_ACTION_GETALLDATA": "BACKEND/ACTION/GETALLDATA",
@@ -44,7 +46,6 @@ Topics = {
"BACKEND_DATA_ERROR": "BACKEND/DATA/ERROR",
"BACKEND_DATA_ROBOTREADY": "BACKEND/DATA/ROBOTREADY"


}

# MQTT Messages:
@@ -83,10 +84,9 @@ DRIVE = {
}

DRIVEALL = {
"PlantIDs": [],
"PlantID": [0, 0], # List containing PlantIDs sorted ascending
"ActionID": ""
}

# GETPOSITION -> no message needed

# GETBATTERY -> no message needed
@@ -128,7 +128,7 @@ BATTERY = {

PLANTCOUNT = {
"CurrenCount": 0,
"maxCount": 0
"MaxCount": 0
}

# endregion
@@ -153,6 +153,8 @@ DELETEPLANT = {

# GETBATTERY -> no message needed

# GETALLDATA -> no message needed
GETALLDATA = {
"PlantNames": []
}

# endregion

+ 0
- 2
software/roboter/raspy/functions.py View File

@@ -106,7 +106,6 @@ def drive_plant_all_thread(plantIDs: list, actionID, client: mqtt.Client):
return

# TODO Test error handling
logging.info("Measuring Sensors")
try:
sensordata = {}
@@ -173,7 +172,6 @@ def drive_plant(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
thread.start()


# TODO Test Drive all Plants
# FIXME Only possible with color codes
def drive_plant_all(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
"""

+ 2
- 6
software/roboter/raspy/mainProg.py View File

@@ -58,13 +58,9 @@ def main():
client.connect(MQTT_BROKER_GLOBAL)
# client.connect("192.168.137.197") # Local Broker


# CHECK forever or start
client.loop_start()

logging.info("Robot initialised")
while True:
pass

client.loop_forever() # Loop_start not needed


if __name__ == "__main__":

+ 0
- 1
software/roboter/raspy/raspy_sensors.py View File

@@ -89,7 +89,6 @@ def readMCP3008():
return percentage


# TODO Function for all sensors
def readSensors(sensorData):
"""
Read DHT22, TSL2561 and Humidity Sensor

Loading…
Cancel
Save