Python Yamcs Client
- General Client
- Mission Database
- TM/TC Processing
- Archive
- Link Management
- Object Storage
- File Transfer
- Time Correlation (TCO)
- Timeline
- Examples
- alarms.py
- archive_breakdown.py
- archive_retrieval.py
- authenticate.py
- ccsds_completeness.py
- commanding.py
- cop1.py
- file_transfer.py
- links.py
- events.py
- mission_time.py
- packet_subscription.py
- parameter_subscription.py
- plot_with_matplotlib.py
- query_mdb.py
- read_write_parameters.py
- reconnection.py
- timeline.py
- write_mdb.py
Related
Download this Document
reconnection.pyΒΆ
from time import sleep
from yamcs.client import ConnectionFailure, YamcsClient
"""
Subscription types are modeled as Python futures which cover
the lifetime of the underlying WebSocket call.
Therefore we can use methods like ``result()`` or
``add_done_callback(fn)`` to observe connection failures.
The following example uses ``result()`` to trigger
a delayed reconnection attempt.
"""
def print_data(data):
for parameter in data.parameters:
print(parameter)
while True:
try:
client = YamcsClient("localhost:8090")
processor = client.get_processor("simulator", "realtime")
subscription = processor.create_parameter_subscription(
"/YSS/SIMULATOR/BatteryVoltage1", on_data=print_data
)
# Wait until WebSocket close
subscription.result()
except ConnectionFailure:
print("Retrying in 5 seconds...")
sleep(5)