-
Notifications
You must be signed in to change notification settings - Fork 3
/
example_signals.py
55 lines (48 loc) · 1.95 KB
/
example_signals.py
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
"""Example Script for sending Signals
This Script sends Signals with Different Colors over the Bridge.The resends parameter
specifies how often a package is resend.
A lower value can lead to package loss. The resends_gap parameter
specifies how long the artificial delay behind every transmission is. Usually this
value can be set to 0 if the resends value is sufficiently high.
The default values are set to values that are moste likely to work on most Systems.
It´s also possible to adjust which stones are targeted by changing the status value.
The Status values for available Gravitrax Power stones can be found in the
gravitrax_constants file.
"""
import asyncio
from gravitraxconnect import gravitrax_bridge as gb
from gravitraxconnect import gravitrax_constants
async def main():
"""Send a Signal Sequence of red, green and blue signals
"""
bridge = gb.Bridge()
gb.logger.disabled = False
try:
if await bridge.connect():
for _ in range(3):
gb.log_print("Send RED", bridge=bridge)
await bridge.send_signal(
gravitrax_constants.STATUS_ALL,
gravitrax_constants.COLOR_RED,
resends=12,
)
await asyncio.sleep(3)
gb.log_print("Send GREEN and BLUE", bridge=bridge)
await bridge.send_signal(
gravitrax_constants.STATUS_ALL,
gravitrax_constants.COLOR_GREEN,
resends=12,
)
await bridge.send_signal(
gravitrax_constants.STATUS_ALL,
gravitrax_constants.COLOR_BLUE,
resends=12,
resend_gap=0,
)
await asyncio.sleep(3)
await bridge.disconnect()
except asyncio.CancelledError:
return
if __name__ == "__main__":
asyncio.run(main())
gb.log_print("Program finished")