Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | 4x 16x 16x 4x 16x 16x 16x 4x 4x 4x 4x 2x 4x 4x 2x 2x | //--------------------------------------------------------------------
// src/index.ts – stateless registration (no Redux)
//--------------------------------------------------------------------
import type { OctopusHost } from '@ska-octopus-widget-sdk/widget-sdk';
import {
COLOR_PALETTES,
makeWidgetDef,
type ColorPaletteId
} from '@ska-octopus-widget-sdk/widget-sdk';
import HDBPPLiveWidget from './HDBPPLiveWidget';
import pkg from '../package.json';
const { version } = pkg as any;
type ColorSchemeOption = { value: ColorPaletteId; label: string };
function humanizePaletteId(id: string) {
return id
.replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/(\d+)/g, ' $1')
.replace(/[-_]/g, ' ')
.replace(/\s+/g, ' ')
.trim()
.replace(/^./, (c) => c.toUpperCase());
}
const paletteOptions: ColorSchemeOption[] = (Object.keys(COLOR_PALETTES) as ColorPaletteId[]).map(
(value) => ({
value,
label: humanizePaletteId(value)
})
);
const colorSchemeEnum = paletteOptions.map((opt) => opt.value);
const colorSchemeEnumNames = paletteOptions.map((opt) => opt.label);
const defaultColorScheme: ColorPaletteId = 'tableau10';
const schema = {
type: 'object',
properties: {
attributes: {
type: 'array',
title: 'Tango attributes',
description: 'Full attribute names - one per line (device/attr)',
items: { type: 'string' },
minItems: 1
},
useLiveData: {
type: 'boolean',
title: 'Use Live Data (subscribe)',
description:
'If disabled, the widget only fetches HDB++ history periodically (according to the dashboard refresh rate).',
default: true
},
useHeatmap: {
type: 'boolean',
title: 'Heatmap mode',
description:
'When enabled, shows a heatmap: Y = attributes, X = time, color = value. When disabled, shows line traces.',
default: false
},
heatmapConnectGaps: {
type: 'boolean',
title: 'Heatmap: connect gaps',
description:
'Forward-fill values on an even time grid so cells stay connected. Disable to leave holes where timestamps are missing.',
default: true
},
legendPosition: {
type: 'string',
title: 'Legend position',
enum: ['left', 'right', 'top', 'bottom'],
enumNames: ['Left', 'Right', 'Top', 'Bottom'],
default: 'bottom'
},
colorMapPosition: {
type: 'string',
title: 'Color map position',
description: 'Placement of the heatmap color bar.',
enum: ['left', 'right', 'top', 'bottom', 'none'],
enumNames: ['Left', 'Right', 'Top', 'Bottom', 'None (hidden)'],
default: 'right'
},
maxPoints: {
type: 'integer',
title: 'Max points per trace',
minimum: 10,
default: 1000
},
downsample: {
type: 'string',
title: 'Downsample',
description:
'How to reduce points over the selected time range: "minmax" (peak-preserving), "avg" (mean), "lttb" (shape-preserving), or "none".',
enum: ['minmax', 'avg', 'lttb', 'none'],
enumNames: ['Min/Max per bucket', 'Average per bucket', 'LTTB (shape)', 'None (raw)'],
default: 'minmax'
},
enumDisplay: {
type: 'string',
title: 'Enum display',
description: 'Show enum values as their integer index or resolved enum label.',
enum: ['value', 'label'],
enumNames: ['Integer value', 'Enum label'],
default: 'value'
},
appendInterval: {
type: 'integer',
title: 'Append interval (s)',
description: '0 = append every packet · N > 0 = append latest value every N seconds',
minimum: 0
},
showLegend: {
type: 'boolean',
title: 'Show legend',
default: true
},
customMargins: {
type: 'string',
title: 'Custom Margins (t:60,r:20,b:50,l:70)'
},
colorScheme: {
type: 'string',
title: 'Color scheme',
enum: colorSchemeEnum,
enumNames: colorSchemeEnumNames,
default: defaultColorScheme,
description: 'Palettes exported by @ska-octopus-widget-sdk for both lines and heatmaps.'
},
legendFormat: {
type: 'string',
description:
'Legend Label Format "fullname", "lastname", "initialname", "number", "station/{number}", "attr-{lastname}"'
},
plotTitle: {
type: 'string',
title: 'Plot title',
description: 'Optional title shown above the chart'
}
}
} as const;
/* ------------------------------------------------------------------ */
/* Default config */
/* ------------------------------------------------------------------ */
const defaultCfg = {
attributes: [
'low-mccs/tile/s8-1-tpm01/fpga1temperature',
'low-mccs/tile/s8-1-tpm02/fpga1temperature',
'low-mccs/tile/s8-1-tpm03/fpga1temperature'
],
useLiveData: false,
useHeatmap: false,
heatmapConnectGaps: false,
legendPosition: 'bottom',
colorMapPosition: 'right',
maxPoints: 1000,
downsample: 'minmax',
enumDisplay: 'value',
appendInterval: 0,
showLegend: true,
customMargins: '',
colorScheme: defaultColorScheme,
legendFormat: 'TPM-{number}/fpga',
plotTitle: ''
} as const;
/* ------------------------------------------------------------------ */
/* Widget definition */
/* ------------------------------------------------------------------ */
const widgetDef = makeWidgetDef({
key: 'HDBPPLiveWidget',
component: HDBPPLiveWidget,
label: 'HDBPP Live',
layout: { x: 0, y: 0, w: 40, h: 30 },
requiredStreams: [],
config: { default: defaultCfg, schema },
polls: true,
docsUrl: 'https://developer.skao.int/projects/ska-octopus-hdbpp-live-widget/en/latest/',
version
});
/* ------------------------------------------------------------------ */
/* 4) Runtime registration */
/* ------------------------------------------------------------------ */
function register(host: OctopusHost) {
host.registerWidget(widgetDef as any);
}
(function wait(h: any) {
if (typeof h.registerWidget === 'function') {
register(h as OctopusHost);
} else {
setTimeout(wait, 50, h);
}
})((globalThis as any).Octopus || ((globalThis as any).Octopus = {}));
/* ------------------------------------------------------------------ */
/* Re-exports */
/* ------------------------------------------------------------------ */
export { HDBPPLiveWidget };
|