From ef7468a61549336109065995e3e52c1c5b455bff Mon Sep 17 00:00:00 2001 From: Oleksandr Husak <oleksandr.husak@mailbox.tu-dresden.de> Date: Mon, 28 Feb 2022 18:21:12 +0100 Subject: [PATCH] agent properties in the popup --- README.md | 64 ++++++++++++++----------- src/app/components/map/map.component.ts | 24 +++++++--- src/app/model/base-model.ts | 9 +++- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 7df9217..4b474f9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ - Public MQTT broker and client from [hivemq](https://www.hivemq.com/public-mqtt-broker/). MQTT client with a standart settings. - `ipos/client/position`: relative position of an agent to a curent root point - `ipos/client/root`: update a root point. Default is `{"latitude": 51.02545, "longitude": 13.72295}`. + - `ipos/client/extracted` extracted attributes. Related with VDA5050 - Messages description: [SimpleSceneIntegration Interface](https://md.inf.tu-dresden.de/IPos_IFSimpleSceneIntegration). ### Online app @@ -30,39 +31,44 @@ Connection settings - topic `ipos/client/position` - new positions - ```json - { - "objects": [ { - "id": "Employee1", - "sensorId": "UWB_1", - "type": "HUMAN", - "sensorType": "UWB", - "position": { - "refSystemId": "ROOT", - "point": { - "x": 3, - "y": 2, - "z": 3 - }, - "accuracy": 1 - }, - "orientation": { - "x": 1, - "y": 0.5, - "z": 1, - "w": 1.5 - }, - "lastPosUpdate": "2021-09-14T09:41:20+00:00", - "zoneDescriptors": [ + "objects": [ { - "zoneId": "door_zone", - "notificationType": "EntryNotification" + "id": "Employee1", + "sensorId": "UWB_1", + "type": "HUMAN", + "sensorType": "UWB", + "position": { + "refSystemId": "ROOT", + "point": { + "x": 28, + "y": -12, + "z": 20 + }, + "accuracy": 1 + }, + "orientation": { + "x": 1, + "y": 0.5, + "z": 1, + "w": 1.5 + }, + "extractedAttributes": { + "batteryChargeLevel": 70, + "loadedItems": [23, 1, 25, 17], + "errors": [2, 1, 6] + }, + "lastPosUpdate": "2021-09-14T09:41:20+00:00", + "zoneDescriptors": [ + { + "zoneId": "door_zone", + "notificationType": "EntryNotification" + } + ] } - ] + ], + "type": "EntryNotification" } - ], - "type": "EntryNotification" - } ``` - More objects can be added to the `"object": []` - There are special colours for objects with id `"Employee1"` - `"Employee4"`. Config: [MarkerColorMap](src/environments/environment.ts) diff --git a/src/app/components/map/map.component.ts b/src/app/components/map/map.component.ts index fa735be..e87b0c6 100644 --- a/src/app/components/map/map.component.ts +++ b/src/app/components/map/map.component.ts @@ -40,11 +40,11 @@ export class MapComponent implements OnInit { }); } - ngOnInit(): void { } + ngOnInit(): void { } - // --- Controllers + // --- Controllers - ref2root(pos: RelativePos) { + ref2root(pos: RelativePos) { // convert a relative position to WFG84 format let source = <WGS84>this.root.point let origin = L.latLng([source.latitude, source.longitude]) @@ -66,10 +66,22 @@ export class MapComponent implements OnInit { // --- Info let pos = desc["position"] this.agentsInfo[key] = desc - this.addMarker(key, pos) + + var props = undefined + if (desc.extractedAttributes) { + props = `<p> \ + <h3>${key}</h3> + <strong>Charge</strong>: ${desc.extractedAttributes.batteryChargeLevel}% <br>\ + <strong>Items</strong>: ${desc.extractedAttributes.loadedItems}\ + </p>` + } else { + props = `<p><h3>${key}</h3></p>` + } + + this.addMarker(key, pos, props) } - addMarker(key: string, pos: Position) { + addMarker(key: string, pos: Position, popup: string) { let point = pos.point if ('x' in point) { @@ -94,7 +106,7 @@ export class MapComponent implements OnInit { shadowUrl: 'assets/marker-shadow.png', className: 'true-position-marker' }) - }).bindPopup(key).openPopup(); + }).bindPopup(popup).openPopup(); marker.addTo(this.markOverlays[key]) // --- Accuracy diff --git a/src/app/model/base-model.ts b/src/app/model/base-model.ts index 645e133..33c757e 100644 --- a/src/app/model/base-model.ts +++ b/src/app/model/base-model.ts @@ -13,6 +13,7 @@ export interface Object { orientation?: Orientation lastPosUpdate: string zoneDescriptors: ZoneDesc[] + extractedAttributes?: ExtAttribute } export interface Position { @@ -47,7 +48,7 @@ interface Orientation { export enum NotificationType { "EntryNotification", - "ExitNotification", + "ExitNotification", "Unknown" } @@ -62,6 +63,10 @@ enum SensorType { "Bluetooth", "WiFi" } - +interface ExtAttribute { + batteryChargeLevel: number + loadedItems: number[] + errors: number[] +} -- GitLab