Time a sequence and pass back value of milliseconds back when sequence stops.

This commit is contained in:
mmcwilliams 2019-05-28 17:48:42 -04:00
parent 8ddc6e5a20
commit 418670ce33
8 changed files with 27 additions and 9 deletions

View File

@ -70,6 +70,8 @@ class Sequencer {
}
//new, replaces exec and init
async start(arg) {
let startTime = +new Date();
let ms;
if (arg && arg.arr) {
this.arr = arg.arr; //overwrite sequence
}
@ -116,9 +118,10 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
}
ms = (+new Date()) - startTime;
//end sequence
this.log.info(`Ended sequence`);
this.ui.send(this.id, { stop: true });
this.ui.send(this.id, { stop: true, ms });
}
//new
pause() {

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,7 @@ interface Arg {
step : number;
stop : boolean;
start : boolean;
ms : number;
}
interface Step {
@ -48,7 +49,8 @@ class Sequence {
ipcRenderer.on(this.id, this.listener.bind(this))
}
private listener (event : Event, arg : Arg) {
//console.log(JSON.stringify(arg))
let timeStr;
console.log(JSON.stringify(arg))
if (arg.start) {
if (typeof arg.loop !== 'undefined' && typeof arg.step !== 'undefined') {
this.activeStep(arg.step);
@ -69,6 +71,9 @@ class Sequence {
gui.overlay(false);
gui.spinner(false);
log.info('Sequence stopped', 'SERIAL', true);
log.info(typeof arg.ms)
timeStr = ( arg.ms < 2000 ) ? `${arg.ms}ms` : humanizeDuration(arg.ms);
gui.notify(`SEQUENCE`, `Sequence finished in ${timeStr}`);
}
}
return event.returnValue = true;

View File

@ -70,6 +70,8 @@ class Sequencer {
}
//new, replaces exec and init
async start(arg) {
let startTime = +new Date();
let ms;
if (arg && arg.arr) {
this.arr = arg.arr; //overwrite sequence
}
@ -116,9 +118,10 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
}
ms = (+new Date()) - startTime;
//end sequence
this.log.info(`Ended sequence`);
this.ui.send(this.id, { stop: true });
this.ui.send(this.id, { stop: true, ms });
}
//new
pause() {

File diff suppressed because one or more lines are too long

View File

@ -70,6 +70,8 @@ class Sequencer {
}
//new, replaces exec and init
async start(arg) {
let startTime = +new Date();
let ms;
if (arg && arg.arr) {
this.arr = arg.arr; //overwrite sequence
}
@ -116,9 +118,10 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
}
ms = (+new Date()) - startTime;
//end sequence
this.log.info(`Ended sequence`);
this.ui.send(this.id, { stop: true });
this.ui.send(this.id, { stop: true, ms });
}
//new
pause() {

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,6 @@ import Log = require('log');
let seq : Sequencer;
class Sequencer {
private time : number;
private running : boolean = false;
private paused : boolean = false;
@ -86,6 +85,9 @@ class Sequencer {
//new, replaces exec and init
public async start (arg : any) {
let startTime : number = +new Date();
let ms : number;
if (arg && arg.arr) {
this.arr = arg.arr; //overwrite sequence
} else {
@ -140,9 +142,11 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`)
this.ui.send(this.id, { loop : x, stop : true });
}
ms = ( +new Date() ) - startTime;
//end sequence
this.log.info(`Ended sequence`)
this.ui.send(this.id, { stop : true })
this.ui.send(this.id, { stop : true, ms })
}
//new