Python Yamcs Client
- General Client
- Mission Database
- TM/TC Processing
- Archive
- Link Management
- Object Storage
- File Transfer
- Time Correlation (TCO)
- Timeline
- Examples
Related
Download this Document
/
Python Yamcs Client /
Timeline
Timeline¶
The Timeline API provides methods that you can use to programmatically work with Yamcs bands and items.
Reference¶
Snippets¶
Create a TimelineClient
for a specific instance:
from yamcs.client import YamcsClient
client = YamcsClient("localhost:8090")
timeline = client.get_timeline_client(instance="simulator")
Create a few Band
objects:
from yamcs.client import ItemBand, TimeRuler
utc_time = TimeRuler()
utc_time.name = "UTC"
timeline.save_band(utc_time)
local_time = TimeRuler()
local_time.name = "Local"
local_time.timezone = "Europe/Brussels"
timeline.save_band(local_time)
group_a = ItemBand()
group_a.name = "Group A"
group_a.tags = ["group-a"]
timeline.save_band(group_a)
group_b = ItemBand()
group_b.name = "Group B"
group_b.tags = ["group-b"]
group_b.item_border_color = "#ff4500"
group_b.item_background_color = "#ffa500"
timeline.save_band(group_b)
Create some Item
objects. Bands of type ItemBand
will display items with matching tags:
from datetime import datetime, timedelta, timezone
from yamcs.client import Item
now = datetime.now(tz=timezone.utc)
for i in range(10):
item = Item()
item.name = f"A {i + 1}"
item.start = now + timedelta(seconds=i * 7200)
item.duration = timedelta(seconds=3600)
item.tags = ["group-a"]
timeline.save_item(item)
item = Item()
item.name = f"B {i + 1}"
item.start = now + timedelta(seconds=3600 + (i * 7200))
item.duration = timedelta(seconds=3600)
item.tags = ["group-b"]
timeline.save_item(item)
Create a View
showing all bands:
from yamcs.client import View
view = View()
view.name = "Two groups"
view.bands = [utc_time, local_time, group_a, group_b]
timeline.save_view(view)
To update a Band
, Item
or View
use the same save methods as for inserting. When saving or fetching these objects they are assigned a server identifier that is used to detect whether further saves require an insert or update.
group_a.description = "A few random items"
timeline.save_band(group_a)
for item in timeline.list_items():
item.tags.append("example")
timeline.save_item(item)