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
14 changed files with 33 additions and 18 deletions
Showing only changes of commit 02639466ee - Show all commits

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.17", "version": "1.7.18",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -0,0 +1,8 @@
/**
* Delay in an async/await function
*
* @param {integer} ms Milliseconds to delay for
*
* @returns {Promise} Promise to resolve after timeout
**/
declare function delay(ms: number): Promise<unknown>;

View File

@ -146,7 +146,7 @@ class Sequencer {
//start sequence //start sequence
this.log.info(`Starting sequence...`); this.log.info(`Starting sequence...`);
this.ui.send(this.id, { start: true }); this.ui.send(this.id, { start: true });
if (this.cmd.proj.filmout.state.enabled === true) { if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.open(); await this.cmd.proj.filmout.display.open();
} }
for (let x = 0; x < this.loops; x++) { for (let x = 0; x < this.loops; x++) {
@ -179,7 +179,7 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`); this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true }); this.ui.send(this.id, { loop: x, stop: true });
} }
if (this.cmd.proj.filmout.state.enabled === true) { if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.close(); await this.cmd.proj.filmout.display.close();
} }
electron_1.powerSaveBlocker.stop(psbId); electron_1.powerSaveBlocker.stop(psbId);

File diff suppressed because one or more lines are too long

View File

@ -149,7 +149,7 @@ class Server {
} }
async cmdAll(action, options = {}) { async cmdAll(action, options = {}) {
const cmds = []; const cmds = [];
if (this.isActive && this.wss.clients.size > 0) { if (this.useServer()) {
this.wss.clients.forEach(function (ws) { this.wss.clients.forEach(function (ws) {
cmds.push(this.cmd(ws, action, options)); cmds.push(this.cmd(ws, action, options));
}.bind(this)); }.bind(this));
@ -160,7 +160,7 @@ class Server {
} }
async displayImage(src) { async displayImage(src) {
let key; let key;
if (this.isActive && this.wss.clients.size > 0) { if (this.useServer()) {
key = path_1.basename(src); key = path_1.basename(src);
this.addProxy(key, src); this.addProxy(key, src);
await this.cmdAll('image', { image: `/image/${key}` }); await this.cmdAll('image', { image: `/image/${key}` });
@ -168,6 +168,9 @@ class Server {
} }
return false; return false;
} }
useServer() {
return this.isActive && this.wss.clients.size > 0;
}
/** /**
* WSS * WSS
**/ **/

File diff suppressed because one or more lines are too long

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.7.17", "version": "1.7.18",
"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.17", "version": "1.7.18",
"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

@ -1,5 +1,5 @@
{ {
"version": "1.7.17", "version": "1.7.18",
"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.17", "version": "1.7.18",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mcopy", "name": "mcopy",
"version": "1.7.17", "version": "1.7.18",
"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.17", "version": "1.7.18",
"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.17", "version": "1.7.18",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -168,7 +168,7 @@ class Sequencer {
this.log.info(`Starting sequence...`); this.log.info(`Starting sequence...`);
this.ui.send(this.id, { start : true }); this.ui.send(this.id, { start : true });
if (this.cmd.proj.filmout.state.enabled === true) { if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.open(); await this.cmd.proj.filmout.display.open();
} }
@ -209,7 +209,7 @@ class Sequencer {
this.ui.send(this.id, { loop : x, stop : true }); this.ui.send(this.id, { loop : x, stop : true });
} }
if (this.cmd.proj.filmout.state.enabled === true) { if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.close(); await this.cmd.proj.filmout.display.close();
} }

View File

@ -190,7 +190,7 @@ class Server {
public async cmdAll (action : string, options : any = {}) { public async cmdAll (action : string, options : any = {}) {
const cmds : any[] = [] const cmds : any[] = []
if (this.isActive && this.wss.clients.size > 0) { if (this.useServer()) {
this.wss.clients.forEach(function (ws : WebSocket) { this.wss.clients.forEach(function (ws : WebSocket) {
cmds.push(this.cmd(ws, action, options)) cmds.push(this.cmd(ws, action, options))
}.bind(this)) }.bind(this))
@ -202,7 +202,7 @@ class Server {
public async displayImage (src : string) { public async displayImage (src : string) {
let key let key
if (this.isActive && this.wss.clients.size > 0) { if (this.useServer()) {
key = basename(src) key = basename(src)
this.addProxy(key, src) this.addProxy(key, src)
await this.cmdAll('image', { image : `/image/${key}` }) await this.cmdAll('image', { image : `/image/${key}` })
@ -211,6 +211,10 @@ class Server {
return false return false
} }
public useServer () : boolean {
return this.isActive && this.wss.clients.size > 0
}
/** /**
* WSS * WSS
**/ **/