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

# Topics: # Topics:
Topics = { Topics = {
"ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE", "ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE",
"ROBOT_ACTION_DRIVEALL": "ROBOT/ACTION/DRIVEALL",
"ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION", "ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION",
"ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY", "ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY",


"ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE", "ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE",
"ROBOT_DATA_ERROR": "ROBOT/DATA/ERROR", "ROBOT_DATA_ERROR": "ROBOT/DATA/ERROR",
"ROBOT_DATA_ROBOTREADY": "ROBOT/DATA/ROBOTREADY", "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_DRIVE": "BACKEND/ACTION/DRIVE",
"BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL", "BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL",
"SoilMoisture": 0.0, "SoilMoisture": 0.0,
"Brightness": 0, "Brightness": 0,
"PlantID": 0, "PlantID": 0,
"ActionID": 0
"ActionID": ""
}

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


# TODO When sensor is available # TODO When sensor is available

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

MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io" MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io"
RASPI_CLIENT_ID = "smart_farming_raspi" RASPI_CLIENT_ID = "smart_farming_raspi"
BACKEND_CLIENT_ID = "smart_farming_server" BACKEND_CLIENT_ID = "smart_farming_server"
MAX_PLANT_COUNT = 6
DATABASE_NAME = 'backend_database.db'


# Topics: # Topics:
Topics = { Topics = {
"ROBOT_DATA_ALL": "ROBOT/DATA/ALL", "ROBOT_DATA_ALL": "ROBOT/DATA/ALL",


"BACKEND_ACTION_DRIVE": "BACKEND/ACTION/DRIVE", "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_GETPOSITION": "BACKEND/ACTION/GETPOSITION",
"BACKEND_ACTION_GETBATTERY": "BACKEND/ACTION/GETBATTERY", "BACKEND_ACTION_GETBATTERY": "BACKEND/ACTION/GETBATTERY",
"BACKEND_ACTION_GETALLDATA": "BACKEND/ACTION/GETALLDATA", "BACKEND_ACTION_GETALLDATA": "BACKEND/ACTION/GETALLDATA",
"BACKEND_DATA_ERROR": "BACKEND/DATA/ERROR", "BACKEND_DATA_ERROR": "BACKEND/DATA/ERROR",
"BACKEND_DATA_ROBOTREADY": "BACKEND/DATA/ROBOTREADY" "BACKEND_DATA_ROBOTREADY": "BACKEND/DATA/ROBOTREADY"



} }


# MQTT Messages: # MQTT Messages:
} }


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

# GETPOSITION -> no message needed # GETPOSITION -> no message needed


# GETBATTERY -> no message needed # GETBATTERY -> no message needed


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


# endregion # endregion


# GETBATTERY -> no message needed # GETBATTERY -> no message needed


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


# endregion # endregion

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

return return


# TODO Test error handling
logging.info("Measuring Sensors") logging.info("Measuring Sensors")
try: try:
sensordata = {} sensordata = {}
thread.start() thread.start()




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

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

client.connect(MQTT_BROKER_GLOBAL) client.connect(MQTT_BROKER_GLOBAL)
# client.connect("192.168.137.197") # Local Broker # client.connect("192.168.137.197") # Local Broker



# CHECK forever or start
client.loop_start()

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

client.loop_forever() # Loop_start not needed




if __name__ == "__main__": if __name__ == "__main__":

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

return percentage return percentage




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

Loading…
Cancel
Save