openc3-cosmos-constellation 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96e58e8bfe303ce4366826261aa110703a0b2be39652fc9be8b6360ec51e040a
4
- data.tar.gz: ebc7922734b48fa8437059a999d985f3cfccfc62285de6bf96da21dcb0723194
3
+ metadata.gz: ad3cbfc7648b177285a954c17e4c592c254862d2c0e79f128526b4dad52957f9
4
+ data.tar.gz: ff7be196ea8274ab1b35dc13194dab2b1d34b80f72bea88b8c3a24208d7c0869
5
5
  SHA512:
6
- metadata.gz: 84cc92cd55c5e864280d81110bb997becbf61c001dc2d36e17570cdf442803814655f57ba442e32faeedd73839dc34a5faabf4419b578be917769ca747881257
7
- data.tar.gz: 54a40947f6cf787e3511c87a5e78a4c3c5a4958af0eb5efb3dfd8e88d7d0c7370f3815148bfe150943bb482e5d1f948c9854ba87362cb009f02838748a1eafc3
6
+ metadata.gz: afefedd0cefea489de19b2ee79118567b602cea73dbc52ad47b26934cb9624950af4cc2915015bfb87d8ab1e86d7f5c0d7861f6b768e5693a39e8e13a9968149
7
+ data.tar.gz: 6c4e10555ffa3ff8127ccae734e5ca63c10e7a920c5816cf557490c2ae54d2f5576fce8ee5d0143aa3b7dd894198b25253f0c1f595cd3aa159976892bbaef687
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- # Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.8.1
2
- # (or ./openc3.sh cli rake build VERSION=0.8.1 inside a COSMOS checkout).
1
+ # Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.8.3
2
+ # (or ./openc3.sh cli rake build VERSION=0.8.3 inside a COSMOS checkout).
3
3
  PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
4
4
 
5
5
  # The tool draws the shared Constellation Forecast view, copied in from this repo when it is here.
@@ -13,7 +13,7 @@ SHARED_RESULTS = '../../clients/python/src/constellation_space/results.py'
13
13
  SHARED_LICENSE = '../../LICENSE'
14
14
 
15
15
  task :build do
16
- abort('VERSION is required: rake build VERSION=0.8.1') unless ENV['VERSION']
16
+ abort('VERSION is required: rake build VERSION=0.8.3') unless ENV['VERSION']
17
17
  FileUtils.cp(SHARED_VIEW, VIEW) if File.exist?(SHARED_VIEW)
18
18
  abort("#{VIEW} is missing: copy bridges/shared/forecast-view.js there") unless File.exist?(VIEW)
19
19
  if File.exist?(SHARED_RESULTS)
@@ -38,7 +38,7 @@ from typing import Any
38
38
 
39
39
  from constellation_space import results
40
40
 
41
- VERSION = "0.8.1"
41
+ VERSION = "0.8.3"
42
42
  TARGET = "CONSTELLATION"
43
43
  POLL_S = int(os.environ.get("POLL_SECONDS", "15"))
44
44
  # COSMOS shows a packet stale 30 s after its last value: re-inject every poll so a quiet feed
@@ -321,9 +321,10 @@ def modcod_plans(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
321
321
 
322
322
  def modcod_packet(items: list[dict[str, Any]], now: datetime) -> dict[str, Any] | None:
323
323
  """MODCOD: the next pass's MODCOD plan, its changes and its lowest SINR at a change (the series
324
- holds only the changes). None without a plan still to fly."""
324
+ holds only the changes). The next AOS, as NEXT_PASS has it: a pass under way is not next.
325
+ None without a plan ahead."""
325
326
  plans = sorted(
326
- (p for p in modcod_plans(items) if datetime.fromisoformat(p["until"]) > now),
327
+ (p for p in modcod_plans(items) if datetime.fromisoformat(p["target_at"]) > now),
327
328
  key=lambda p: p["target_at"],
328
329
  )
329
330
  if not plans:
data/plugin.txt CHANGED
@@ -1,7 +1,6 @@
1
1
  # LANGUAGE python
2
2
  # Constellation workflow forecasts in COSMOS: a CONSTELLATION target whose packets the bridge
3
- # microservice fills from the Constellation feed. Everything here is a forecast, not telemetry
4
- # measured from a spacecraft or a ground station.
3
+ # microservice fills from the Constellation feed.
5
4
  VARIABLE constellation_api_url https://api.constellation.space
6
5
  VARIABLE_DESCRIPTION "Constellation API URL. The API key goes in Admin > Secrets as CONSTELLATION_API_KEY"
7
6
  VARIABLE consumer cosmos-bridge
data/public/store_img.png CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- TELEMETRY CONSTELLATION NEXT_PASS BIG_ENDIAN "Forecast: the next predicted pass, not a scheduled contact"
1
+ TELEMETRY CONSTELLATION NEXT_PASS BIG_ENDIAN "Forecast: the next predicted pass"
2
2
  ALLOW_SHORT
3
3
  APPEND_ITEM SATELLITE 512 STRING "Satellite id"
4
4
  APPEND_ITEM ANTENNA 512 STRING "Antenna id"
@@ -43,7 +43,7 @@ TELEMETRY CONSTELLATION SWAP BIG_ENDIAN "Forecast: the soonest open rain-fade sw
43
43
  APPEND_ITEM BACKUP_ANTENNA 512 STRING "Antenna to book instead, or NONE"
44
44
  APPEND_ITEM BACKUP_AOS 256 STRING "Backup pass AOS, UTC"
45
45
  APPEND_ITEM DEADLINE 256 STRING "Cancel the original by, UTC"
46
- APPEND_ITEM MINUTES_TO_DEADLINE 32 FLOAT "Minutes left to decide (99999 when no swap is open)"
46
+ APPEND_ITEM MINUTES_TO_DEADLINE 32 FLOAT "Minutes left to decide: yellow at 30 or less, red at 15 or less (99999 when no swap is open)"
47
47
  UNITS Minutes min
48
48
  FORMAT_STRING "%.1f"
49
49
  LIMITS DEFAULT 1 ENABLED 15 30 100000 100000
@@ -75,13 +75,13 @@ TELEMETRY CONSTELLATION MODCOD BIG_ENDIAN "Forecast: the next pass's MODCOD plan
75
75
  APPEND_ITEM SATELLITE 512 STRING "Satellite id"
76
76
  APPEND_ITEM ANTENNA 512 STRING "Antenna id"
77
77
  APPEND_ITEM AOS 256 STRING "Predicted AOS, UTC"
78
- APPEND_ITEM CHANGES 32 UINT "MODCOD changes over the pass"
78
+ APPEND_ITEM CHANGES 32 UINT "MODCOD changes over the pass, after the one at AOS"
79
79
  APPEND_ITEM FIRST 256 STRING "MODCOD at AOS"
80
80
  APPEND_ITEM LAST 256 STRING "MODCOD at LOS"
81
81
  APPEND_ITEM MIN_SINR_DB 32 FLOAT "Lowest planned SINR (p50) at a MODCOD change"
82
82
  UNITS Decibels dB
83
83
  FORMAT_STRING "%.2f"
84
- APPEND_ITEM PLANNED_PASSES 32 UINT "Passes with a plan still to fly"
84
+ APPEND_ITEM PLANNED_PASSES 32 UINT "Passes ahead with a plan"
85
85
 
86
86
  TELEMETRY CONSTELLATION RUN BIG_ENDIAN "The latest workflow run received, of any kind: each other packet holds the newest run of its own kind"
87
87
  ALLOW_SHORT
@@ -1,6 +1,6 @@
1
1
  SCREEN AUTO AUTO 1.0
2
2
 
3
- TITLE "Constellation forecast: predicted values, not measured telemetry"
3
+ TITLE "Constellation forecast"
4
4
 
5
5
  HORIZONTALBOX "Latest run received"
6
6
  LABELVALUEDESC CONSTELLATION RUN WORKFLOW "Workflow" CONVERTED 16
@@ -57,6 +57,9 @@ const gbOf = (item) => {
57
57
  const g = typeof ledger?.p50 === 'number' ? ledger : item.value;
58
58
  return g && typeof g.p50 === 'number' ? g : null;
59
59
  };
60
+ // A MODCOD plan's series holds each switch, the first at AOS: its changes are the steps after it,
61
+ // as the COSMOS MODCOD packet's CHANGES and the Lattice bridge count them.
62
+ const changes = (series) => `${series.length - 1} change${series.length === 2 ? '' : 's'}`;
60
63
  const ledgerOf = (item) => item.explain?.ledger?.value || {};
61
64
  // A pass's max elevation: the ledger entry the orbit wrote, under whichever node wrote it.
62
65
  const elevationOf = (item) =>
@@ -119,7 +122,7 @@ function bandChart(buckets, { height = 180, unit = 'GB' } = {}) {
119
122
  }
120
123
 
121
124
  /** Horizontal bars with p10 to p90 whiskers, one row per key. */
122
- function rangeBars(rows, { unit = 'GB' } = {}) {
125
+ function rangeBars(rows, { unit = 'GB', digits = 1 } = {}) {
123
126
  const rowH = 20;
124
127
  const pad = { l: 128, r: 56, t: 4 };
125
128
  const h = pad.t + rows.length * rowH;
@@ -133,7 +136,7 @@ function rangeBars(rows, { unit = 'GB' } = {}) {
133
136
  r.p10 !== undefined
134
137
  ? `<line class="cf-whisker" x1="${x(r.p10)}" x2="${x(r.p90)}" y1="${y + rowH / 2}" y2="${y + rowH / 2}"/>`
135
138
  : '';
136
- return `<g ${tip(r.tip ?? `${r.label}: ${num(value)} ${unit}`)}><text class="cf-label" x="${pad.l - 8}" y="${y + rowH / 2 + 4}" text-anchor="end">${esc(r.label)}</text><rect class="cf-bar${r.warn ? ' cf-bar-warn' : ''}" x="${pad.l}" y="${y + 6}" width="${Math.max(x(value) - pad.l, 2)}" height="${rowH - 12}" rx="2"/>${whisker}<text class="cf-value" x="${x(r.p90 ?? value) + 6}" y="${y + rowH / 2 + 4}">${big(value)}</text></g>`;
139
+ return `<g ${tip(r.tip ?? `${r.label}: ${num(value)} ${unit}`)}><text class="cf-label" x="${pad.l - 8}" y="${y + rowH / 2 + 4}" text-anchor="end">${esc(r.label)}</text><rect class="cf-bar${r.warn ? ' cf-bar-warn' : ''}" x="${pad.l}" y="${y + 6}" width="${Math.max(x(value) - pad.l, 2)}" height="${rowH - 12}" rx="2"/>${whisker}<text class="cf-value" x="${x(r.p90 ?? value) + 6}" y="${y + rowH / 2 + 4}">${num(value, digits)}</text></g>`;
137
140
  })
138
141
  .join('');
139
142
  return `<svg class="cf-chart" viewBox="0 0 ${W} ${h}" role="img" aria-label="Values per row">${body}</svg>`;
@@ -153,7 +156,7 @@ function heatGrid(rows, cols, cell, { unit = 'GB' } = {}) {
153
156
  .map((c, j) => {
154
157
  const v = cell(r, c);
155
158
  const share = v ? v.value / max : 0;
156
- const label = v && cw > 48 ? `<text class="cf-heat-label${share > 0.55 ? ' cf-on-dark' : ''}" x="${pad.l + j * cw + cw / 2}" y="${pad.t + i * ch + 15}" text-anchor="middle">${big(v.value)}</text>` : '';
159
+ const label = v && cw > 48 ? `<text class="cf-heat-label${share > 0.55 ? ' cf-on-dark' : ''}" x="${pad.l + j * cw + cw / 2}" y="${pad.t + i * ch + 15}" text-anchor="middle">${num(v.value)}</text>` : '';
157
160
  return `<g ${tip(v ? `${r} · ${c}: ${num(v.value)} ${unit}, ${v.detail}` : `${r} · ${c}: no passes`)}><rect class="cf-heat" x="${pad.l + j * cw + 1}" y="${pad.t + i * ch + 1}" width="${cw - 2}" height="${ch - 2}" rx="3" style="--share:${share.toFixed(3)}"/>${label}</g>`;
158
161
  })
159
162
  .join('');
@@ -264,6 +267,8 @@ export function actionState(item) {
264
267
  /** A swap to show: advice, or approved in Constellation; never one held or rejected. */
265
268
  const actionable = (i) => actionState(i) === 'advice' || actionState(i) === 'approved';
266
269
 
270
+ // A probability or share column reads as a percent, as the lock-loss risk does.
271
+ const SHARES = ['probability', 'share'];
267
272
  // rfi-watch items are links whose value is RFI in dB (p10/p50/p90) with a lock-loss risk (a
268
273
  // share), and whose action is a reroute with no deadline: never GB, never a swap.
269
274
  const pct = (v) => (typeof v === 'number' ? `${Math.round(v * 100)}%` : num(v));
@@ -400,7 +405,7 @@ export const VIEWS = {
400
405
  const mix = new Map();
401
406
  for (const item of items) for (const s of item.series || []) mix.set(s.value.modcod, (mix.get(s.value.modcod) || 0) + 1);
402
407
  const rows = [...mix.entries()].sort((a, b) => b[1] - a[1]).slice(0, 12).map(([label, value]) => ({ label, value, tip: `${label}: chosen ${value} times across the plan` }));
403
- return section('MODCOD mix across the plan', rangeBars(rows, { unit: 'steps' }), 'How often each MODCOD is planned. Select a pass below to see its own plan.');
408
+ return section('MODCOD mix across the plan', rangeBars(rows, { unit: 'steps', digits: 0 }), 'How often each MODCOD is planned. Select a pass below to see its own plan.');
404
409
  }
405
410
  return section('Expected GB over the next 24 hours', bandChart(hourly(items)), 'The line is the median (p50); the band runs from the wet tail (p10) to the best case (p90). Hover an hour for its passes.');
406
411
  },
@@ -467,7 +472,7 @@ export const VIEWS = {
467
472
  ? `<td>${minute(i.target_at)}</td><td>${esc(linkLabel(i))}</td><td class="cf-num">${num(ledgerOf(i).delivered_gb)} / ${num(ledgerOf(i).possible_gb)}</td><td>${ledgerOf(i).dead ? `<span class="cf-status-warn">▲</span> ${esc(ledgerOf(i).status)}` : esc(ledgerOf(i).status)}</td>`
468
473
  : run.kind === 'antenna-capacity'
469
474
  ? `<td>${esc(i.target_at.slice(0, 10))}</td><td>${esc(i.entity.id)}</td><td class="cf-num">${num(g?.p10)} / <b>${num(g?.p50)}</b> / ${num(g?.p90)}</td><td>${esc(gbOf(i)?.passes)} · ${num(gbOf(i)?.sellable_min, 0)} min</td>`
470
- : `<td>${minute(i.target_at)}</td><td>${esc(linkLabel(i))}</td><td class="cf-num">${num(g?.p10)} / <b>${num(g?.p50)}</b> / ${num(g?.p90)}</td><td>${i.action || i.severity ? '<span class="cf-status-warn" title="rain-fade risk">▲</span>' : ''}${i.series ? `${esc(i.series.length)} MODCODs` : elevationOf(i) != null ? `${Math.round(elevationOf(i))}°` : ''}</td>`;
475
+ : `<td>${minute(i.target_at)}</td><td>${esc(linkLabel(i))}</td><td class="cf-num">${num(g?.p10)} / <b>${num(g?.p50)}</b> / ${num(g?.p90)}</td><td>${i.action || i.severity ? '<span class="cf-status-warn" title="rain-fade risk">▲</span>' : ''}${i.series ? changes(i.series) : elevationOf(i) != null ? `${Math.round(elevationOf(i))}°` : ''}</td>`;
471
476
  return `<tr data-id="${esc(i.entity.id)}" class="${i.entity.id === selected ? 'cf-sel' : ''}">${cells}</tr>`;
472
477
  })
473
478
  .join('');
@@ -481,7 +486,7 @@ export const VIEWS = {
481
486
  const x = item.explain || {};
482
487
  const laneRows = Object.entries(x)
483
488
  .filter(([, l]) => shown(l?.value) != null)
484
- .map(([column, l]) => `<tr><td>${esc(column)}</td><td class="cf-num">${num(shown(l.value))} ${esc(l.unit ?? '')}</td><td class="cf-src" ${tip(l.source ?? '')}>${esc(sourceLabel(l.source))}</td></tr>`)
489
+ .map(([column, l]) => `<tr><td>${esc(column)}</td><td class="cf-num">${SHARES.includes(l.unit) ? pct(shown(l.value)) : `${num(shown(l.value))} ${esc(l.unit ?? '')}`}</td><td class="cf-src" ${tip(l.source ?? '')}>${esc(sourceLabel(l.source))}</td></tr>`)
485
490
  .join('');
486
491
  const g = run.kind === 'rfi-watch' ? null : gbOf(item);
487
492
  const plan = item.series?.length ? `<h4>Plan over the pass</h4>${stepChart(item.series)}` : '';
@@ -497,15 +502,14 @@ export const VIEWS = {
497
502
  const STYLE = `
498
503
  .cf { --cf-ink: var(--y-foreground-color, #0b0b0b); --cf-muted: var(--y-hint-foreground, #6b6b66); --cf-line: var(--y-border-color, rgba(0,0,0,.1));
499
504
  --cf-surface: var(--y-background-color, #fff); --cf-raise: var(--y-detail-pane-background-color, #fafaf9); --cf-series: #2a78d6; --cf-band: rgba(42,120,214,.18);
500
- --cf-warn: #fab219; --cf-warn-ink: #8a5a00;
505
+ --cf-warn: #fab219;
501
506
  font: 13px/1.45 Roboto, "Helvetica Neue", system-ui, sans-serif; color: var(--cf-ink); background: var(--cf-surface); padding: 20px 24px 48px; position: relative; }
502
507
  /* Dark hosts (Open MCT's Espresso, Yamcs's dark theme): the same roles stepped for a dark surface. */
503
508
  .cf[data-theme="dark"] { --cf-ink: #e8e8e6; --cf-muted: #a3a29c; --cf-line: rgba(255,255,255,.12); --cf-surface: #1a1a19;
504
- --cf-raise: #242423; --cf-series: #3987e5; --cf-band: rgba(57,135,229,.28); --cf-warn: #fab219; --cf-warn-ink: #fab219; }
509
+ --cf-raise: #242423; --cf-series: #3987e5; --cf-band: rgba(57,135,229,.28); --cf-warn: #fab219; }
505
510
  .cf * { box-sizing: border-box; }
506
511
  .cf-head { display:flex; align-items:baseline; gap:12px; flex-wrap:wrap; margin-bottom:4px; }
507
512
  .cf-head h2 { font-size:20px; font-weight:500; margin:0; }
508
- .cf-forecast { font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--cf-warn-ink); border:1px solid var(--cf-warn); border-radius:999px; padding:1px 8px; }
509
513
  .cf-meta { color:var(--cf-muted); font-size:12px; }
510
514
  .cf-cats { display:flex; gap:2px; border-bottom:1px solid var(--cf-line); margin:16px 0 0; }
511
515
  .cf-cats button { background:none; border:none; border-bottom:2px solid transparent; padding:8px 14px; color:var(--cf-muted); cursor:pointer; font:inherit; }
@@ -580,6 +584,16 @@ function categoryOf(kind) {
580
584
  return CATEGORIES.find((c) => c.kinds.includes(kind))?.key ?? 'passes';
581
585
  }
582
586
 
587
+ const KINDS = CATEGORIES.flatMap((c) => c.kinds);
588
+ const rank = (w) => (KINDS.includes(w.kind) ? KINDS.indexOf(w.kind) : KINDS.length);
589
+
590
+ /** The workflow a category (else the whole view) opens on: by kind in CATEGORIES order, so Passes
591
+ * opens on pass yield before a MODCOD plan, then in index order. */
592
+ export function firstWorkflow(workflows, category) {
593
+ const pool = category ? workflows.filter((w) => categoryOf(w.kind) === category) : workflows;
594
+ return [...pool].sort((a, b) => rank(a) - rank(b))[0] ?? null;
595
+ }
596
+
583
597
  export function mountForecast(element, { load, refreshMs = REFRESH_MS, theme = 'light' }) {
584
598
  const state = { workflows: [], category: null, workflow: null, run: null, selected: null, error: null, loaded: false };
585
599
  element.innerHTML = '';
@@ -597,7 +611,7 @@ export function mountForecast(element, { load, refreshMs = REFRESH_MS, theme = '
597
611
  const index = await load('index.json');
598
612
  state.workflows = index.workflows || [];
599
613
  if (!state.workflow || !state.workflows.some((w) => w.workflow === state.workflow)) {
600
- const first = CATEGORIES.map((c) => state.workflows.find((w) => c.kinds.includes(w.kind))).find(Boolean) || state.workflows[0];
614
+ const first = firstWorkflow(state.workflows);
601
615
  state.workflow = first?.workflow ?? null;
602
616
  state.category = first ? categoryOf(first.kind) : null;
603
617
  }
@@ -637,8 +651,8 @@ export function mountForecast(element, { load, refreshMs = REFRESH_MS, theme = '
637
651
  const side = blocks.includes('ledger') ? VIEWS.ledger(run, items, selected) : '';
638
652
  body = `<p class="cf-meta">${esc(TITLES[run.kind] ?? run.kind)} · workflow ${esc(run.workflow)} v${esc(run.workflow_version)} · run ${esc(run.run_id)} · delivered ${ago(run.delivered_at)}</p>${flows}<div class="cf-grid2"><div>${main}</div><div>${side}</div></div>`;
639
653
  }
640
- root.innerHTML = `<div class="cf-head"><h2>Constellation Forecast</h2><span class="cf-forecast">Forecast · not scheduled contacts</span></div>
641
- <p class="cf-meta">Predicted by Constellation workflows. Nothing here is measured telemetry.</p>
654
+ root.innerHTML = `<div class="cf-head"><h2>Constellation Forecast</h2></div>
655
+ <p class="cf-meta">Predictions from Constellation workflows.</p>
642
656
  ${error === 'restarting' ? '<p class="cf-note">Waiting for the host to come back; this refreshes on its own.</p>' : error ? `<div class="cf-error">Could not read the forecasts: ${esc(error)}</div>` : ''}
643
657
  ${workflows.length ? `<div class="cf-cats" role="tablist">${cats}</div>` : ''}${body}`;
644
658
  }
@@ -647,7 +661,7 @@ export function mountForecast(element, { load, refreshMs = REFRESH_MS, theme = '
647
661
  const cat = e.target.closest('[data-category]');
648
662
  if (cat) {
649
663
  state.category = cat.dataset.category;
650
- const first = state.workflows.find((w) => categoryOf(w.kind) === state.category);
664
+ const first = firstWorkflow(state.workflows, state.category);
651
665
  state.workflow = first?.workflow ?? null;
652
666
  state.selected = null;
653
667
  return void refresh();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openc3-cosmos-constellation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Constellation Space Corp
@@ -14,8 +14,7 @@ description: 'A CONSTELLATION target whose packets a bridge microservice fills f
14
14
  the Constellation feed: the next predicted pass, the next 24 hours, the soonest
15
15
  rain-fade swap to decide, a day''s capacity across the antennas (CAPACITY), the
16
16
  next pass''s MODCOD plan (MODCOD), and the run they came from. A Telemetry Viewer
17
- screen shows them all, and a Constellation Forecast tool charts each workflow. Every
18
- value is a forecast.'
17
+ screen shows them all, and a Constellation Forecast tool charts each workflow.'
19
18
  email:
20
19
  - support@constellation.space
21
20
  executables: []