Merge all work on server with filmout features #77

Merged
mattmcw merged 12 commits from server into main 2023-02-26 02:16:29 +00:00
18 changed files with 45 additions and 30 deletions
Showing only changes of commit f296488bc2 - Show all commits

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.12", "version": "1.7.13",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -50,9 +50,7 @@ function setImage(src) {
imgTmp = new Image(); imgTmp = new Image();
let img = document.getElementById('img'); let img = document.getElementById('img');
let body = document.querySelector('body'); let body = document.querySelector('body');
if (body.classList.contains('meter')) { body.className = '';
body.classList.remove('meter');
}
imgTmp.onload = function () { imgTmp.onload = function () {
img.style.backgroundImage = `url('${src}')`; img.style.backgroundImage = `url('${src}')`;
return resolve(src); return resolve(src);
@ -88,6 +86,8 @@ function onFocus(arg) {
const can = document.getElementById('can'); const can = document.getElementById('can');
const dpr = window.devicePixelRatio || 1; const dpr = window.devicePixelRatio || 1;
let ctx; let ctx;
const body = document.querySelector('body');
body.className = '';
if (!can.classList.contains('show')) { if (!can.classList.contains('show')) {
can.classList.add('show'); can.classList.add('show');
} }
@ -132,6 +132,8 @@ function onField(arg) {
const can = document.getElementById('can'); const can = document.getElementById('can');
const dpr = window.devicePixelRatio || 1; const dpr = window.devicePixelRatio || 1;
const screen = window.outerWidth / window.outerHeight; const screen = window.outerWidth / window.outerHeight;
const body = document.querySelector('body');
body.className = '';
let ctx; let ctx;
if (!can.classList.contains('show')) { if (!can.classList.contains('show')) {
can.classList.add('show'); can.classList.add('show');

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ class FilmOut {
* @param {object} ui Electron ui object * @param {object} ui Electron ui object
* @param {object} light Light device object * @param {object} light Light device object
**/ **/
constructor(display, ffmpeg, ffprobe, ui, light) { constructor(display, server, ffmpeg, ffprobe, ui, light) {
this.id = 'filmout'; this.id = 'filmout';
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4']; this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp']; this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
@ -42,6 +42,7 @@ class FilmOut {
files: [] files: []
}; };
this.display = display; this.display = display;
this.server = server;
this.ffmpeg = ffmpeg; this.ffmpeg = ffmpeg;
this.ffprobe = ffprobe; this.ffprobe = ffprobe;
this.ui = ui; this.ui = ui;
@ -426,6 +427,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
await this.server.cmdAll('focus');
} }
catch (err) { catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
@ -440,6 +442,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.field(ratio); await this.display.field(ratio);
await this.server.cmdAll('field', { ratio });
} }
catch (err) { catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
@ -453,6 +456,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
await this.server.cmdAll('meter');
} }
catch (err) { catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
@ -465,6 +469,7 @@ class FilmOut {
try { try {
await this.display.hide(); await this.display.hide();
await this.display.close(); await this.display.close();
await this.server.cmdAll('blank');
} }
catch (err) { catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
@ -478,7 +483,7 @@ class FilmOut {
this.log.info(`Changing the display to ${arg.display}`); this.log.info(`Changing the display to ${arg.display}`);
} }
} }
module.exports = (display, ffmpeg, ffprobe, ui, light) => { module.exports = (display, server, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light); return new FilmOut(display, server, ffmpeg, ffprobe, ui, light);
}; };
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -63,10 +63,11 @@ class Server {
this.wss.on('connection', async function (ws) { this.wss.on('connection', async function (ws) {
ws.on("message", function (data) { ws.on("message", function (data) {
let obj = JSON.parse(data); let obj = JSON.parse(data);
this.log.info(data); //this.log.info(data)
if (obj.id && this.queue[obj.id]) { if (obj.id && this.queue[obj.id]) {
this.queue[obj.id](obj); this.queue[obj.id](obj);
delete this.queue[obj.id]; delete this.queue[obj.id];
this.log.info(`${obj.action} complete`);
} }
}.bind(this)); }.bind(this));
ws.on('close', function () { ws.on('close', function () {

File diff suppressed because one or more lines are too long

View File

@ -117,8 +117,9 @@ var init = async function () {
log.error('Error enumerating connected devices', err) log.error('Error enumerating connected devices', err)
} }
server = require('server')()
light = require('light')(arduino, cfg, mainWindow.webContents) light = require('light')(arduino, cfg, mainWindow.webContents)
filmout = require('filmout')(display, ffmpeg, ffprobe, mainWindow.webContents, light) filmout = require('filmout')(display, server, ffmpeg, ffprobe, mainWindow.webContents, light)
cam = require('cam')(arduino, cfg, mainWindow.webContents, filmout) cam = require('cam')(arduino, cfg, mainWindow.webContents, filmout)
proj = require('proj')(arduino, cfg, mainWindow.webContents, filmout) proj = require('proj')(arduino, cfg, mainWindow.webContents, filmout)
alert = require('alert')(mainWindow.webContents) alert = require('alert')(mainWindow.webContents)
@ -136,8 +137,6 @@ var init = async function () {
cmd = require('cmd')(cfg, proj, cam, light, alert, cam2, proj2, capper) cmd = require('cmd')(cfg, proj, cam, light, alert, cam2, proj2, capper)
seq = require('sequencer')(cfg, cmd, mainWindow.webContents) seq = require('sequencer')(cfg, cmd, mainWindow.webContents)
server = require('server')()
} }
app.on('ready', init) app.on('ready', init)

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.7.12", "version": "1.7.13",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.7.12", "version": "1.7.13",
"description": "GUI for the mcopy small gauge film optical printer platform", "description": "GUI for the mcopy small gauge film optical printer platform",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@ -4,8 +4,7 @@
html, body{ background: #000; padding: 0; margin: 0; width: 100vw; height: 100vh; overflow: hidden; } html, body{ background: #000; padding: 0; margin: 0; width: 100vw; height: 100vh; overflow: hidden; }
body.meter { background: rgb(117, 117, 117); } body.meter { background: rgb(117, 117, 117); }
body.blank { background: #000; } body.blank { background: #000; }
body.blank #img { display: none; } body.blank #img, body.blank #can, body.meter #img, body.meter #can { display: none; }
body.blank #can { display: none; }
#nosleep { color: #fff; margin: 50px auto } #nosleep { color: #fff; margin: 50px auto }
#img { #img {
position: absolute; position: absolute;

View File

@ -32,9 +32,7 @@ async function setImage (src : string) {
imgTmp = new Image() imgTmp = new Image()
let img = document.getElementById('img') let img = document.getElementById('img')
let body = document.querySelector('body') let body = document.querySelector('body')
if (body.classList.contains('meter')) { body.className = ''
body.classList.remove('meter')
}
imgTmp.onload = function () { imgTmp.onload = function () {
img.style.backgroundImage = `url('${src}')`; img.style.backgroundImage = `url('${src}')`;
return resolve(src) return resolve(src)
@ -66,6 +64,8 @@ async function onFocus (arg : McopyRequest ) {
const can : HTMLCanvasElement = document.getElementById('can') as HTMLCanvasElement const can : HTMLCanvasElement = document.getElementById('can') as HTMLCanvasElement
const dpr = window.devicePixelRatio || 1 const dpr = window.devicePixelRatio || 1
let ctx; let ctx;
const body = document.querySelector('body')
body.className = ''
if (!can.classList.contains('show')) { if (!can.classList.contains('show')) {
can.classList.add('show') can.classList.add('show')
@ -113,6 +113,8 @@ async function onField (arg : McopyRequest) {
const can : HTMLCanvasElement = document.getElementById('can') as HTMLCanvasElement const can : HTMLCanvasElement = document.getElementById('can') as HTMLCanvasElement
const dpr : number = window.devicePixelRatio || 1 const dpr : number = window.devicePixelRatio || 1
const screen : number = window.outerWidth / window.outerHeight const screen : number = window.outerWidth / window.outerHeight
const body = document.querySelector('body')
body.className = ''
let ctx : CanvasRenderingContext2D; let ctx : CanvasRenderingContext2D;
if (!can.classList.contains('show')) { if (!can.classList.contains('show')) {
can.classList.add('show') can.classList.add('show')

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.12", "version": "1.7.13",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.7.12", "version": "1.7.13",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mcopy", "name": "mcopy",
"version": "1.7.12", "version": "1.7.13",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"arduino": "file:app/lib/arduino", "arduino": "file:app/lib/arduino",

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.7.12", "version": "1.7.13",
"description": "Small gauge film optical printer platform", "description": "Small gauge film optical printer platform",
"main": "build.js", "main": "build.js",
"directories": { "directories": {

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.12", "version": "1.7.13",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -37,6 +37,7 @@ class FilmOut {
private ipc : any; private ipc : any;
private ui : any; private ui : any;
private log : any; private log : any;
private server : any;
/** /**
* @constructor * @constructor
* Builds FilmOut class with display, ffmpeg, ffprobe, ui and light as internal properties. * Builds FilmOut class with display, ffmpeg, ffprobe, ui and light as internal properties.
@ -47,8 +48,9 @@ class FilmOut {
* @param {object} ui Electron ui object * @param {object} ui Electron ui object
* @param {object} light Light device object * @param {object} light Light device object
**/ **/
constructor (display : any, ffmpeg : any, ffprobe : any, ui : any, light : any) { constructor (display : any, server : any, ffmpeg : any, ffprobe : any, ui : any, light : any) {
this.display = display; this.display = display;
this.server = server;
this.ffmpeg = ffmpeg; this.ffmpeg = ffmpeg;
this.ffprobe = ffprobe; this.ffprobe = ffprobe;
this.ui = ui; this.ui = ui;
@ -444,6 +446,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
await this.server.cmdAll('focus')
} catch (err) { } catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
@ -457,6 +460,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.field(ratio); await this.display.field(ratio);
await this.server.cmdAll('field', { ratio });
} catch (err) { } catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
@ -469,6 +473,7 @@ class FilmOut {
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
await this.server.cmdAll('meter');
} catch (err) { } catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
@ -480,6 +485,7 @@ class FilmOut {
try { try {
await this.display.hide(); await this.display.hide();
await this.display.close(); await this.display.close();
await this.server.cmdAll('blank');
} catch (err) { } catch (err) {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
@ -493,6 +499,6 @@ class FilmOut {
} }
} }
module.exports = (display : any, ffmpeg : any, ffprobe : any, ui : any, light : any) => { module.exports = (display : any, server : any, ffmpeg : any, ffprobe : any, ui : any, light : any) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light); return new FilmOut(display, server, ffmpeg, ffprobe, ui, light);
} }

View File

@ -95,10 +95,11 @@ class Server {
this.wss.on('connection', async function (ws : WebSocket) { this.wss.on('connection', async function (ws : WebSocket) {
ws.on("message", function (data : string ) { ws.on("message", function (data : string ) {
let obj : any = JSON.parse(data) let obj : any = JSON.parse(data)
this.log.info(data) //this.log.info(data)
if (obj.id && this.queue[obj.id]) { if (obj.id && this.queue[obj.id]) {
this.queue[obj.id](obj) this.queue[obj.id](obj)
delete this.queue[obj.id] delete this.queue[obj.id]
this.log.info(`${obj.action} complete`)
} }
}.bind(this)) }.bind(this))