Final status
This commit is contained in:
parent
5e14633f42
commit
f6f6421620
@ -19,7 +19,6 @@ export class PlantsComponent {
|
|||||||
filteredOptions: Observable<string[]>;
|
filteredOptions: Observable<string[]>;
|
||||||
plants$: Observable<Plant[]> = this.storeService.currentPlants;
|
plants$: Observable<Plant[]> = this.storeService.currentPlants;
|
||||||
|
|
||||||
|
|
||||||
constructor(public dialog: MatDialog, public storeService: StoreService, private mqttRequestService: MqttRequestService) {
|
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
|
// sobald es eine änderung bei den pflanzenNamen gibt, wird bei der suchleiste ein neuer filter eingesetzt
|
||||||
this.options$.subscribe(response => {
|
this.options$.subscribe(response => {
|
||||||
@ -58,12 +57,10 @@ export class PlantsComponent {
|
|||||||
this.selectedPlant = value;
|
this.selectedPlant = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onOptionDefault() {
|
onOptionDefault() {
|
||||||
this.selectedPlant = 'undefined';
|
this.selectedPlant = 'undefined';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private _filter(value: string, options: string[]): string[] {
|
private _filter(value: string, options: string[]): string[] {
|
||||||
const filterValue = value.toLowerCase();
|
const filterValue = value.toLowerCase();
|
||||||
|
|
||||||
|
@ -66,19 +66,6 @@ export class MqttRequestService {
|
|||||||
console.error('Error:', err);
|
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 => {
|
this.mqttService.subscribeToTopic("BACKEND/DATA/BATTERY").subscribe(data => {
|
||||||
if (typeof data !== "object") {
|
if (typeof data !== "object") {
|
||||||
const payload = JSON.parse(data) as RobotBattery;
|
const payload = JSON.parse(data) as RobotBattery;
|
||||||
@ -119,22 +106,6 @@ export class MqttRequestService {
|
|||||||
console.error('Error:', err);
|
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
|
//Publish to the Topic to recieve the first Data
|
||||||
this.publishToPLANTCOUNT();
|
this.publishToPLANTCOUNT();
|
||||||
this.publishToGETBATTERY();
|
this.publishToGETBATTERY();
|
||||||
@ -145,18 +116,14 @@ export class MqttRequestService {
|
|||||||
publishToGETALLDATA() {
|
publishToGETALLDATA() {
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/GETALLDATA', JSON.stringify(this.storeService.getAllPlantNames()));
|
this.mqttService.publishToTopic('BACKEND/ACTION/GETALLDATA', JSON.stringify(this.storeService.getAllPlantNames()));
|
||||||
}
|
}
|
||||||
publishToDRIVE() {
|
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/DRIVE');
|
|
||||||
}
|
|
||||||
publishToGETBATTERY() {
|
publishToGETBATTERY() {
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/GETBATTERY');
|
this.mqttService.publishToTopic('BACKEND/ACTION/GETBATTERY');
|
||||||
}
|
}
|
||||||
|
|
||||||
publishToROBOTREADY() {
|
publishToROBOTREADY() {
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/ROBOTREADY');
|
this.mqttService.publishToTopic('BACKEND/ACTION/ROBOTREADY');
|
||||||
}
|
}
|
||||||
publishToGETPOSITION() {
|
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/GETPOSITION');
|
|
||||||
}
|
|
||||||
|
|
||||||
publishToNEWPLANT(plant: Plant) {
|
publishToNEWPLANT(plant: Plant) {
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/NEWPLANT', JSON.stringify(plant));
|
this.mqttService.publishToTopic('BACKEND/ACTION/NEWPLANT', JSON.stringify(plant));
|
||||||
@ -173,6 +140,7 @@ export class MqttRequestService {
|
|||||||
publishToPLANTCOUNT() {
|
publishToPLANTCOUNT() {
|
||||||
this.mqttService.publishToTopic('BACKEND/ACTION/PLANTCOUNT');
|
this.mqttService.publishToTopic('BACKEND/ACTION/PLANTCOUNT');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* publishToINPUT wird die Spracheingabe übermittelt, die dann mit
|
* publishToINPUT wird die Spracheingabe übermittelt, die dann mit
|
||||||
* mehreren if else anweisungen einen Request an das Backend sendet und
|
* mehreren if else anweisungen einen Request an das Backend sendet und
|
||||||
|
@ -32,5 +32,4 @@ export class MqttSetDataService {
|
|||||||
setPlantCount(data: PlantCount): void {
|
setPlantCount(data: PlantCount): void {
|
||||||
this.storeService.setPlantCount(data);
|
this.storeService.setPlantCount(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ export class MqttService {
|
|||||||
|
|
||||||
// Connection zu dem MQTT Broker
|
// Connection zu dem MQTT Broker
|
||||||
constructor() {
|
constructor() {
|
||||||
// this.client = connect('wss://mqtt.eclipseprojects.io:443/mqtt'); //Je nachdem welchen Link der Broker hat
|
this.client = connect('wss://mqtt.eclipseprojects.io:443/mqtt'); //Online Broker
|
||||||
this.client = connect('mqtt://192.168.137.197:1883', { clientId: 'kemal' });
|
// this.client = connect('mqtt://192.168.137.197:1883', { clientId: 'kemal' }); //lokaler Broker
|
||||||
}
|
}
|
||||||
|
|
||||||
public subscribeToTopic(topic: string): Observable<any> {
|
public subscribeToTopic(topic: string): Observable<any> {
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
<img class="img-item" src="assets/images/logo.png" alt="not available">
|
<img class="img-item" src="assets/images/logo.png" alt="not available">
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user