Files
Linus Wileryd c3ddbd8353 Feature: Ontime (#373)
* Feature: Ontime support, WebSocket, Embedded fonts.

* Fix: Clock matching operator view

Also more notes showing

* Fix: ws path+font assets
2026-05-15 08:39:29 -05:00

61 lines
1.5 KiB
JavaScript

exports.config = {
defaultName: 'Ontime',
connectionType: 'websocket',
remotePort: 4001,
mayChangePorts: true,
heartbeatInterval: 500,
heartbeatTimeout: 15000,
fields: [
{
key: 'wsPath',
label: 'WS Path',
type: 'textinput',
value: '/ws',
action: () => {},
},
],
};
exports.ready = function ready(device) {
const d = device;
d.data = {
timer: { current: null, playback: 'stop', addedTime: 0, duration: null, elapsed: null },
eventNow: null,
eventNext: null,
clock: null,
};
d.send({ tag: 'poll' });
};
exports.data = function data(_device, msg) {
const device = _device;
if (!device.data) {
device.data = {
timer: { current: null, playback: 'stop', addedTime: 0, duration: null, elapsed: null },
eventNow: null,
eventNext: null,
clock: null,
};
}
// Ontime v4 sends all state updates as { tag: "runtime-data", payload: Partial<RuntimeStore> }
// Poll responses arrive as { tag: "poll", payload: Partial<RuntimeStore> }
if (msg.tag !== 'runtime-data' && msg.tag !== 'poll') return;
const p = msg.payload;
if (!p) return;
if (p.timer !== undefined) device.data.timer = p.timer;
if (p.eventNow !== undefined) device.data.eventNow = p.eventNow;
if (p.eventNext !== undefined) device.data.eventNext = p.eventNext;
if (p.clock !== undefined) device.data.clock = p.clock;
device.draw();
};
exports.heartbeat = function heartbeat(device) {
device.send({ tag: 'poll' });
};
exports.update = function update(_device, _doc, _updateType, _data) {};