2024-10-19 02:13:52 +00:00
|
|
|
let client;
|
2024-08-16 04:52:46 +00:00
|
|
|
var SequenceStatus;
|
|
|
|
(function (SequenceStatus) {
|
|
|
|
SequenceStatus[SequenceStatus["IDLE"] = 0] = "IDLE";
|
|
|
|
SequenceStatus[SequenceStatus["RUNNING"] = 1] = "RUNNING";
|
|
|
|
SequenceStatus[SequenceStatus["PAUSED"] = 2] = "PAUSED";
|
|
|
|
})(SequenceStatus || (SequenceStatus = {}));
|
|
|
|
class Display {
|
|
|
|
constructor() {
|
2024-08-18 01:22:17 +00:00
|
|
|
this.sequence = false;
|
2024-10-24 15:01:03 +00:00
|
|
|
this.focus = false;
|
2024-10-24 15:23:33 +00:00
|
|
|
this.framing = false;
|
2024-08-18 01:22:17 +00:00
|
|
|
this.offsetX = 0;
|
|
|
|
this.offsetY = 0;
|
|
|
|
this.width = 0;
|
|
|
|
this.height = 0;
|
|
|
|
this.canvasScale = 0;
|
|
|
|
this.canvasWidth = 0;
|
|
|
|
this.canvasHeight = 0;
|
|
|
|
this.canvasOffsetX = 0;
|
|
|
|
this.canvasOffsetY = 0;
|
|
|
|
this.screenWidth = 0;
|
|
|
|
this.screenHeight = 0;
|
|
|
|
this.screenOffsetX = 0;
|
|
|
|
this.screenOffsetY = 0;
|
|
|
|
this.displayWidth = 0;
|
|
|
|
this.displayHeight = 0;
|
|
|
|
this.displayOffsetX = 0;
|
|
|
|
this.displayOffsetY = 0;
|
2024-08-16 04:52:46 +00:00
|
|
|
this.parentElement = document.getElementById('display');
|
|
|
|
this.create();
|
2024-08-18 01:22:17 +00:00
|
|
|
window.onresize = this.onResize.bind(this);
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
|
|
|
create() {
|
|
|
|
this.canvas = this.parentElement.getElementsByTagName('canvas')[0];
|
|
|
|
this.ctx = this.canvas.getContext('2d');
|
|
|
|
this.screen = {
|
|
|
|
width: parseInt(document.getElementById('width').value),
|
|
|
|
height: parseInt(document.getElementById('height').value)
|
|
|
|
};
|
|
|
|
this.updateSize();
|
2024-08-18 01:22:17 +00:00
|
|
|
this.clear();
|
|
|
|
this.updateScreen();
|
|
|
|
this.updateDisplay();
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
|
|
|
updateSize() {
|
2024-08-18 01:22:17 +00:00
|
|
|
this.canvasScale = window.devicePixelRatio;
|
|
|
|
this.canvasWidth = this.parentElement.clientWidth - 12;
|
|
|
|
this.canvasHeight = this.parentElement.clientHeight - 12;
|
|
|
|
this.canvas.width = this.canvasWidth;
|
|
|
|
this.canvas.height = this.canvasHeight;
|
|
|
|
}
|
|
|
|
clear() {
|
|
|
|
this.ctx.fillStyle = 'rgb(0, 0, 0)';
|
|
|
|
this.ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
|
|
|
|
}
|
|
|
|
updateScreen() {
|
|
|
|
const clientRatio = this.canvasWidth / this.canvasHeight;
|
2024-08-16 04:52:46 +00:00
|
|
|
const screenRatio = this.screen.width / this.screen.height;
|
|
|
|
if (screenRatio > clientRatio) {
|
2024-08-18 01:22:17 +00:00
|
|
|
this.screenWidth = this.canvasWidth - 2;
|
|
|
|
this.screenHeight = Math.floor(this.canvasWidth / screenRatio);
|
|
|
|
this.screenOffsetX = 1;
|
|
|
|
this.screenOffsetY = Math.round((this.canvasHeight - this.screenHeight) / 2);
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2024-08-18 01:22:17 +00:00
|
|
|
this.screenWidth = Math.round(this.canvasHeight * screenRatio);
|
|
|
|
this.screenHeight = this.canvasHeight - 2;
|
|
|
|
this.screenOffsetY = 1;
|
|
|
|
this.screenOffsetX = Math.round((this.canvasWidth - this.screenWidth) / 2);
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
2024-08-18 01:22:17 +00:00
|
|
|
this.ctx.strokeStyle = 'rgb(0, 0, 255)';
|
|
|
|
this.ctx.rect(this.screenOffsetX, this.screenOffsetY, this.screenWidth, this.screenHeight);
|
2024-08-16 04:52:46 +00:00
|
|
|
this.ctx.stroke();
|
|
|
|
}
|
2024-08-18 01:22:17 +00:00
|
|
|
updateDisplay() {
|
2024-10-24 15:23:33 +00:00
|
|
|
if (!this.sequence && !this.focus && !this.framing) {
|
2024-08-18 01:22:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
const screenScaleX = this.screenWidth / this.screen.width;
|
|
|
|
const screenScaleY = this.screenHeight / this.screen.height;
|
|
|
|
this.displayWidth = Math.round(this.width * screenScaleX);
|
|
|
|
this.displayHeight = Math.round(this.height * screenScaleY);
|
|
|
|
this.displayOffsetX = this.screenOffsetX + Math.round(this.offsetX * screenScaleX);
|
|
|
|
this.displayOffsetY = this.screenOffsetY + Math.round(this.offsetY * screenScaleY);
|
2024-08-24 14:23:15 +00:00
|
|
|
this.ctx.fillStyle = 'rgb(0, 0, 0)';
|
2024-08-18 01:22:17 +00:00
|
|
|
this.ctx.fillRect(this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
|
|
|
|
this.updateImage();
|
|
|
|
}
|
|
|
|
updateImage() {
|
2024-10-22 20:31:04 +00:00
|
|
|
this.img = new Image;
|
|
|
|
this.img.onload = function () {
|
|
|
|
this.ctx.drawImage(this.img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
|
2024-08-18 01:22:17 +00:00
|
|
|
}.bind(this);
|
2024-10-22 20:31:04 +00:00
|
|
|
this.img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg?cacheBreaker=${+new Date()}`;
|
2024-08-18 01:22:17 +00:00
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
update(msg) {
|
|
|
|
}
|
2024-08-18 01:22:17 +00:00
|
|
|
set(state) {
|
|
|
|
this.sequence = true;
|
2024-10-24 15:01:03 +00:00
|
|
|
this.focus = false;
|
2024-08-18 01:22:17 +00:00
|
|
|
this.offsetX = state.offset.x;
|
|
|
|
this.offsetY = state.offset.y;
|
|
|
|
this.width = state.display.width;
|
|
|
|
this.height = state.display.height;
|
|
|
|
this.updateDisplay();
|
|
|
|
}
|
2024-10-24 15:01:03 +00:00
|
|
|
setFocus() {
|
|
|
|
this.focus = true;
|
|
|
|
}
|
|
|
|
unsetFocus() {
|
|
|
|
this.focus = false;
|
|
|
|
}
|
2024-10-24 15:23:33 +00:00
|
|
|
setFraming() {
|
|
|
|
this.framing = true;
|
|
|
|
}
|
|
|
|
unsetFraming() {
|
|
|
|
this.framing = false;
|
|
|
|
}
|
2024-08-18 01:22:17 +00:00
|
|
|
onResize(event) {
|
|
|
|
this.updateSize();
|
|
|
|
this.clear();
|
|
|
|
this.updateScreen();
|
|
|
|
this.updateDisplay();
|
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
2024-05-15 21:29:59 +00:00
|
|
|
class Client {
|
|
|
|
constructor() {
|
|
|
|
this.connected = false;
|
2024-08-30 17:49:16 +00:00
|
|
|
this.frames = 0;
|
2024-08-24 20:26:49 +00:00
|
|
|
let uri = this.getWebsocketUri();
|
2024-07-12 13:51:39 +00:00
|
|
|
this.progress = document.getElementById('progress');
|
2024-08-24 14:23:15 +00:00
|
|
|
this.progressText = document.getElementById('progressText');
|
2024-05-15 21:29:59 +00:00
|
|
|
this.client = new WebSocket(uri);
|
2024-08-16 04:52:46 +00:00
|
|
|
this.display = new Display();
|
2024-05-15 21:29:59 +00:00
|
|
|
this.client.onopen = this.onOpen.bind(this);
|
2024-08-15 02:43:02 +00:00
|
|
|
this.client.onclose = this.onClose.bind(this);
|
2024-05-15 21:29:59 +00:00
|
|
|
this.client.onmessage = this.onMessage.bind(this);
|
2024-10-20 01:15:52 +00:00
|
|
|
this.resetForm('sequenceSelectForm');
|
|
|
|
this.resetForm('sequenceCtrlForm');
|
|
|
|
this.resetForm('manualCtrlForm');
|
|
|
|
this.resetForm('exposureCtrlForm');
|
|
|
|
this.resetForm('statisticsForm');
|
2024-08-16 04:52:46 +00:00
|
|
|
this.disableClass('sequenceCtrl');
|
|
|
|
this.disableClass('manualCtrl');
|
2024-10-18 03:06:37 +00:00
|
|
|
this.disableClass('exposureCtrl');
|
2024-08-24 20:26:49 +00:00
|
|
|
this.setProgress({ hash: null, progress: 0 });
|
|
|
|
}
|
|
|
|
getWebsocketUri() {
|
|
|
|
const host = (window.location.host + '').split(':')[0];
|
|
|
|
return `ws://${host}:${WEBSOCKET_PORT}`;
|
2024-05-15 21:29:59 +00:00
|
|
|
}
|
|
|
|
onMessage(event) {
|
2024-07-13 13:23:58 +00:00
|
|
|
const msg = JSON.parse(event.data);
|
2024-08-16 04:52:46 +00:00
|
|
|
if (typeof msg.cmd !== 'undefined' && msg.cmd !== null) {
|
2024-08-02 14:29:12 +00:00
|
|
|
this.cmd(msg);
|
2024-07-12 13:51:39 +00:00
|
|
|
}
|
2024-05-15 21:29:59 +00:00
|
|
|
}
|
|
|
|
onOpen(event) {
|
|
|
|
console.log('Connected');
|
|
|
|
this.connected = true;
|
2024-08-15 02:43:02 +00:00
|
|
|
this.active();
|
2024-08-16 04:52:46 +00:00
|
|
|
this.enableClass('manualCtrl');
|
2024-08-15 02:43:02 +00:00
|
|
|
}
|
|
|
|
onClose(event) {
|
|
|
|
console.log('Disconnected');
|
|
|
|
this.connected = false;
|
|
|
|
this.inactive();
|
2024-05-15 21:29:59 +00:00
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
setSequence(state) {
|
|
|
|
this.setProgress(state.sequence);
|
2024-08-24 14:23:15 +00:00
|
|
|
this.setFrame(state.sequence);
|
2024-08-16 04:52:46 +00:00
|
|
|
this.setStatus(state.sequence);
|
2024-10-18 03:06:37 +00:00
|
|
|
this.setExposure(state);
|
2024-08-16 04:52:46 +00:00
|
|
|
this.setDisplay(state);
|
2024-10-19 02:13:52 +00:00
|
|
|
this.set('sequence', state.sequence.hash);
|
|
|
|
this.removeClass('sequence', 'edited');
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
2024-08-24 14:23:15 +00:00
|
|
|
setUpdate(state) {
|
|
|
|
this.setProgress(state.sequence);
|
|
|
|
this.setFrame(state.sequence);
|
|
|
|
this.setStatus(state.sequence);
|
2024-10-18 03:06:37 +00:00
|
|
|
this.setExposure(state);
|
2024-10-19 02:13:52 +00:00
|
|
|
this.setStatistics(state.statistics);
|
2024-08-24 14:23:15 +00:00
|
|
|
this.display.updateImage();
|
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
setStatus(sequence) {
|
|
|
|
let status;
|
|
|
|
switch (sequence.status) {
|
|
|
|
case SequenceStatus.IDLE:
|
|
|
|
status = 'Idle';
|
|
|
|
break;
|
|
|
|
case SequenceStatus.RUNNING:
|
|
|
|
status = 'Running';
|
|
|
|
break;
|
|
|
|
case SequenceStatus.PAUSED:
|
|
|
|
status = 'Paused';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 'Unknown State';
|
|
|
|
}
|
2024-08-30 17:49:16 +00:00
|
|
|
this.frames = sequence.frames;
|
2024-08-16 04:52:46 +00:00
|
|
|
document.getElementById('sequenceStatus').innerText = status;
|
|
|
|
document.getElementById('sequenceName').innerText = sequence.name;
|
|
|
|
document.getElementById('sequenceLength').innerText = `Sequence Length: ${sequence.frames}`;
|
|
|
|
}
|
|
|
|
setProgress(sequence) {
|
2024-07-12 13:51:39 +00:00
|
|
|
const percent = sequence.progress * 100.0;
|
2024-10-19 02:13:52 +00:00
|
|
|
this.progress.value = sequence.progress;
|
|
|
|
this.progressText.innerText = `Progress: ${Math.floor(percent)}%`;
|
2024-08-24 14:23:15 +00:00
|
|
|
}
|
|
|
|
setFrame(sequence) {
|
|
|
|
if (typeof sequence.current !== 'undefined') {
|
2024-10-19 02:13:52 +00:00
|
|
|
this.set('frame', `${sequence.current}`.padStart(5, '0'));
|
|
|
|
this.removeClass('frame', 'edited');
|
2024-08-16 04:52:46 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-18 03:06:37 +00:00
|
|
|
setExposure(state) {
|
|
|
|
if (typeof state.exposure !== 'undefined') {
|
2024-10-19 02:13:52 +00:00
|
|
|
const el = document.getElementById('exposure');
|
2024-10-18 03:06:37 +00:00
|
|
|
this.enableClass('exposureCtrl');
|
2024-10-19 02:13:52 +00:00
|
|
|
this.set('exposure', `${state.exposure}`);
|
|
|
|
this.removeClass('exposure', 'edited');
|
2024-10-18 03:06:37 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
setDisplay(state) {
|
2024-08-24 14:23:15 +00:00
|
|
|
if (typeof state.display !== 'undefined') {
|
2024-10-19 02:13:52 +00:00
|
|
|
this.set('displayWidth', state.display.width.toString());
|
|
|
|
this.set('displayHeight', state.display.height.toString());
|
2024-10-22 19:04:25 +00:00
|
|
|
this.set('offsetLeft', state.offset.x.toString());
|
|
|
|
this.set('offsetTop', state.offset.y.toString());
|
2024-10-19 02:13:52 +00:00
|
|
|
this.set('sourceWidth', state.source.width.toString());
|
|
|
|
this.set('sourceHeight', state.source.height.toString());
|
2024-08-24 14:23:15 +00:00
|
|
|
this.display.set(state);
|
|
|
|
}
|
2024-07-12 13:51:39 +00:00
|
|
|
}
|
2024-10-19 02:13:52 +00:00
|
|
|
edited(el) {
|
|
|
|
el.classList.add('edited');
|
|
|
|
}
|
|
|
|
setStatistics(stats) {
|
|
|
|
if (stats !== null) {
|
2024-10-20 12:53:25 +00:00
|
|
|
this.set('statsFrameTotalLast', this.roundDigits(stats.totalFrameLast, 0));
|
|
|
|
this.set('statsFrameTotalAvg', this.roundDigits(stats.totalFrameAvg, 2));
|
|
|
|
this.set('statsFrameTotalMargin', this.roundDigits(stats.totalFrameMargin, 1));
|
|
|
|
this.set('statsFPS', this.roundDigits(stats.fps, 2));
|
|
|
|
this.set('statsFrameLoadAvg', this.roundDigits(stats.loadAvg, 2));
|
|
|
|
this.set('statsFrameLoadMargin', this.roundDigits(stats.loadMargin, 1));
|
|
|
|
this.set('statsFrameOpenLast', this.roundDigits(stats.openLast, 0));
|
|
|
|
this.set('statsFrameOpenAvg', this.roundDigits(stats.openAvg, 2));
|
|
|
|
this.set('statsFrameOpenMargin', this.roundDigits(stats.openMargin, 1));
|
|
|
|
this.set('statsFrameCloseLast', this.roundDigits(stats.closeLast, 0));
|
|
|
|
this.set('statsFrameCloseAvg', this.roundDigits(stats.closeAvg, 2));
|
|
|
|
this.set('statsFrameCloseMargin', this.roundDigits(stats.closeMargin, 1));
|
|
|
|
this.set('statsExposureLast', this.roundDigits(stats.exposureLast, 0));
|
|
|
|
this.set('statsExposureAvg', this.roundDigits(stats.exposureAvg, 2));
|
|
|
|
this.set('statsExposureMargin', this.roundDigits(stats.exposureMargin, 1));
|
|
|
|
this.set('statsElapsed', this.roundDigits(stats.elapsed, 0));
|
|
|
|
this.set('statsEstimate', this.roundDigits(stats.estimate, 0));
|
2024-10-20 01:15:52 +00:00
|
|
|
this.set('statsElapsedHuman', this.shortenHumanize(Math.round(stats.elapsed)));
|
|
|
|
this.set('statsEstimateHuman', this.shortenHumanize(Math.round(stats.estimate)));
|
2024-10-19 02:13:52 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-02 14:29:12 +00:00
|
|
|
cmd(msg) {
|
|
|
|
switch (msg.cmd) {
|
2024-08-24 20:26:49 +00:00
|
|
|
case 'ping':
|
|
|
|
this.receivePing();
|
|
|
|
break;
|
2024-07-13 13:23:58 +00:00
|
|
|
case 'open':
|
|
|
|
this.receiveCameraOpen();
|
|
|
|
break;
|
2024-08-01 15:57:49 +00:00
|
|
|
case 'close':
|
|
|
|
this.receiveCameraClose();
|
|
|
|
break;
|
2024-08-02 14:29:12 +00:00
|
|
|
case 'select':
|
|
|
|
this.receiveSelect(msg);
|
2024-08-09 20:20:07 +00:00
|
|
|
break;
|
2024-08-24 14:23:15 +00:00
|
|
|
case 'update':
|
|
|
|
this.receiveUpdate(msg);
|
|
|
|
break;
|
2024-10-22 03:51:38 +00:00
|
|
|
case 'focus':
|
|
|
|
this.receiveFocus(msg);
|
|
|
|
break;
|
2024-10-24 15:01:03 +00:00
|
|
|
case 'unfocus':
|
|
|
|
this.receiveUnfocus(msg);
|
2024-10-24 15:23:33 +00:00
|
|
|
break;
|
|
|
|
case 'framing':
|
|
|
|
this.receiveFraming(msg);
|
|
|
|
break;
|
|
|
|
case 'unframing':
|
|
|
|
this.receiveUnframing(msg);
|
|
|
|
break;
|
2024-10-22 19:04:25 +00:00
|
|
|
case 'display':
|
|
|
|
this.receiveDisplay(msg);
|
|
|
|
break;
|
2024-07-13 13:23:58 +00:00
|
|
|
default:
|
2024-08-09 20:20:07 +00:00
|
|
|
console.warn(`No command "${msg.cmd}"`);
|
2024-07-13 13:23:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-08-09 20:20:07 +00:00
|
|
|
disableClass(className) {
|
2024-08-15 22:55:37 +00:00
|
|
|
console.log(`Disabling class: ${className}`);
|
2024-08-09 20:20:07 +00:00
|
|
|
document.querySelectorAll(`.${className}`).forEach((el) => {
|
|
|
|
el.disabled = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
enableClass(className) {
|
2024-08-15 22:55:37 +00:00
|
|
|
console.log(`Enabling class: ${className}`);
|
2024-08-09 20:20:07 +00:00
|
|
|
document.querySelectorAll(`.${className}`).forEach((el) => {
|
|
|
|
el.disabled = false;
|
|
|
|
});
|
|
|
|
}
|
2024-07-13 13:23:58 +00:00
|
|
|
sendCameraOpen() {
|
|
|
|
console.log('send camera open');
|
2024-08-09 20:20:07 +00:00
|
|
|
this.disableClass('manualCtrl');
|
2024-07-13 02:00:24 +00:00
|
|
|
this.client.send(JSON.stringify({ cmd: 'open' }));
|
|
|
|
}
|
2024-08-24 20:26:49 +00:00
|
|
|
receivePing() {
|
|
|
|
this.sendPong();
|
|
|
|
}
|
2024-07-13 13:23:58 +00:00
|
|
|
receiveCameraOpen() {
|
|
|
|
console.log('got camera open');
|
2024-08-09 20:20:07 +00:00
|
|
|
this.enableClass('manualCtrl');
|
2024-07-13 13:23:58 +00:00
|
|
|
}
|
2024-08-01 15:57:49 +00:00
|
|
|
sendCameraClose() {
|
|
|
|
console.log('send camera close');
|
2024-08-09 20:20:07 +00:00
|
|
|
this.disableClass('manualCtrl');
|
2024-08-01 15:57:49 +00:00
|
|
|
this.client.send(JSON.stringify({ cmd: 'close' }));
|
|
|
|
}
|
|
|
|
receiveCameraClose() {
|
|
|
|
console.log('got camera close');
|
2024-08-09 20:20:07 +00:00
|
|
|
this.enableClass('manualCtrl');
|
2024-08-01 15:57:49 +00:00
|
|
|
}
|
2024-08-24 20:26:49 +00:00
|
|
|
sendPong() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'pong' }));
|
|
|
|
}
|
2024-08-24 14:23:15 +00:00
|
|
|
sendAdvance() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'advance' }));
|
|
|
|
}
|
|
|
|
sendRewind() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'rewind' }));
|
|
|
|
}
|
2024-08-30 17:49:16 +00:00
|
|
|
sendFrameSet() {
|
|
|
|
const frameStr = document.getElementById('frame').value;
|
|
|
|
let frameNum = null;
|
|
|
|
try {
|
|
|
|
frameNum = parseInt(frameStr);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(`Error parsing ${frameStr}`);
|
|
|
|
}
|
|
|
|
if (frameNum === null) {
|
|
|
|
frameNum = 0;
|
|
|
|
}
|
|
|
|
if (frameNum < 0) {
|
|
|
|
frameNum = 0;
|
|
|
|
}
|
|
|
|
if (frameNum > this.frames - 1) {
|
|
|
|
frameNum = this.frames - 1;
|
|
|
|
}
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'set', state: { sequence: { current: frameNum } } }));
|
|
|
|
}
|
|
|
|
sendToEnd() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'set', state: { sequence: { current: this.frames - 1 } } }));
|
|
|
|
}
|
|
|
|
sendToStart() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'set', state: { sequence: { current: 0 } } }));
|
|
|
|
}
|
2024-08-01 15:57:49 +00:00
|
|
|
sendSelect() {
|
2024-08-16 04:52:46 +00:00
|
|
|
const hash = document.getElementById('sequence').value;
|
2024-08-01 15:57:49 +00:00
|
|
|
let msg;
|
2024-08-16 04:52:46 +00:00
|
|
|
if (hash === '- Select Image Sequence -') {
|
2024-08-01 15:57:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
msg = { cmd: 'select', state: { sequence: { hash } } };
|
2024-10-19 02:13:52 +00:00
|
|
|
console.log(`send select ${hash}`);
|
2024-08-01 15:57:49 +00:00
|
|
|
this.client.send(JSON.stringify(msg));
|
|
|
|
}
|
2024-08-02 14:29:12 +00:00
|
|
|
receiveSelect(msg) {
|
2024-08-16 04:52:46 +00:00
|
|
|
this.enableClass('sequenceCtrl');
|
|
|
|
this.setSequence(msg.state);
|
|
|
|
}
|
2024-08-24 14:23:15 +00:00
|
|
|
sendStart() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'start' }));
|
|
|
|
}
|
|
|
|
sendStop() {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'stop' }));
|
|
|
|
}
|
2024-10-18 03:06:37 +00:00
|
|
|
sendExposure() {
|
2024-10-19 02:13:52 +00:00
|
|
|
const exposure = parseInt(this.get('exposure'));
|
2024-10-18 03:06:37 +00:00
|
|
|
this.client.send(JSON.stringify({ cmd: 'exposure', state: { exposure } }));
|
|
|
|
}
|
2024-08-16 04:52:46 +00:00
|
|
|
receiveUpdate(msg) {
|
2024-08-24 14:23:15 +00:00
|
|
|
this.setUpdate(msg.state);
|
2024-08-02 14:29:12 +00:00
|
|
|
}
|
2024-10-22 19:04:25 +00:00
|
|
|
receiveDisplay(msg) {
|
|
|
|
this.display.clear();
|
|
|
|
this.display.updateScreen();
|
|
|
|
this.setDisplay(msg.state);
|
|
|
|
}
|
2024-10-22 03:51:38 +00:00
|
|
|
sendFocus() {
|
|
|
|
console.log('send focus');
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'focus' }));
|
|
|
|
}
|
|
|
|
receiveFocus(msg) {
|
2024-10-24 15:01:03 +00:00
|
|
|
this.display.setFocus();
|
|
|
|
this.display.updateImage();
|
|
|
|
}
|
|
|
|
receiveUnfocus(msg) {
|
|
|
|
this.display.unsetFocus();
|
2024-10-22 03:51:38 +00:00
|
|
|
this.display.updateImage();
|
2024-10-24 15:23:33 +00:00
|
|
|
}
|
|
|
|
sendFraming() {
|
|
|
|
console.log('send framing');
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'framing' }));
|
|
|
|
}
|
|
|
|
receiveFraming(msg) {
|
|
|
|
this.display.setFraming();
|
|
|
|
this.display.updateImage();
|
|
|
|
}
|
|
|
|
receiveUnframing(msg) {
|
|
|
|
this.display.unsetFraming();
|
|
|
|
this.display.updateImage();
|
2024-10-22 03:51:38 +00:00
|
|
|
}
|
2024-10-22 19:04:25 +00:00
|
|
|
sendOffset(x, y) {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'offset', x, y }));
|
|
|
|
}
|
|
|
|
sendSize(width, height) {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'size', width, height }));
|
|
|
|
}
|
|
|
|
sendScale(scale) {
|
|
|
|
this.client.send(JSON.stringify({ cmd: 'scale', scale }));
|
|
|
|
}
|
2024-08-01 15:57:49 +00:00
|
|
|
fullscreen() {
|
|
|
|
if (!document.fullscreenElement) {
|
|
|
|
document.documentElement.requestFullscreen();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.exitFullscreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exitFullscreen() {
|
|
|
|
if (document.fullscreenElement) {
|
|
|
|
document.exitFullscreen();
|
|
|
|
}
|
|
|
|
}
|
2024-08-15 02:43:02 +00:00
|
|
|
active() {
|
2024-10-19 02:13:52 +00:00
|
|
|
this.addClass('overlay', 'active');
|
2024-08-15 02:43:02 +00:00
|
|
|
}
|
|
|
|
inactive() {
|
2024-10-19 02:13:52 +00:00
|
|
|
this.removeClass('overlay', 'active');
|
|
|
|
}
|
|
|
|
addClass(id, className) {
|
|
|
|
document.getElementById(id).classList.add(className);
|
|
|
|
}
|
|
|
|
removeClass(id, className) {
|
|
|
|
document.getElementById(id).classList.remove(className);
|
|
|
|
}
|
|
|
|
set(id, value) {
|
|
|
|
try {
|
|
|
|
document.getElementById(id).value = value;
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.warn(`Element ${id} does not exist or cannot be set`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
get(id) {
|
|
|
|
return document.getElementById(id).value;
|
2024-08-15 02:43:02 +00:00
|
|
|
}
|
2024-10-20 01:15:52 +00:00
|
|
|
resetForm(id) {
|
|
|
|
document.getElementById(id).reset();
|
|
|
|
}
|
|
|
|
shortenHumanize(val) {
|
|
|
|
const str = humanizeDuration(val, { round: true });
|
|
|
|
return str.replace('years', 'y').replace('year', 'y')
|
|
|
|
.replace('months', 'mo').replace('month', 'mo')
|
|
|
|
.replace('weeks', 'w').replace('week', 'w')
|
|
|
|
.replace('days', 'd').replace('day', 'd')
|
|
|
|
.replace('hours', 'h').replace('hour', 'h')
|
|
|
|
.replace('minutes', 'm').replace('minute', 'm')
|
|
|
|
.replace('seconds', 's').replace('second', 's');
|
|
|
|
}
|
2024-10-20 01:22:15 +00:00
|
|
|
roundDigits(val, digits) {
|
|
|
|
const mult = Math.pow(10.0, digits);
|
2024-10-20 12:53:25 +00:00
|
|
|
const rounded = Math.round(val * mult) / mult;
|
|
|
|
return rounded.toString();
|
2024-10-20 01:22:15 +00:00
|
|
|
}
|
2024-05-15 21:29:59 +00:00
|
|
|
}
|
2024-10-19 02:13:52 +00:00
|
|
|
client = new Client();
|
2024-05-15 21:29:59 +00:00
|
|
|
//# sourceMappingURL=index.js.map
|