From f6f64216200c7c2bc97cde581e8957d54ee9ab55 Mon Sep 17 00:00:00 2001 From: "duelgerke82357@th-nuernberg.de" Date: Wed, 20 Sep 2023 18:26:22 +0200 Subject: [PATCH] Final status --- .../src/app/Plants/plants.component.ts | 3 -- .../app/Service/Mqtt/mqtt-request.service.ts | 38 ++----------------- .../app/Service/Mqtt/mqtt-set-data.service.ts | 1 - .../src/app/Service/Mqtt/mqtt.service.ts | 4 +- software/Frontend/src/app/app.component.html | 1 - 5 files changed, 5 insertions(+), 42 deletions(-) diff --git a/software/Frontend/src/app/Plants/plants.component.ts b/software/Frontend/src/app/Plants/plants.component.ts index a6e33aa..27c3e68 100644 --- a/software/Frontend/src/app/Plants/plants.component.ts +++ b/software/Frontend/src/app/Plants/plants.component.ts @@ -19,7 +19,6 @@ export class PlantsComponent { filteredOptions: Observable; plants$: Observable = this.storeService.currentPlants; - constructor(public dialog: MatDialog, public storeService: StoreService, private mqttRequestService: MqttRequestService) { // sobald es eine Ƥnderung bei den pflanzenNamen gibt, wird bei der suchleiste ein neuer filter eingesetzt this.options$.subscribe(response => { @@ -58,12 +57,10 @@ export class PlantsComponent { this.selectedPlant = value; } - onOptionDefault() { this.selectedPlant = 'undefined'; } - private _filter(value: string, options: string[]): string[] { const filterValue = value.toLowerCase(); diff --git a/software/Frontend/src/app/Service/Mqtt/mqtt-request.service.ts b/software/Frontend/src/app/Service/Mqtt/mqtt-request.service.ts index a609668..68011f1 100644 --- a/software/Frontend/src/app/Service/Mqtt/mqtt-request.service.ts +++ b/software/Frontend/src/app/Service/Mqtt/mqtt-request.service.ts @@ -66,19 +66,6 @@ export class MqttRequestService { console.error('Error:', err); }); - // this.mqttService.subscribeToTopic("BACKEND/DATA/POSITION").subscribe(data => { - // if (typeof data !== "object") { - // const payload = JSON.parse(data) as Position; - // this.mqttSetDataService.setRobotPosition(payload); - // } - // }, err => { - // this.dialog.open(ErrorDialogComponent, { - // data: err, - // width: '400px', - // }); - // console.error('Error:', err); - // }); - this.mqttService.subscribeToTopic("BACKEND/DATA/BATTERY").subscribe(data => { if (typeof data !== "object") { const payload = JSON.parse(data) as RobotBattery; @@ -119,22 +106,6 @@ export class MqttRequestService { console.error('Error:', err); }); - // this.mqttService.subscribeToTopic("BACKEND/DATA/PICTURE").subscribe(data => { - // if (typeof data !== "object") { - // const payload = JSON.parse(data) as Plant; - // this.mqttSetDataService.setDataPlant(payload); - // } - // }, err => { - // console.error('Error:', err); - // }); - - //Request to get ALL DATA every 10sec!! - // this.timerSubscription = timer(0, 10000).pipe( - // map(() => { - // this.mqttService.publishToTopic('BACKEND/ACTION/GETALLDATA'); - // }) - // ).subscribe(); - //Publish to the Topic to recieve the first Data this.publishToPLANTCOUNT(); this.publishToGETBATTERY(); @@ -145,18 +116,14 @@ export class MqttRequestService { publishToGETALLDATA() { this.mqttService.publishToTopic('BACKEND/ACTION/GETALLDATA', JSON.stringify(this.storeService.getAllPlantNames())); } - publishToDRIVE() { - this.mqttService.publishToTopic('BACKEND/ACTION/DRIVE'); - } + publishToGETBATTERY() { this.mqttService.publishToTopic('BACKEND/ACTION/GETBATTERY'); } + publishToROBOTREADY() { this.mqttService.publishToTopic('BACKEND/ACTION/ROBOTREADY'); } - publishToGETPOSITION() { - this.mqttService.publishToTopic('BACKEND/ACTION/GETPOSITION'); - } publishToNEWPLANT(plant: Plant) { this.mqttService.publishToTopic('BACKEND/ACTION/NEWPLANT', JSON.stringify(plant)); @@ -173,6 +140,7 @@ export class MqttRequestService { publishToPLANTCOUNT() { this.mqttService.publishToTopic('BACKEND/ACTION/PLANTCOUNT'); } + /** * publishToINPUT wird die Spracheingabe Ć¼bermittelt, die dann mit * mehreren if else anweisungen einen Request an das Backend sendet und diff --git a/software/Frontend/src/app/Service/Mqtt/mqtt-set-data.service.ts b/software/Frontend/src/app/Service/Mqtt/mqtt-set-data.service.ts index cf68d45..7c28ab3 100644 --- a/software/Frontend/src/app/Service/Mqtt/mqtt-set-data.service.ts +++ b/software/Frontend/src/app/Service/Mqtt/mqtt-set-data.service.ts @@ -32,5 +32,4 @@ export class MqttSetDataService { setPlantCount(data: PlantCount): void { this.storeService.setPlantCount(data); } - } diff --git a/software/Frontend/src/app/Service/Mqtt/mqtt.service.ts b/software/Frontend/src/app/Service/Mqtt/mqtt.service.ts index c2762a6..90e7403 100644 --- a/software/Frontend/src/app/Service/Mqtt/mqtt.service.ts +++ b/software/Frontend/src/app/Service/Mqtt/mqtt.service.ts @@ -10,8 +10,8 @@ export class MqttService { // Connection zu dem MQTT Broker constructor() { - // this.client = connect('wss://mqtt.eclipseprojects.io:443/mqtt'); //Je nachdem welchen Link der Broker hat - this.client = connect('mqtt://192.168.137.197:1883', { clientId: 'kemal' }); + this.client = connect('wss://mqtt.eclipseprojects.io:443/mqtt'); //Online Broker + // this.client = connect('mqtt://192.168.137.197:1883', { clientId: 'kemal' }); //lokaler Broker } public subscribeToTopic(topic: string): Observable { diff --git a/software/Frontend/src/app/app.component.html b/software/Frontend/src/app/app.component.html index ba52e00..b2fa36b 100644 --- a/software/Frontend/src/app/app.component.html +++ b/software/Frontend/src/app/app.component.html @@ -28,7 +28,6 @@ not available -