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
    
    
  ccsds_completeness.pyΒΆ
Note
CCSDS Completeness is a concept specific to CCSDS-style packets. If you store a different type of packet in Yamcs, then this code example is not applicable.
from datetime import datetime, timedelta, timezone
from yamcs.client import YamcsClient
def print_latest():
    """
    Prints completeness records for the last two days
    """
    now = datetime.now(tz=timezone.utc)
    start = now - timedelta(days=2)
    # Results are returned in records per 'group'.
    # A completeness group matches with a CCSDS APID.
    # We may receive multiple groups with the same APID
    # depending on how much data there is for the selected
    # range.
    # Combine all returned pages by APID
    records_by_apid = {}
    for group in archive.list_completeness_index(start=start, stop=now):
        if group.name not in records_by_apid:
            records_by_apid[group.name] = []
        records_by_apid[group.name].extend(group.records)
    for apid, records in records_by_apid.items():
        print("APID:", apid)
        total = 0
        for rec in records:
            print("  -", rec)
            total += rec.count
        print(f"  --> Total packets for {apid}: {total}")
if __name__ == "__main__":
    client = YamcsClient("localhost:8090")
    archive = client.get_archive(instance="simulator")
    print_latest()