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,
"profiles": {
"mcopy": {

View File

@ -281,9 +281,7 @@ class Commands {
ms = await this.cam.both();
}
else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all([this.cam.move(), this.cam2.move()]);
ms = Math.max(...both);
}
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -323,9 +321,7 @@ class Commands {
ms = await this.cam.both();
}
else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all([this.cam.move(), this.cam2.move()]);
ms = Math.max(...both);
}
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -365,9 +361,7 @@ class Commands {
ms = await this.cam.both();
}
else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all([this.cam.move(), this.cam2.move()]);
ms = Math.max(...both);
}
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -407,9 +401,7 @@ class Commands {
ms = await this.cam.both();
}
else {
this.cam.move();
this.cam.move();
both = [await this.cam.move, await this.proj2.move];
both = await Promise.all([this.cam.move(), this.cam2.move()]);
ms = Math.max(...both);
}
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
@ -482,9 +474,7 @@ class Commands {
ms = await this.proj.both();
}
else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([this.proj.move(), this.proj2.move()]);
ms = Math.max(...both);
}
}
@ -511,14 +501,11 @@ class Commands {
await this.proj2.set(false);
}
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) {
ms = await this.proj.both();
}
else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([this.proj.move(), this.proj2.move()]);
ms = Math.max(...both);
}
}
@ -546,14 +533,11 @@ class Commands {
await this.proj2.set(false);
}
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) {
ms = await this.proj.both();
}
else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([this.proj.move(), this.proj2.move()]);
ms = Math.max(...both);
}
}
@ -581,14 +565,11 @@ class Commands {
await this.proj2.set(true);
}
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) {
ms = await this.proj.both();
}
else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([this.proj.move(), this.proj2.move()]);
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",
"version": "1.8.105",
"version": "1.8.106",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

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

View File

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

4
package-lock.json generated
View File

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

View File

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

View File

@ -1,5 +1,5 @@
{
"version": "1.8.105",
"version": "1.8.106",
"ext_port": 1111,
"profiles": {
"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) {
ms = await this.cam.both();
} else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all( [this.cam.move(), this.cam2.move()] );
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) {
ms = await this.cam.both();
} else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all( [this.cam.move(), this.cam2.move()] );
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) {
ms = await this.cam.both();
} else {
this.cam.move();
this.cam2.move();
both = [await this.cam.move, await this.cam2.move];
both = await Promise.all( [this.cam.move(), this.cam2.move()] );
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) {
ms = await this.cam.both();
} else {
this.cam.move();
this.cam.move();
both = [await this.cam.move, await this.proj2.move];
both = await Promise.all( [this.cam.move(), this.cam2.move()] );
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) {
ms = await this.proj.both();
} else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
ms = Math.max(...both);
}
} catch (err) {
@ -522,13 +512,10 @@ class Commands {
await this.proj2.set(false);
}
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) {
ms = await this.proj.both();
} else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
ms = Math.max(...both);
}
} catch (err) {
@ -556,13 +543,10 @@ class Commands {
await this.proj2.set(false);
}
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) {
ms = await this.proj.both();
} else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
ms = Math.max(...both);
}
} catch (err) {
@ -589,13 +573,10 @@ class Commands {
await this.proj2.set(true);
}
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) {
ms = await this.proj.both();
} else {
this.proj.move();
this.proj2.move();
both = [await this.proj.move, await this.proj2.move];
both = await Promise.all([ this.proj.move(), this.proj2.move() ]);
ms = Math.max(...both);
}
} catch (err) {