Initial updates to sequence module. Will try to simplify into a for loop, but if tests fail will re-write to a similar form as the renderer seq.js module
This commit is contained in:
parent
c436406e9e
commit
425dd9fd6a
|
@ -1,16 +1,59 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
let log;
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequence {
|
class Sequence {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.arr = [];
|
||||||
|
this.loops = 1;
|
||||||
|
this.CMDS = {};
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
this.cmds(cfg.cmd);
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
cmds(obj) {
|
||||||
|
let keys = Object.keys(obj);
|
||||||
|
let key;
|
||||||
|
for (key in keys) {
|
||||||
|
this.CMDS[keys[key]] = key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//currently called by ui
|
//currently called by ui
|
||||||
init() {
|
async init() {
|
||||||
|
this.log = Log({ label: 'sequence' });
|
||||||
|
this.ipc = require('electron').ipcMain;
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
listen() {
|
||||||
|
this.ipc.on('sequence', this.listener.bind(this));
|
||||||
|
}
|
||||||
|
async listener(event, arg) {
|
||||||
|
if (arg && arg.diff) {
|
||||||
|
this.diff(arg.diff);
|
||||||
|
}
|
||||||
|
else if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
diff(steps) {
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
start() {
|
async start(arg) {
|
||||||
|
if (arg && arg.arr) {
|
||||||
|
this.arr = arg.arr;
|
||||||
|
}
|
||||||
|
if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
if (this.running) {
|
||||||
|
await this.step(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
@ -20,19 +63,23 @@ class Sequence {
|
||||||
**/
|
**/
|
||||||
stop() {
|
stop() {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
//clear?
|
||||||
}
|
}
|
||||||
exec() {
|
async step(index) {
|
||||||
|
try {
|
||||||
|
await this.cmdMap(index);
|
||||||
}
|
}
|
||||||
execStop() {
|
catch (err) {
|
||||||
}
|
throw err;
|
||||||
//private
|
|
||||||
run() {
|
|
||||||
}
|
|
||||||
step() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (cfg, cmd, l) {
|
async cmdMap(index) {
|
||||||
log = l;
|
const cmdOriginal = this.arr[index].cmd;
|
||||||
|
const cmd = this.CMDS[cmdOriginal];
|
||||||
|
return await this.cmd[cmd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = function (cfg, cmd) {
|
||||||
seq = new Sequence(cfg, cmd);
|
seq = new Sequence(cfg, cmd);
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;I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AAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,QAAQ;IAET,CAAC;IAEO,KAAK,CAAC,IAAI,CAAE,KAAc;QACjC,IAAI;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SACxB;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;IAEF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,KAAc;QACnC,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
|
|
@ -1,16 +1,59 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
let log;
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequence {
|
class Sequence {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.arr = [];
|
||||||
|
this.loops = 1;
|
||||||
|
this.CMDS = {};
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
this.cmds(cfg.cmd);
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
cmds(obj) {
|
||||||
|
let keys = Object.keys(obj);
|
||||||
|
let key;
|
||||||
|
for (key in keys) {
|
||||||
|
this.CMDS[keys[key]] = key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//currently called by ui
|
//currently called by ui
|
||||||
init() {
|
async init() {
|
||||||
|
this.log = Log({ label: 'sequence' });
|
||||||
|
this.ipc = require('electron').ipcMain;
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
listen() {
|
||||||
|
this.ipc.on('sequence', this.listener.bind(this));
|
||||||
|
}
|
||||||
|
async listener(event, arg) {
|
||||||
|
if (arg && arg.diff) {
|
||||||
|
this.diff(arg.diff);
|
||||||
|
}
|
||||||
|
else if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
diff(steps) {
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
start() {
|
async start(arg) {
|
||||||
|
if (arg && arg.arr) {
|
||||||
|
this.arr = arg.arr;
|
||||||
|
}
|
||||||
|
if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
if (this.running) {
|
||||||
|
await this.step(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
@ -20,19 +63,23 @@ class Sequence {
|
||||||
**/
|
**/
|
||||||
stop() {
|
stop() {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
//clear?
|
||||||
}
|
}
|
||||||
exec() {
|
async step(index) {
|
||||||
|
try {
|
||||||
|
await this.cmdMap(index);
|
||||||
}
|
}
|
||||||
execStop() {
|
catch (err) {
|
||||||
}
|
throw err;
|
||||||
//private
|
|
||||||
run() {
|
|
||||||
}
|
|
||||||
step() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (cfg, cmd, l) {
|
async cmdMap(index) {
|
||||||
log = l;
|
const cmdOriginal = this.arr[index].cmd;
|
||||||
|
const cmd = this.CMDS[cmdOriginal];
|
||||||
|
return await this.cmd[cmd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = function (cfg, cmd) {
|
||||||
seq = new Sequence(cfg, cmd);
|
seq = new Sequence(cfg, cmd);
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD;;QAEI;IACG,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,IAAI;IAEX,CAAC;IAEM,QAAQ;IAEf,CAAC;IAED,SAAS;IACD,GAAG;IAEX,CAAC;IACO,IAAI;IAEZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,CAAO;IACvD,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,2BAA4B;AAE5B,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IAab,YAAa,GAAS,EAAE,GAAS;QATzB,QAAG,GAAW,EAAE,CAAC;QACjB,UAAK,GAAY,CAAC,CAAC;QAInB,SAAI,GAAS,EAAE,CAAC;QAKvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,G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Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequence {
|
class Sequence {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.arr = [];
|
||||||
|
this.loops = 1;
|
||||||
|
this.CMDS = {};
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
this.cmds(cfg.cmd);
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
cmds(obj) {
|
||||||
|
let keys = Object.keys(obj);
|
||||||
|
let key;
|
||||||
|
for (key in keys) {
|
||||||
|
this.CMDS[keys[key]] = key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//currently called by ui
|
//currently called by ui
|
||||||
init() {
|
async init() {
|
||||||
|
this.log = Log({ label: 'sequence' });
|
||||||
|
this.ipc = require('electron').ipcMain;
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
listen() {
|
||||||
|
this.ipc.on('sequence', this.listener.bind(this));
|
||||||
|
}
|
||||||
|
async listener(event, arg) {
|
||||||
|
if (arg && arg.diff) {
|
||||||
|
this.diff(arg.diff);
|
||||||
|
}
|
||||||
|
else if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
diff(steps) {
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
start() {
|
async start(arg) {
|
||||||
|
if (arg && arg.arr) {
|
||||||
|
this.arr = arg.arr;
|
||||||
|
}
|
||||||
|
if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
if (this.running) {
|
||||||
|
await this.step(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
@ -20,19 +63,23 @@ class Sequence {
|
||||||
**/
|
**/
|
||||||
stop() {
|
stop() {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
//clear?
|
||||||
}
|
}
|
||||||
exec() {
|
async step(index) {
|
||||||
|
try {
|
||||||
|
await this.cmdMap(index);
|
||||||
}
|
}
|
||||||
execStop() {
|
catch (err) {
|
||||||
}
|
throw err;
|
||||||
//private
|
|
||||||
run() {
|
|
||||||
}
|
|
||||||
step() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (cfg, cmd, l) {
|
async cmdMap(index) {
|
||||||
log = l;
|
const cmdOriginal = this.arr[index].cmd;
|
||||||
|
const cmd = this.CMDS[cmdOriginal];
|
||||||
|
return await this.cmd[cmd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = function (cfg, cmd) {
|
||||||
seq = new Sequence(cfg, cmd);
|
seq = new Sequence(cfg, cmd);
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,GAAS,CAAC;AACd,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IAOb,YAAa,GAAS,EAAE,GAAS;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,wBAAwB;IACjB,IAAI;IAEX,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD,KAAK;IACE,KAAK;IAEZ,CAAC;IACD;;QAEI;IACG,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,IAAI;IAEX,CAAC;IAEM,QAAQ;IAEf,CAAC;IAED,SAAS;IACD,GAAG;IAEX,CAAC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AA;SACxB;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;IAEF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,KAAc;QACnC,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}
|
|
@ -1,26 +1,76 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let log : any;
|
import Log = require('log');
|
||||||
|
|
||||||
let seq : Sequence;
|
let seq : Sequence;
|
||||||
|
|
||||||
class Sequence {
|
class Sequence {
|
||||||
private i : number;
|
|
||||||
private time : number;
|
private time : number;
|
||||||
private running : boolean;
|
private running : boolean;
|
||||||
|
|
||||||
|
private arr : any[] = [];
|
||||||
|
private loops : number = 1;
|
||||||
|
|
||||||
private cfg : any;
|
private cfg : any;
|
||||||
private cmd : any;
|
private cmd : any;
|
||||||
|
private CMDS : any = {};
|
||||||
|
private ipc : any;
|
||||||
|
private log : any;
|
||||||
|
|
||||||
constructor (cfg : any, cmd : any) {
|
constructor (cfg : any, cmd : any) {
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
this.cmds(cfg.cmd);
|
||||||
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private cmds (obj : any) {
|
||||||
|
let keys : string[] = Object.keys(obj);
|
||||||
|
let key : string;
|
||||||
|
for (key in keys) {
|
||||||
|
this.CMDS[keys[key]] = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//currently called by ui
|
//currently called by ui
|
||||||
public init () {
|
private async init () {
|
||||||
|
this.log = Log({ label : 'sequence' })
|
||||||
|
this.ipc = require('electron').ipcMain;
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
|
||||||
|
private listen () {
|
||||||
|
this.ipc.on('sequence', this.listener.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async listener (event : any, arg : any) {
|
||||||
|
if (arg && arg.diff) {
|
||||||
|
this.diff(arg.diff);
|
||||||
|
} else if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private diff (steps : any[]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
public start () {
|
public async start (arg : any) {
|
||||||
|
if (arg && arg.arr) {
|
||||||
|
this.arr = arg.arr;
|
||||||
|
}
|
||||||
|
if (arg && arg.loops) {
|
||||||
|
this.loops = arg.loops;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
if (this.running) {
|
||||||
|
await this.step(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
public pause () {
|
public pause () {
|
||||||
|
@ -31,26 +81,26 @@ class Sequence {
|
||||||
**/
|
**/
|
||||||
public stop () {
|
public stop () {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
}
|
//clear?
|
||||||
|
|
||||||
public exec () {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public execStop () {
|
private async step (index : number) {
|
||||||
|
try {
|
||||||
|
await this.cmdMap(index)
|
||||||
|
} catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//private
|
private async cmdMap (index : number) {
|
||||||
private run () {
|
const cmdOriginal : string = this.arr[index].cmd;
|
||||||
|
const cmd : string = this.CMDS[cmdOriginal];
|
||||||
}
|
return await this.cmd[cmd];
|
||||||
private step () {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function (cfg : any, cmd : any, l : any) {
|
module.exports = function (cfg : any, cmd : any) {
|
||||||
log = l;
|
|
||||||
seq = new Sequence(cfg, cmd);
|
seq = new Sequence(cfg, cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue