-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
75 lines (48 loc) · 2.2 KB
/
example.py
File metadata and controls
75 lines (48 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import asyncio
import omlox_client
configuration = omlox_client.Configuration(
host="https://demo.coriva.io/corivahub/v2"
)
async def list_all_trackables() -> None:
"""Prints a list of all trackables and their associated location providers.
* Trackable: An object in the real world that needs to be tracked (e.g., a machine).
* Location Provider: A device capable of functioning within a locating system using a specific technology
(e.g., a CorivaTag Plus, which is a UWB location provider).
"""
async with omlox_client.ApiClient(configuration) as api_client:
trackables_api = omlox_client.TrackablesApi(api_client)
try:
trackables = await trackables_api.get_all_trackable_objects()
for trackable in trackables:
print(f"Trackable '{trackable.name}'\tLocation Providers: {trackable.location_providers}")
except Exception as e:
print(f"Exception: {e}")
async def list_all_fences():
async with omlox_client.ApiClient(configuration) as api_client:
fences_api = omlox_client.FencesApi(api_client)
try:
fences = await fences_api.get_all_fences()
if len(fences) == 0:
print("No Geofences found")
else:
for fence in fences:
print(f"Geofence '{fence.name}' with ID: {fence.id} found")
except Exception as e:
print(f"Exception: {e}")
async def trackables_in_geofence(fence_id: str) -> None:
"""Prints a list of all trackables inside a geofence.
"""
async with omlox_client.ApiClient(configuration) as api_client:
fences_api = omlox_client.FencesApi(api_client)
try:
trackables_inside = await fences_api.get_trackables_inside(fence_id)
if len(trackables_inside) == 0:
print("No Trackables inside this Geofence")
else:
for trackable in trackables_inside:
print(f"Trackable '{trackable.name}' is in Geofence {fence_id}")
except Exception as e:
print(f"Exception: {e}")
if __name__ == '__main__':
asyncio.run(list_all_fences())
asyncio.run(list_all_trackables())