In a two device simultaneous action, the cmd module was attemptint to await both actions in an array. This was not working and caused await to not occur. Instead, all actions have been replaced by a Promise.all, which awaits both actions simultaneously until both are complete. After that, function is correct.

This commit is contained in:
Matt McWilliams 2024-05-19 11:05:16 -04:00
parent 9b7d1a3e5c
commit 5bad15a79a
10 changed files with 25 additions and 63 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.8.105", "version": "1.8.106",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -281,9 +281,7 @@ class Commands {
ms = await this.cam.both(); ms = await this.cam.both();
} }
else { else {
this.cam.move(); both = await Promise.all([this.cam.move(), this.cam2.move()]);
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -323,9 +321,7 @@ class Commands {
ms = await this.cam.both(); ms = await this.cam.both();
} }
else { else {
this.cam.move(); both = await Promise.all([this.cam.move(), this.cam2.move()]);
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -365,9 +361,7 @@ class Commands {
ms = await this.cam.both(); ms = await this.cam.both();
} }
else { else {
this.cam.move(); both = await Promise.all([this.cam.move(), this.cam2.move()]);
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -407,9 +401,7 @@ class Commands {
ms = await this.cam.both(); ms = await this.cam.both();
} }
else { else {
this.cam.move(); both = await Promise.all([this.cam.move(), this.cam2.move()]);
this.cam.move();
both = [await this.cam.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -482,9 +474,7 @@ class Commands {
ms = await this.proj.both(); ms = await this.proj.both();
} }
else { else {
this.proj.move(); both = await Promise.all([this.proj.move(), this.proj2.move()]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} }
@ -511,14 +501,11 @@ class Commands {
await this.proj2.set(false); await this.proj2.set(false);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} }
else { else {
this.proj.move(); both = await Promise.all([this.proj.move(), this.proj2.move()]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} }
@ -546,14 +533,11 @@ class Commands {
await this.proj2.set(false); await this.proj2.set(false);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} }
else { else {
this.proj.move(); both = await Promise.all([this.proj.move(), this.proj2.move()]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} }
@ -581,14 +565,11 @@ class Commands {
await this.proj2.set(true); await this.proj2.set(true);
} }
await (0, delay_1.delay)(this.cfg.arduino.serialDelay); await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} }
else { else {
this.proj.move(); both = await Promise.all([this.proj.move(), this.proj2.move()]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} }

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.8.105", "version": "1.8.106",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.8.105", "version": "1.8.106",
"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.8.105", "version": "1.8.106",
"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.8.105", "version": "1.8.106",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mcopy", "name": "mcopy",
"version": "1.8.105", "version": "1.8.106",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"alert": "file:app/lib/alert", "alert": "file:app/lib/alert",

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.8.105", "version": "1.8.106",
"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.8.105", "version": "1.8.106",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -293,9 +293,7 @@ class Commands {
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) { if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both(); ms = await this.cam.both();
} else { } else {
this.cam.move(); both = await Promise.all( [this.cam.move(), this.cam2.move()] );
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
@ -335,9 +333,7 @@ class Commands {
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) { if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both(); ms = await this.cam.both();
} else { } else {
this.cam.move(); both = await Promise.all( [this.cam.move(), this.cam2.move()] );
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
@ -378,9 +374,7 @@ class Commands {
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) { if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both(); ms = await this.cam.both();
} else { } else {
this.cam.move(); both = await Promise.all( [this.cam.move(), this.cam2.move()] );
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
@ -420,9 +414,7 @@ class Commands {
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) { if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both(); ms = await this.cam.both();
} else { } else {
this.cam.move(); both = await Promise.all( [this.cam.move(), this.cam2.move()] );
this.cam.move();
both = [await this.cam.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
@ -494,9 +486,7 @@ class Commands {
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} else { } else {
this.proj.move(); both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} catch (err) { } catch (err) {
@ -522,13 +512,10 @@ class Commands {
await this.proj2.set(false); await this.proj2.set(false);
} }
await delay(this.cfg.arduino.serialDelay); await delay(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} else { } else {
this.proj.move(); both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} catch (err) { } catch (err) {
@ -556,13 +543,10 @@ class Commands {
await this.proj2.set(false); await this.proj2.set(false);
} }
await delay(this.cfg.arduino.serialDelay); await delay(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} else { } else {
this.proj.move(); both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} catch (err) { } catch (err) {
@ -589,13 +573,10 @@ class Commands {
await this.proj2.set(true); await this.proj2.set(true);
} }
await delay(this.cfg.arduino.serialDelay); await delay(this.cfg.arduino.serialDelay);
//run one projector without await?
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) { if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
ms = await this.proj.both(); ms = await this.proj.both();
} else { } else {
this.proj.move(); both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
ms = Math.max(...both); ms = Math.max(...both);
} }
} catch (err) { } catch (err) {