By doing a check for active clients during the sequencer start and stop actions, the local display is no longer used. Resolves first part of #20.

This commit is contained in:
Matt McWilliams 2023-02-25 17:00:11 -05:00
parent 6e2795d380
commit 02639466ee
14 changed files with 33 additions and 18 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.7.17",
"version": "1.7.18",
"ext_port": 1111,
"profiles": {
"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
this.log.info(`Starting sequence...`);
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();
}
for (let x = 0; x < this.loops; x++) {
@ -179,7 +179,7 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`);
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();
}
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 = {}) {
const cmds = [];
if (this.isActive && this.wss.clients.size > 0) {
if (this.useServer()) {
this.wss.clients.forEach(function (ws) {
cmds.push(this.cmd(ws, action, options));
}.bind(this));
@ -160,7 +160,7 @@ class Server {
}
async displayImage(src) {
let key;
if (this.isActive && this.wss.clients.size > 0) {
if (this.useServer()) {
key = path_1.basename(src);
this.addProxy(key, src);
await this.cmdAll('image', { image: `/image/${key}` });
@ -168,6 +168,9 @@ class Server {
}
return false;
}
useServer() {
return this.isActive && this.wss.clients.size > 0;
}
/**
* 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",
"version": "1.7.17",
"version": "1.7.18",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

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

View File

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

4
package-lock.json generated
View File

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

View File

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

View File

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

View File

@ -168,7 +168,7 @@ class Sequencer {
this.log.info(`Starting sequence...`);
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();
}
@ -209,7 +209,7 @@ class Sequencer {
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();
}

View File

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