Camera mock not supports directional arguments. CLI scripting language now includes single frame movements without an image to expose

This commit is contained in:
Matt McWilliams 2026-05-25 19:15:11 -04:00
parent e46785e8f0
commit 66a4e97af1
7 changed files with 61 additions and 3 deletions

View File

@ -41,6 +41,12 @@ class CameraSerialPortMock extends serialport_1.SerialPortMock {
case Commands.CAMERA_CLOSE:
this._mockSend(Commands.CAMERA_CLOSE, 125);
break;
case Commands.CAMERA_FORWARD:
this._mockSend(Commands.CAMERA_FORWARD, 2);
break;
case Commands.CAMERA_BACKWARD:
this._mockSend(Commands.CAMERA_BACKWARD, 2);
break;
default:
this.log.warn(`[MOCK] Command "${buffer}" does not exist on mock`);
}

File diff suppressed because one or more lines are too long

2
dist/cli/index.d.ts vendored
View File

@ -27,6 +27,8 @@ export declare class CLI {
private parseLine;
private execute;
private expose;
private forward;
private backward;
private rgb;
private parseDimensions;
}

20
dist/cli/index.js vendored
View File

@ -249,6 +249,12 @@ class CLI {
case Actions.IRGB:
await this.rgb(cmd, true);
break;
case Actions.FORWARD:
await this.forward(cmd);
break;
case Actions.BACKWARD:
await this.backward(cmd);
break;
default:
break;
}
@ -278,6 +284,7 @@ class CLI {
this.display.setHeight(this.altDimensions.h);
}
dimensions = this.display.getOutgoingPosition();
await this.camera.direction(true);
this.log.info(`${invert ? 'INVERT' : 'EXPOSE'}: [${cmd.time}] ${img.name}`);
try {
await this.fd.load(img.path, dimensions.x, dimensions.y, dimensions.w, dimensions.h);
@ -312,6 +319,18 @@ class CLI {
}
}
}
async forward(cmd) {
await this.camera.direction(true);
for (let i = 0; i < cmd.count; i++) {
await this.camera.frame();
}
}
async backward(cmd) {
await this.camera.direction(false);
for (let i = 0; i < cmd.count; i++) {
await this.camera.frame();
}
}
async rgb(cmd, invert = false) {
const start = Date.now();
let result;
@ -329,6 +348,7 @@ class CLI {
}
dimensions = this.display.getOutgoingPosition();
this.log.info(`RGB: ${img.name}`);
await this.camera.direction(true);
try {
channels = await this.image.rgb(img.path, invert);
}

File diff suppressed because one or more lines are too long

View File

@ -55,6 +55,12 @@ class CameraSerialPortMock extends SerialPortMock {
case Commands.CAMERA_CLOSE :
this._mockSend(Commands.CAMERA_CLOSE, 125);
break;
case Commands.CAMERA_FORWARD :
this._mockSend(Commands.CAMERA_FORWARD, 2);
break;
case Commands.CAMERA_BACKWARD :
this._mockSend(Commands.CAMERA_BACKWARD, 2);
break;
default:
this.log.warn(`[MOCK] Command "${buffer}" does not exist on mock`);
}

View File

@ -247,7 +247,7 @@ export class CLI {
break;
case 'B' :
cmd.action = Actions.BACKWARD;
cmd.count = 1;
cmd.count = 1;
break;
default :
return null;
@ -313,6 +313,12 @@ export class CLI {
case Actions.IRGB :
await this.rgb(cmd, true);
break;
case Actions.FORWARD :
await this.forward(cmd);
break;
case Actions.BACKWARD :
await this.backward(cmd)
break;
default :
break;
}
@ -348,6 +354,8 @@ export class CLI {
}
dimensions = this.display.getOutgoingPosition();
await this.camera.direction(true);
this.log.info(`${invert ? 'INVERT' : 'EXPOSE'}: [${cmd.time}] ${img.name}`);
@ -384,6 +392,20 @@ export class CLI {
}
}
private async forward (cmd : CMD) {
await this.camera.direction(true);
for (let i = 0; i < cmd.count; i++) {
await this.camera.frame();
}
}
private async backward (cmd : CMD) {
await this.camera.direction(false);
for (let i = 0; i < cmd.count; i++) {
await this.camera.frame();
}
}
private async rgb (cmd : CMD, invert : boolean = false) {
const start : number = Date.now();
let result : fdResult;
@ -407,6 +429,8 @@ export class CLI {
this.log.info(`RGB: ${img.name}`);
await this.camera.direction(true);
try {
channels = await this.image.rgb(img.path, invert);
} catch (err) {